From fdab994fcbc9834d09a41f010c13d1cbc6593acf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 20 Nov 2016 01:11:01 +0100 Subject: [PATCH] - scriptified the Rocket launcher. --- src/g_doom/a_doomweaps.cpp | 55 ------ src/p_mobj.cpp | 21 +++ wadsrc/static/zscript.txt | 1 + wadsrc/static/zscript/actor.txt | 1 + wadsrc/static/zscript/doom/doomweapons.txt | 129 ------------- wadsrc/static/zscript/doom/weaponrlaunch.txt | 189 +++++++++++++++++++ wadsrc/static/zscript/shared/inventory.txt | 2 - 7 files changed, 212 insertions(+), 186 deletions(-) create mode 100644 wadsrc/static/zscript/doom/weaponrlaunch.txt diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index c23bd7f1ff..cce1161cf1 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -22,61 +22,6 @@ static FRandom pr_bfgspray ("BFGSpray"); static FRandom pr_oldbfg ("OldBFG"); -// -// A_FireMissile -// -DEFINE_ACTION_FUNCTION(AActor, A_FireMissile) -{ - PARAM_ACTION_PROLOGUE(AActor); - - player_t *player; - - if (NULL == (player = self->player)) - { - return 0; - } - AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) - { - if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) - return 0; - } - P_SpawnPlayerMissile (self, PClass::FindActor("Rocket")); - return 0; -} - -// -// A_FireSTGrenade: not exactly backported from ST, but should work the same -// -DEFINE_ACTION_FUNCTION(AActor, A_FireSTGrenade) -{ - PARAM_ACTION_PROLOGUE(AActor); - PARAM_CLASS_DEF(grenade, AActor); - - player_t *player; - - if (grenade == NULL) - return 0; - - if (NULL == (player = self->player)) - { - return 0; - } - AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) - { - if (!weapon->DepleteAmmo (weapon->bAltFire)) - return 0; - } - - // Temporarily raise the pitch to send the grenade slightly upwards - DAngle SavedPlayerPitch = self->Angles.Pitch; - self->Angles.Pitch -= 6.328125; //(1152 << F RACBITS); - P_SpawnPlayerMissile(self, grenade); - self->Angles.Pitch = SavedPlayerPitch; - return 0; -} - // // A_FirePlasma // diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f28ea4b5f8..964736fed1 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6463,6 +6463,27 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z, return NULL; } +DEFINE_ACTION_FUNCTION(AActor, SpawnPlayerMissile) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_CLASS(type, AActor); + PARAM_ANGLE_DEF(angle); + PARAM_FLOAT_DEF(x); + PARAM_FLOAT_DEF(y); + PARAM_FLOAT_DEF(z); + PARAM_POINTER_DEF(lt, FTranslatedLineTarget); + PARAM_BOOL_DEF(nofreeaim); + PARAM_BOOL_DEF(noautoaim); + PARAM_INT_DEF(aimflags); + AActor *missileactor; + if (numparam == 2) angle = self->Angles.Yaw; + AActor *misl = P_SpawnPlayerMissile(self, x, y, z, type, angle, lt, &missileactor, nofreeaim, noautoaim, aimflags); + if (numret > 0) ret[0].SetPointer(misl, ATAG_OBJECT); + if (numret > 1) ret[1].SetPointer(missileactor, ATAG_OBJECT), numret = 2; + return numret; +} + + int AActor::GetTeam() { if (player) diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index e911764331..aec7e80896 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -54,6 +54,7 @@ zscript/doom/weaponshotgun.txt zscript/doom/weaponssg.txt zscript/doom/weaponchaingun.txt zscript/doom/weaponchainsaw.txt +zscript/doom/weaponrlaunch.txt zscript/doom/deadthings.txt zscript/doom/doomammo.txt diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 7f845472a4..2288b6c1b6 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -89,6 +89,7 @@ class Actor : Thinker native native Actor SpawnMissile(Actor dest, class type, Actor owner = null); native Actor SpawnMissileZ (double z, Actor dest, class type); native Actor SpawnMissileAngleZSpeed (double z, class type, float angle, double vz, double speed, Actor owner = null, bool checkspawn = true); + native Actor, Actor SpawnPlayerMissile(class type, double angle = 0, double x = 0, double y = 0, double z = 0, out FTranslatedLineTarget pLineTarget = null, bool nofreeaim = false, bool noautoaim = false, int aimflags = 0); native void A_Light(int extralight); void A_Light0() { A_Light(0); } diff --git a/wadsrc/static/zscript/doom/doomweapons.txt b/wadsrc/static/zscript/doom/doomweapons.txt index 55f3f3bcfc..ade261d33f 100644 --- a/wadsrc/static/zscript/doom/doomweapons.txt +++ b/wadsrc/static/zscript/doom/doomweapons.txt @@ -13,135 +13,6 @@ class DoomWeapon : Weapon } -// -------------------------------------------------------------------------- -// -// Rocket launcher -// -// -------------------------------------------------------------------------- - -class RocketLauncher : DoomWeapon -{ - Default - { - Weapon.SelectionOrder 2500; - Weapon.AmmoUse 1; - Weapon.AmmoGive 2; - Weapon.AmmoType "RocketAmmo"; - +WEAPON.NOAUTOFIRE - Inventory.PickupMessage "$GOTLAUNCHER"; - Tag "$TAG_ROCKETLAUNCHER"; - } - States - { - Ready: - MISG A 1 A_WeaponReady; - Loop; - Deselect: - MISG A 1 A_Lower; - Loop; - Select: - MISG A 1 A_Raise; - Loop; - Fire: - MISG B 8 A_GunFlash; - MISG B 12 A_FireMissile; - MISG B 0 A_ReFire; - Goto Ready; - Flash: - MISF A 3 Bright A_Light1; - MISF B 4 Bright; - MISF CD 4 Bright A_Light2; - Goto LightDone; - Spawn: - LAUN A -1; - Stop; - } -} - -class Rocket : Actor -{ - Default - { - Radius 11; - Height 8; - Speed 20; - Damage 20; - Projectile; - +RANDOMIZE - +DEHEXPLOSION - +ROCKETTRAIL - SeeSound "weapons/rocklf"; - DeathSound "weapons/rocklx"; - Obituary "$OB_MPROCKET"; - } - States - { - Spawn: - MISL A 1 Bright; - Loop; - Death: - MISL B 8 Bright A_Explode; - MISL C 6 Bright; - MISL D 4 Bright; - Stop; - BrainExplode: - MISL BC 10 Bright; - MISL D 10 A_BrainExplode; - Stop; - } -} - -// -------------------------------------------------------------------------- -// -// Grenade -- Taken and adapted from Skulltag, with MBF stuff added to it -// -// -------------------------------------------------------------------------- - -class Grenade : Actor -{ - Default - { - Radius 8; - Height 8; - Speed 25; - Damage 20; - Projectile; - -NOGRAVITY - +RANDOMIZE - +DEHEXPLOSION - +GRENADETRAIL - BounceType "Doom"; - Gravity 0.25; - SeeSound "weapons/grenlf"; - DeathSound "weapons/grenlx"; - BounceSound "weapons/grbnce"; - Obituary "$OB_GRENADE"; - DamageType "Grenade"; - } - States - { - Spawn: - SGRN A 1 Bright; - Loop; - Death: - MISL B 8 Bright A_Explode; - MISL C 6 Bright; - MISL D 4 Bright; - Stop; - Grenade: - MISL A 1000 A_Die; - Wait; - Detonate: - MISL B 4 A_Scream; - MISL C 6 A_Detonate; - MISL D 10; - Stop; - Mushroom: - MISL B 8 A_Mushroom; - Goto Death+1; - } -} - // -------------------------------------------------------------------------- // // Plasma rifle diff --git a/wadsrc/static/zscript/doom/weaponrlaunch.txt b/wadsrc/static/zscript/doom/weaponrlaunch.txt new file mode 100644 index 0000000000..906db38239 --- /dev/null +++ b/wadsrc/static/zscript/doom/weaponrlaunch.txt @@ -0,0 +1,189 @@ +// -------------------------------------------------------------------------- +// +// Rocket launcher +// +// -------------------------------------------------------------------------- + +class RocketLauncher : DoomWeapon +{ + Default + { + Weapon.SelectionOrder 2500; + Weapon.AmmoUse 1; + Weapon.AmmoGive 2; + Weapon.AmmoType "RocketAmmo"; + +WEAPON.NOAUTOFIRE + Inventory.PickupMessage "$GOTLAUNCHER"; + Tag "$TAG_ROCKETLAUNCHER"; + } + States + { + Ready: + MISG A 1 A_WeaponReady; + Loop; + Deselect: + MISG A 1 A_Lower; + Loop; + Select: + MISG A 1 A_Raise; + Loop; + Fire: + MISG B 8 A_GunFlash; + MISG B 12 A_FireMissile; + MISG B 0 A_ReFire; + Goto Ready; + Flash: + MISF A 3 Bright A_Light1; + MISF B 4 Bright; + MISF CD 4 Bright A_Light2; + Goto LightDone; + Spawn: + LAUN A -1; + Stop; + } +} + +class Rocket : Actor +{ + Default + { + Radius 11; + Height 8; + Speed 20; + Damage 20; + Projectile; + +RANDOMIZE + +DEHEXPLOSION + +ROCKETTRAIL + SeeSound "weapons/rocklf"; + DeathSound "weapons/rocklx"; + Obituary "$OB_MPROCKET"; + } + States + { + Spawn: + MISL A 1 Bright; + Loop; + Death: + MISL B 8 Bright A_Explode; + MISL C 6 Bright; + MISL D 4 Bright; + Stop; + BrainExplode: + MISL BC 10 Bright; + MISL D 10 A_BrainExplode; + Stop; + } +} + +// -------------------------------------------------------------------------- +// +// Grenade -- Taken and adapted from Skulltag, with MBF stuff added to it +// +// -------------------------------------------------------------------------- + +class Grenade : Actor +{ + Default + { + Radius 8; + Height 8; + Speed 25; + Damage 20; + Projectile; + -NOGRAVITY + +RANDOMIZE + +DEHEXPLOSION + +GRENADETRAIL + BounceType "Doom"; + Gravity 0.25; + SeeSound "weapons/grenlf"; + DeathSound "weapons/grenlx"; + BounceSound "weapons/grbnce"; + Obituary "$OB_GRENADE"; + DamageType "Grenade"; + } + States + { + Spawn: + SGRN A 1 Bright; + Loop; + Death: + MISL B 8 Bright A_Explode; + MISL C 6 Bright; + MISL D 4 Bright; + Stop; + Grenade: + MISL A 1000 A_Die; + Wait; + Detonate: + MISL B 4 A_Scream; + MISL C 6 A_Detonate; + MISL D 10; + Stop; + Mushroom: + MISL B 8 A_Mushroom; + Goto Death+1; + } +} + +//=========================================================================== +// +// Code (must be attached to StateProvider) +// +//=========================================================================== + +extend class StateProvider +{ + + //=========================================================================== + // + // A_FireMissile + // + //=========================================================================== + + action void A_FireMissile() + { + if (player == null) + { + return; + } + Weapon weap = player.ReadyWeapon; + if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) + { + if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) + return; + } + + SpawnPlayerMissile ("Rocket"); + } + + //=========================================================================== + // + // A_FireSTGrenade: not exactly backported from ST, but should work the same + // + //=========================================================================== + + action void A_FireSTGrenade(class grenadetype = "Grenade") + { + if (grenadetype == null) + return; + + if (player == null) + { + return; + } + Weapon weap = player.ReadyWeapon; + if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) + { + if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) + return; + } + + // Temporarily raise the pitch to send the grenadetype slightly upwards + double savedpitch = pitch; + pitch -= 6.328125; + SpawnPlayerMissile(grenadetype); + pitch = SavedPitch; + } +} \ No newline at end of file diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index 8509001a90..c1f40fd1f1 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -51,8 +51,6 @@ class StateProvider : Inventory native action native void A_Lower(); action native void A_Raise(); - action native void A_FireSTGrenade(class grenadetype = "Grenade"); - action native void A_FireMissile(); action native void A_FirePlasma(); action native void A_FireRailgun(); action native void A_FireRailgunLeft();