Page 1 of 1
NPC behavior
Posted: Wed Apr 10, 2013 2:15 pm
by RobbyPants
So, I've figured out how to make "NPCs" by adding the +FRIENDLY tag to a monster and removing the ISMONSTER tag. This makes them not attack you and attack monsters. Cool.
I've also found that you can add an afraid attribute that makes them scared of you so that they run away from you, but they seem to ignore monsters.
Is there a way to make then friendly (so they won't attack you), but afraid of the monsters? I'd like to have people that will run away from any monster they encounter, but I haven't figured a way to do that.
Thanks!
RE: NPC behavior
Posted: Wed Apr 10, 2013 2:44 pm
by Cruduxy
Well A_wander can simulate them running in circles while monsters attack them from all directions :P
RE: NPC behavior
Posted: Mon Apr 15, 2013 12:49 am
by RobbyPants
Oh well. I might be able to do something weird like have their pain state call A_FaceTarget then give them some recoil, so they back off, but that would look really odd. There's no opposite of A_FaceTarget, is there? Could I possibly call that, then use some ACS to rotate them 180 degrees?
RE: NPC behavior
Posted: Fri Apr 19, 2013 2:24 am
by RobbyPants
Incidentally, I figured out how to make it work. Assuming the NPCs are +FRIENDLY and call A_Wander and A_Look in their See state, I can make them run as follows:
Decorate:
Code: Select all
Melee:
POSS A 0 A_Jump (170, "RunAway")
POSS E 8 A_FaceTarget
POSS F 8 A_CustomMeleeAttack(random(1,10)*2,"grunt/sight","")
Goto RunAway
Missile:
Goto RunAway
RunAway:
POSS A 4 A_FaceTarget
POSS A 0 A_Scream
//turn 45 degrees four times
POSS A 3 ACS_Execute(123, 0, 0, 0, 0)
POSS B 3 ACS_Execute(123, 0, 0, 0, 0)
POSS C 3 ACS_Execute(123, 0, 0, 0, 0)
POSS D 3 ACS_Execute(123, 0, 0, 0, 0)
//run
POSS A 3 A_Recoil(-3)
POSS B 3 A_Recoil(-3)
POSS C 3 A_Recoil(-3)
POSS D 3 A_Recoil(-3)
POSS A 3 A_Recoil(-3)
POSS B 3 A_Recoil(-3)
POSS C 3 A_Recoil(-3)
POSS D 3 A_Recoil(-3)
Goto See
ACS:
Code: Select all
//turn actor 45
script 123 (void)
{
SetActorAngle(0, (GetActorAngle(0) + 0.125));
}
So, the idea is that they wander around, and when they find a target, they turn 180 degrees and run away! I decided to smooth out the animation a bit by breaking the turn into four 45 degree turns, using the A - D frames. It works fairly well. For the time being, I have them using the player death sound to scream every time they run. They'll occasionally make a melee attack out of desperation (33% chance), but they always run away after hitting.
RE: NPC behavior
Posted: Sat Apr 27, 2013 5:12 pm
by Lollipop
Idea for this thing: make them randomly turn left or right :D!