- scriptified the Rocket launcher.

This commit is contained in:
Christoph Oelckers 2016-11-20 01:11:01 +01:00
parent 814493b68d
commit fdab994fcb
7 changed files with 212 additions and 186 deletions

View file

@ -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
//

View file

@ -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)

View file

@ -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

View file

@ -89,6 +89,7 @@ class Actor : Thinker native
native Actor SpawnMissile(Actor dest, class<Actor> type, Actor owner = null);
native Actor SpawnMissileZ (double z, Actor dest, class<Actor> type);
native Actor SpawnMissileAngleZSpeed (double z, class<Actor> type, float angle, double vz, double speed, Actor owner = null, bool checkspawn = true);
native Actor, Actor SpawnPlayerMissile(class<Actor> 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); }

View file

@ -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

View file

@ -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<Actor> 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;
}
}

View file

@ -51,8 +51,6 @@ class StateProvider : Inventory native
action native void A_Lower();
action native void A_Raise();
action native void A_FireSTGrenade(class<Actor> grenadetype = "Grenade");
action native void A_FireMissile();
action native void A_FirePlasma();
action native void A_FireRailgun();
action native void A_FireRailgunLeft();