different pain states for different action frames

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

different pain states for different action frames

Post by bimshwel »

I have a monster that stands in place, picking up bowling balls and tossing them down stairs or whatever. I would like it to have different pain frames depending on if it is hurt while holding a ball (it will drop the ball in an incorrect direction) or not holding one (it will drop nothing). I know it is possible to set the damage factor for any frame I choose, but can I alter the damage appearance?
it is also possible to have two versions of the creature that spawn each other when they finish their job and transfer the hit points remaining (probably), which I will do if necessary. Or I can make it impervious to damage while holding the ball but that would feel cheap!

I could probably do something with like setting ball = true or = false on the action frames, and then for the pain state, something like if ball = true, goto pain + x but figuring out the syntax takes me a long time.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: different pain states for different action frames

Post by Blue Shadow »

It can be done easily. To give you an idea, here's an example, written in DECORATE:

Code: Select all

actor TestBaron : BaronOfHell
{
    var int user_attacking;

    PainChance 256 // Just to test this easily.

    States
    {
    See:
        BOSS A 0 A_SetUserVar("user_attacking", 0)

    See2:
        BOSS AABBCCDD 3 A_Chase
        Loop

    Melee:
    Missile:
        // The monster is attacking, so set the variable to 1.
        BOSS A 0 A_SetUserVar("user_attacking", 1)
        BOSS EEEEEEEEE 8 A_FaceTarget
        BOSS F 8 A_FaceTarget
        BOSS G 8 A_BruisAttack
        Goto See

    Pain:
        // If the variable is 1, then the monster was trying to attack, so use a different pain sequence.
        BOSS H 2 A_JumpIf(user_attacking == 1, "AltPain")
        BOSS H 2 A_Pain
        Goto See

    AltPain:
        BOSS H 2
        BOSS H 105 A_Pain
        Goto See
    }
} 
Reference: [wiki]User variable[/wiki]
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: different pain states for different action frames

Post by bimshwel »

ah thank you! I was examining some other script i found with vars in it but there were just too many for me to comprehend at this stage, never having used them previously. i will try that at my first opportunity. This is a relief; the person i reached in the discord earlier seemed to think it would be a lot more complicated.
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: different pain states for different action frames

Post by bimshwel »

Here is a cheap video that shows what the things looks like at present, including its ability to drop the ball when attacked, although some of the sound effects are not implemented yet and these are not necessarily the places where I would actually place the idiot.
https://youtu.be/1uDQkGrWojg
I cannot even get the video embed code to work. And so is a big deal that the monster does.
Post Reply

Return to “Scripting”