Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 115 Pages +
  • « First
  • 87
  • 88
  • 89
  • 90
  • 91
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   jimbob 

#2641

View PostMark, on 21 December 2020 - 06:35 AM, said:

Wait a minute...After all these years I never knew there was a usable button on the back of a pigtank. :blink:

Make a small sector behind the machine gun and put a stayput version of the enemy in that sector. Then use the findnearactor feature in the gun actor so that if the enemy gets killed first it is no longer found and the gun stops shooting. And if the gun gets "killed" first have that cactor the enemy into the non-stayput version. The only problem is if you need the gun to fire in any direction and not just mostly forward. It would still work but the enemy won't follow the gun direction. Also you would have to tag this enemy somehow different from the rest so they don't all get affected. Maybe a different pal.

yeah, you can press the nuke symbol and the tank will auto destruct ;) saving much ammo
i was thinking allong those line, but most eduke programming is beyond my capabilities at the moment.. for now i have a small sector and an stayput enemy, and made the gun destructable. placed a small wall crack and use that to blow the entire area killing everything. a cop out but for the moment it looks half decent. in the future i will make a custom dedicated machine gunner so the game can look for that actor and ignore all others. making the gun shoot in a 45 degree arc relative to the original angle is something to be added.

so how would i implement the findnearactor, something like findnearactor myactor 1, if 1 run code if 0 dont?

right now i have this coded, basically i hacked the floofflame code.
define MG42NPC		3951
define MG42ANPC		3952 // the a is for ambience, this gun is placed outside the playable areas to make the world seem bigger than it really is. 

action MG42STAND		0 1 5 1 0
action MG42FIRES		5 1 5 1 0
action MG42ASTAND		-1 1 5 1 0 
action MG42AFIRE		4 1 5 1 0

useractor notenemy MG42NPC 100 MG42STAND
  ifaction MG42FIRES
  {
 	ifactioncount 2 
	shoot SHOTSPARK1
	sound MG42FIRE
	ifrnd 64
	{
	shoot FIRELASER
	}
    ifactioncount 16
      action MG42STAND
  }
  ifaction MG42STAND
    ifrnd 8 // was 4
  {
    action MG42FIRES
    resetactioncount
else action MG42STAND
  }
  ifhitweapon       
  {
    debris SCRAP1 2 
    ifdead 
    {           
   sound VENT_BUST
      debris SCRAP1 10
      killit
    }

  }
enda

useractor notenemy MG42ANPC 100 MG42ASTAND // and the ambience version, basically the same but wont require an owner to run.
  ifaction MG42AFIRE
  {
 	ifactioncount 2 
	sound MG42FIRE
	ifrnd 64
	{
	shoot FIRELASER
	}
    ifactioncount 16
      action MG42ASTAND
  }
  ifaction MG42ASTAND
 ifcansee  ifp palive ifcanshoottarget
    ifrnd 16 // was 4
   {
    action MG42AFIRE
    resetactioncount
else action MG42ASTAND
  }
  ifhitweapon       
  {
    debris SCRAP1 2 
    ifdead 
    {           
      sound VENT_BUST
      debris SCRAP1 10
      killit
    }

  }
enda



so i'd probably add something like

gamevar MGNEAR 0 0

findnearactor MGGUNNER 512 MGNEAR

onevent MGNEAR 1

run code ( action MGSTAND, wich will loop in intervalls  )
else

action MGABANDONED or something ( same action as MGSTAND but wont run the shooting code )


i could also run a check if the gun is still 'alive' and if not callactor MGgunner roaming or something so he can abandon his position and change to a regular soldier.

This post has been edited by jimbob: 22 December 2020 - 10:48 AM

0

User is offline   Mark 

#2642

There are multiple ways of accomplishing the same thing and past experience has shown my way of coding can be sloppy or inefficient. I've only used findnearactor once early this year. If nobody else comes to the rescue with a better example I'll post my embarrassing blocks of code. Mine was a boombox and a gangster. The boombox detected if the gangster was nearby and alive. If he wasn't because he got shot and killed, the rest of the boombox code would not run. Also, if the gangster could not detect the boombox because it got "killed" the rest of the gangster code would not run. The problem with posting mine is that the findnearactor stuff is mingled in with music, dialog, sound effects, pal changes, quotes, etc... Its messy. :yucky:

This post has been edited by Mark: 22 December 2020 - 03:19 PM

0

User is offline   jimbob 

#2643

No worries, ill figure out how to make it work i just need to know how to properly set up and use findnearactor
0

User is offline   Danukem 

  • Duke Plus Developer

