I want an actor to access a custom function of another actor.
I.e., when one of my enemies dies, I want it to instill panic in the other enemies around them. The issue is, in my code below the "CausePanic" function tells me that it does not know the "IncreasePanic" function ("Unknown function IncreasePanic").
Code: Select all
class WalpurgisNightEnemy : Actor
{
int currentPanicInt;
property CurrentPanic : currentPanicInt;
int PanicThresholdInt;
property PanicThreshold : PanicThresholdInt;
double panicRangeDouble;
property PanicRange : panicRangeDouble;
void IncreasePanic(int increaseAmount)
{
currentPanicInt = currentPanicInt + increaseAmount;
}
bool DecreasePanic(int decreaseAmount)
{
//Don't go below 0
if(decreaseAmount > currentPanicInt)
{
currentPanicInt = currentPanicInt - decreaseAmount;
}
else
{
currentPanicInt = 0;
}
//return true if no longer panicked.
if(currentPanicInt > 0)
{ return true; }
else
{ return false; }
}
void CausePanic(int amount, double rad)
{
//Create Iterator
BlockThingsIterator PanicTargets = BlockThingsIterator.Create(self, rad);
while(PanicTargets.Next())
{
let obj = PanicTargets.thing;
if(obj.bISMONSTER && obj.health > 0 && Distance3d(obj)<=rad)
{
obj.IncreasePanic(amount);
}
}
}
Default
{
//$Category "WN_Monsters"
+ISMONSTER;
WalpurgisNightEnemy.CurrentPanic 0;
WalpurgisNightEnemy.PanicThreshold 5;
WalpurgisNightEnemy.PanicRange 256;
}
}
I tried to figure out object scropes (https://zdoom.org/wiki/Object_scopes_and_versions), but those do not seem to work. Giving IncreasePanic the "clearscope" or "virtualscope" flag does not work (I just get the additional error that the expression inside "must be a modifiable value", while the Cause Panic function still does not know the IncreasePanic function). Omitting the function and trying to access "obj.CurrentPanic" or "obj.CurrentPanicInt" also does not work.
Does anyone know where to set what flag or if I need a completely different approach?
Thanks in advance!