Skip to content

Commit

Permalink
- exported DukeActor's native member variables.
Browse files Browse the repository at this point in the history
This includes renaming two native ones because they shared the same name with members of spritetype.
  • Loading branch information
coelckers committed Jan 23, 2022
1 parent f194fb6 commit a252b20
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 69 deletions.
2 changes: 1 addition & 1 deletion source/games/duke/src/actors.cpp
Expand Up @@ -5168,7 +5168,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
SKIPJIBS:

actor->attackertype = SHOTSPARK1;
actor->extra = 1;
actor->hitextra = 1;
actor->spr.zvel = 0;
}
else if (actor->spr.zvel > 2048 && actor->sector()->lotag != 1)
Expand Down
38 changes: 19 additions & 19 deletions source/games/duke/src/actors_d.cpp
Expand Up @@ -242,7 +242,7 @@ bool ifsquished(DDukeActor* actor, int p)
if (actor->spr.pal == 1)
{
actor->attackertype = SHOTSPARK1;
actor->extra = 1;
actor->hitextra = 1;
return false;
}

Expand Down Expand Up @@ -349,7 +349,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h

if (d < r && cansee(act2->spr.pos.X, act2->spr.pos.Y, act2->spr.pos.Z - (8 << 8), act2->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (12 << 8), actor->sector()))
{
act2->ang = getangle(act2->spr.pos.X - actor->spr.pos.X, act2->spr.pos.Y - actor->spr.pos.Y);
act2->hitang = getangle(act2->spr.pos.X - actor->spr.pos.X, act2->spr.pos.Y - actor->spr.pos.Y);

if (actor->spr.picnum == RPG && act2->spr.extra > 0)
act2->attackertype = RPG;
Expand Down Expand Up @@ -379,17 +379,17 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
if (d < r / 3)
{
if (hp4 == hp3) hp4++;
act2->extra = hp3 + (krand() % (hp4 - hp3));
act2->hitextra = hp3 + (krand() % (hp4 - hp3));
}
else if (d < 2 * r / 3)
{
if (hp3 == hp2) hp3++;
act2->extra = hp2 + (krand() % (hp3 - hp2));
act2->hitextra = hp2 + (krand() % (hp3 - hp2));
}
else if (d < r)
{
if (hp2 == hp1) hp2++;
act2->extra = hp1 + (krand() % (hp2 - hp1));
act2->hitextra = hp1 + (krand() % (hp2 - hp1));
}

if (act2->spr.picnum != TANK && act2->spr.picnum != ROTATEGUN && act2->spr.picnum != RECON && !bossguy(act2))
Expand All @@ -401,7 +401,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
if (gs.actorinfo[act2->spr.picnum].flags & SFLAG_HITRADIUSCHECK)
fi.checkhitsprite(act2, actor);
}
else if (actor->spr.extra == 0) act2->extra = 0;
else if (actor->spr.extra == 0) act2->hitextra = 0;

if (act2->spr.picnum != RADIUSEXPLOSION && Owner && Owner->spr.statnum < MAXSTATUS)
{
Expand Down Expand Up @@ -598,7 +598,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
int p;
auto hitowner = actor->GetHitOwner();

if (actor->extra >= 0)
if (actor->hitextra >= 0)
{
if (actor->spr.extra >= 0)
{
Expand All @@ -614,7 +614,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
ud.ffire == 0)
return -1;

actor->spr.extra -= actor->extra;
actor->spr.extra -= actor->hitextra;

if (hitowner)
{
Expand All @@ -641,18 +641,18 @@ int ifhitbyweapon_d(DDukeActor *actor)
case SEENINE:
case OOZFILTER:
case EXPLODINGBARREL:
ps[p].vel.X += actor->extra * bcos(actor->ang, 2);
ps[p].vel.Y += actor->extra * bsin(actor->ang, 2);
ps[p].vel.X += actor->hitextra * bcos(actor->hitang, 2);
ps[p].vel.Y += actor->hitextra * bsin(actor->hitang, 2);
break;
default:
ps[p].vel.X += actor->extra * bcos(actor->ang, 1);
ps[p].vel.Y += actor->extra * bsin(actor->ang, 1);
ps[p].vel.X += actor->hitextra * bcos(actor->hitang, 1);
ps[p].vel.Y += actor->hitextra * bsin(actor->hitang, 1);
break;
}
}
else
{
if (actor->extra == 0)
if (actor->hitextra == 0)
if (actor->attackertype == SHRINKSPARK && actor->spr.xrepeat < 24)
return -1;

Expand All @@ -662,27 +662,27 @@ int ifhitbyweapon_d(DDukeActor *actor)
return -1;
}

actor->spr.extra -= actor->extra;
actor->spr.extra -= actor->hitextra;
auto Owner = actor->GetOwner();
if (actor->spr.picnum != RECON && Owner && Owner->spr.statnum < MAXSTATUS)
actor->SetOwner(hitowner);
}

actor->extra = -1;
actor->hitextra = -1;
return actor->attackertype;
}
}


