Jump to content

Is there a way to make monsters think before attacking?


CaptainManiac

Recommended Posts

Ok,i tried to make a decorate zombieman who thinks twice before attacking
Here is the code:
actor BlaBlaZombieman : Zombieman
+QuicktoRetaliate
+Floorclip
Monster
States
{
Spawn:
POSS AB 10 A_Look
loop
See:
POSS AABBCCDD 4 A_Chase
TNT1 A 1 A_Jump(65,"PreventAttack")
loop
PreventAttack:
TNT1 A 1 A_GiveInventory("NoAttack",1)
goto See
Missile:
TNT1 A 1 A_JumpIfInventory("NoAttack",1,"Spawn")
POSS E 10 A_FaceTarget
POSS F 8 A_PosAttack
POSS E 8
Goto See
Pain:
TNT1 A 1 A_TakeInventory("NoAttack,1)
POSS G 3
POSS G 3 A_Pain
Goto See
Death:
POSS H 5
POSS I 5 A_Scream
POSS J 5 A_NoBlocking
POSS K 5
POSS L -1
Stop
XDeath:
POSS M 5
POSS N 5 A_XScream
POSS O 5 A_NoBlocking
POSS PQRST 5
POSS U -1
Stop
Raise:
POSS K 5
POSS JIH 5
Goto See
}

loop
}

actor NoAttack:CustomInventory
{
-inventory.invbar
-countitem
+inventory.keepdepleted
inventory.maxamount 1
}



With all this code there is 65% chance for the zombie to not attack the player,but when i tested it the zombie still attacks the player.How to make it really prevent attack with 65% chance to prevent?Sorry for the dumb question

Share this post


Link to post

You should just take the base definition of the zombieman and add an 'A_Jump' action to the start of the 'Missile' state that points it back to the 'See' state with whatever amount of chance you want it to have.

Also, the chance in any variant of 'A_Jump' codepointer is out of 255, not 100.

http://zdoom.org/wiki/A_Jump

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...