Skip to content

Commit

Permalink
Merge pull request #574 from LoboEire/master
Browse files Browse the repository at this point in the history
New handling of  "PLAYER_ATTACK" special
  • Loading branch information
dashodanger authored Oct 3, 2023
2 parents a2e7c13 + fef0e94 commit 1f242a9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
21 changes: 19 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,29 @@ CHANGELOG for EDGE-Classic 1.36 (since EDGE-Classic 1.35)

New Features
------------
- ATTACKS.DDF: DAMAGE_UNLESS_BENEFIT and DAMAGE_IF_BENEFIT subcommands Added
- ATTACKS.DDF: DAMAGE_UNLESS_BENEFIT and DAMAGE_IF_BENEFIT subcommands added
- Can be used anywhere that DAMAGE is used (sectors, attacks, etc)
- DAMAGE.DAMAGE_UNLESS_BENEFIT: Player will take damage unless they have at least one of the benefits listed
- DAMAGE.DAMAGE_IF_BENEFIT: Player will take damage if they have at least one of the benefits listed

-WEAPONS.DDF: Can now define a 3RD and 4TH attack.
- WEAPONS.DDF: Can now define a 3RD and 4TH attack. Equivalent DDF syntax to SEC_xxx used for second attack
DDF Fields:
- 3RD_ATTACK, 3RD_AMMOTYPE, 3RD_AMMOPERSHOT, 3RD_CLIPSIZE, 3RD_AUTOMATIC, 3RD_SPECIAL
- 4TH_ATTACK, 4TH_AMMOTYPE, 4TH_AMMOPERSHOT, 4TH_CLIPSIZE, 4TH_AUTOMATIC, 4TH_SPECIAL

DDF States:
- 3RD_ATTACK, 3RD_RELOAD, 3RD_DISCARD, 3RD_WARMUP, 3RD_FLASH
- 4TH_ATTACK, 4TH_RELOAD, 4TH_DISCARD, 4TH_WARMUP, 4TH_FLASH

DDF Actions:
- 3RD_SHOOT, 3RD_REFIRE, 3RD_NOFIRE, 3RD_NOFIRE_RETURN, 3RD_CHECKRELOAD, 3RD_FLASH
- 4TH_SHOOT, 4TH_REFIRE, 4TH_NOFIRE, 4TH_NOFIRE_RETURN, 4TH_CHECKRELOAD, 4TH_FLASH

For consistency, all the old SEC_xxx ddf commands can also be used with 2ND_xxx instead
i.e. 2ND_AMMOTYPE can replace SEC_AMMOTYPE

- ATTACKS.DDF: Attack special "PLAYER_ATTACK" makes attack behave as if originating from the
player, even if it's an indirect secondary attack i.e. the player gets his VAMPIRE health and KillBenefits.


General Improvements/Changes
Expand Down
3 changes: 2 additions & 1 deletion edge_defs/scripts/attacks.ddf
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ ATTACK_HEIGHT=32;
SPEED=25;
KEEP_FIRING_CHANCE=3.92%;
ATTACKRANGE=2048;
ATTACK_SPECIAL=KILL_FAILED_SPAWN;
ATTACK_SPECIAL=KILL_FAILED_SPAWN,PLAYER_ATTACK;
PROJECTILE_SPECIAL=NOBLOCKMAP,MISSILE,DROPOFF,NOGRAVITY,NOSHADOW;
LAUNCH_SOUND=PLASMA;
TRANSLUCENCY=55%;
Expand Down Expand Up @@ -162,6 +162,7 @@ DAMAGE.VAL=15;
DAMAGE.MAX=120;
DAMAGE.OBITUARY="OB_BFG";
ATTACKRANGE=2048;
ATTACK_SPECIAL=PLAYER_ATTACK;
PROJECTILE_SPECIAL=NOGRAVITY,NOSHADOW;
DLIGHT.TYPE=MODULATE;
DLIGHT.RADIUS=100;
Expand Down
8 changes: 1 addition & 7 deletions source_files/edge/p_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ static mobj_t *DoLaunchProjectile(mobj_t * source, float tx, float ty, float tz,

if (! (attack->flags & AF_Player))
{
if (target->flags & MF_FUZZY && !source->player)
if (target->flags & MF_FUZZY)
angle += P_RandomNegPos() << (ANGLEBITS - 12);

if (target->visibility < VISIBLE)
Expand Down Expand Up @@ -1945,11 +1945,6 @@ static void SprayAttack(mobj_t * mo)
return;

float range = (attack->range > 0) ? attack->range : MISSILERANGE;
int old_hf = mo->source->hyperflags;

// hacky, but prevents messing with P_DamageMobj
if (attack->flags & AF_Vampire)
mo->source->hyperflags |= HF_VAMPIRE;

// offset angles from its attack angle
for (int i = 0; i < 40; i++)
Expand Down Expand Up @@ -1985,7 +1980,6 @@ static void SprayAttack(mobj_t * mo)
P_DamageMobj(target, NULL, mo->source, damage, &attack->damage);
}

mo->source->hyperflags = old_hf;
}

static void DoMeleeAttack(mobj_t * mo)
Expand Down
17 changes: 17 additions & 0 deletions source_files/edge/p_inter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,23 @@ void P_DamageMobj(mobj_t * target, mobj_t * inflictor, mobj_t * source,
player->health = MAX(0, player->health - damage);
}


//Lobo 2023: Handle attack flagged with the "PLAYER_ATTACK" special.
// This attack will always be treated as originating from the player, even if it's an indirect secondary attack.
// This way the player gets his VAMPIRE health and KillBenefits.
if(inflictor && inflictor->currentattack &&
(inflictor->currentattack->flags & AF_Player))
{
player_t *CurrentPlayer;
CurrentPlayer = players[consoleplayer];

source = CurrentPlayer->mo;

if (source && source->isRemoved()) //Sanity check?
source = NULL;
}


// -AJA- 2007/11/06: vampire mode!
if (source && source != target &&
source->health < source->info->spawnhealth &&
Expand Down

0 comments on commit 1f242a9

Please sign in to comment.