Jump to content
  • 0

Custom weapon causing unknown freezes


Alexagon

Question

I posted this in the zdoom forums, but not having much luck there.

 

Anyway, I added a custom weapon to replace the SSG, but for whatever reason, after I pick it up and use it for a bit (sometimes it takes a few mins) the game locks up entirely and I have to force quit. I can't figure this issue out at all. Here's the code, and I'll also link a file for download if anyone wants to test it out themselves.

 

https://drive.google.com/file/d/10Ykaoksv1-aio4jCAPZcwOYx5kpmCjPo/view?usp=sharing

 

Spoiler

Actor FusionPistol : ModWeapon replaces SuperShotgun
{
  Weapon.SelectionOrder 3000
  Weapon.SlotNumber 3
  Weapon.AmmoType "FusionMag"
  Weapon.AmmoUse 1
  Weapon.AmmoGive 0
  Weapon.AmmoType2 "clip2"
  Weapon.AmmoGive2 10
  Weapon.AmmoUse2 0
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.NOAUTOFIRE
  Inventory.PickupMessage "You got a Fusion Pistol!"
  obituary "%o was melted by %k's Fusion Pistol"
  states
  {
  Ready:
    TNT1 A 0 A_jumpifinventory ("givefire", 1, "FireReady")
    PLPG A 1 A_WeaponReady (WRF_ALLOWRELOAD)
    loop
  FireReady:
    PLPR A 1 A_WeaponReady (WRF_ALLOWRELOAD)
    loop
  Select:
    TNT1 A 0 A_PlaySound("weapons/prifle/equp")
   PLPG A 1 A_Raise 
   PLPG A 1 Offset(67, 100)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(54, 81)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(32, 69)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(22, 58)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(10, 47)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(7, 39)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(2, 34)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
    GOTO READY
  Deselect:
   TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("AnimToggle")==1, "DeadSelect")
   TNT1 A 0 A_PlaySound("weapons/deselect")
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(2, 34)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(7, 39)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(10, 47)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(22, 58)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(32, 69)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(54, 81)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(67, 100)
   PLZR A 1 A_Lower
   TNT1 A 0 A_TaKeInventory ("givefire", 999)
   Wait
  Fire:
    TNT1 A 0 A_JumpIfNoAmmo ("dryfire")
    TNT1 A 0 A_jumpifinventory ("givefire", 1, "FireFire")
   TNT1 A 0 A_playsound ("weapons/bfg/fire")
    PLPG B 3 BRIGHT
    PLPG C 3 BRIGHT A_FireCustomMissile("FusionBulletPoison")
    PLPG A 8
    goto Ready
  NoReloadFire:
    TNT1 A 0 A_JumpIfInventory("Clip2", 1, 1)
    goto fire+1
    TNT1 A 0 A_TakeInventory("Cell", 1, TIF_NOTAKEINFINITE)
    TNT1 A 0 A_jumpifinventory ("givefire", 1, "FireFire")
    PLPG A 0
   TNT1 A 0 A_playsound ("weapons/bfg/fire")
    PLPG B 3 BRIGHT
    PLPG C 3 BRIGHT A_FireCustomMissile("FusionBulletPoison")
    PLPG A 8
    goto Ready
  AltFire:
    TNT1 A 0 A_playsound ("weapons/bfg/pickup", 1, 0.6)
    TNT1 A 0 A_jumpifinventory ("givefire", 1, "disablealt")
    TNT1 A 0 A_GiveInventory ("givefire")
   PLPG A 1 Offset(0, 35)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPR A 2 Offset(0, 34)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(0, 33)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPR A 2 Offset(0, 33)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   goto fireready
  DisableAlt:
    TNT1 A 0 A_playsound ("weapons/bfg/pickup", 1, 0.6)
    TNT1 A 0 A_TaKeInventory ("givefire", 999)
   PLPR A 1 Offset(0, 35)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 2 Offset(0, 34)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPR A 1 Offset(0, 33)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 2 Offset(0, 33)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   goto ready
  Firefire:
    TNT1 A 0 A_JumpIfNoAmmo ("Dryfire")
    PLPR A 0
   TNT1 A 0 A_playsound ("weapons/bfg/fire")
    PLPR B 3 BRIGHT
    PLPR C 3 BRIGHT A_FireCustomMissile("FusionBulletFire")
    PLPR A 8
   PLPR A 10 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
    goto Ready
  Dryfire:
   TNT1 A 0 A_PlaySound("weapons/pistol/dryf", 6)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(0, 35)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPR A 2 Offset(0, 34)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPG A 1 Offset(0, 33)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   PLPR A 2 Offset(0, 33)
   TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
  Reload:
      TNT1 A 0 A_JumpIfInventory("FusionMag", 10, 2)
      TNT1 A 0 A_JumpIfInventory("Clip2", 1, "ReloadWork")
      PLPG A 1 A_WeaponReady
      Goto Ready
   ReloadWork:
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 2 Offset(4, 38)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 2 Offset(8, 46)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 2 Offset(10, 54)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 2 Offset(12, 62)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 2 Offset(13, 70)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 10 Offset(14, 78)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
   ReloadLoop:
      TNT1 A 0 A_TakeInventory("Clip2", 1)
      TNT1 A 0 A_GiveInventory("FusionMag", 1)
      TNT1 A 0 A_JumpIfInventory("FusionMag", 3, "ReloadFinish")
      TNT1 A 0 A_JumpIfInventory("Clip2", 1, "ReloadLoop")
      Goto ReloadFinish
   ReloadFinish:
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 10 Offset(14, 78)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPR A 1 Offset(13, 70)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      TNT1 A 0 A_PlaySound("weapons/prifle/beep")
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 1 Offset(12, 62)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPR A 1 Offset(10, 54)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPG A 1 Offset(8, 46)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      PLPR A 1 Offset(4, 38)
      TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
      Goto Ready
  Spawn:
    PLSP A -1
      Stop
  }
}

