From a3da3a4c431de80357e23da88eda94b1eb236397 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Dec 2022 22:46:13 +0100 Subject: [PATCH] - added a large bunch of script exports. --- source/common/engine/namedef.h | 1 + .../common/scripting/frontend/zcc-parse.lemon | 7 + source/core/thingdef.h | 3 + source/core/vmexports.cpp | 14 + source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/actors_r.cpp | 4 +- source/games/duke/src/funct.h | 23 +- source/games/duke/src/game.cpp | 40 +- source/games/duke/src/gameexec.cpp | 14 +- source/games/duke/src/namelist_r.h | 5 +- source/games/duke/src/player.cpp | 17 +- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/vmexports.cpp | 384 +++++++++++++++++- wadsrc/static/zscript/games/duke/dukeactor.zs | 123 +++++- wadsrc/static/zscript/games/duke/dukegame.zs | 39 +- wadsrc/static/zscript/maptypes.zs | 3 + wadsrc/static/zscript/razebase.zs | 13 +- 17 files changed, 656 insertions(+), 38 deletions(-) diff --git a/source/common/engine/namedef.h b/source/common/engine/namedef.h index 92fa6fa34..2571cb315 100644 --- a/source/common/engine/namedef.h +++ b/source/common/engine/namedef.h @@ -270,3 +270,4 @@ xx(BuiltinNameToClass) xx(BuiltinClassCast) xx(ScreenJobRunner) +xx(Action) diff --git a/source/common/scripting/frontend/zcc-parse.lemon b/source/common/scripting/frontend/zcc-parse.lemon index 1a9146f37..71385c582 100644 --- a/source/common/scripting/frontend/zcc-parse.lemon +++ b/source/common/scripting/frontend/zcc-parse.lemon @@ -272,6 +272,13 @@ dottable_id(X) ::= IDENTIFIER(A). id->Id = A.Name(); X = id; } +// this is needed for defining properties named 'action'. +dottable_id(X) ::= ACTION(A). +{ + NEW_AST_NODE(Identifier,id,A); + id->Id = NAME_Action; + X = id; +} dottable_id(X) ::= dottable_id(A) DOT IDENTIFIER(B). { NEW_AST_NODE(Identifier,id2,A); diff --git a/source/core/thingdef.h b/source/core/thingdef.h index 746cca577..94a3c0e2b 100644 --- a/source/core/thingdef.h +++ b/source/core/thingdef.h @@ -100,6 +100,9 @@ struct Baggage PClassActor *Info; int Lumpnum; VersionInfo Version; + FName DefaultAction; + FName DefaultMove; + int moveflags; FScriptPosition ScriptPosition; }; diff --git a/source/core/vmexports.cpp b/source/core/vmexports.cpp index faceb7293..483f79595 100644 --- a/source/core/vmexports.cpp +++ b/source/core/vmexports.cpp @@ -166,6 +166,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, tileflags, raze_tileflags) ACTION_RETURN_INT(raze_tileflags(which)); } +int raze_tilesurface(int tex) +{ + return tilesurface(FSetTextureID(tex)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Raze, tilesurface, raze_tilesurface) +{ + PARAM_PROLOGUE; + PARAM_INT(which); + ACTION_RETURN_INT(raze_tilesurface(which)); +} + //============================================================================= // @@ -185,6 +197,8 @@ DEFINE_FIELD_X(sectortype, sectortype, type) DEFINE_FIELD_X(sectortype, sectortype, hitag) DEFINE_FIELD_X(sectortype, sectortype, ceilingheinum) DEFINE_FIELD_X(sectortype, sectortype, floorheinum) +DEFINE_FIELD_X(sectortype, sectortype, ceilingtexture) +DEFINE_FIELD_X(sectortype, sectortype, floortexture) DEFINE_FIELD_X(sectortype, sectortype, extra) DEFINE_FIELD_X(sectortype, sectortype, ceilingshade) DEFINE_FIELD_X(sectortype, sectortype, ceilingpal) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index b886ceb3c..52d819159 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -103,7 +103,7 @@ void addweapon_d(player_struct *p, int weapon, bool wswitch) // //--------------------------------------------------------------------------- -bool ifsquished(DDukeActor* actor, int p) +int ifsquished(DDukeActor* actor, int p) { if (isRR()) return false; // this function is a no-op in RR's source. diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index e91780547..f96f48525 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1485,7 +1485,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) } } -void fakebubbaspawn(DDukeActor *actor, int g_p) +void fakebubbaspawn(DDukeActor *actor, player_struct* p) { fakebubba_spawn++; switch (fakebubba_spawn) @@ -1503,7 +1503,7 @@ void fakebubbaspawn(DDukeActor *actor, int g_p) break; case 4: spawn(actor, RTILE_VIXEN); - operateactivators(666, &ps[g_p]); + operateactivators(666, p); break; } } diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 1786e825e..351198273 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -116,24 +116,24 @@ int setpal(player_struct* p); int madenoise(int playerNum); int haskey(sectortype* sect, int snum); void purplelavacheck(player_struct* p); -bool addphealth(player_struct* p, int amount, bool bigitem); -bool playereat(player_struct* p, int amount, bool bigitem); +void addphealth(player_struct* p, int amount, bool bigitem); +int playereat(player_struct* p, int amount, bool bigitem); void playerdrink(player_struct* p, int amount); -bool playeraddammo(player_struct* p, int weaponindex, int amount); -bool playeraddweapon(player_struct* p, int weaponindex, int amount); +int playeraddammo(player_struct* p, int weaponindex, int amount); +int playeraddweapon(player_struct* p, int weaponindex, int amount); void playeraddinventory(player_struct* p, DDukeActor* item, int type, int amount); void actorsizeto(DDukeActor* actor, double x, double y); void spawndebris(DDukeActor* g_ac, int dnum, int count); -bool checkp(DDukeActor* self, player_struct* p, int flags); -bool playercheckinventory(player_struct* p, DDukeActor* item, int type, int amount); +int checkp(DDukeActor* self, player_struct* p, int flags); +int playercheckinventory(player_struct* p, DDukeActor* item, int type, int amount); void playerstomp(player_struct* p, DDukeActor* stomped); void playerreset(player_struct* p, DDukeActor* g_ac); void wackplayer(player_struct* p); void actoroperate(DDukeActor* g_ac); void playerkick(player_struct* p, DDukeActor* g_ac); void garybanjo(DDukeActor* g_ac); -bool ifsquished(DDukeActor* i, int p); -void fakebubbaspawn(DDukeActor* actor, int g_p); +int ifsquished(DDukeActor* i, int p); +void fakebubbaspawn(DDukeActor* actor, player_struct* p); void tearitup(sectortype* sect); void destroyit(DDukeActor* actor); void mamaspawn(DDukeActor* actor); @@ -225,7 +225,7 @@ void displayrooms(int32_t playerNum, double interpfrac, bool sceneonly); void setgamepalette(int palid); void resetmys(); void resettimevars(); -bool setnextmap(bool checksecretexit); +int setnextmap(bool checksecretexit); void prelevel_d(int g, TArray&); void prelevel_r(int g, TArray&); void e4intro(const CompletionFunc& completion); @@ -243,6 +243,11 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act); void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h); void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAngle viewang); +int LookupAction(DDukeActor* self, FName name); +int LookupMove(DDukeActor* self, FName name); +int LookupAI(DDukeActor* self, FName name); + + inline int32_t krand(void) { randomseed = (randomseed * 27584621) + 1; diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index f6d5c63d6..5f4e02e3d 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -483,6 +483,26 @@ void GameInterface::FinalizeSetup() } +int LookupAction(DDukeActor* self, FName name) +{ + // todo + return 0; +} + +int LookupMove(DDukeActor* self, FName name) +{ + // todo + return 0; +} + +int LookupAI(DDukeActor* self, FName name) +{ + // todo + return 0; +} + + + void CallInitialize(DDukeActor* actor) { IFVIRTUALPTR(actor, DDukeActor, Initialize) @@ -713,7 +733,7 @@ DEFINE_PROPERTY(movef, Sff, DukeActor) DEFINE_PROPERTY(action, SZIiiii, DukeActor) { auto action = &actions[actions.Reserve(1)]; - memset(&action, 0, sizeof(action)); + memset(action, 0, sizeof(*action)); PROP_STRING_PARM(n, 0); action->name = n; action->qualifiedName = FStringf("%s.%s", info->TypeName.GetChars(), n); @@ -761,6 +781,24 @@ DEFINE_PROPERTY(ai, SSSi, DukeActor) } } +DEFINE_PROPERTY(startaction, S, DukeActor) +{ + PROP_STRING_PARM(n, 0); + bag.DefaultAction = n; +} + +DEFINE_PROPERTY(startmove, S, DukeActor) +{ + PROP_STRING_PARM(n, 0); + bag.DefaultMove = n; +} + +DEFINE_PROPERTY(moveflags, I, DukeActor) +{ + PROP_INT_PARM(n, 0); + bag.moveflags = n; +} + CCMD(changewalltexture) { if (argv.argc() < 2) return; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index a218f9fb1..9bb7feaf8 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1447,7 +1447,7 @@ static int ifcanshoottarget(DDukeActor *actor, int g_p, int g_x) // //--------------------------------------------------------------------------- -bool ifcansee(DDukeActor* actor, int pnum) +int ifcansee(DDukeActor* actor, player_struct* p) { int j; DDukeActor* tosee; @@ -1455,19 +1455,19 @@ bool ifcansee(DDukeActor* actor, int pnum) // select sprite for monster to target // if holoduke is on, let them target holoduke first. // - if (ps[pnum].holoduke_on != nullptr && !isRR()) + if (p->holoduke_on != nullptr && !isRR()) { - tosee = ps[pnum].holoduke_on; + tosee = p->holoduke_on; j = cansee(actor->spr.pos.plusZ(-zrand(32)), actor->sector(), tosee->spr.pos, tosee->sector()); if (j == 0) { // they can't see player's holoduke // check for player.. - tosee = ps[pnum].GetActor(); + tosee = p->GetActor(); } } - else tosee = ps[pnum].GetActor(); // holoduke not on. look for player + else tosee = p->GetActor(); // holoduke not on. look for player // can they see player, (or player's holoduke) j = cansee(actor->spr.pos.plusZ(-zrand(48)), actor->sector(), tosee->spr.pos.plusZ(isRR()? -28 : -24), tosee->sector()); @@ -1533,7 +1533,7 @@ int ParseState::parse(void) parseifelse(g_ac->actorstayput == nullptr); break; case concmd_ifcansee: - parseifelse(ifcansee(g_ac, g_p)); + parseifelse(ifcansee(g_ac, &ps[g_p])); break; case concmd_ifhitweapon: @@ -1611,7 +1611,7 @@ int ParseState::parse(void) break; case concmd_fakebubba: insptr++; - fakebubbaspawn(g_ac, g_p); + fakebubbaspawn(g_ac, &ps[g_p]); break; case concmd_rndmove: diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index dd503d620..686e570e4 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -1117,6 +1117,7 @@ y(RRTILE5024, 5024) y(RRTILE5025, 5025) y(RRTILE5026, 5026) y(RRTILE5027, 5027) +y(BARRELBROKE, 5028) y(RRTILE5029, 5029) y(RRTILE5030, 5030) y(RRTILE5031, 5031) @@ -1130,6 +1131,7 @@ y(RRTILE5038, 5038) y(RRTILE5039, 5039) y(RRTILE5040, 5040) y(RRTILE5041, 5041) +y(BARREL2BROKE, 5042) y(RRTILE5043, 5043) y(RRTILE5044, 5044) y(RRTILE5045, 5045) @@ -1463,7 +1465,8 @@ x(HULKC, 4653) x(HULKJIBA, 4748) x(HULKJIBB, 4753) x(HULKJIBC, 4758) -x(SBSWIPE, 4770) +x(BUBBAELVIS, 4770) // RRRA +x(SBSWIPE, 4770) // RR x(SBPAIN, 4810) x(SBDIE, 4820) x(HEN, 4861) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 535b0a48b..7839cbd19 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -1050,7 +1050,7 @@ void purplelavacheck(player_struct* p) // //--------------------------------------------------------------------------- -bool addphealth(player_struct* p, int amount, bool bigitem) +void addphealth(player_struct* p, int amount, bool bigitem) { if (p->newOwner != nullptr) { @@ -1072,7 +1072,7 @@ bool addphealth(player_struct* p, int amount, bool bigitem) { if (curhealth > gs.max_player_health && amount > 0) { - return false; + return;// false; } else { @@ -1103,9 +1103,9 @@ bool addphealth(player_struct* p, int amount, bool bigitem) p->last_extra = curhealth; } + p->GetActor()->spr.extra = curhealth; } - return true; } //--------------------------------------------------------------------------- @@ -1114,7 +1114,7 @@ bool addphealth(player_struct* p, int amount, bool bigitem) // //--------------------------------------------------------------------------- -bool playereat(player_struct* p, int amount, bool bigitem) +int playereat(player_struct* p, int amount, bool bigitem) { p->eat += amount; if (p->eat > 100) @@ -1211,7 +1211,7 @@ void playerdrink(player_struct* p, int amount) // //--------------------------------------------------------------------------- -bool playeraddammo(player_struct* p, int weaponindex, int amount) +int playeraddammo(player_struct* p, int weaponindex, int amount) { if (p->ammo_amount[weaponindex] >= gs.max_ammo_amount[weaponindex]) { @@ -1224,7 +1224,7 @@ bool playeraddammo(player_struct* p, int weaponindex, int amount) return true; } -bool playeraddweapon(player_struct* p, int weaponindex, int amount) +int playeraddweapon(player_struct* p, int weaponindex, int amount) { if (p->gotweapon[weaponindex] == 0) fi.addweapon(p, weaponindex, !!(WeaponSwitch(p- ps) & 1)); else if (p->ammo_amount[weaponindex] >= gs.max_ammo_amount[weaponindex]) @@ -1312,7 +1312,7 @@ void playeraddinventory(player_struct* p, DDukeActor* item, int type, int amount // //--------------------------------------------------------------------------- -bool checkp(DDukeActor* self, player_struct* p, int flags) +int checkp(DDukeActor* self, player_struct* p, int flags) { bool j = 0; @@ -1371,7 +1371,7 @@ bool checkp(DDukeActor* self, player_struct* p, int flags) // //--------------------------------------------------------------------------- -bool playercheckinventory(player_struct* p, DDukeActor* item, int type, int amount) +int playercheckinventory(player_struct* p, DDukeActor* item, int type, int amount) { bool j = 0; switch (type) @@ -1470,7 +1470,6 @@ void playerreset(player_struct* p, DDukeActor* g_ac) if (ud.multimode < 2) { gameaction = ga_autoloadgame; - g_ac->killit_flag = 2; } else { diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 3925da31c..e6c3ffe02 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -1186,7 +1186,7 @@ void GameInterface::NewGame(MapRecord* map, int skill, bool) // //--------------------------------------------------------------------------- -bool setnextmap(bool checksecretexit) +int setnextmap(bool checksecretexit) { MapRecord* map = nullptr; MapRecord* from_bonus = nullptr; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 01b45c958..b93270dfc 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -228,6 +228,29 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, isshootableswitch, Duke_isshootableswitch) return 0; } +int Duke_checksprite(PClassActor* self) +{ + auto texid = GetDefaultByType(self)->spr.spritetexture(); + auto tex = TexMan.GetGameTexture(texid); + return tex && tex->isValid(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Duke, checksprite, Duke_checksprite) +{ + PARAM_PROLOGUE; + PARAM_POINTER(v, PClassActor); + ACTION_RETURN_BOOL(Duke_checksprite(v)); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Duke, setnextmap, setnextmap) +{ + PARAM_PROLOGUE; + PARAM_INT(v); + ACTION_RETURN_BOOL(setnextmap(v)); + return 0; +} + DEFINE_GLOBAL_UNSIZED(dlevel) DEFINE_GLOBAL(camsprite) @@ -266,6 +289,11 @@ DEFINE_FIELD(DDukeActor, actorstayput) DEFINE_FIELD(DDukeActor, temp_pos) DEFINE_FIELD(DDukeActor, temp_pos2) DEFINE_FIELD(DDukeActor, temp_angle) +DEFINE_FIELD(DDukeActor, curAction) +DEFINE_FIELD(DDukeActor, curMove) +DEFINE_FIELD(DDukeActor, curAI) +DEFINE_FIELD(DDukeActor, actioncounter) +DEFINE_FIELD(DDukeActor, killit_flag) void TickActor(DDukeActor*); DEFINE_ACTION_FUNCTION(DDukeActor, Tick) @@ -385,6 +413,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, CheckSoundPlaying, DukeActor_IsSoundPl ACTION_RETURN_INT(DukeActor_IsSoundPlaying(self, snd, chan)); } +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, CheckAnyActorSoundPlaying, S_CheckAnyActorSoundPlaying) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + ACTION_RETURN_INT(S_CheckAnyActorSoundPlaying(self)); +} + void DukeActor_StopSound(DDukeActor* self, int snd, int flags) { S_StopSound(FSoundID::fromInt(snd), self, flags); @@ -699,6 +733,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, restoreloc, DukeActor_restoreloc) return 0; } +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, fakebubbaspawn, fakebubbaspawn) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(p, player_struct); + fakebubbaspawn(self, p); + return 0; +} + DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, aim, aim_) { PARAM_SELF_PROLOGUE(DDukeActor); @@ -707,6 +749,200 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, aim, aim_) ACTION_RETURN_POINTER(aim_(self, weapon, aimangle)); } +void Duke_SetAction(DDukeActor* self, int intname) +{ + int ndx = LookupAction(self, FName(ENamedName(intname))); + self->curAction = &actions[ndx]; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, SetAction, Duke_SetAction) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(n); + Duke_SetAction(self, n); + return 0; +} + +void Duke_SetMove(DDukeActor* self, int intname, int flags) +{ + int ndx = LookupMove(self, FName(ENamedName(intname))); + self->curMove = &moves[ndx]; + self->spr.hitag = flags; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, SetMove, Duke_SetMove) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(n); + PARAM_INT(f); + Duke_SetMove(self, n, f); + return 0; +} + +void Duke_SetAI(DDukeActor* self, int intname) +{ + int ndx = LookupAI(self, FName(ENamedName(intname))); + self->curMove = &moves[ais[ndx].move]; + self->curAction = &actions[ais[ndx].action]; + self->spr.hitag = ais[ndx].moveflags; + self->curAI = ais[ndx].name; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, SetAI, Duke_SetAI) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(n); + Duke_SetAI(self, n); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, checkp, checkp) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(p, player_struct); + PARAM_INT(n); + ACTION_RETURN_INT(checkp(self, p, n)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, cansee, ifcansee) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(p, player_struct); + PARAM_INT(n); + ACTION_RETURN_INT(ifcansee(self, p)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, actoroperate, actoroperate) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + actoroperate(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, ifsquished, ifsquished) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(p, player_struct); + ACTION_RETURN_INT(ifcansee(self, p)); +} + +void Duke_ChangeType(DDukeActor* self, PClassActor* type) +{ + self->ChangeType(type); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, ChangeType, Duke_ChangeType) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(type, PClassActor); + self->ChangeType(type); + return 0; +} + +void Duke_fall(DDukeActor* self, player_struct* p) +{ + fi.fall(self, p->GetPlayerNum()); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, fall, Duke_fall) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(p, player_struct); + Duke_fall(self, p); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, actorsizeto, actorsizeto) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + actorsizeto(self, x, y); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, dodge, dodge) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + ACTION_RETURN_INT(dodge(self)); +} + +int Duke_ifcanshoottarget(DDukeActor* self, player_struct* p, double dist) +{ + return ifcanshoottarget(self, p->GetPlayerNum(), int(dist * worldtoint)); +} +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, ifcanshoottarget, Duke_ifcanshoottarget) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(p, player_struct); + PARAM_FLOAT(x); + ACTION_RETURN_INT(Duke_ifcanshoottarget(self, p, x)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spriteglass, spriteglass) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(x); + spriteglass(self, x); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawndebris, spawndebris) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(x); + PARAM_INT(y); + spawndebris(self, x, y); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, respawnhitag, respawnhitag) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + respawnhitag(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, destroyit, destroyit) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + destroyit(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, mamaspawn, mamaspawn) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + mamaspawn(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, garybanjo, garybanjo) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + garybanjo(self); + return 0; +} + +int duke_GetambientSound(DDukeActor* actor) +{ + return ambienttags.SafeGet(actor->spr.detail, {}).lo; +} +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, GetAmbientSound, duke_GetambientSound) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + ACTION_RETURN_INT(duke_GetambientSound(self)); +} + +double duke_GetambientDist(DDukeActor* actor) +{ + return ambienttags.SafeGet(actor->spr.detail, {}).hi * maptoworld; +} +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, GetAmbientDist, duke_GetambientDist) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + ACTION_RETURN_FLOAT(duke_GetambientDist(self)); +} DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, addkill, addkill) { @@ -751,9 +987,7 @@ DEFINE_FIELD_X(DukePlayer, player_struct, invdisptime) //DEFINE_FIELD_X(DukePlayer, player_struct, bobposy) DEFINE_FIELD_X(DukePlayer, player_struct, pyoff) DEFINE_FIELD_X(DukePlayer, player_struct, opyoff) -//DEFINE_FIELD_X(DukePlayer, player_struct, posxv) -//DEFINE_FIELD_X(DukePlayer, player_struct, posyv) -//DEFINE_FIELD_X(DukePlayer, player_struct, poszv) +DEFINE_FIELD_X(DukePlayer, player_struct, vel) DEFINE_FIELD_X(DukePlayer, player_struct, last_pissed_time) DEFINE_FIELD_X(DukePlayer, player_struct, truefz) DEFINE_FIELD_X(DukePlayer, player_struct, truecz) @@ -1131,6 +1365,127 @@ DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, checkhitswitch, pl_checkhitswitch) return 0; } +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playerkick, playerkick) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_POINTER(act, DDukeActor); + playerkick(self, act); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playerstomp, playerstomp) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_POINTER(act, DDukeActor); + playerstomp(self, act); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playerreset, playerreset) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_POINTER(act, DDukeActor); + playerreset(self, act); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, addphealth, addphealth) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_INT(amt); + PARAM_INT(big); + addphealth(self, amt, big); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, wackplayer, wackplayer) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + wackplayer(self); + return 0; +} + +static void duke_checkweapons(player_struct* p) +{ + fi.checkweapons(p); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, checkweapons, duke_checkweapons) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + duke_checkweapons(self); + return 0; +} + +static void msg(player_struct* p, int num) +{ + FTA(num, p); +} +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, FTA, msg) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_INT(num); + FTA(num, self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playercheckinventory, playercheckinventory) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_POINTER(act, DDukeActor); + PARAM_INT(num); + PARAM_INT(amt); + ACTION_RETURN_BOOL(playercheckinventory(self, act, num, amt)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playeraddinventory, playeraddinventory) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_POINTER(act, DDukeActor); + PARAM_INT(num); + PARAM_INT(amt); + playeraddinventory(self, act, num, amt); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playeraddweapon, playeraddweapon) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_INT(num); + PARAM_INT(amt); + ACTION_RETURN_BOOL(playeraddweapon(self, num, amt)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playeraddammo, playeraddammo) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_INT(num); + PARAM_INT(amt); + ACTION_RETURN_BOOL(playeraddammo(self, num, amt)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, forceplayerangle, forceplayerangle) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + forceplayerangle(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playereat, playereat) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_INT(amt); + PARAM_BOOL(big); + ACTION_RETURN_BOOL(playereat(self, amt, big)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, playerdrink, playerdrink) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_INT(amt); + playerdrink(self, amt); + return 0; +} static DDukeActor* duke_firstStat(DukeStatIterator* it, int statnum) { @@ -1395,6 +1750,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(_DukeLevel, setanimation, static_cast type); native DukeActor spawnsprite(int type); // for cases where the map has a picnum stored. Avoid when possible. @@ -210,6 +306,24 @@ class DukeActor : CoreActor native native int SpriteHeight(); native DukeActor aim(readonly weapon, double aimangle = -1); + // CON simulation + native void SetAction(Name act); + native void SetAI(Name ai); + native void SetMove(Name mov, int flags = 0); + native bool checkp(DukePlayer p, int flags); + native bool cansee(DukePlayer p); + native void actoroperate(); + native bool ifsquished(DukePlayer p); + native void ChangeType(class newtype); + native void fall(DukePlayer p); + native void actorsizeto(double x, double y); + native bool dodge(); + native bool ifcanshoottarget(DukePlayer p, double pdist); + native void spriteglass(int n); + native void spawndebris(int dnum, int count); + native void respawnhitag(); + + virtual native void Tick(); @@ -222,7 +336,7 @@ class DukeActor : CoreActor native virtual void onMotoSmash(DukePlayer toucher) {} virtual void onRespawn(int tag) { } virtual bool animate(tspritetype tspr) { return false; } - virtual void RunState() {} // this is the CON function. + virtual void RunState(DukePlayer p, double pdist) {} // this is the CON function. virtual void PlayFTASound() {} virtual void StandingOn(DukePlayer p) {} virtual bool TriggerSwitch(DukePlayer activator) { return false; } @@ -249,6 +363,12 @@ class DukeActor : CoreActor native native void insertspriteq(); native void operateforcefields(int tag); native void restoreloc(); + native void fakebubbaspawn(DukePlayer p); + native void destroyit(); + native void mamaspawn(); + native void garybanjo(); + native Sound GetAmbientSound(); + native double GetAmbientDist(); native void addkill(); native void subkill(); @@ -379,6 +499,7 @@ struct DukeLevel native static DukeActor LocateTheLocator(int n, sectortype sect); native static int getanimationindex(int type, sectortype sec); native static int setanimation(sectortype animsect, int type, sectortype sec, double target, double vel); + native static void tearitup(sectortype sect); } struct DukeStatIterator diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index 053012cf8..05c7f85f0 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -180,6 +180,8 @@ struct Duke native static native void setlastvisinc(int amount); static native bool isaccessswitch(TextureID tex); static native bool isshootableswitch(TextureID tex); + static native bool CheckSprite(class tex); + static native bool setnextmap(bool checksecret); static int rnd(int val) { return (random(0, 255) >= (255 - (val))); @@ -239,6 +241,7 @@ struct DukePlayer native uint16_t frags[MAXPLAYERS]; */ + native vector3 vel; native bool gotweapon[DukeWpn.MAX_WEAPONS]; // Palette management uses indices into the engine's palette table now. @@ -387,7 +390,20 @@ struct DukePlayer native native void StartBoat(); native void checkhitswitch(walltype wal, DukeActor act); - + native void playerkick(DukeActor target); + native void playerstomp(DukeActor target); + native void addphealth(int amount, bool bigitem = false); + native void wackplayer(); + native void checkweapons(); + native void playerreset(DukeActor ac); + native void FTA(int num); + native bool playercheckinventory(DukeActor item, int type, int amount); + native void playeraddinventory(DukeActor item, int type, int amount); + native bool playeraddweapon(int type, int amount); + native bool playeraddammo(int type, int amount); + native void forceplayerangle(); + native bool playereat(int amount, bool bigitem); + native void playerdrink(int amount); } struct DukeWpn @@ -480,7 +496,7 @@ struct DukeGameInfo native struct DukeUserDefs native { - native readonly uint8 god, cashman, eog; + native uint8 god, cashman, eog; native readonly uint8 clipping; native readonly uint8 user_pals[MAXPLAYERS]; native readonly int16 from_bonus; @@ -497,3 +513,22 @@ struct DukeUserDefs native native DukeActor cameraactor; native bool joe9000; } + +struct ActorMove native +{ + native Name qualifiedName; // this is only used for serialization. + native Name name; + native float movex, movez; +} + +struct ActorAction native +{ + native Name qualifiedName; // this is only used for serialization. + native Name name; + native TextureID base; + native int offset; + native int16 numframes; + native int16 rotationtype; + native int16 increment; + native int16 delay; +}; diff --git a/wadsrc/static/zscript/maptypes.zs b/wadsrc/static/zscript/maptypes.zs index efeb26cf4..5f7c22d8c 100644 --- a/wadsrc/static/zscript/maptypes.zs +++ b/wadsrc/static/zscript/maptypes.zs @@ -148,6 +148,9 @@ struct sectortype native native readonly int16 ceilingheinum; native readonly int16 floorheinum; + native readonly TextureID ceilingtexture; + native readonly TextureID floortexture; + native Array<@walltype> walls; native int16 ceilingstat; native int16 floorstat; diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index be18290d0..ca8d671ae 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -215,13 +215,14 @@ struct Raze native static Sound FindSoundByResID(int id); native static int tileflags(TextureID tex); + native static int tilesurface(TextureID tex); native static sectortype updatesector(Vector2 pos, sectortype lastsect, double maxdist = 96); native static sectortype, Vector3 clipmove(Vector3 pos, sectortype sect, Vector2 move, double walldist, double ceildist, double flordist, uint cliptype, CollisionData coll, int clipmoveboxtracenum = 3); native static bool cansee(Vector3 start, sectortype startsec, Vector3 end, sectortype endsec); native static int hitscan(Vector3 start, sectortype startsect, Vector3 vect, HitInfo hitinfo, uint cliptype, double maxrange = -1); - // game check shortcuts + // game check shortcuts (todo: meake these compile time constant intrinsics) static bool isDuke() { @@ -248,6 +249,11 @@ struct Raze return gameinfo.gametype & (GAMEFLAG_RRALL); } + static bool isRoute66() + { + return gameinfo.gametype & (GAMEFLAG_ROUTE66); + } + static bool isRRRA() { return gameinfo.gametype & (GAMEFLAG_RRRA); @@ -263,6 +269,11 @@ struct Raze return gameinfo.gametype & GAMEFLAG_PLUTOPAK; } + static bool isVacation() + { + return gameinfo.gametype & GAMEFLAG_DUKEVACA; + } + static bool isShareware() { return gameinfo.gametype & GAMEFLAG_SHAREWARE;