Killing an Enemy makes them friendly?

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
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Killing an Enemy makes them friendly?

Post by Hidden Hands »

How can I code this? Instead of the enemy being shot to death, I want to "shoot the evil out of them" and make them change into an NPC that roams around the map. Like an Exorcism of sorts? I'm sure I've seen this done before, I think it was a Doom mod in which you could rescue people. How would I code this please?

Thanks in advance.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Killing an Enemy makes them friendly?

Post by Void Weaver »

Strongly depends on way that kill enemy (melee, projectile, puff), but in general easiest way I guess are: kill enemy=>resurrect it+set on FRIENDLY flag.

If you are looking for specific example:

Code: Select all

//That plasmaball will resurrect and\or turn friendly revived enemies
Actor Charmer : PlasmaBall replaces PlasmaBall
{
+HITTRACER //Pointer-marker flag
Damage (0) //Damage set below
{
Death:
    PLSE AB 4 Bright
    PLSE C 4 Bright A_DamageTracer(random(1,8)*5) //Damage set here
    PLSE C 0 A_GiveInventory("Ass-kicker",1,AAPTR_TRACER) //Main item operator
    PLSE DE 4 Bright
    Stop
}
}

Actor Ass-kicker : CustomInventory
{
+INVENTORY.ALWAYSPICKUP
Inventory.MaxAmount 0
{
Pickup:
TNT1 A 0 A_JumpIfHealthLower(41,1) //If my health higher then value then... 
Goto Pickup+5 //... do nothing, else...
TNT1 A 0 A_CheckFlag("CORPSE",1) //... check is I still alive. If true then...
Goto Pickup+3 //... I will serve to player, else...
TNT1 A 0 Thing_Raise(0) //... I'll revive self...
TNT1 A 0 A_ClearTarget //(If any)
TNT1 A 0 A_ChangeFlag("FRIENDLY",1) //... and will serve to player
TNT1 A 0
Stop
}
}
EDIT:
Core actions moved into CustomItem.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Killing an Enemy makes them friendly?

Post by Hidden Hands »

Void Weaver wrote:Strongly depends on way that kill enemy (melee, projectile, puff), but in general easiest way I guess are: kill enemy=>resurrect it+set on FRIENDLY flag.

If you are looking for specific example:

Code: Select all

//That plasmaball will resurrect and\or turn friendly revived enemies
Actor Charmer : PlasmaBall replaces PlasmaBall
{
+HITTRACER //Pointer-marker flag
Damage (0) //Damage set below
{
Death:
    PLSE AB 4 Bright
    PLSE C 4 Bright A_DamageTracer(random(1,8)*5) //Damage set here
    PLSE C 0 A_GiveInventory("Ass-kicker",1,AAPTR_TRACER) //Main item operator
    PLSE DE 4 Bright
    Stop
}
}

Actor Ass-kicker : CustomInventory
{
+INVENTORY.ALWAYSPICKUP
Inventory.MaxAmount 0
{
Pickup:
TNT1 A 0 A_JumpIfHealthLower(41,1) //If my health higher then value then... 
Goto Pickup+5 //... do nothing, else...
TNT1 A 0 A_CheckFlag("CORPSE",1) //... check is I still alive. If true then...
Goto Pickup+3 //... I will serve to player, else...
TNT1 A 0 Thing_Raise(0) //... I'll revive self...
TNT1 A 0 A_ClearTarget //(If any)
TNT1 A 0 A_ChangeFlag("FRIENDLY",1) //... and will serve to player
TNT1 A 0
Stop
}
}
EDIT:
Core actions moved into CustomItem.
Thank you for this. Is there a simple way to make it resurrect with a differnt sprite set? For example, without red eyes to show its back to normal. Alternatively, a way to kill the monster, and in its place, according to its death, spawn a new, friendly version? Similar to how the Pain Elemental spawns Lost Souls but instantanious and only one friendly version of the same monster?
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Killing an Enemy makes them friendly?

Post by Void Weaver »

Hidden Hands wrote:Is there a simple way to make it resurrect with a differnt sprite set? For example, without red eyes to show its back to normal.
I guess there is no simple way to do it on DECORATE.
Hidden Hands wrote:Alternatively, a way to kill the monster, and in its place, according to its death, spawn a new, friendly version?
Easy. Just use A_SpawnItemEx("similar_monster_of_the_same_class_with_a_bit_different_sprites") for that. But in that case you haven't needs use revive and\or "charming" at all. :| Just kill monster and spawn via _SpawnItemEx friendly one version on enemy's death place. And if you want to emulate resurrection animation then make sure that your new friend start its spawn animation from its "Raise:" state sequence, and don't forget to remove dead body by one of A_Remove f-tions.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Killing an Enemy makes them friendly?

Post by Hidden Hands »

Void Weaver wrote:
Hidden Hands wrote:Is there a simple way to make it resurrect with a differnt sprite set? For example, without red eyes to show its back to normal.
I guess there is no simple way to do it on DECORATE.
Hidden Hands wrote:Alternatively, a way to kill the monster, and in its place, according to its death, spawn a new, friendly version?
Easy. Just use A_SpawnItemEx("similar_monster_of_the_same_class_with_a_bit_different_sprites") for that. But in that case you haven't needs use revive and\or "charming" at all. :| Just kill monster and spawn via _SpawnItemEx friendly one version on enemy's death place. And if you want to emulate resurrection animation then make sure that your new friend start its spawn animation from its "Raise:" state sequence, and don't forget to remove dead body by one of A_Remove f-tions.
Thanks, I did it this way. Works great, thank you a ton.
Post Reply

Return to “Scripting”