Visual Identifier For Monster

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Visual Identifier For Monster

Postby CaptainNurbles » Wed Nov 24, 2021 11:07 am

Simple enough, I've made a monster that, when detecting the player, lets out a scream that alerts all monsters nearby and gives them a buff to damage resistance. That part is fully functional, but I've been struggling to figure out how to make the buffed monsters visually distinct from non-buffed monsters. Something like a recolor to their sprites, or a floating aura of particles or something to denote to the player that they're tougher now. Any of y'all know a good way to universally make this work without having to go through every single monster actor and give them clones of their States with a differing appearance or something?
CaptainNurbles
 
Joined: 27 Jan 2018
Location: The Deepest Reaches of Space
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Visual Identifier For Monster

Postby Virathas » Wed Nov 24, 2021 1:17 pm

I do have a few solutions for you, both DECORATE and ZScript, (the latter prefered and cleaner, but the former is zandronum compatible)

(The code is actually ripped from my mod)

DECORATE:
Code: Select allExpand view
ACTOR LordshipFriendBonus : CustomInventory // Ignore this actor if the bonus cannot be used by non-enemies
{
  States
  {
  Pickup:
  Use:
   TNT1 A 0 A_CheckFlag("ISMONSTER", "MonsterTest")
   Goto GoAhead
  MonsterTest:
   TNT1 A 0 A_CheckFlag("FRIENDLY", "GoAhead")
   Stop
  GoAhead:
   TNT1 A 0 A_JumpIfInventory("LordshipBuff", 1, "NoMissile")
   TNT1 A 0 A_CustomMissile("LordshipBuffTrail", 40, 0, 0)
  NoMissile:
   TNT1 A 0 A_TakeInventory("LordshipBuff", 1)
   TNT1 A 0 A_GiveInventory("LordshipBuff", 1)
    Stop
  }
}
ACTOR LordshipBonus : CustomInventory // This is the item you should give to the monster. It grants the actual buff, and creates a VFX
{
  States
  {
  Pickup:
  Use:
   TNT1 A 0 A_CheckFlag("FRIENDLY", "NoAhead")
   TNT1 A 0 A_JumpIfInventory("LordshipBuff", 1, "NoMissile")
   TNT1 A 0 A_CustomMissile("LordshipBuffTrail", 40, 0, 0)
  NoMissile:
   TNT1 A 0 A_TakeInventory("LordshipBuff", 1)
   TNT1 A 0 A_GiveInventory("LordshipBuff", 1)
    Stop   
  NoAhead:
   TNT1 A 0
   Stop
   
  }
}
actor LordshipBuff : PowerDamage // The buff, you have your own for this
{
   damagefactor "normal", 1.5
   Inventory.Icon "I_RSTR"
   powerup.Duration 36
}
ACTOR LordshipBuffTrail // The actual VFX for the effect, in this case it is an orb flying in circles close to the bottom of the monster
{
  RenderStyle "Add"
 Translation "0:255=%[0,0,0]:[1.7,0.2,0.2]"

   +MISSILE
   +NOINTERACTION
   
  var int user_angle;

  States
  {
   Spawn:
      PDDR A 0
   Idle:
      BAL1 A 1 Bright A_Warp(AAPTR_TARGET, 32, 0, 4, user_angle, WARPF_ABSOLUTEANGLE|WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
      MTRX A 0 A_JumpIfinTargetInventory("LordshipBuff", 1, "Continue") // Check for the buff item
      MTRX A 0 A_Jump(256,"Death")
   Continue:
      TNT1 A 0 A_SetUserVar("user_angle", user_angle + 8)
      goto Idle
   Death:
      TNT1 A 0
      Stop
   }
}

ACTOR LordshipAuraActivator : CustomInventory // You probably wont need this, this item is more of a wrapper that i use directly from a monster.
{
   +Untossable
   -INVENTORY.INVBAR
   +AUTOACTIVATE
   Inventory.Amount 1
   Inventory.MaxAmount 0
   INVENTORY.InterHubAmount 0
   States
   {
   Spawn:
       PINV ABCD 6 Bright
       Loop
   Use:
      TNT1 A 0 A_CheckFlag("FRIENDLY", "FriendlyBuff")
       TNT1 A 0 A_RadiusGive("LordshipBonus",256,RGF_MONSTERS, 1)
      Stop      
   FriendlyBuff:
      TNT1 A 0 A_JumpIfInventory("MMAuraRangeBonus", 1, "FriendlyBuffRange")      
       TNT1 A 0 A_RadiusGive("LordshipFriendBonus",256,RGF_MONSTERS | RGF_PLAYERS, 1)
      TNT1 A 0
      Stop
   FriendlyBuffRange:
       TNT1 A 0 A_RadiusGive("LordshipFriendBonus",384,RGF_MONSTERS | RGF_PLAYERS, 1)
      TNT1 A 0
      Stop
   }
}



ZScript(Also ripped):
Code: Select allExpand view
class CurseSpellEffect : PowerProtection
{
   Default
   {
   Damagefactor "normal", 1.5;
   Damagefactor "SelfDamage", 1.0;
   PowerUp.Duration -30;
   Inventory.Icon "I_RRGN";
   
   }
   override void DoEffect()
   {
      Super.DoEffect();
      if (health > 900) // All actors by default have 1000 health, so this is certain to run only once
      {
         if (Owner is "PlayerPawn")
         {
         Owner.A_Print("You feel weakened!"); // A message that you are debuffed
         }
      }
      if (Owner.Health > 0 && health >= 4) //Once every 4 tics a VFX is spawned
      {
         Actor speedMo = Spawn("CurseDoodad", Owner.Pos + (random(-Owner.Radius,Owner.Radius),random(-Owner.Radius,Owner.Radius),Owner.Height * 0.8), NO_REPLACE);
         if (speedMo)
         {
            speedMo.Angle = Owner.Angle;
            speedMo.Vel.Z = random(1,2);


            if (Owner == players[consoleplayer].camera &&
               !(Owner.player.cheats & CF_CHASECAM))
            {
               speedMo.bInvisible = true;
            }
         }
         Health = 0;
      }
      health++;
//         A_Log(TEXTCOLOR_BLACK .. "---");
   }
}


If you need any help understanding the code, feel free to ask - i personally was hyped when i figured this all out myself :)
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: Visual Identifier For Monster

Postby CaptainNurbles » Fri Nov 26, 2021 1:17 pm

The DECORATE is doing the job fine enough! Decided to add a few lines of code onto it to make the revolving sprite invisible and in its place fullbright particles are floating around the affected monsters.
CaptainNurbles
 
Joined: 27 Jan 2018
Location: The Deepest Reaches of Space
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests