random gibbing chance with chaingun

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!)
occultfactory
Posts: 6
Joined: Thu Apr 06, 2017 1:53 pm

random gibbing chance with chaingun

Post by occultfactory »

I'm new to programming stuff. I did my best to study Zdoom wiki and read articles about damagetype and A_jump.

I wanna make 2 types of puffs, one with normal puff and the other one with damagetype Extreme (+Extremedeath doesn't work for this actor, idk why).
I learned that A_Jump(127 gives 50% chance to do (?) something...
Also which file should I define damagetype? Wiki says MAPINFO has it but I can't find damagetype declaration within MAPINFO.

Just don't know how to put them in the below code. Somebody please help...

Actor ChaingunPuff : HARPuff
{
+ALWAYSPUFF +FORCERADIUSDMG
DamageType "Chaingun"
States
{
XDeath:
Melee:
Spawn:
"----" A 0 A_FaceTarget
"----" A 0 A_Warp(AAPTR_DEFAULT,5,0,0,0,WARPF_NOCHECKPOSITION)
"----" A 0 A_JumpIfInTargetInventory(MTurretLoad,1,"Super::Spawn")
"----" A 0 A_JumpIfInTargetInventory(ChaingunRotationSpeed,0,2)
"----" A 0 A_Jump(256,"Super::Spawn")
"----" A 0 A_JumpIfInTargetInventory(haschainIncendiaryRounds,1,2)
"----" A 0 A_Jump(256,"Super::Spawn")
"----" A 0 A_ChangeFlag(NODAMAGETHRUST,1)
"----" A 0 A_ChangeFlag(BLOODLESSIMPACT,1)
"----" A 0 A_ChangeFlag(NOPAIN,1)
"----" A 0 A_Explode(5,32,0)
"----" A 0 A_SpawnItem(ChainGunIncendiaryFX)
Goto Super::Spawn
}
}
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: random gibbing chance with chaingun

Post by hfc2x »

Custom damage types should be included in MAPINFO as it says here. Just make a block inside your MAPINFO lump/file that's called DamageType and inside the brackets, you define the properties you want.

And about the puff.. you shouldn't have it doing that. A puff should only be for displaying something on colission, and playing specific impact sounds, or specifying a damage type for your hitscan weapon. Making a puff do complex stuff like that will end up having unintended side effects. If you want your puff to have a random chance of gibbing, you should define a "clone" puff with the +EXTREMEDEATH flag, and have your weapon fire it with a random chance. Also try making your weapon do all those complex actions in its firing states instead.
occultfactory
Posts: 6
Joined: Thu Apr 06, 2017 1:53 pm

Re: random gibbing chance with chaingun

Post by occultfactory »

hfc2x wrote:Custom damage types should be included in MAPINFO as it says here. Just make a block inside your MAPINFO lump/file that's called DamageType and inside the brackets, you define the properties you want.

And about the puff.. you shouldn't have it doing that. A puff should only be for displaying something on colission, and playing specific impact sounds, or specifying a damage type for your hitscan weapon. Making a puff do complex stuff like that will end up having unintended side effects. If you want your puff to have a random chance of gibbing, you should define a "clone" puff with the +EXTREMEDEATH flag, and have your weapon fire it with a random chance. Also try making your weapon do all those complex actions in its firing states instead.
Thank you so much! If you don't mind... can I get an example code? Also, +EXTREMEDEATH doesn't work on some puffs.
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: random gibbing chance with chaingun

Post by hfc2x »

From my mod here. You can check the code by opening Qua.pk3, and going into QuakeW/Weapons/Machinegun.txt.

This is what I used in the Machinegun firing definition (it's ZScript, that's why the syntax is different, but DECORATE should work very similarly):

Code: Select all

	Fire:
		TNT1 A 0
		{
			A_PlaySound ("q2mgun/fire", 5);
			A_GunFlash();
			A_SpawnItemEx ("GunLightFlash", 0, 0, 0, vel.x, vel.y, vel.z, 0, SXF_TRANSFERPOINTERS);
			if (CountInv("PowerWeaponLevel2"))
			{
				A_PlaySound ("quad/fire", CHAN_WEAPON);
				A_FireBullets(3,3,-1,32,"SuperMGPuff",FBF_USEAMMO|FBF_NORANDOM);
			}
			else
			{
				A_FireBullets (3,3,-1,8,"MachinegunPuff",FBF_USEAMMO|FBF_NORANDOM);
			}
			if (invoker.user_machinegunvalue > 0)
			{
				if (invoker.user_machinegunvalue == 1)
				{
					return resolvestate ("HandBack1");
				}
				else
				{
					return resolvestate ("HandBack2");
				}
			}
			return resolvestate (null);
		}
		MACH BC 2 Bright;
		TNT1 A 0 A_JumpIfNoAmmo(2);
		TNT1 A 0 A_ReFire("HoldFire1");
		MACH DEF 2;
		TNT1 A 0 A_CheckReload;
		Goto Ready1;
And both puff actors used in this instance:

Code: Select all

CLASS MachinegunPuff : BulletPuff
{
	States
	{
	Crash:
		TNT1 A 0;
		TNT1 A 0 A_Jump (40, "PlayWallSound");
		Goto Super::Spawn;
	PlayWallSound:
		TNT1 A 0 A_PlaySound ("puffhitwall");
		Goto Super::Spawn;
	}
}

CLASS SuperMGPuff : MachinegunPuff
{
	Default
	{
		+EXTREMEDEATH;
	}
}
+EXTREMEDEATH does work on puffs. If it doesn't work for you, then your code must have some errors.

Return to “Scripting”