EDuke32 Scripting "CON coding help"
#3271 Posted 02 April 2023 - 06:37 PM
#3273 Posted 03 April 2023 - 01:48 AM
Fox, on 03 April 2023 - 01:36 AM, said:
that's an Even Greater Solution than the one which more closely matches his prompt lol
#3274 Posted 03 April 2023 - 01:49 PM
#3275 Posted 03 April 2023 - 10:10 PM
VGames, on 03 April 2023 - 01:49 PM, said:
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.
#3276 Posted 12 April 2023 - 01:30 AM
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
#3277 Posted 12 April 2023 - 01:46 AM
but im pretty sleep deprived so i might be mistaken
[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
This post has been edited by jimbob: 12 April 2023 - 01:48 AM
#3278 Posted 12 April 2023 - 01:46 AM
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.
#3279 Posted 12 April 2023 - 01:08 PM
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..
#3280 Posted 12 April 2023 - 01:12 PM
MC84, on 12 April 2023 - 01:08 PM, said:
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
#3281 Posted 12 April 2023 - 01:16 PM
Danukem, on 12 April 2023 - 01:12 PM, said:
ifai AIVALDROWNING nullop else ifinwater ai AIVALDROWNING
That was quick! And yes bingo the action plays now. Thanks!
#3282 Posted 13 April 2023 - 12:29 PM
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
#3283 Posted 13 April 2023 - 12:53 PM
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)
#3284 Posted 14 April 2023 - 01:28 PM
#3285 Posted 14 April 2023 - 05:14 PM
#3286 Posted 14 April 2023 - 06:08 PM
#3287 Posted 15 April 2023 - 08:24 AM
#3288 Posted 15 April 2023 - 08:29 AM
lllllllllllllll, on 15 April 2023 - 08:24 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?
#3289 Posted 15 April 2023 - 06:34 PM
#3290 Posted 15 April 2023 - 09:27 PM
VGames, on 15 April 2023 - 08:29 AM, said:
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.
#3292 Posted 16 April 2023 - 11:02 AM
#3293 Posted 16 April 2023 - 11:33 AM
lllllllllllllll, on 15 April 2023 - 06:34 PM, said:
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.
#3294 Posted 16 April 2023 - 09:01 PM
#3295 Posted 17 April 2023 - 02:34 PM
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 } } }
#3296 Posted 17 April 2023 - 08:33 PM
#3297 Posted 18 April 2023 - 02:03 AM
Danukem, on 17 April 2023 - 08:33 PM, said:
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!
#3298 Posted 18 April 2023 - 03:31 AM
MC84, on 17 April 2023 - 02:34 PM, 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:
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 }
#3299 Posted 18 April 2023 - 12:59 PM
Reaper_Man, on 18 April 2023 - 03:31 AM, said:
That's a good tip! thank you