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

Jump to content

  • 120 Pages +
  • « First
  • 108
  • 109
  • 110
  • 111
  • 112
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   VGames 

#3271

Is there a way to capture the moment the RESPAWN actor is activated and it spawns an actor? Event_Killit is a little too late. I’m trying to replace the moment an actor is spawned with a new enemy spawning actor to help further randomize the type of enemy spawned but I can’t figure out how to tap into the moment the RESPAWN actor is activated by a touch plate or some other means of getting it to activate.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#3272

Can you not use EVENT_LOADACTOR to change the RESPAWN tag?
1

User is offline   Danukem 

  • Duke Plus Developer

#3273

 Fox, on 03 April 2023 - 01:36 AM, said:

Can you not use EVENT_LOADACTOR to change the RESPAWN tag?


that's an Even Greater Solution than the one which more closely matches his prompt lol
0

User is offline   VGames 

#3274

Event_EGS doesn’t work because the enemies being spawned in by Respawn actors are considered to be part of the enemies loaded into the map when it first loads. I found Event_Spawn to actually work the best for my needs. I just have to set it up for each enemy.
0

User is offline   Danukem 

  • Duke Plus Developer

#3275

 VGames, on 03 April 2023 - 01:49 PM, said:

Event_EGS doesn’t work because the enemies being spawned in by Respawn actors are considered to be part of the enemies loaded into the map when it first loads. I found Event_Spawn to actually work the best for my needs. I just have to set it up for each enemy.


Are you talking about for the purposes of the kill counter?

You can use "ifspawnedby RESPAWN" in EVENT_EGS and it works fine, you can then change them however you want.
0

User is offline   MC84 

#3276

I've been following Dan's enemy coding tutorial and am currently trying to setup the states for my enemy attacks. I was able to get decent results using the code from the PIGCOP (using ifcount 12 nullop else ifcount 11 etc).. however I wanted to try and replace these ifcount statements with ifactioncount; however it needs some fine-tuning... Basically my shoot action is 5 frames; the first 2 frames are firing the shotgun and the next 3 are reloading/pumping it. The following code works pretty much as I'd like, however the shotgun sounds occur on the 5th frame of the action... obviously if I change ifactioncount to 2 then it just plays the shotgun sound every 2 frames of the action... Is there a simple way around this, or should I split up my action into two actions? I was reluctant to do this as I've already got 15-20 for this enemy type.

defstate VALDUCKSHOOTstate
{
	ifactioncount 5
	{
		ifcanshoottarget
		{
			sound PIG_ATTACK
			shoot SHOTGUN
			ifrnd 64
			{	
				ai AIVALSTAND else
				ai AIVALDUCKSHOOT
			}
			resetactioncount
		
		}
		
	}
}
else 
ai AIVALSTAND

ends	


This state is placed inside the following AI:

ifai AIVALDUCKSHOOT state VALDUCKSHOOTstate


which contains the 5 framed action:

action AVALDUCKSHOOT 196 5 8 1 20

0

User is offline   jimbob 

#3277