ACTOR FusionBulletPoison : FastProjectile
{
  Radius 2
  Height 2
  Speed 80
  Damage 3
  PoisonDamage 5, 80, 25
  Projectile
  +RANDOMIZE
  +BLOODSPLATTER
  Obituary "%o was shot to pieces"
  Decal "bulletchip"
  States
  {
  Spawn:
    BLT1 A 1 Bright
    Loop
  Death:
    BLT1 A 1 Bright A_spawnitem("bulletpuff")
    Stop
  XDeath:
    BLT1 A 0
    Stop
  }
}

ACTOR FusionBulletFire : FastProjectile
{
  Radius 2
  Height 2
  Speed 80
  Damage 3
  Projectile
  +RANDOMIZE
  Obituary "%o was shot to pieces"
  Decal "bulletchip"
  States
  {
  Spawn:
    BLT1 A 1 Bright
    Loop
  Death:
    BLT1 A 1 A_PlaySound("Afrit/Hellfire")
     BLT1 A 1 Bright A_spawnitem("Hellfire1")
     Stop
   xDeath:
    BLT1 A 1 A_PlaySound("Afrit/Hellfire")
    BLT1 A 1 Bright A_spawnitem("Hellfire1")
    stop
   }
}

Actor GiveFire : Inventory
{
   Inventory.maxamount 1
}

ACTOR FusionMag : Ammo
{
  Inventory.PickupMessage ""
  Inventory.Amount 0
  Inventory.MaxAmount 3
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 3
  Inventory.PickupSound ""
}

 

 

Share this post


Link to post

7 answers to this question

Recommended Posts

  • 1
	PLZR A 1 A_Lower
	TNT1 A 0 A_TaKeInventory ("givefire", 999)
   	Wait

This piece of code in the deselect state makes the game stop in an infinite 0-tic loop, causing a crash.

