diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index cc3052b57..02dc05b72 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -803,6 +803,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) // An even more customizable hitscan attack // //========================================================================== +enum CBA_Flags +{ + CBAF_AIMFACING = 1, + CBAF_NORANDOM = 2, +}; + DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { ACTION_PARAM_START(7); @@ -812,7 +818,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) ACTION_PARAM_INT(DamagePerBullet, 3); ACTION_PARAM_CLASS(pufftype, 4); ACTION_PARAM_FIXED(Range, 5); - ACTION_PARAM_BOOL(AimFacing, 6); + ACTION_PARAM_INT(Flags, 6); if(Range==0) Range=MISSILERANGE; @@ -820,9 +826,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) int bangle; int bslope; - if (self->target || AimFacing) + if (self->target || (Flags & CBAF_AIMFACING)) { - if (!AimFacing) A_FaceTarget (self); + if (!(Flags & CBAF_AIMFACING)) A_FaceTarget (self); bangle = self->angle; if (!pufftype) pufftype = PClass::FindClass(NAME_BulletPuff); @@ -834,7 +840,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { int angle = bangle + pr_cabullet.Random2() * (Spread_XY / 255); int slope = bslope + pr_cabullet.Random2() * (Spread_Z / 255); - int damage = ((pr_cabullet()%3)+1) * DamagePerBullet; + int damage = DamagePerBullet; + + if (!(Flags & CBAF_NORANDOM)) + damage *= ((pr_cabullet()%3)+1); + P_LineAttack(self, angle, Range, slope, damage, NAME_None, pufftype); } } @@ -948,6 +958,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) // An even more customizable hitscan attack // //========================================================================== +enum FB_Flags +{ + FBF_USEAMMO = 1, + FBF_NORANDOM = 2, +}; + DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) { ACTION_PARAM_START(7); @@ -956,7 +972,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) ACTION_PARAM_INT(NumberOfBullets, 2); ACTION_PARAM_INT(DamagePerBullet, 3); ACTION_PARAM_CLASS(PuffType, 4); - ACTION_PARAM_BOOL(UseAmmo, 5); + ACTION_PARAM_INT(Flags, 5); ACTION_PARAM_FIXED(Range, 6); if (!self->player) return; @@ -968,7 +984,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) int bangle; int bslope; - if (UseAmmo && weapon) + if ((Flags & FBF_USEAMMO) && weapon) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo } @@ -986,7 +1002,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) if ((NumberOfBullets==1 && !player->refire) || NumberOfBullets==0) { - int damage = ((pr_cwbullet()%3)+1)*DamagePerBullet; + int damage = DamagePerBullet; + + if (!(Flags & FBF_NORANDOM)) + damage *= ((pr_cwbullet()%3)+1); + P_LineAttack(self, bangle, Range, bslope, damage, NAME_None, PuffType); } else @@ -996,7 +1016,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) { int angle = bangle + pr_cwbullet.Random2() * (Spread_XY / 255); int slope = bslope + pr_cwbullet.Random2() * (Spread_Z / 255); - int damage = ((pr_cwbullet()%3)+1) * DamagePerBullet; + int damage = DamagePerBullet; + + if (!(Flags & FBF_NORANDOM)) + damage *= ((pr_cwbullet()%3)+1); + P_LineAttack(self, angle, Range, slope, damage, NAME_None, PuffType); } } diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 7ef500d0a..1a18d2ed4 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -184,7 +184,7 @@ ACTOR Actor native //: Thinker action native A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); action native A_Jump(int chance = 256, state label, ...); action native A_CustomMissile(class missiletype, float spawnheight = 32, int spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0); - action native A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, bool aimfacing = false); + action native A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, int flags = 0); action native A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, bool aim = false, float maxdiff = 0, class pufftype = "BulletPuff"); action native A_JumpIfHealthLower(int health, state label); action native A_JumpIfCloser(float distance, state label); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 71fb3d511..10d36dd65 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -5,6 +5,14 @@ const int CMF_AIMDIRECTION = 2; const int CMF_TRACKOWNER = 4; const int CMF_CHECKTARGETDEAD = 8; +// Flags for A_CustomBulletAttack +const int CBAF_AIMFACING = 1; +const int CBAF_NORANDOM = 2; + +// Flags for A_FireBullets +const int FBF_USEAMMO = 1; +const int FBF_NORANDOM = 2; + // Flags for A_SpawnItemEx const int SXF_TRANSFERTRANSLATION=1; const int SXF_ABSOLUTEPOSITION=2; diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index e64012921..48a966878 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -8,7 +8,7 @@ ACTOR Inventory native action native A_JumpIfNoAmmo(state label); action native A_CustomPunch(int damage, bool norandom = false, bool useammo = true, class pufftype = "BulletPuff", float range = 0, float lifesteal = 0); - action native A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", bool useammo = true, float range = 0); + action native A_FireBullets(float spread_xy, float 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, int spawnofs_xy = 0, float spawnheight = 0, bool aimatangle = false, float pitch = 0); action native A_RailAttack(int damage, int spawnofs_xy = 0, int useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class pufftype = "BulletPuff"); action native A_Light(int extralight);