- scriptified the Super Shotgun.

This commit is contained in:
Christoph Oelckers 2016-11-20 00:45:06 +01:00
parent af34d82888
commit 814493b68d
5 changed files with 117 additions and 111 deletions

View file

@ -16,63 +16,12 @@
*/
void P_SetSafeFlash(AWeapon *weapon, player_t *player, FState *flashstate, int index);
static FRandom pr_fireshotgun2 ("FireSG2");
static FRandom pr_fireplasma ("FirePlasma");
static FRandom pr_firerail ("FireRail");
static FRandom pr_bfgspray ("BFGSpray");
static FRandom pr_oldbfg ("OldBFG");
//
// A_FireShotgun2
//
DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
{
PARAM_ACTION_PROLOGUE(AActor);
int i;
DAngle angle;
int damage;
player_t *player;
if (nullptr == (player = self->player))
{
return 0;
}
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
return 0;
P_SetPsprite(player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
}
player->mo->PlayAttacking2 ();
DAngle pitch = P_BulletSlope (self);
for (i=0 ; i<20 ; i++)
{
damage = 5*(pr_fireshotgun2()%3+1);
angle = self->Angles.Yaw + pr_fireshotgun2.Random2() * (11.25 / 256);
// Doom adjusts the bullet slope by shifting a random number [-255,255]
// left 5 places. At 2048 units away, this means the vertical position
// of the shot can deviate as much as 255 units from nominal. So using
// some simple trigonometry, that means the vertical angle of the shot
// can deviate by as many as ~7.097 degrees or ~84676099 BAMs.
P_LineAttack (self,
angle,
PLAYERMISSILERANGE,
pitch + pr_fireshotgun2.Random2() * (7.097 / 256), damage,
NAME_Hitscan, NAME_BulletPuff);
}
return 0;
}
//
// A_FireMissile
//

View file

@ -51,6 +51,7 @@ zscript/doom/bossbrain.txt
zscript/doom/weaponfist.txt
zscript/doom/weaponpistol.txt
zscript/doom/weaponshotgun.txt
zscript/doom/weaponssg.txt
zscript/doom/weaponchaingun.txt
zscript/doom/weaponchainsaw.txt

View file

@ -13,61 +13,6 @@ class DoomWeapon : Weapon
}
// --------------------------------------------------------------------------
//
// Shotgun
//
// --------------------------------------------------------------------------
class SuperShotgun : DoomWeapon
{
Default
{
Weapon.SelectionOrder 400;
Weapon.AmmoUse 2;
Weapon.AmmoGive 8;
Weapon.AmmoType "Shell";
Inventory.PickupMessage "$GOTSHOTGUN2";
Obituary "$OB_MPSSHOTGUN";
Tag "$TAG_SUPERSHOTGUN";
}
States
{
Ready:
SHT2 A 1 A_WeaponReady;
Loop;
Deselect:
SHT2 A 1 A_Lower;
Loop;
Select:
SHT2 A 1 A_Raise;
Loop;
Fire:
SHT2 A 3;
SHT2 A 7 A_FireShotgun2;
SHT2 B 7;
SHT2 C 7 A_CheckReload;
SHT2 D 7 A_OpenShotgun2;
SHT2 E 7;
SHT2 F 7 A_LoadShotgun2;
SHT2 G 6;
SHT2 H 6 A_CloseShotgun2;
SHT2 A 5 A_ReFire;
Goto Ready;
// unused states
SHT2 B 7;
SHT2 A 3;
Goto Deselect;
Flash:
SHT2 I 4 Bright A_Light1;
SHT2 J 3 Bright A_Light2;
Goto LightDone;
Spawn:
SGN2 A -1;
Stop;
}
}
// --------------------------------------------------------------------------
//
// Rocket launcher

View file

@ -0,0 +1,116 @@
// --------------------------------------------------------------------------
//
// Super Shotgun
//
// --------------------------------------------------------------------------
class SuperShotgun : DoomWeapon
{
Default
{
Weapon.SelectionOrder 400;
Weapon.AmmoUse 2;
Weapon.AmmoGive 8;
Weapon.AmmoType "Shell";
Inventory.PickupMessage "$GOTSHOTGUN2";
Obituary "$OB_MPSSHOTGUN";
Tag "$TAG_SUPERSHOTGUN";
}
States
{
Ready:
SHT2 A 1 A_WeaponReady;
Loop;
Deselect:
SHT2 A 1 A_Lower;
Loop;
Select:
SHT2 A 1 A_Raise;
Loop;
Fire:
SHT2 A 3;
SHT2 A 7 A_FireShotgun2;
SHT2 B 7;
SHT2 C 7 A_CheckReload;
SHT2 D 7 A_OpenShotgun2;
SHT2 E 7;
SHT2 F 7 A_LoadShotgun2;
SHT2 G 6;
SHT2 H 6 A_CloseShotgun2;
SHT2 A 5 A_ReFire;
Goto Ready;
// unused states
SHT2 B 7;
SHT2 A 3;
Goto Deselect;
Flash:
SHT2 I 4 Bright A_Light1;
SHT2 J 3 Bright A_Light2;
Goto LightDone;
Spawn:
SGN2 A -1;
Stop;
}
}
//===========================================================================
//
// Code (must be attached to StateProvider)
//
//===========================================================================
extend class StateProvider
{
action void A_FireShotgun2()
{
if (player == null)
{
return;
}
A_PlaySound ("weapons/sshotf", CHAN_WEAPON);
Weapon weap = player.ReadyWeapon;
if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
{
if (!weap.DepleteAmmo (weap.bAltFire, true, 2))
return;
player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true);
}
player.mo.PlayAttacking2 ();
double pitch = BulletSlope ();
for (int i = 0 ; i < 20 ; i++)
{
int damage = 5 * random[FireSG2](1, 3);
double ang = angle + Random2[FireSG2]() * (11.25 / 256);
// Doom adjusts the bullet slope by shifting a random number [-255,255]
// left 5 places. At 2048 units away, this means the vertical position
// of the shot can deviate as much as 255 units from nominal. So using
// some simple trigonometry, that means the vertical angle of the shot
// can deviate by as many as ~7.097 degrees.
LineAttack (ang, PLAYERMISSILERANGE, pitch + Random2[FireSG2]() * (7.097 / 256), damage, 'Hitscan', "BulletPuff");
}
}
action void A_OpenShotgun2()
{
A_PlaySound("weapons/sshoto", CHAN_WEAPON);
}
action void A_LoadShotgun2()
{
A_PlaySound("weapons/sshotl", CHAN_WEAPON);
}
action void A_CloseShotgun2()
{
A_PlaySound("weapons/sshotc", CHAN_WEAPON);
}
}

View file

@ -50,11 +50,6 @@ class StateProvider : Inventory native
action native void A_WeaponReady(int flags = 0);
action native void A_Lower();
action native void A_Raise();
action native void A_FireShotgun2();
action void A_OpenShotgun2() { A_PlaySound("weapons/sshoto", CHAN_WEAPON); }
action void A_LoadShotgun2() { A_PlaySound("weapons/sshotl", CHAN_WEAPON); }
action void A_CloseShotgun2() { A_PlaySound("weapons/sshotc", CHAN_WEAPON); }
action native void A_FireSTGrenade(class<Actor> grenadetype = "Grenade");
action native void A_FireMissile();