...But what if you want it to check to see if there are allies for it to heal or buff, before entering those states, and to avoid going into them if there's nothing around for it to heal or buff? Now things get a little harder.
Here is a method for a monster to check around it for potential "targets" to heal or buff, without using ACS, and without exhaustive and extensive editing of all your other monsters. This tutorial expects that you have some expertise with DECORATE; I'd rate it somewhere between beginner and intermediate difficulty.
This method relies on the fact that any action functions exectued by a CustomInventory actor in its Pickup state are treated as though the actor picking them up is the one executing them, rather than the pickup. Not only does this mean we don't have to do tons of edits to all the monsters, it comes in handy with some tweaks you may want to do when using the method in your mod.
So, let's start with the monster we want to have the healing ability:
Code: Select all
ACTOR HealingWizard : Wizard
{
States
{
RadiusHeal:
TNT1 A 0 A_RadiusGive("HealingWizardAlliesCheck",512,RGF_MONSTERS,5)
WZRD A 4 A_Chase
TNT1 A 0 A_JumpIfInventory("HealingWizardAlliesTrue",1,"AlliesFound")
Goto See
}
}
Code: Select all
ACTOR HealingWizardAlliesCheck : CustomInventory
{
+ALWAYSPICKUP
States
{
Pickup:
TNT1 A 0 A_RadiusGive("HealingWizardAlliesCheckBack",512,RGF_MONSTERS,5)
Stop
}
}
Code: Select all
ACTOR HealingWizardAlliesCheckBack : CustomInventory
{
+ALWAYSPICKUP
States
{
Pickup:
TNT1 A 0 A_JumpIf(CheckClass("HealingWizard",AAPTR_DEFAULT),"PickupWizard")
Stop
PickupHealerGolem:
TNT1 A 0 A_GiveInventory("HDRLAHealerGolemAlliesTrue")
Stop
}
}
Code: Select all
ACTOR HealingWizardAlliesTrue : Inventory{+ALWAYSPICKUP}
Now, let's check back with our HealingWizard.
Code: Select all
ACTOR HealingWizard : Wizard
{
States
{
RadiusHeal:
TNT1 A 0 A_RadiusGive("HealingWizardAlliesCheck",512,RGF_MONSTERS,5)
WZRD A 4 A_Chase
TNT1 A 0 A_JumpIfInventory("HealingWizardAlliesTrue",1,"AlliesFound")
Goto See
AlliesFound:
WZRD CCCCCC 4 A_FaceTarget
WZRD D 12 A_RadiusGive("HealingWizardHealth",512,RGF_MONSTERS,5)
TNT1 A 0 A_TakeInventory("HealingWizardAlliesCheck")
TNT1 A 0 A_TakeInventory("HealingWizardAlliesCheckBack")
TNT1 A 0 A_TakeInventory("HealingWizardAlliesTrue")
Goto See
}
}
ACTOR HealingWizardHealth : CustomInventory
{
+ALWAYSPICKUP
States
{
Pickup:
TNT1 A 0 A_SetHealth(health+random(1,2))
Stop
}
}
And... that's that! There's a lot of flexibility to this method, so put your own spin on it! For example, you could have the monster check for different amounts of the item it gets (HealingWizardAlliesTrue in our example) to determine the strength of its healing ability; if there aren't many monsters in the area, the healer could jump to a state where the healing effect is stronger. Or it could check for multiples of that item to set the priority with which it uses the heal ability. Or, how about checking to see if there are any allies that need healing badly, and prioritizing the healing ability then? You could do something like this:
Code: Select all
ACTOR HealingWizardAlliesCheck : CustomInventory
{
+ALWAYSPICKUP
States
{
Pickup:
TNT1 A 0 A_JumpIfHealthLower(40,"Critical")
TNT1 A 0 A_RadiusGive("HealingWizardAlliesCheckBack",512,RGF_MONSTERS,5)
Stop
Critical:
TNT1 A 0 A_RadiusGive("HealingWizardAlliesCheckBackCritical",512,RGF_MONSTERS,5)
Stop
}
}
Code: Select all
ACTOR HealingWizardAlliesCheck : CustomInventory
{
+ALWAYSPICKUP
States
{
Pickup:
TNT1 A 0 A_JumpIf(CheckClass("DoomPlayerRoboBuddy",AAPTR_DEFAULT),"PickupFail")
TNT1 A 0 A_RadiusGive("HealingWizardAlliesCheckBack",512,RGF_MONSTERS,5)
Stop
PickupFail:
Stop
}
}