Unique monsters

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.

Unique monsters

Postby Sebelino » Thu Oct 19, 2017 5:38 pm

I have implemented a weapon that spawns a monster of a certain actor class each time it is fired. I want to make sure that there can only exist at most one such monster at any given time.

I figured that one way to do it would be to kill all monsters of that type (if any) in the map immediately when the weapon is fired. How do I do that in Decorate/ACS/ZScript?

Any alternative solutions?
User avatar
Sebelino
 
Joined: 28 May 2017

Re: Unique monsters

Postby comet1337 » Thu Oct 19, 2017 5:44 pm

give the player an inventory token
use a_spawnitemex to set the player as the monster's master
when the monster dies, use a_takeinventory("monsterlimiter", 1, aaptr_master)
and in the weapon, check for the inventory item and disallow firing if it is present
User avatar
comet1337
 
Joined: 25 Sep 2015
Location: elsewhere

Re: Unique monsters

Postby Matt » Thu Oct 19, 2017 11:28 pm

User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Unique monsters

Postby Sebelino » Fri Oct 20, 2017 3:15 pm

Thank you both. I went with the simple but effective A_CheckProximity solution:

Code: Select allExpand view
actor HuaPoDSP : DSP
{
   Weapon.SelectionOrder 3200
   Weapon.AmmoUse 50
   Weapon.AmmoGive 0
   Weapon.SlotNumber 8
   Inventory.Pickupmessage "You formed a contract with Hua Po!"
   States
   {
   Ready:
      HUPG A 1 A_WeaponReady
      Loop
   Deselect:
      HUPG A 1 A_Lower
      Loop
   Select:
      HUPG A 1 A_Raise
      Loop
   Fire:
       NULL A 0 A_CheckProximity("Error", "HuaPoAlly", 100000) // Distance should be infinity
      // Fall through
   Summon:
      NULL A 0 A_PlaySound("demon/appear")
      NULL A 0 A_FireProjectile(HuaPoBall, 0, 1, 0, 0, 0, -90) // Workaround for losing ammo
      NULL A 0 A_SpawnItemEx("TeleportFog", 100, 0, 0)
      CEXE A 15 A_SpawnItemEx("HuaPoAlly", 100, 0, 0)
      CEXE A 15 A_PlaySound("huapo/sight", CHAN_AUTO)
      HUPG A 5 A_ReFire
      Goto Ready
   Error:
      CERR A 15 A_PlaySound("ui/error", CHAN_AUTO)
      Goto Ready
   Flash:
      CEXE A 7 Bright A_Light1
      Goto LightDone
      CEXE A 7 Bright A_Light1
      Goto LightDone
    }
}
User avatar
Sebelino
 
Joined: 28 May 2017


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests