Projectile Just Spins in Place and Never Moves

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
Post Reply
[name_withheld]
Posts: 16
Joined: Thu Apr 13, 2023 2:41 pm
Preferred Pronouns: He/Him

Projectile Just Spins in Place and Never Moves

Post by [name_withheld] »

I nabbed up the Cacobot sprites and wrote some decorate for it, and for the most part, it works great. However, a custom fireball I created doesn't work correctly. When I originally had the fireball set to home in on the player, it spawned and moved appropriately (though it would spawn randomly out of the sides of the Cacobot and fly off randomly sometimes.)

In trying to figure out why it was doing that, I removed the homing functionality, which I assumed would just make it a normal fireball. Not so much, apparently? The Cacobot spawns the fireball, but it just spins in place and never moves from where it was spawned. I can run into it, however, and it functions normally. What causes this? Is it a bug, or just me scripting all wonky? Here's my code:

Code: Select all

ACTOR Cacobot : Cacodemon 26491
{
  Health 1500
  Radius 31
  Height 56
  Mass 400
  Speed 12
  PainChance 128
  Monster
  +FLOAT
  +NOGRAVITY
  +AVOIDMELEE
  +NOBLOOD
  +MISSILEMORE
  AttackSound "cacobot/bite"
  SeeSound "cacobot/activate"
  PainSound "cacobot/pain"
  DeathSound "cacobot/die"
  ActiveSound "cacobot/idle"
  Obituary "$OB_CACO"
  HitObituary "$OB_CACOHIT"
  States
  {
  Spawn:
    TNT1 A 0 A_Gravity
	CABT F 10 A_Look
    Loop
  See:
	CABT F 10
	CABT F 5
	CABT E 10
	CABT F 5
	CABT E 5
	CABT F 5
	CABT E 3
	CABT A 3 A_PlaySound("cacobot/sight")
	TNT1 A 0 A_NoGravity
	CABT A 3 A_Chase
    Goto See+9
  Missile:
    TNT1 A 0 A_JumpIfHealthLower(250, "HealSelf")
	TNT1 A 0 a_jump(256,"Standard","SingleHoming","DoubleHoming","ComboAttack","Melee")
	Goto See+9
  Standard:
	TNT1 A 0 A_JumpIfHealthLower(200, "LowestHealthAttack")
	CABT MMMNNNMMMNNN 1 A_FaceTarget
	CABT BC 5 A_FaceTarget
    CABT D 5 Bright A_FatAttack3
	TNT1 A 0 A_JumpIfHealthLower(750, "LowHealthAttack")
    Goto See+9
  HealSelf:
	TNT1 A 0 a_jump(64,"Standard","SingleHoming","DoubleHoming","ComboAttack","Melee")
	TNT1 A 0 A_JumpIfHealthLower(250, "HealSelf2")
	Goto See+9
  HealSelf2:
	TNT1 A 0 A_Gravity
	CABT E 3
	CABT F 3
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	CABT F 15
	TNT1 A 0 A_PlaySound("cacobot/pain")
	CABT E 15 HealThing(100,1500)
	TNT1 A 0 A_PlaySound("cacobot/activate")
	TNT1 A 0 A_NoGravity
	CABT F 10
	CABT E 10
	CABT F 5
	CABT E 5
	CABT F 5
	CABT E 3
	CABT A 3 A_PlaySound("cacobot/sight")
	Goto See+9
  SingleHoming:
	TNT1 A 0 A_FaceTarget
	CABT MMNNMMNN 1 A_FaceTarget
	CABT BC 3 A_FaceTarget
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,0,0,0,0)
	TNT1 A 0 A_JumpIfHealthLower(750, "LowHealthAttack")
	Goto See+9
  DoubleHoming:
	TNT1 A 0 A_FaceTarget
	CABT MMNNMMNN 1 A_FaceTarget
	CABT MMMNNNMMMNNN 1 A_FaceTarget
	CABT BC 3 A_FaceTarget
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,50,0,0,0)
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,-50,0,0,0)
	TNT1 A 0 A_JumpIfHealthLower(750, "LowHealthAttack")
	Goto See+9
  ComboAttack:
	TNT1 A 0 A_FaceTarget
	CABT MMNNMMNN 1 A_FaceTarget
	CABT MMMNNNMMMNNN 1 A_FaceTarget
	CABT MMNNMMNN 1 A_FaceTarget
	CABT BC 3 A_FaceTarget
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,50,0,0,0)
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,0,0,0,0)
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,-50,0,0,0)
	TNT1 A 0 A_JumpIfHealthLower(750, "LowHealthAttack")
	Goto See+9
  LowHealthAttack:
	TNT1 A 0 A_FaceTarget
	CABT MMMMNNNNMMMMNNNN 1
	CABT C 3 A_FaceTarget
	CABT D 3 Bright A_FatAttack3
	CABT C 3 A_FaceTarget
	CABT D 1 Bright A_FatAttack3
	TNT1 A 0 A_JumpIfHealthLower(350, "LowerHealthAttack")
	Goto See+9
  LowerHealthAttack:
	TNT1 A 0 A_FaceTarget
	CABT MMNNMMNN 2 A_FaceTarget
	CABT C 2 A_FaceTarget
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,0,0,0,0)
	CABT D 3
	Goto See+9
  LowestHealthAttack:
	TNT1 A 0 A_FaceTarget
	CABT MMMNNNMMMNNN 2
	CABT BC 5 A_FaceTarget
    CABT D 5 Bright A_FatAttack3
	CABT C 5 A_FaceTarget
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,0,0,0,0)
	CABT C 5 A_FaceTarget
    CABT D 5 Bright A_FatAttack3
	CABT C 5 A_FaceTarget
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,50,0,0,0)
	CABT D 5 Bright A_Custommissile("CacobotShot",32,0,-50,0,0,0)
	CABT D 3
	Goto See+9
  Melee:
	TNT1 A 0 A_Jumpifcloser(224, 2)
	Goto See+9
	CABT B 4 A_FaceTarget
	CABT B 4 A_Chase(CHF_FASTCHASE)
	CABT B 4 A_FaceTarget
	CABT CD 5 A_SkullAttack
	CABT EFE 3
	Goto See+9
  Pain:
    TNT1 A 0 A_NoGravity
	CABT E 3
    CABT E 3 A_Pain
    CABT F 6
    Goto See+9
  Death:
    CABT G 8
    CABT H 8 A_Scream
    CABT IJ 8
    CABT K 8 A_NoBlocking
    CABT L -1 A_SetFloorClip
    Stop
  }
}
 
