diff --git a/src/p_local.h b/src/p_local.h index f7862d45f..c96afa6e5 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -334,6 +334,7 @@ struct FRailParams double drift = 1.0; PClassActor *spawnclass = nullptr; int SpiralOffset = 270; + int limit = 0; }; // [RH] Shoot a railgun void P_RailAttack(FRailParams *params); diff --git a/src/p_map.cpp b/src/p_map.cpp index 69d18ce18..cf7655917 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4610,6 +4610,8 @@ struct RailData bool ThruSpecies; bool MThruSpecies; bool ThruActors; + int limit; + int count; }; static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) @@ -4664,7 +4666,11 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) } data->RailHits.Push(newhit); - return data->StopAtOne ? TRACE_Stop : TRACE_Continue; + if (data->limit) + { + data->count++; + } + return (data->StopAtOne || (data->limit && (data->count >= data->limit))) ? TRACE_Stop : TRACE_Continue; } //========================================================================== @@ -4706,7 +4712,8 @@ void P_RailAttack(FRailParams *p) RailData rail_data; rail_data.Caller = source; - + rail_data.limit = p->limit; + rail_data.count = 0; rail_data.StopAtOne = !!(p->flags & RAF_NOPIERCE); start.X = xy.X; start.Y = xy.Y; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 4d88a56fc..e2bda69d0 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1996,6 +1996,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; } PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; } PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; } + PARAM_INT_OPT (limit) { limit = 0; } if (range == 0) range = 8192; if (sparsity == 0) sparsity=1.0; @@ -2036,6 +2037,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) p.drift = driftspeed; p.spawnclass = spawnclass; p.SpiralOffset = SpiralOffset; + p.limit = limit; P_RailAttack(&p); return 0; } @@ -2073,6 +2075,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; } PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; } PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; } + PARAM_INT_OPT (limit) { limit = 0; } if (range == 0) range = 8192.; if (sparsity == 0) sparsity = 1; @@ -2155,6 +2158,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) p.drift = driftspeed; p.spawnclass = spawnclass; p.SpiralOffset = SpiralOffset; + p.limit = 0; P_RailAttack(&p); self->SetXYZ(savedpos); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 2ce48b036..0d5e8e2de 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -190,7 +190,7 @@ ACTOR Actor native //: Thinker native state A_Jump(int chance = 256, state label, ...); native void A_CustomMissile(class missiletype, float spawnheight = 32, float spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET); native void A_CustomBulletAttack(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET); - native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270); + native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0); native state A_JumpIfHealthLower(int health, state label, int ptr_selector = AAPTR_DEFAULT); native state A_JumpIfCloser(float distance, state label, bool noz = false); native state A_JumpIfTracerCloser(float distance, state label, bool noz = false); diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index f7250117d..73f252320 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -11,7 +11,7 @@ ACTOR Inventory native action native A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = ""); action native A_FireBullets(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, float range = 0); action native A_FireCustomMissile(class missiletype, float angle = 0, bool useammo = true, float spawnofs_xy = 0, float spawnheight = 0, int flags = 0, float pitch = 0); - action native A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270); + action native A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0); action native A_Light(int extralight); action native A_Light0(); action native A_Light1();