if (ud.multimode < 2 || !isWorldTour()
|| actor->attackertype != FLAMETHROWERFLAME
|| actor->extra >= 0
|| actor->hitextra >= 0
|| actor->spr.extra > 0
|| actor->spr.picnum != APLAYER
|| ps[actor->PlayerIndex()].numloogs > 0
|| hitowner == nullptr)
{
actor->extra = -1;
actor->hitextra = -1;
return -1;
}
else
Expand All @@ -695,7 +695,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
ps[p].frag_ps = hitowner->PlayerIndex(); // set the proper player index here - this previously set the sprite index...

actor->SetHitOwner(ps[p].GetActor());
actor->extra = -1;
actor->hitextra = -1;

return FLAMETHROWERFLAME;
}
Expand Down Expand Up @@ -745,7 +745,7 @@ void movefallers_d(void)
}
else
{
act->extra = 0;
act->hitextra = 0;
act->spr.extra = x;
}
}
Expand Down
36 changes: 18 additions & 18 deletions source/games/duke/src/actors_r.cpp
Expand Up @@ -301,7 +301,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
continue;
}

act2->ang = getangle(act2->spr.pos.X - actor->spr.pos.X, act2->spr.pos.Y - actor->spr.pos.Y);
act2->hitang = getangle(act2->spr.pos.X - actor->spr.pos.X, act2->spr.pos.Y - actor->spr.pos.Y);

if (actor->spr.picnum == RPG && act2->spr.extra > 0)
act2->attackertype = RPG;
Expand All @@ -313,17 +313,17 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
if (d < r / 3)
{
if (hp4 == hp3) hp4++;
act2->extra = hp3 + (krand() % (hp4 - hp3));
act2->hitextra = hp3 + (krand() % (hp4 - hp3));
}
else if (d < 2 * r / 3)
{
if (hp3 == hp2) hp3++;
act2->extra = hp2 + (krand() % (hp3 - hp2));
act2->hitextra = hp2 + (krand() % (hp3 - hp2));
}
else if (d < r)
{
if (hp2 == hp1) hp2++;
act2->extra = hp1 + (krand() % (hp2 - hp1));
act2->hitextra = hp1 + (krand() % (hp2 - hp1));
}

int pic = act2->spr.picnum;
Expand Down Expand Up @@ -502,7 +502,7 @@ int ifhitbyweapon_r(DDukeActor *actor)
int p;
auto hitowner = actor->GetHitOwner();

if (actor->extra >= 0)
if (actor->hitextra >= 0)
{
if (actor->spr.extra >= 0)
{
Expand All @@ -518,7 +518,7 @@ int ifhitbyweapon_r(DDukeActor *actor)
ud.ffire == 0)
return -1;

actor->spr.extra -= actor->extra;
actor->spr.extra -= actor->hitextra;

if (hitowner)
{
Expand Down Expand Up @@ -549,32 +549,32 @@ int ifhitbyweapon_r(DDukeActor *actor)
case EXPLODINGBARREL:
case TRIPBOMBSPRITE:
case RPG2:
ps[p].vel.X += actor->extra * bcos(actor->ang, 2);
ps[p].vel.Y += actor->extra * bsin(actor->ang, 2);
ps[p].vel.X += actor->hitextra * bcos(actor->hitang, 2);
ps[p].vel.Y += actor->hitextra * bsin(actor->hitang, 2);
break;
default:
ps[p].vel.X += actor->extra * bcos(actor->ang, 1);
ps[p].vel.Y += actor->extra * bsin(actor->ang, 1);
ps[p].vel.X += actor->hitextra * bcos(actor->hitang, 1);
ps[p].vel.Y += actor->hitextra * bsin(actor->hitang, 1);
break;
}
}
else
{
if (actor->extra == 0)
if (actor->hitextra == 0)
if (actor->spr.xrepeat < 24)
return -1;

actor->spr.extra -= actor->extra;
actor->spr.extra -= actor->hitextra;
if (actor->spr.picnum != RECON && actor->GetOwner() && actor->GetOwner()->spr.statnum < MAXSTATUS)
actor->SetOwner(hitowner);
}

actor->extra = -1;
actor->hitextra = -1;
return actor->attackertype;
}
}

actor->extra = -1;
actor->hitextra = -1;
return -1;
}

