How to detect if a monster has any nearby allies?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Sergeant_Mark_IV
Posts: 812
Joined: Wed Feb 02, 2011 12:44 pm
Location: United Communist Nazi Republic Dictactorship of Banana Land (Brazil)

How to detect if a monster has any nearby allies?

Post by Sergeant_Mark_IV »

This is a bit complicated to explain, but I am trying to make a script to detect if a monster has any fellas nearby.

For example, I want to detect if the monster has other monsters in sight. Let's say, if at the given animation he can't see any friendly monster nearby, he will jump to a different state.
Or the script could make the monster don't jump to a state if there are still monsters in sight.

Also, no, I can't have tagged monsters. This is supposed to work as a generic script to affect any monster placed in the map.

So far, I have been trying a DECORATE script poking with the A_CheckSight, A_JUmpIfTargetInLos, and A_ChangeFlag functions, but I still didn't got the expected result.

Code: Select all

          See: //Now the see state is not the state where the monster chases the player. The see state only checks if the monster has any allies nearby. If he has allies nearby, he should jump to the common chase state, but if all allies died and he is now the only one nearby fighting the player, he should act differently.
		TNT1 A 0 A_CheckSight("Chase") //Chase is supposed to be the See state. So, if theres no players in sight, he will just play his original see animation

	        XXXX A 1 A_ChangeFlag("FRIENDLY", 1) //Make the monster friendly for a instant so he can use the A_JumpIfTargetINLOS to check if there are any monsters nearby
		XXXX A 1 A_Chase // One A_Chase just to make sure that he will count the nearby monsters as targets.
		XXXX A 1 A_JumpIfTargetInLOS("Chase") //Check if the monster has valid allies in sight. If yes, he will jump to his chase state where he is going to change his friendly flag to 0 and act like a normal monster.
               //If the state didnt jumped to the chase state, it means that the monster failed to see any nearby allies. So this should take his friendly flag away, and jump to the special state.
                 XXXX A 1 A_ChangeFlag("FRIENDLY", 0)
		Goto SpecialState 
And I have a problem so far: It's never jumping to the specialstate. It always fails at checking if there are no friendly monsters nearby. Can anybody help me with this?
User avatar
Nightfall
Posts: 555
Joined: Thu Aug 06, 2009 4:00 am
Location: Finland

Re: How to detect if a monster has any nearby allies?

Post by Nightfall »

Shouldn't you be using A_LookEx to check for nearby allies? A_Chase moves the monster towards its current target, not look for new ones.
User avatar
Sergeant_Mark_IV
Posts: 812
Joined: Wed Feb 02, 2011 12:44 pm
Location: United Communist Nazi Republic Dictactorship of Banana Land (Brazil)

Re: How to detect if a monster has any nearby allies?

Post by Sergeant_Mark_IV »

Gonna check it. Thanks for the advice.
Locked

Return to “Editing (Archive)”