Scripting monsters types to hate each other by default

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
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Scripting monsters types to hate each other by default

Post by Hidden Hands »

I need some help. I have two monster classes that I want to hate each other even more than they hate the player. Obviously, monsters attack each other in the Doom Engine if they accidentally hit each other while attacking the player, and in DECORATE we can code monsters to disable infighting. But how can I script these two monster types to attack each other upon seeing each other immediately, so their priority is each other first and foremost?

So basically, you're just in the middle of a war. You're not important to the two monsters primarily, you're just in the wrong place at the wrong time. These two monsters care more about killing each other than killing you. Until their rival is gone of course, then they turn fire on you.

Any advice please?
Thanks in advance.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Scripting monsters types to hate each other by default

Post by Enjay »

Sounds like using [wiki]Thing_Hate[/wiki] in an ACS script might do what you want.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Scripting monsters types to hate each other by default

Post by Hidden Hands »

Enjay wrote:Sounds like using [wiki]Thing_Hate[/wiki] in an ACS script might do what you want.
Sounds perfect. I'm currently using a linedef trigger, but that only works in a single instance.
User avatar
Ravick
Posts: 2003
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Re: Scripting monsters types to hate each other by default

Post by Ravick »

You can also use this command directly at the DECORATE code, without the need of an ACS script.

For example, this zombieman will chase any actor (player, monster, decoration) with a tid of 1000:

Code: Select all

ACTOR ZombieMan_teste : ZombieMan
{
  States
  {
  Spawn:
	POSS E 0 //This zero time frame prevents an internal bug, use it when calling a command at the very firts line of your actors.
	POSS E 1 Thing_hate (0, 1000, 0)
    POSS E 10 A_Look
    loop
	}
}
Just make sure to also use Thing_ChangeTID in each one of your monster species so they have different TIDs by default.

For example, any actor with this spawn label will be targeted by the previous zombieman when the game begins:

Code: Select all

  States
  {
  Spawn:
        PLAY A 0
	TNT1 A 0 Thing_ChangeTID (0,1000)
	PLAY A 1
    Loop
:)
Post Reply

Return to “Scripting”