personally i'd split the actions into firing and reloading, this gives you much more controll imho, maybe there is an easier way but thats how i'd do it. right now everything triggers at the same time, on frame 5 of the animation so after the actual firing frames. you could try to code it like ifactioncount 2 { sound PIG_ATTACK shoot SHOTGUN } ifactioncount 3 { sound RELOAD } ifactioncount 5 { ifrnd 64 { ifrnd 128 { ai AIVALSTAND } else { ai AIVALDUCKSHOOT } } } } resetactioncount ( got the bracketing wrong but you get the idea. right now it also seems to trigger AIVALSTAND and AIVALDUCKSHOOT at once, the else doesnt really do anything without some if statements.

but im pretty sleep deprived so i might be mistaken :P

[edit] one of the reasons i'd split it, is because once ifactioncount reaches number X it starts running the code, and afaik it will continue to do so until it gets something else to do, so ifactioncount 2, shoot stuff, and then ifactioncount 3 sound reload might just stack those things together until it reaches actioncount 5 and goes into another AI routine. so splitting it up should prevent continuous firing and sounds going off...
i'd better take a nap though :P

This post has been edited by jimbob: 12 April 2023 - 01:48 AM

2

User is offline   Danukem 

  • Duke Plus Developer

#3278

Actions normally take longer than a tic, so splitting the firing into two actions makes a lot of sense, and I do it all the time. One action is the actor aiming, the other is the frame that shows the muzzleflash. This also allows for one frame to be shown longer than the other -- I will make the aiming frame display significantly longer than the flash frame. What you want to do is make the actor fire the projectiles and make the firing sound at the moment it transitions to the muzzleflash frame. Here is an example from the army ant of AA:

state antshootstate

	ifaction ANTSHOOT
	{
		ifactioncount 1
		{
			ife bottarget -1 set botclip 10
			ifg botclip 8
			{
				ai AIANTWAIT
				set botclip 0
				break
			}
			action ANTSHOOT2
			add botclip 1
			ifvarand initflags 32 state antshootpurple else
			state antshootbullet
		}
	}
	ifaction ANTSHOOT2
	{
		ifactioncount 1
		action ANTSHOOT
	}
ends


ANTSHOOT is the aiming frame. When it reaches actioncount 1, it checks to see if it has fired 9 rounds or if there is no longer a target. If either of those conditions is true it changes to AIANTWAIT and leaves the state, at which point it will reassess what to do next tic. If those conditions are not true it fires the next bullet (or the purple plasma if it's a special ant), increments the clip counter, and switches to the muzzleflash firing frame ANTSHOOT2. Once there it simply waits one actioncount and goes back to the aiming frame.

I removed the part where it checks to see if it needs to dodge something just to keep it relatively simple.

For further reference here is the state referred to above where the bullet firing happens:

state antshootbullet
	
	sound M4FIRE
	state hitscan_targetprep
	zshoot zdist SHOTSPARK1

ends


The state hitscan_targetprep is a routine that aims the bullet up/down appropriately at the target and it takes into account additional factors. This isn't necessary if your actors will only be targeting the player though.
1

User is offline   MC84 

#3279

Thanks guys - and thanks for the detailed explanation Dan; I managed to get it working to my satisfaction.

I also had another quick question; is there some hard-coded behaviour for actors in water? I tried to quickly slap together a drowning action for my enemy but it just stays frozen on a single frame;

action AVALDROWNING 262 8 1 1 12
move VALSINKVEL 0 4
ai AIVALDROWNING		AVALDROWNING VALSINKVEL getv


ifinwater
{
	ai AIVALDROWNING else nullop
}


I mean it can't get any more basic than that; when the actor falls into water he does change to the AVALDROWNING action... but the action doesn't animate..I've triple-checked the tiles/that the action is referencing the correct number etc... so either I'm doing something really dumb or there is some hard-coded behaviour I'm unaware of..
0

User is offline   Danukem 

  • Duke Plus Developer

#3280

 MC84, on 12 April 2023 - 01:08 PM, said:

Thanks guys - and thanks for the detailed explanation Dan; I managed to get it working to my satisfaction.

I also had another quick question; is there some hard-coded behaviour for actors in water? I tried to quickly slap together a drowning action for my enemy but it just stays frozen on a single frame;

action AVALDROWNING 262 8 1 1 12
move VALSINKVEL 0 4
ai AIVALDROWNING		AVALDROWNING VALSINKVEL getv


ifinwater
{
	ai AIVALDROWNING else nullop
}


I mean it can't get any more basic than that; when the actor falls into water he does change to the AVALDROWNING action... but the action doesn't animate..I've triple-checked the tiles/that the action is referencing the correct number etc... so either I'm doing something really dumb or there is some hard-coded behaviour I'm unaware of..


I'm not sure if this will fully address the problem, but that snippet of code is not correct. I think what you intend is this:

ifai AIVALDROWNING nullop else ifinwater ai AIVALDROWNING

1

User is offline   MC84 

#3281

 Danukem, on 12 April 2023 - 01:12 PM, said:

I'm not sure if this will fully address the problem, but that snippet of code is not correct. I think what you intend is this:

ifai AIVALDROWNING nullop else ifinwater ai AIVALDROWNING



That was quick! And yes bingo the action plays now. Thanks!
0

User is offline   jimbob 

#3282

hmm, could this potentially work for realistic falldamage for enemies aswell? right now they can fall off of infinitely high sectors and be just fine... if i where to make a state
 
state falldamage
iffloordistl 1024 nullop // maximum hight, just taking a random guess here, will need to be adjusted to taste
else
ifai ai AIDROPDEAD nullop else ai AIDROPDEAD
ends


and just call it in the main line of the actors code somewhere, with the apropriate transition to when they actually hit the floor like

ifai AIDROPDEAD
 action falling
iffloordistl 32 
 ai AIDYING
sound SPLAT


or am i way off on this. its annoying they keep falling off of my bridges and buildings and not go down screaming. i would have to make several exclusions for special floor textures that will trigger a similar effect though.

This post has been edited by jimbob: 13 April 2023 - 12:30 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#3283

iffloordistl is not reliable enough

For example, if you have a jumping actor that can jump across a gap, then that code would make them immediately start screaming and falling when over the gap, which would be hilarious. I also think the engine will screw you on false positives sometimes, in situations with sprite bridges or TROR, and possibly sloped floors as well. And don't forget that falling into water should not necessarily be fatal.

What I would do instead is increment a falling counter when the actor's zvel is positive (similar to the player's falling_counter, but per-actor). If the counter reaches 15 or so (i.e. 15 tics of falling), then you start their falling animation. If the actor's zvel suddenly goes from positive to not-positive it means they landed, check the surface type and apply damage appropriately based on how high the counter incremented. They could potentially survive and go back to their normal animation, too (e.g. if they landed on water)
0

User is offline   jimbob 

#3284

well the reason i want it to be pretty much instantanious is because i dont want them to fall out of sight before starting to scream and flail thier arms about, i can always make exclusions for sectors tagged 1, or using the water texture.
0

User is offline   VGames 

#3285

I was trying to add a cool floating effect to bodies and gibs and debris that's in water, but I noticed that when they reach the surface of the water they disappear. Is there a way to keep the actors from simply disappearing when they reach the surface of the water? I expected them to simply show up on top of the water above the surface, but they don't. If there is a way, how would I go about it?
0

User is online   Mark 

#3286

are you using ifinwater while under the surface and ifonwater when they are on the surface?
0

#3287

When they're in an underwater sector have them stop at x distance from the ceiling
0

User is offline   VGames 

#3288

 lllllllllllllll, on 15 April 2023 - 08:24 AM, said:

When they're in an underwater sector have them stop at x distance from the ceiling


I’m doing exactly this but I’d like them to go all the way up to the surface. If I have them stop right before exiting the water I can’t see them on the water’s surface. Is there a way to have them show up on the surface too after floating all the way up until they hit the ceiling when under water?
0

#3289

Yeah. When items surface from below water they can be picked up on the surface even though they are not visible. If the jibs travel high enough to surface it would just be an issue of subtracting some Z after it stops (or stop it) on the surface of the water
0

User is offline   Danukem 

  • Duke Plus Developer

#3290

 VGames, on 15 April 2023 - 08:29 AM, said:

I’m doing exactly this but I’d like them to go all the way up to the surface. If I have them stop right before exiting the water I can’t see them on the water’s surface. Is there a way to have them show up on the surface too after floating all the way up until they hit the ceiling when under water?


A sprite can't be in two sectors at once, so either have it spawn a copy to be in the other sector, or transport it along with the player.
0

User is online   Mark 

#3291

Would using TROR water be another possible solution?
0

User is offline   VGames 

#3292

They're actually still there when they disappear upon hitting the ceiling of the underwater sector but the reason, they're not showing up above the surface is because they're in between both sectors. By raising their Y position up a little when they exit the water you can see their bodies on top of the water as they should. Getting the gibs and debris to do the same is trickier because they're so much smaller in size compared to the corpses. I'll keep at it.
0

User is offline   Reaper_Man 

  • Once and Future King

#3293

View Postlllllllllllllll, on 15 April 2023 - 06:34 PM, said:

When items surface from below water they can be picked up on the surface even though they are not visible.

I am pretty positive they are still physically in the above water sector, even if they are below the floor and appear "under water", and that's why you can pick them up. Similar to how enemies will half sink in above water sectors, or their corpses go "under water" when they die. I don't believe there's anything that allows you to pick up an item that is truly in the underwater sector from the above water sector.
0

User is offline   Danukem 

  • Duke Plus Developer

#3294

Use SFLAG_NOWATERDIP documented under .htflags to prevent sprites from appearing as partially submerged when on top of water. In reality, shorter sprites will completely disappear when using the hardcoded water dip even though they are still above the water. You could use your own code to make them dip only slightly or bob up and down after disabling the hardcoded water dip.
0

User is offline   MC84 

#3295

I'm trying to code a chaingun enemy and have it so when he loses sight of the player there's a wind-down action before either resuming the shooting or seeking the player. What I've got currently sort of works - except that if the player moves behind something thin like a window frame he'll start the wind-down... To try and get around this limitation I tried adding 'ifcount 16' so that he'll continue firing for 1/2 a second even if he's lost sight of the player, but the following doesn't seem to work (ie he'll stop firing immediately). Also the firing action is 4 frames, hence the doubling up of code here.

ifaction ABCOPSHOOT
{
	ifg beltcount 0
	{
		ifactioncount 2
		{
			ifcansee 
			{        
				ifcanshoottarget
				{
					sound CAPT_ATTACK
					shoot SHOTSPARK1
					sub beltcount 1
				}
			}
			else 
			ifcount 16
			{
				soundonce BCOPSH3 // wind-down sound
				action ABCOPWINDDN
			}
		}
		ifactioncount 4
		{
			ifcansee
			{
				ifcanshoottarget
				{
					sound CAPT_ATTACK
					shoot SHOTSPARK1
					sub beltcount 1
				}
			}
			else
			ifcount 16
			{
				soundonce BCOPSH3 // wind-down sound
				action ABCOPWINDDN
			}
		}
	}

0

User is offline   Danukem 

  • Duke Plus Developer

#3296

Try adding a "resetcount" into those blocks of code where he fires the bullet and makes the shooting sound.
0

User is offline   MC84 

#3297

View PostDanukem, on 17 April 2023 - 08:33 PM, said:

Try adding a "resetcount" into those blocks of code where he fires the bullet and makes the shooting sound.


Thank you - that does seem to improve it but it's still far from perfect - I guess a 'proper' solution would require some complex code that's probably beyond my capabilities, so for now I'll leave it be!
0

User is offline   Reaper_Man 

  • Once and Future King

#3298

View PostMC84, on 17 April 2023 - 02:34 PM, said:

I'm trying to code a chaingun enemy and have it so when he loses sight of the player there's a wind-down action before either resuming the shooting or seeking the player. What I've got currently sort of works - except that if the player moves behind something thin like a window frame he'll start the wind-down... To try and get around this limitation I tried adding 'ifcount 16' so that he'll continue firing for 1/2 a second even if he's lost sight of the player, but the following doesn't seem to work (ie he'll stop firing immediately). Also the firing action is 4 frames, hence the doubling up of code here.


