|
Note: Wait! Stop! Before you copy this actor's definition into your mod, remember the following things:
- You do not need to copy that actor, since it is already defined.
- In fact, it's not just useless, it's actually harmful as it can cause problems.
- If you want to modify it, or use a modified version, using inheritance is the way to go.
- The actor definitions here are put on the wiki for reference purpose only. Learn from them, don't copy them.
- There is only one exception: if what you want is changing Ammo capacity, you need to create a new type from Ammo.
|
Shotgun
|
Actor type
|
Weapon
|
Game
|
(Doom)
|
DoomEd Number
|
2001
|
Class Name
|
Shotgun
|
Spawn ID
|
27
|
Identifier
|
T_SHOTGUN
|
Classes: Inventory→Weapon→DoomWeapon→Shotgun
The shotgun. A hitscan weapon which has a large spread. Uses shells for ammo.
|
Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub.
|
class Shotgun : DoomWeapon
{
Default
{
Weapon.SelectionOrder 1300;
Weapon.AmmoUse 1;
Weapon.AmmoGive 8;
Weapon.AmmoType "Shell";
Inventory.PickupMessage "$GOTSHOTGUN";
Obituary "$OB_MPSHOTGUN";
Tag "$TAG_SHOTGUN";
}
States
{
Ready:
SHTG A 1 A_WeaponReady;
Loop;
Deselect:
SHTG A 1 A_Lower;
Loop;
Select:
SHTG A 1 A_Raise;
Loop;
Fire:
SHTG A 3;
SHTG A 7 A_FireShotgun;
SHTG BC 5;
SHTG D 4;
SHTG CB 5;
SHTG A 3;
SHTG A 7 A_ReFire;
Goto Ready;
Flash:
SHTF A 4 Bright A_Light1;
SHTF B 3 Bright A_Light2;
Goto LightDone;
Spawn:
SHOT A -1;
Stop;
}
}
extend class StateProvider
{
action void A_FireShotgun()
{
if (player == null)
{
return;
}
A_StartSound ("weapons/shotgf", CHAN_WEAPON);
Weapon weap = player.ReadyWeapon;
if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
{
if (!weap.DepleteAmmo (weap.bAltFire, true, 1))
return;
player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true);
}
player.mo.PlayAttacking2 ();
double pitch = BulletSlope ();
for (int i = 0; i < 7; i++)
{
GunShot (false, "BulletPuff", pitch);
}
}
}
|
Note: This is legacy code, kept here for reference only. DECORATE is still supported but no longer used by GZDoom. GZDoom internally uses the ZScript definition above.
|
ACTOR Shotgun : DoomWeapon
{
Weapon.SelectionOrder 1300
Weapon.AmmoUse 1
Weapon.AmmoGive 8
Weapon.AmmoType "Shell"
Inventory.PickupMessage "$GOTSHOTGUN"
Obituary "$OB_MPSHOTGUN"
Tag "$TAG_SHOTGUN"
States
{
Ready:
SHTG A 1 A_WeaponReady
Loop
Deselect:
SHTG A 1 A_Lower
Loop
Select:
SHTG A 1 A_Raise
Loop
Fire:
SHTG A 3
SHTG A 7 A_FireShotgun
SHTG BC 5
SHTG D 4
SHTG CB 5
SHTG A 3
SHTG A 7 A_ReFire
Goto Ready
Flash:
SHTF A 4 Bright A_Light1
SHTF B 3 Bright A_Light2
Goto LightDone
Spawn:
SHOT A -1
Stop
}
}