Overcoming Limitations of Thing_Hate Behavior

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
ReX
Posts: 1584
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace
Contact:

Overcoming Limitations of Thing_Hate Behavior

Post by ReX »

Here's my scenario:
1. I have two enemies of one species tagged 14 (say, Team 1)
2. I have several enemies of two different species tagged 15 (say, Team 2)
3. My script is (Thing_Hate 14, 15); and (Thing_Hate 15, 14);
4. Once at least one member of each team is killed the surviving enemies appear to ignore the other team enemies.
5. This results in surviving enemies returning to their idle states rather than seeking out their opponents until all enemies with a given tag are killed

How should I set up my scenario so that the fighting continues until all enemies with a given tag are killed?

I suppose I can assign each enemy a unique tag and duplicate the Thing_Hate instructions, but this seems an extremely inelegant want to achieve what I want.

I'd appreciate any suggestions. Thanks.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Overcoming Limitations of Thing_Hate Behavior

Post by Logan MTM »

While loop checking the count, call the same script to force hellish chaos (i like that), until team A or B count 0?
User avatar
ReX
Posts: 1584
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace
Contact:

Re: Overcoming Limitations of Thing_Hate Behavior

Post by ReX »

Logan MTM wrote:While loop checking the count, call the same script to force hellish chaos (i like that), until team A or B count 0?
Yes, this is probably the way to go. Let me think about how to execute the loop.

Many thanks.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Overcoming Limitations of Thing_Hate Behavior

Post by Logan MTM »

Code: Select all

PrevTeamA = Thingcount(0,15);
PrevTeamB = Thingcount(0,16);
Delay(1);
LateTeamA = Thingcount(0,15);
LateTeamB = Thingcount(0,16);

If(PrevTeamA != LateTeamA || PrevTeamB != LateTeamB)
//inFighting script
User avatar
ReX
Posts: 1584
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace
Contact:

Re: Overcoming Limitations of Thing_Hate Behavior

Post by ReX »

Here's what I have, but it doesn't activate the HATE behavior in the enemies:
Spoiler:
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Overcoming Limitations of Thing_Hate Behavior

Post by Logan MTM »

And Never will! You forgot the While Loop! :|

This should work:

Code: Select all

int PrevTeamA;
int PrevTeamB;
int LateTeamA;
int LateTeamB;

script "Test" OPEN
{
Delay (140);

NoiseAlert(14,15);
NoiseAlert(15,14);

While(1)
 {
 PrevTeamA = Thingcount(0,14);
 PrevTeamB = Thingcount(0,15);

 Delay(1);

 LateTeamA = Thingcount(0,14);
 LateTeamB = Thingcount(0,15);

 If(PrevTeamA != LateTeamA || PrevTeamB != LateTeamB)
  {
  NoiseAlert(14,15);
  NoiseAlert(15,14);
  }

 If(!PrevTeamA || !PrevTeamB)
  {
  Terminate;
  }
 }
}
Edit: Tested and working! Besides, NoiseAlert works better for this matters!
User avatar
ReX
Posts: 1584
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace
Contact:

Re: Overcoming Limitations of Thing_Hate Behavior

Post by ReX »

Yes, it would have helped to have the WHILE statement in there.

It all works as expected now. Many thanks.
Post Reply

Return to “Scripting”