If you wanted to not repeat code (generally a bad practice), you could move the repeated code into a new state block, and have the ifactioncount statements call that state, IE:

defstate doshooting
{
	ifcansee 
	{        
		ifcanshoottarget
		{
			sound CAPT_ATTACK
			shoot SHOTSPARK1
			sub beltcount 1
		}
	}
	else 
	ifcount 16
	{
		soundonce BCOPSH3 // wind-down sound
		action ABCOPWINDDN
	}
}
ends


ifaction ABCOPSHOOT
{
	ifg beltcount 0
	{
		ifactioncount 2
			state doshooting
		ifactioncount 4
			state doshooting
	}

1

User is offline   MC84 

#3299

View PostReaper_Man, on 18 April 2023 - 03:31 AM, said:

If you wanted to not repeat code (generally a bad practice), you could move the repeated code into a new state block, and have the ifactioncount statements call that state, IE:


That's a good tip! thank you
0

User is offline   Danukem 

  • Duke Plus Developer

#3300

It would sure be useful if there were script access to the map start position. I mean the coordinates and angle of the green arrow start position in mapster, not the multiplayer Duke sprites. But AFAIK that is not the case. Anyone know different?
0

Share this topic:


  • 120 Pages +
  • « First
  • 108
  • 109
  • 110
  • 111
  • 112
  • 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