Expand Down Expand Up @@ -670,7 +670,7 @@ void movefallers_r(void)
}
else
{
act->extra = 0;
act->hitextra = 0;
act->spr.extra = x;
}
}
Expand Down Expand Up @@ -3880,7 +3880,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
return 0;
}
actor->attackertype = SHOTSPARK1;
actor->extra = 1;
actor->hitextra = 1;
}
else if (isRRRA() && (actor->sector()->floorpicnum == RRTILE7820 || actor->sector()->floorpicnum == RRTILE7768))
{
Expand All @@ -3889,7 +3889,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
if ((krand() & 3) == 1)
{
actor->attackertype = SHOTSPARK1;
actor->extra = 5;
actor->hitextra = 5;
}
}
}
Expand Down Expand Up @@ -3941,7 +3941,7 @@ void destroyit(DDukeActor *actor)
if (a3->spr.picnum == DESTRUCTO)
{
a3->attackertype = SHOTSPARK1;
a3->extra = 1;
a3->hitextra = 1;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/cheats.cpp
Expand Up @@ -68,7 +68,7 @@ static const char *cheatGod(int myconnectindex, int state)

p->resurrected = true;
act->spr.extra = gs.max_player_health;
act->extra = 0;
act->hitextra = 0;
if (ud.god)
{
if (isRRRA()) S_PlaySound(218, CHAN_AUTO, CHANF_UI);
Expand All @@ -92,7 +92,7 @@ static const char *cheatGod(int myconnectindex, int state)
{
ud.god = 0;
act->spr.extra = gs.max_player_health;
act->extra = -1;
act->hitextra = -1;
ps[myconnectindex].last_extra = gs.max_player_health;
return quoteMgr.GetQuote(QUOTE_CHEAT_GODMODE_OFF);
}
Expand Down
9 changes: 2 additions & 7 deletions source/games/duke/src/constants.h
Expand Up @@ -292,11 +292,6 @@ enum amoveflags_t
antifaceplayerslow = 32768
};

enum aflags_t
{
AFLAG_USEACTIVATOR = 0x00000001,
};

enum sflags_t
{
SFLAG_INVENTORY = 0x00000001,
Expand All @@ -317,7 +312,7 @@ enum sflags_t
SFLAG_TRIGGER_IFHITSECTOR = 0x00008000,
SFLAG_MOVEFTA_WAKEUPCHECK = 0x00010000,
SFLAG_MOVEFTA_CHECKSEEWITHPAL8 = 0x00020000, // let's hope this can be done better later. For now this was what blocked merging the Duke and RR variants of movefta
SFLAG_NOSHADOW = 0x00020000,
SFLAG_NOSHADOW = 0x00040000,

};

Expand All @@ -326,7 +321,7 @@ DEFINE_TFLAGS_OPERATORS(EDukeFlags1)

enum sflags2_t
{

SFLAG2_USEACTIVATOR = 0x00000001,
};

using EDukeFlags2 = TFlags<sflags2_t, uint32_t>;
Expand Down
20 changes: 20 additions & 0 deletions source/games/duke/src/game.cpp
Expand Up @@ -41,6 +41,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "gamestate.h"
#include "razefont.h"
#include "psky.h"
#include "vm.h"

BEGIN_DUKE_NS

Expand Down Expand Up @@ -397,4 +398,23 @@ void GameInterface::app_init()
S_ParseDeveloperCommentary();
}

DEFINE_FIELD(DDukeActor, ownerActor)
DEFINE_FIELD(DDukeActor, hitOwnerActor)
DEFINE_FIELD(DDukeActor, cgg)
DEFINE_FIELD(DDukeActor, spriteextra)
DEFINE_FIELD(DDukeActor, hitang)
DEFINE_FIELD(DDukeActor, hitextra)
DEFINE_FIELD(DDukeActor, movflag)
DEFINE_FIELD(DDukeActor, tempang)
DEFINE_FIELD(DDukeActor, timetosleep)
DEFINE_FIELD(DDukeActor, floorz)
DEFINE_FIELD(DDukeActor, ceilingz)
DEFINE_FIELD(DDukeActor, saved_ammo)
DEFINE_FIELD(DDukeActor, palvals)
DEFINE_FIELD(DDukeActor, temp_data)
DEFINE_FIELD(DDukeActor, temp_actor)
DEFINE_FIELD(DDukeActor, seek_actor)
DEFINE_FIELD(DDukeActor, flags1)
DEFINE_FIELD(DDukeActor, flags2)

END_DUKE_NS
10 changes: 5 additions & 5 deletions source/games/duke/src/gameexec.cpp
Expand Up @@ -1281,12 +1281,12 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
else SetGameVarID(lVar2, act->attackertype, sActor, sPlayer);
break;
case ACTOR_HTANG:
if (bSet) act->ang = lValue;
else SetGameVarID(lVar2, act->ang, sActor, sPlayer);
if (bSet) act->hitang = lValue;
else SetGameVarID(lVar2, act->hitang, sActor, sPlayer);
break;
case ACTOR_HTEXTRA:
if (bSet) act->extra = lValue;
else SetGameVarID(lVar2, act->extra, sActor, sPlayer);
if (bSet) act->hitextra = lValue;
else SetGameVarID(lVar2, act->hitextra, sActor, sPlayer);
break;
case ACTOR_HTOWNER:
if (bSet) act->hitOwnerActor = vValue.safeActor();
Expand Down Expand Up @@ -2281,7 +2281,7 @@ int ParseState::parse(void)

ps[g_p].falling_counter = 0;

g_ac->extra = -1;
g_ac->hitextra = -1;

g_ac->cgg = 0;
g_ac->movflag = 0;
Expand Down

0 comments on commit a252b20

Please sign in to comment.