Replace that bit of code with this fixed version:

TNT1 A 0 A_TaKeInventory ("givefire", 999)
PLZR A 1 A_Lower
Wait

 

On to the second problem.

XDeath:
    BLT1 A 0
    Stop

This causes a crash almost all of the time in FusionBulletPoison, and should instead be replaced with a Goto Null instead of Stop.

Replace that code with this fixed version:

XDeath:
	Goto Null

 

Share this post


Link to post
  • 0
21 hours ago, -TDRR- said:

XDeath:
    BLT1 A 0
    Stop

This causes a crash almost all of the time in FusionBulletPoison, and should instead be replaced with a Goto Null instead of Stop.

Replace that code with this fixed version:


XDeath:
	Goto Null

 

I have never had a problem with Stop.  It removes the actor from the game.  Also, you need the BLT1 A 0 or TNT1 A 0 or some state after the label.

 

I suspect that what you really need is:

XDeath:
    TNT1 A 1
    Stop

My theory is that it was the zero-length of the XDeath state that was the problem, in addition to the 0-tic loop, of course.

Share this post


Link to post
  • 0
12 hours ago, Empyre said:

I have never had a problem with Stop.  It removes the actor from the game.  Also, you need the BLT1 A 0 or TNT1 A 0 or some state after the label.

 

I suspect that what you really need is:


XDeath:
    TNT1 A 1
    Stop

My theory is that it was the zero-length of the XDeath state that was the problem, in addition to the 0-tic loop, of course.

Except Goto Null does the very exact same thing as TNT1 A 1 followed by a stop, and is also shorter to type.

Share this post


Link to post
  • 0
On 6/24/2019 at 2:02 AM, -TDRR- said:

Except Goto Null does the very exact same thing as TNT1 A 1 followed by a stop, and is also shorter to type.

You may be right about Goto Null being the same as Stop, but I do know that there must be an actual state (such as TNT1 A 1) after a label or there will be nothing for the actor to jump to.  Following a state label with Stop is the way to remove a state from an actor, so if Goto Null is equivalent to Stop, then that might remove the label, too.  From the ZDoom Wiki page about actor states:

Quote

Note that if a state contains only the stop instruction, the actor will behave as if it doesn't have that state. This can be useful, for example, to remove a state that an actor has inherited from its parent.

 

Also, I found this on that same page:

Quote

Warning: For monsters that disappear with their death states, always ensure there is at least a 1 tic delay before the stop of the actor. A VM abort can potentially happen otherwise.

 

Share this post


Link to post
  • 0
4 hours ago, Empyre said:

You may be right about Goto Null being the same as Stop, but I do know that there must be an actual state (such as TNT1 A 1) after a label or there will be nothing for the actor to jump to.  Following a state label with Stop is the way to remove a state from an actor, so if Goto Null is equivalent to Stop, then that might remove the label, too.

Nope, it just redirects that state to go to "Null" the instant it is entered. Using Stop directly is the only way to remove a state after it's been defined.

Share this post


Link to post
  • 0

Still, XDeath is not a state.  It is a label. TNT1 A 1 is a state, which can be labeled with a label like XDeath:.  Goto is an instruction, not a state, so it cannot be labeled with a label like XDeath:.  In order to be used, a label must be followed by a state, with a sprite name, frame, and duration.

 

I searched the ZDoom wiki for Goto Null, and it is not in there.

 

Share this post


Link to post
  • 0

@Empyre zdoom wiki calls these "predefined states". and the effect of "goto" without a previous frame is not described there, so it is uknown how it should work. from my expirience, "goto" without a frame should still retain a label, and perform a jump (i had to introduce this behaviour in k8vavoom to make some mods work).

 

p.s.: "null" is one of built-in labels, which always means "stop". zdoom wiki says that "All actors have a Null state by default unless overridden." (yet overriding "null" state can be UB in other engines.)

Edited by ketmar

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...