Enemy last stand states?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Enemy last stand states?

Post by Graaicko »

So back in 2014 I made some terrorist sprite that have a last stand sprites. I've seen this before and was wondering what the code would look like for something like this?

Heres what I mean:
Image
User avatar
Voros
Posts: 151
Joined: Fri Feb 03, 2017 11:47 pm

Re: Enemy last stand states?

Post by Voros »

Code: Select all

Death:
    AAHH A 2 A_Jump(127, "LStand")
    AAHH B 3
    AAHH C -1
Stop
LIdle:
    NZAH D 2 A_JumpIfTargetInLOS("LStand")
Loop
LDeath:
    NZAH JKL 2
    NZAH M -1
Stop
LStand:
    NZAH EFG 2
    NZAH H 2 A_FirePistol
    NZAH I 2 A_Jump(127, "LDeath", "LStand")
Goto LIdle
Something similar to this I guess.

Overview:
In Death, there's a 50% chance of it going to the LStand state.
In LStand state, it fires a pistol at the player. Then has a 50% chance of firing again or dying.
In LDeath, the actor dies in its last stand state (LStand).
In LIdle, it checks if the target in its line of sight before engaging. I have never used A_JumpIfTargetInLOS, but I assume this is how you use it.
Last edited by Voros on Mon Aug 14, 2017 11:06 pm, edited 1 time in total.
Nevander
Posts: 2254
Joined: Mon Jan 06, 2014 11:32 pm

Re: Enemy last stand states?

Post by Nevander »

Shouldn't the ending states be -1 duration?
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Enemy last stand states?

Post by Graaicko »

Yeah, I believe so. I dont have rotations for the last stand sprites.
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Enemy last stand states?

Post by Graaicko »

Btw is there a way to randomize it?
User avatar
Voros
Posts: 151
Joined: Fri Feb 03, 2017 11:47 pm

Re: Enemy last stand states?

Post by Voros »

It's only an example. Just trying to give a good enough example for Graaicko.

But still, which ending state should be -1?
User avatar
DoomRater
Posts: 8265
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Re: Enemy last stand states?

Post by DoomRater »

LDeath. It needs to have a frame with -1 duration instead of a Stop command.
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Enemy last stand states?

Post by Graaicko »

Alright set everything up, tried testing it but it gave this: (Script error, "SE5.wad:DECORATE" line 1112:
Invalid parameter 'a_firepistol').
User avatar
Voros
Posts: 151
Joined: Fri Feb 03, 2017 11:47 pm

Re: Enemy last stand states?

Post by Voros »

You didn't actually use my code did you? You'll need to work on it more. What I posted is a proof of concept.
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Enemy last stand states?

Post by Graaicko »

Well I replaced it with A_CustomBulletAttack and fixed some of the states, but he doesnt wait to shoot and dies imediately after firing a few shots. he dies too quick. also when hes in his last stand, hes not shootable, and was wondering if there is a way to change the 'chance' value that he will go into last stand mode? 50 out 50 seems too much.
User avatar
Voros
Posts: 151
Joined: Fri Feb 03, 2017 11:47 pm

Re: Enemy last stand states?

Post by Voros »

256 is 100%. Change the value between 1-256 get different results.
Increase the number of frames via repeating the same frames 5 times then the frames related to jumping states come in.
Increase the number of tics. The ones I gave are very low.

Obviously you'll have to experiment a bit. And consider using dummy inventory items.
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Enemy last stand states?

Post by Graaicko »

Okay, many thanks. Bit of an odd thing for a probability system.
User avatar
DoomRater
Posts: 8265
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Re: Enemy last stand states?

Post by DoomRater »

For making the target shootable, it might be best to rework the entire monster using Wound states instead.

Wound states typically are entered when a monster reaches 6 health but you can override this to exactly the amount of health you set. Basically, using wound states you can make it so monsters can be overkilled so they can never enter this state, but if they reach this state on their own and they're supposed to just die instead of lying there trying to shoot you with a pistol, you can use actor commands to kill them. At that point, they'll lie there and just be ready to shoot the player, all wounded.

viewtopic.php?f=3&t=30642 Over here has an example of what wound states do to a player. Finally, using the example coded in this thread...

Code: Select all

Wound:
    AAHH A 2 A_Jump(127,2)
    AAHH A 1 A_Die
Goto Death
LIdle:
    NZAH D 2 A_JumpIfTargetInLOS("LStand")
Loop
LDeath:
    NZAH JKL 2
    NZAH M -1
Stop
LStand:
    NZAH EFG 2
    NZAH H 2 A_FirePistol
    NZAH I 2
Goto Wound
What I would do is add however much extra health a character should have in this wounded state to their base health and set that amount of wound health to the "Woundhealth" property.
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Re: Enemy last stand states?

Post by Graaicko »

Sent you a pm Rater. :)
User avatar
DoomRater
Posts: 8265
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Re: Enemy last stand states?

Post by DoomRater »

Although I got it, I haven't had a free moment to debug anything. I'll report back when I do!
Locked

Return to “Editing (Archive)”