Page 1 of 1

[DECORATE] Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 9:39 am
by doomista
Hi guys, I started making some small weapon mode, so far I DECORATEd this:

Code: Select all

ACTOR Projectile_Beamgun : PlasmaBall 16040 {
	Speed 30									// It's a bit faster than plasma ball
	Damage 50									// Player has two lives
	-RANDOMIZE
}

ACTOR Ammo_Beamgun : Cell 16050 {
	Inventory.Amount 25
	Inventory.MaxAmount 100	
	Ammo.BackpackAmount 50
	Ammo.BackpackMaxAmount 200
}

ACTOR Gun_Beamgun : PlasmaRifle 16060 {
	Weapon.SelectionOrder 350
	Weapon.AmmoType "Ammo_Beamgun"
	Weapon.AmmoGive 50
	Weapon.AmmoUse	25
	Weapon.SlotNumber 2
	+WEAPON.NOAUTOFIRE	
	+WEAPON.NOAUTOAIM
	
	States
	{
	Ready:
		TNT1 A 0 A_GiveInventory ("Ammo_Beamgun",0)	// Ammo regen
		TNT1 A 2 A_WeaponReady						// By putting here A 1 regen can be faster
		Loop
	Deselect:
		TNT1 A 0 A_Lower
		Loop
	Select:
		TNT1 A 0 A_Raise
		Loop
	Fire:
		TNT1 A 3
		TNT1 A 0 A_FireCustomMissile ("Projectile_Beamgun")
		TNT1 A 16 
		TNT1 A 5 A_ReFire
		Goto Ready
	Spawn:
		TNT1 A -1
		Stop
	}
}
Which works as I wanted, most of the time. But if the player holding the "Gun_Beamgun" dies, Zandronum freezes in a horrible way. That happens for Zandro 2.1.2, but not for the 3.0-alpha-r151004-2012. Has anybody a slight idea what can cause this bug and how to fix it for 2.1.2? I intend to do a DM mod and I'd like to develop for a played version of the game. I've attached custom wad reproducing this bug to this post, but be aware - this really freezes zandro in a horrible way! For those who still have enough courage, in the console type give gun_beamgun and then die in any way desired (this bug also happens if a bot holding the weapon dies, tested in Zandro deathmatch).
Thanks for help in advance

EDIT: Freeze happens even before any ondeath script can be called, so no, ACS is probably not an answer

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 9:54 am
by ZZYZX
TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_Lower

The Deselect state should have finite length as sometimes it just lowers the weapon without switching states or switching to another weapon, like in case of player death.

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 10:39 am
by doomista
ZZYZX wrote:TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_Lower
The Deselect state should have finite length as sometimes it just lowers the weapon without switching states or switching to another weapon, like in case of player death.
This community is really for the best. Thanks.

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 1:36 pm
by SwordGrunt
You can really just change the 0 tic duration to 1 tic on the Select and Deselect states. Looping A_Lower and A_Raise is fine.

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 3:56 pm
by ZZYZX
I believe he wanted instant switch.

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 5:38 pm
by SwordGrunt
Yeah but that should probably be taken care of by the player property instead of the actual weapon code, unless you want to do it for a single weapon (which would look really odd and out of place)

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Wed Apr 20, 2016 9:39 pm
by doomista
Yes. I wanted to have an instant switch, and yes, I eventually done it with the ACS and set player property. That TNT1 A 0 A_Lower was a relic of an old approach and I totally missed it.

[DECORATE] Re: Custom weapon, Zandro freezes on Player death

Posted: Sun May 15, 2016 6:00 pm
by darkmessenger84
SetPlayerProperty(0,1,2) is your friend.

Put it either in a weapon's ready state or a player definition in DECORATE.


EDIT: Apologies, I just this moment noticed that you used the SetPlayerProperty approach. Still, I'm happy to be of assistance.

If anyone else is interested, SetPlayerProperty(0,1,2) enables instant weapon switch.