Hi. I've been working on a TC where I want the player to be able to work with allies. I think it would be cool to make it so that the Player can summon his allies with a spell. That way the player can have allies when they want them but they don't need to be overly concerned with their safety and they don't need to deal with them if they don't want npc help.
There's a big problem though, I don't want the player to be able to summon more than one ally of a particular type at any particular time because if they can do that they can spam the level with npc fodder and it'll be silly.
What would the code look like if the summon spell always worked but if the creature being summoned already existed on the map the first one would vanish and leave only the newest summon? Would that be better done with an event handler or a struct inside the spell? This is the code I've got for the spell, its ZScript I run on gzdoom version "4.10.0". I don't know where to start.
Class SUMMONMONSTER : CustomInventory
{
int inuse;
Default
{
+INVENTORY.INVBAR
+INVENTORY.UNDROPPABLE
+INVENTORY.UNTOSSABLE
Inventory.Icon "FAMSA0";
}
States
{
Use:
TNT1 A 0 A_Overlay(-2,"RAY");
TNT1 A 0 A_OverlayOffset(-2,0,32);
Fail;
RAY:
TNT1 A 0
{
if (CountInv("MANA") <= 59)
return ResolveState("NoRAY"); //if insufficent mana go to fizzled spell sequence
return ResolveState(null); //otherwise, don't jump, move on to the next frame
}
TOSS ABC 1;
TNT1 A 0 {
A_Print("SUMMON MONSTER");
A_TakeInventory("MANA",60);
A_SpawnItemEx("Malatrix",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0);
A_SpawnItem("TeleportFog");
A_PlaySound("familiar/throw");
}
TOSS D 2 ;
TOSS CBA 2;
TNT1 A 1;
Fail;
NoRAY:
TOSS ABC 1 {
A_StartSound("NotEnoughMana", CHAN_WEAPON);
A_Print("NOT ENOUGH MANA");
}
TOSS D 2;
TOSS CBA 2;
TNT1 A 1 A_ClearOverlays(-2,-2);
Fail;
}
}
Question
Nihlith
Hi. I've been working on a TC where I want the player to be able to work with allies. I think it would be cool to make it so that the Player can summon his allies with a spell. That way the player can have allies when they want them but they don't need to be overly concerned with their safety and they don't need to deal with them if they don't want npc help.
There's a big problem though, I don't want the player to be able to summon more than one ally of a particular type at any particular time because if they can do that they can spam the level with npc fodder and it'll be silly.
What would the code look like if the summon spell always worked but if the creature being summoned already existed on the map the first one would vanish and leave only the newest summon? Would that be better done with an event handler or a struct inside the spell? This is the code I've got for the spell, its ZScript I run on gzdoom version "4.10.0". I don't know where to start.
Share this post
Link to post
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.