How does the AI prevent monsters from seeing the corpses of friendly monsters? Does it check for the "Corpse" flag?
If so, would removing that flag and setting the "Friendly" flag on monsters when they die allow the AI to be alerted when coming across another dead monster? Or is there an easier way to do this?
Re: Monsters Checking For Corpses
Posted: Sun Sep 18, 2022 4:44 pm
by Jarewill
I am pretty sure monsters don't detect friendly monsters at all for performance reasons.
If you want to make monsters see dead monsters, here's how I did it in my mod:
Override void Tick()
{
Super.Tick();
If(health>0)
{
For(let i = BlockThingsIterator.Create(self,256); i.Next();)
{ //Iterate through all things within 256 map units
Actor other = i.thing;
If(other==self)
{Continue;} //If the found thing is the monster itself, skip
double distance = Distance3D(other);
If(distance>256)
{Continue;} //If distance is greater than 256, skip
Actor prevtarg = target;
target=other //Temporarily change the monster's target while saving the previous one
If(other.bISMONSTER && other.health<1 && CheckIfTargetInLOS(90))
{ //If the thing is a monster with less than 1 health (dead) and it's in the monster's cone of vision, continue
target=other.target; //Set the target as the dead monster's target
A_AlertMonsters(1); //Alert itself to start the chase
}
Else{target=prevtarg;} //If previous check fails, reset the target
}
}
}
Put this Tick override within your monster's class in ZScript.
Or rather this is modified code that I'm not 100% sure will work, but it still might be a good start.
Re: Monsters Checking For Corpses
Posted: Sun Sep 18, 2022 4:49 pm
by Drake Raider
I was curious what mod you were referring to, and just found Lost Frontier, is that a separate campaign for Strife or is it a gameplay mod? Because Strife is where I was planning to use it.
(Though this code is probably still good as a modder's resource, thank you!)