[DECORATE]Custom enemy only shoots forward

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.

[DECORATE]Custom enemy only shoots forward

Postby lizardcommando » Thu Nov 26, 2020 12:40 am

Hi guys.

I'm making a mini mod that basically changes all the hitscanning enemies shoot projectiles. The shotgun enemy I made seems to only shoot forward. For example, if I am above the enemy, he won't be able to aim properly at all. I am not sure what I am doing wrong here.

Code: Select allExpand view
ACTOR Shotgunner replaces ShotgunGuy
{
   health 30
   height 56
   mass 130
   speed 9
   Scale 1.1
   MONSTER
   +FLOORCLIP
   painchance 170
   AttackSound "weapons/shotgun"
   Obituary "%o was shot by a Shotgunner."
   DropItem Shotgun 255 4
   SeeSound "enemysoldier/sight"
   PainSound "enemysoldier/pain"
   DeathSound "enemysoldier/death"
   ActiveSound "enemysoldier/active"
   States
   {
   Spawn:
      SGNR A 10 A_Look
      loop
   See:
      SGNR AABBCCDD 3 A_Chase
      loop
   Missile:
      SGNR E 10 A_FaceTarget
      SGNR F 1 bright A_PlaySound("weapons/shotgun")
      SGNR FFFFF 1 bright A_CustomMissile("EnemyShotgunShot", 36, 0, random(-9, 9), 6, random(-9, 9))
      SGNR E 10
      goto See
   Pain:
      SGNR G 3
      SGNR G 3 A_Pain
      goto See
   Death:
      SGNR A 0 A_Jump(65,"Death2")
      SGNR A 0 A_Jump(75,"Death3")
      SGNR H 4
      SGNR I 4 A_Scream
      SGNR J 4 A_NoBlocking
      SGNR K 4
      SGNR L -1
      stop
   Death2:
      SGD2 A 3
      SGD2 B 3 A_Scream
      SGD2 C 3 A_NoBlocking
      SGD2 DEF 3
      SGD2 G -1
      stop
   Death3:
      SGD3 A 3
      SGD3 B 3 A_Scream
      SGD3 C 3 A_NoBlocking
      SGD3 DEF 3
      SGD3 G -1
      stop
   XDeath:
      SGNR M 3
      SGNR N 3 A_PlaySound("misc/sloppy")
      SGNR O 3 A_NoBlocking
      SGNR PQRST 3
      SGNR U -1
      stop
   Raise:
      SGNR LKJIH 5
      goto See
   Burn:
      BURN A 3 BRIGHT
      BURN B 3 BRIGHT A_PlaySound("misc/firedie")
      BURN CDEFABCDEFGHIJKLMN 3 BRIGHT
      BURN O 3 BRIGHT A_NoBlocking
      BURN PQRST 3 BRIGHT
      BURN U 3
      BURN V -1
      Stop
   }
}
User avatar
lizardcommando
Thread killer
 
Joined: 07 Sep 2006
Location: Boringland, California

Re: [DECORATE]Custom enemy only shoots forward

Postby Player701 » Thu Nov 26, 2020 1:07 am

You've set the fifth argument of A_CustomMissile to 6. This means the following flags are used:

ZDoom Wiki wrote:CMF_AIMDIRECTION - The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch.
CMF_TRACKOWNER - If a missile is fired by another missile, use this flag to ensure the secondary projectile knows who is its real owner. This behavior would have been the default, but it wasn't in the 2.0.x branch of ZDoom, allowing erroneous behavior which has been used by some mods, so fixing this would break compatibility.

CMF_AIMDIRECTION is what probably messing it up. I'm pretty sure you don't need CMF_TRACKOWNER either, since your missile is not fired by another missile. You probably have to change the value from 6 to 0 so that everything works properly.

In addition to the above, I'd also recommend the following:

  1. Do not use A_CustomMissile since it's been deprecated due to bad pitch calculation. Use A_SpawnProjectile instead.
  2. In general: Do not use magic numbers to set flags like that. It's very difficult to remember what these numbers stand for, and as a result they can generate subtle bugs in your code that might be extremely hard to track down. Use pre-defined constants instead - you don't need ZScript for that, they should be available in DECORATE as well.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [DECORATE]Custom enemy only shoots forward

Postby lizardcommando » Thu Nov 26, 2020 9:46 am

Changing that 6th argument to 0 seems to have done the trick. Thanks for the assist!
User avatar
lizardcommando
Thread killer
 
Joined: 07 Sep 2006
Location: Boringland, California


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests