Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
CaptainManiac

Is there a way to make monsters think before attacking?

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

Ok,i put that in the Missile State,giving 127.5 chance of going back into the See state,but the zombie still attacks me

Crap,i used Floating point instead of integer

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×