ACTOR CacobotShot
{
  Radius 6
  Height 8
  Speed 10
  FastSpeed 20
  Damage 5
  Projectile
  +RANDOMIZE
  +ZDOOMTRANS
  RenderStyle Add
  Alpha 1
  SeeSound "caco/attack"
  DeathSound "caco/shotx"
  States
  {
  Spawn:
    BAL2 AB 4 Bright
    Loop
  Death:
    BAL2 CDE 6 Bright
   Stop
  }
}
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Projectile Just Spins in Place and Never Moves

Post by Gez »

You're explicitly setting all parameters of A_CustomMissile. The problem is that the last one is the actor pointer to the target. By setting it to 0, you force the missile to be aimed at nothing; and since it is aimed at nothing, it moves in the direction of nothing, meaning it doesn't move.

You should just delete the last three zeroes from each of you A_CustomMissile calls. Flags and pitch are defaulting to 0, so this will not change how it works, and pointer should be kept at its default value (which is not zero) if you want the projectile to work normally. The ability to override the pointer is there mostly for some special effects, a regular enemy projectile should never change it.
[name_withheld]
Posts: 16
Joined: Thu Apr 13, 2023 2:41 pm
Preferred Pronouns: He/Him

Re: Projectile Just Spins in Place and Never Moves

Post by [name_withheld] »

Thank you so much! I am very appreciative of the help! I thought that may have had something to do with it, but wasn't entirely sure.
Post Reply

Return to “Scripting”