#2644

I recommend against using findnearactor because it has too many limitations. It's going to find the actor with the lowest sprite ID of the specified picnum within the specified range. So it doesn't allow you to narrow down a list of targets. For example, if an actor of that picnum is right behind the turret, and another is in front, findnearactor might find the one behind that it can't shoot anyway, and then the turret won't be able to shoot the one in front. Or, it can find an actor that is already dead and not a viable target.
0

User is offline   Reaper_Man 

  • Once and Future King

#2645

I can't follow your code and what you're trying to do exactly. As Dan said, findnearactor really sucks because it just finds A near actor, not the nearest actor. I use this code to find the actual nearest actor a lot:

setvar DISTANCE 2147483647 // Maximum integer value, you should use some sort of realistic maximum range
setvar ACTORTARGET -1

setvar ACTORI 0
for ACTORI sprofstat 1
{
	ifvare sprite[ACTORI].picnum MYACTOR
	{
		ldist ACTORCHECK THISACTOR ACTORI
		ifvarvarl ACTORCHECK DISTANCE
		{
			setvarvar DISTANCE ACTORCHECK
			setvarvar ACTORTARGET ACTORI
		}
	}
}

ifvare ACTORTARGET -1
	killit // Couldn't find a valid target, goodbye


This post has been edited by Reaper_Man: 22 December 2020 - 06:33 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2646

But you should use "spritesofstatus 1" instead of "allsprites" because currently that searches through every single sprite in the game, whereas statnum 1 is just a linked list of actors which will be a small fraction of that number.
1

User is offline   Reaper_Man 

  • Once and Future King

#2647

Good catch, I should pay more attention to which code I'm copying!
0

User is offline   jimbob 

#2648

View PostReaper_Man, on 22 December 2020 - 04:29 PM, said:

I can't follow your code and what you're trying to do exactly. As Dan said, findnearactor really sucks because it just finds A near actor, not the nearest actor. I use this code to find the actual nearest actor a lot:

setvar DISTANCE 2147483647 // Maximum integer value, you should use some sort of realistic maximum range
setvar ACTORTARGET -1

setvar ACTORI 0
for ACTORI allsprites
{
	ifvare sprite[ACTORI].picnum MYACTOR
	{
		ldist ACTORCHECK THISACTOR ACTORI
		ifvarvarl ACTORCHECK DISTANCE
		{
			setvarvar DISTANCE ACTORCHECK
			setvarvar ACTORTARGET ACTORI
		}
	}
}

ifvare ACTORTARGET -1
	killit // Couldn't find a valid target, goodbye

that bit of code was mostly mental note for myself, basically i wanted to create a variable MGNEAR and set that to one for yes, zero for no

If no, do nothing by calling an idle action

If yes, run active action wich runs/triggers the shooting code.
And if the operator dies, i planned on using callactor to call a different actor to lower the MGNEAR flag to zero.
0

User is online   Sangman 

#2649

View PostDanukem, on 22 December 2020 - 04:49 PM, said:

But you should use "spritesofstatus 1" instead of "allsprites" because currently that searches through every single sprite in the game, whereas statnum 1 is just a linked list of actors which will be a small fraction of that number.


Another option, if it's only one specific enemy type that you want to check for, is to appendevent EVENT_SPAWN and add it to an array if it is that actor type. Then loop that array... it's a micro optimization in jimbob's scenario I'm guessing but just throwing that out there.
0

User is offline   jimbob 

#2650

i still cant make heads or tails of this :') i suck at this :P

yes, there wil be one dedicated enemy that occupies the fixed MG position, and will be in various positions on itself ( prone, standing, crouching ) wich means i cant make it one large sprite, given the size of the machinegun, and the size of the enemy it would make more than half of the sprite seethrough causing lots of clipping issues and a ton of useless data being wasted.

Attached thumbnail(s)

  • Attached Image: mg1.png
  • Attached Image: mg2.png
  • Attached Image: mg3.png

0

User is offline   jimbob 

#2651

well, i seem to have fixed it, now the gunner has to be alive, and on the MG for it to shoot

state checkoccupied
findnearsprite MGGUNNERSTAND ONMGDIST ONMG
ifvarn ONMG -1 { action MG42ASTAND break }  // run code as normal
else { action MG42ADONOTHING break }

ends

useractor notenemy MG42ANPC 100 MG42ASTAND
ifaction MG42AFIRE 
  {
 	ifactioncount 2 
	state checkoccupied
	shoot SHOTSPARK1
	sound MG42FIRE
	ifrnd 64
	{
	shoot FIRELASER
	}
    ifactioncount 16
      action MG42ASTAND
  }
ifaction MG42ASTAND state checkoccupied
  ifcansee  ifp palive ifcanshoottarget // only fire if can see the player
    ifrnd 16 // was 4
   {
ifvarn ONMG -1   
	 action MG42AFIRE
    resetactioncount
else
ifvarn ONMG -1  action MG42ASTAND
else action MG42ADONOTHING
  }
  ifhitweapon       
  {
    debris SCRAP1 2 
    ifdead 
    {           
      sound VENT_BUST
      debris SCRAP1 10
      killit
    }

  }
ifaction MG42ADONOTHING 
	{ 
	}
enda

added a few checks, for whatever reason it occasionally still went to the fire action and fire once or twice.

This post has been edited by jimbob: 08 January 2021 - 12:40 PM

0

User is offline   jimbob 

#2652

how do i make weapons 'shoot' my custom shells, right now i have them set up as projectiles in combination with useractor, but they dont show up when i use them with the weaponX_spawns customshell
and i also dont know how to make a gun eject a clip, an actual clip this time, i want my M1 garand to eject the enbloc clip at the start of the reload. any help would be very much appericiated :)

i have my MG42 shells set up as this

define MG42SHELL	3650
define MG42FS		3651
action MG42SFLY		0 4 1 1 4
action MG42FS1		-1 1 1 


useractor notenemy MG42SHELL 0 MG42SFLY // ejected brass
enda

useractor notenemy MG42FS 0 MG42FS1 0 randomangle // shells on the floor
fall
sizeat 3 3
cstat 32
ifcount 300 killit
enda

defineprojectile 3650 PROJ_WORKSLIKE 6210
defineprojectile 3650 PROJ_XREPEAT 3
defineprojectile 3650 PROJ_YREPEAT 3
defineprojectile 3650 PROJ_VEL 150
defineprojectile 3650 PROJ_DROP -100
defineprojectile 3650 PROJ_BOUNCES -1
defineprojectile 3650 PROJ_CLIPDIST 0
defineprojectile 3650 PROJ_HITRADIUS -1
defineprojectile 3650 PROJ_BSOUND -1
defineprojectile 3650 PROJ_ISOUND -1
// defineprojectile 3650 PROJ_TOFFSET -30
// defineprojectile 365 PROJ_CSTAT 130
// defineprojectile 365 PROJ_RANGE 40
defineprojectile 3650 PROJ_SPAWNS MG42FS
defineprojectile 3650 PROJ_EXTRA 0
defineprojectile 3650 PROJ_OFFSET 240


This post has been edited by jimbob: 30 January 2021 - 01:57 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2653

The player or whatever actor is ejecting the shell needs to fire the shell at the same time as the bullet. I would try firing it a bit upward and to whichever side the shell comes out of the gun. If this is for the player, then I would use EVENT_DOFIRE on the relevant weapons. So for example:

gamevar TEMPANG 0 0
onevent EVENT_DOFIRE

ife player[].curr_weapon CHAINGUN_WEAPON
{
  ezshoot -1024 MG42SHELL
  geta[].ang TEMPANG
  sub TEMPANG 512
  seta[RETURN].ang TEMPANG
}

endevent


In a non-player actor, you don't use an event. Use shoot CHAINGUN or whatever bullet they are shooting, followed by the angle stuff. I deliberately used "geta[].ang" instead of "getp[].ang" to avoid any errors if you port it to other actors.
0

User is offline   jimbob 

#2654

Thanks a lot, im going to mess around with that untill i get it right, for now i only use it for the player, but who knows.

it seems to work, just changed the angle to 1536 ( 3 * 512 ) to make the shells fly off to the right, wuch works. but it doesnt fire, and immediatly goed to the reload animation :/

This post has been edited by jimbob: 31 January 2021 - 10:07 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2655

View Postjimbob, on 31 January 2021 - 08:42 AM, said:

it seems to work, just changed the angle to 1536 ( 3 * 512 ) to make the shells fly off to the right, wuch works. but it doesnt fire, and immediatly goed to the reload animation :/


Oh whoops! I forgot that setting RETURN in that event messes with the actual gun firing. Set RETURN to 0 at the end of the event code and that should fix it:

gamevar TEMPANG 0 0
onevent EVENT_DOFIRE

ife player[].curr_weapon CHAINGUN_WEAPON
{
  ezshoot -1024 MG42SHELL
  geta[].ang TEMPANG
  sub TEMPANG 1536
  seta[RETURN].ang TEMPANG
  set RETURN 0
}

endevent

0

User is offline   jimbob 

#2656

yes, that works like a charm :) thanks a lot, i'll add a credit aswell
0

#2657

Good to be back; How do I remove the tint completely that comes from using the nightvision goggles, while still lighting up opponents and tripmines in mode 2? (if other things lights up its ok, it's more the walls, floor and ceiling I want to look normal). I want the goggles to be nice to have on for a longer period of time :D

Another question: Can I change pal and stuff of LASERLINE that active/placed tripmines shoot out?

And: Will a pal change of something cause a desync in multiplayer if it only happens for one of the players? I'm considering changing how stuff LOOKS depending on what player ID you have.

Thanks in advance!
0

User is offline   Danukem 

  • Duke Plus Developer

#2658

I think you would have to disable the normal hardcoded function of the goggles entirely and code your own effect from scratch. I don't think there is a simple way to separate the overall palette change from the sprites appearing to be pal 6. You could try using setgamepalette to 0 (or 1 if you happen to be under water at that moment) to counteract the goggle palette, but like I said I think that would also make the sprites look normal.
0

#2659

View PostDanukem, on 10 February 2021 - 01:08 PM, said:

I think you would have to disable the normal hardcoded function of the goggles entirely and code your own effect from scratch. I don't think there is a simple way to separate the overall palette change from the sprites appearing to be pal 6. You could try using setgamepalette to 0 (or 1 if you happen to be under water at that moment) to counteract the goggle palette, but like I said I think that would also make the sprites look normal.


Damn, that was EXACTLY what I needed. Everything looks so normal I was confused the first time I turned them on. Looking at players in dark areas lights them up tho, and tripmines on mode 2 are visible too. Thanks!
0

User is offline   Danukem 

  • Duke Plus Developer

#2660

That's fortunate -- I thought that the brightness of the sprites would be linked to the changed game palette but apparently not. Do you have the palette switches working correctly under water?
0

#2661

View PostDanukem, on 11 February 2021 - 12:18 PM, said:

That's fortunate -- I thought that the brightness of the sprites would be linked to the changed game palette but apparently not. Do you have the palette switches working correctly under water?


Haven't thoroughly tested, we ain't DM'ing on maps with water. A 1 minute test, however, showed that setgamepalette 1 will probably make everything look normal underwater, but special stuff like players and tripmine lasers will still light up when goggles are on (just like above water/setgamepalette 0). In general, setgamepalette works properly on everything except the few things that has a special interaction with the goggles (if the goggles are on) - in other words: nothing looks weird.

Question: How do I "redefine" certain actors to do stuff I want? For example when I spawn OOZFILTER (1079) ingame I see nothing, but if I spawn 1080 (also oozfilter but without animation) it appears in the game. In my CON file I have a simple block: actor 1079 { do stuff... } enda. Some actors seem to be reserved but they are usually the more interesting ones...

This post has been edited by thisbecasper: 12 February 2021 - 01:32 PM

0

User is offline   jimbob 

#2662

View Postthisbecasper, on 12 February 2021 - 10:54 AM, said:

Haven't thoroughly tested, we ain't DM'ing on maps with water. A 1 minute test, however, showed that setgamepalette 1 will probably make everything look normal underwater, but special stuff like players and tripmine lasers will still light up when goggles are on (just like above water/setgamepalette 0). In general, setgamepalette works properly on everything except the few things that has a special interaction with the goggles (if the goggles are on) - in other words: nothing looks weird.

Question: How do I "redefine" certain actors to do stuff I want? For example when I spawn OOZFILTER (1079) ingame I see nothing, but if I spawn 1080 (also oozfilter but without animation) it appears in the game. In my CON file I have a simple block: actor 1079 { do stuff... } enda. Some actors seem to be reserved but they are usually the more interesting ones...

why would you want to repurpose existing actors? you can use useractor for new actors unless you are using duke1.3 wich i consider obsolete.
0

#2663

View Postjimbob, on 13 February 2021 - 09:21 AM, said:

why would you want to repurpose existing actors? you can use useractor for new actors unless you are using duke1.3 wich i consider obsolete.


Some existing actors are ones we wont encounter when playing DM, but have nice animations (e.g. OOZFILTER could be a new item to be picked up). Should I understand your reply as it can't be done, or how would I go about overwriting OOZFILTER? I've also not experimented with creating actors with animation myself, but the tiles that can make up an animation are usually an existing actor - I don't know if my point came across very well...

Maybe I am misunderstanding, does it make any difference having "useractor OOZFILTER ..." instead of "actor OOZFILTER ..."?

This post has been edited by thisbecasper: 13 February 2021 - 09:46 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2664

To answer his question: A lot of sprites do not have a default coded size, and so when they are spawned they spawn with size 0 0. As a result, they are too small to see and usually they get deleted right away. With oozfilter and many other sprites, you have to either place them in the map, or you have to add code to make them have a certain size when they are spawned.
0

#2665

View PostDanukem, on 13 February 2021 - 09:46 AM, said:

To answer his question: A lot of sprites do not have a default coded size, and so when they are spawned they spawn with size 0 0. As a result, they are too small to see and usually they get deleted right away. With oozfilter and many other sprites, you have to either place them in the map, or you have to add code to make them have a certain size when they are spawned.


The first thing I do in the block is sizeat 24 24, and it works with tile 1080 (OOZFILTER being 1079). So sizeat does not help me when actor is tile #1079.
0

User is offline   Danukem 

  • Duke Plus Developer

#2666

View Postthisbecasper, on 13 February 2021 - 09:55 AM, said:

The first thing I do in the block is sizeat 24 24, and it works with tile 1080 (OOZFILTER being 1079). So sizeat does not help me when actor is tile #1079.


Not sure what you mean by "the block" but OOZFILTER is hardcoded, it is not a scripted actor. So the correct approach if you want that size would be something like this:

appendevent EVENT_EGS

ifactor OOZFILTER sizeat 24 24

endevent

0

#2667

View PostDanukem, on 13 February 2021 - 10:02 AM, said:

Not sure what you mean by "the block" but OOZFILTER is hardcoded, it is not a scripted actor. So the correct approach if you want that size would be something like this:

appendevent EVENT_EGS

ifactor OOZFILTER sizeat 24 24

endevent



Does this mean that all my code regarding OOZFILTER has to go into the events, and that my "actor OOZFILTER ... enda" block is ignored completely because, as you said, OOZFILTER is hardcoded?
0

User is offline   Danukem 

  • Duke Plus Developer

#2668

View Postthisbecasper, on 13 February 2021 - 10:05 AM, said:

Does this mean that all my code regarding OOZFILTER has to go into the events, and that my "actor OOZFILTER ... enda" block is ignored completely because, as you said, OOZFILTER is hardcoded?


It might be ignored completely, yeah. But I can tell you for certain that code I posted above works. If you want it to use your code instead you would probably need to change the statnum to 1.
0

User is offline   jimbob 

#2669

View Postthisbecasper, on 13 February 2021 - 09:45 AM, said:

Some existing actors are ones we wont encounter when playing DM, but have nice animations (e.g. OOZFILTER could be a new item to be picked up). Should I understand your reply as it can't be done, or how would I go about overwriting OOZFILTER? I've also not experimented with creating actors with animation myself, but the tiles that can make up an animation are usually an existing actor - I don't know if my point came across very well...

Maybe I am misunderstanding, does it make any difference having "useractor OOZFILTER ..." instead of "actor OOZFILTER ..."?

i still dont quite get what you want to do, if you want a new pickup, but use the oozefilter' animation you could create a new actor, make some rudimentary art for it ( doesnt matter how ugle, you wont see it ) and set the action to the value of your actor - the first animation frame of the oozefilter and set up the rest accordingly ( if it has 4 animation frames set it up as such ) and then add your code for picking the item up like you would on any other pickup.

so for example, you create a new useractor like

define MYPICKUPACTOR **** where **** is the arttile you import

action MYPICKUPANIMATION ***** - 1079 for oozefilter, so say my art is 3000, then 3000 - 1079 = 1921, so the first frame has an offset of -1921
and your all set, the animation is 'hardcoded'

so

define MYPICKUPACTOR ****
action MYPICKUPANIMATION *****

useractor notenemy MYPICKUPACTOR 0 MYPICKUPANIMATION
sizeat X X
fall // if you want it to fall, if not dont use this command
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
            ifcanseetarget
      {
        addammo PISTOL_WEAPON PISTOLAMMOAMOUNT 
        quote 65
        ifspawnedby AMMO
          state getcode
        else
          state quikget
      }
enda


This post has been edited by jimbob: 13 February 2021 - 12:01 PM

0

#2670

Is there a way to access nicknames used in multiplayer? The name property seems to be useless.

This post has been edited by thisbecasper: 19 February 2021 - 10:42 AM

0

Share this topic:


  • 115 Pages +
  • « First
  • 87
  • 88
  • 89
  • 90
  • 91
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options