NPC behavior

Discuss all aspects related to modding Zandronum here.
Post Reply
RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

NPC behavior

#1

Post by RobbyPants » Wed Apr 10, 2013 2:15 pm

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!

Cruduxy
Zandrone
Posts: 1059
Joined: Fri Jun 08, 2012 4:24 pm

RE: NPC behavior

#2

Post by Cruduxy » Wed Apr 10, 2013 2:44 pm

Well A_wander can simulate them running in circles while monsters attack them from all directions :P
[][][][][][][][][][][][][][][]
Nothing to see here
[][][][][][][][][][][][][][][]

RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

RE: NPC behavior

#3

Post by RobbyPants » Mon Apr 15, 2013 12:49 am

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?

RobbyPants
 
Posts: 37
Joined: Wed Mar 13, 2013 12:53 am

RE: NPC behavior

#4

Post by RobbyPants » Fri Apr 19, 2013 2:24 am

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.

Lollipop
Zandrone
Posts: 1124
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

RE: NPC behavior

#5

Post by Lollipop » Sat Apr 27, 2013 5:12 pm

Idea for this thing: make them randomly turn left or right :D!
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there

Post Reply