diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index c5a086c4a..98a9769e8 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -514,9 +514,7 @@ void A_DeleteSprite(int32_t s) { int32_t p, pl=A_FindPlayer(&sprite[s],&p); - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_KILLIT, s, pl, p); - if (aGameVars[g_iReturnVarID].val.lValue) + if (VM_OnEvent(EVENT_KILLIT, s, pl, p, 0)) return; } @@ -8264,7 +8262,7 @@ void G_MoveWorld(void) j = nextspritestat[i]; pl = A_FindPlayer(&sprite[i], &p); - VM_OnEvent(EVENT_GAME,i, pl, p); + VM_OnEvent(EVENT_GAME,i, pl, p, 0); i = j; } } diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index b66a209cc..df1011aab 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2859,10 +2859,7 @@ void G_DisplayRest(int32_t smoothratio) if (pp->invdisptime > 0) G_DrawInventory(pp); - aGameVars[g_iReturnVarID].val.lValue = 0; - if (apScriptGameEvent[EVENT_DISPLAYSBAR]) - VM_OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek, -1, 0) == 0) G_DrawStatusBar(screenpeek); G_PrintGameQuotes(); @@ -2923,15 +2920,11 @@ void G_DisplayRest(int32_t smoothratio) } if (apScriptGameEvent[EVENT_DISPLAYREST]) - VM_OnEvent(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek, -1); + VM_OnEvent(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek, -1, 0); if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1) { - aGameVars[g_iReturnVarID].val.lValue = 0; - if (apScriptGameEvent[EVENT_DISPLAYCROSSHAIR]) - VM_OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, -1, 0) == 0) { int32_t x, y; #ifdef GEKKO @@ -3160,22 +3153,24 @@ void G_DrawBackground(void) } else { + int32_t bgtile; + if (getrendermode() >= 3) clearview(0); // when not rendering a game, fullscreen wipe #define MENUTILE (!getrendermode()?MENUSCREEN:LOADSCREEN) // Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1); - aGameVars[g_iReturnVarID].val.lValue = (tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE); + bgtile = (tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE); if (apScriptGameEvent[EVENT_GETMENUTILE]) - VM_OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1); + bgtile = VM_OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1, bgtile); if (Gv_GetVarByLabel("MENU_TILE", tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?0:1, -1, -1)) { - for (y=y1; yi, screenpeek, -1); + VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1, 0); ud.camerahoriz = clamp(ud.camerahoriz, HORIZ_MIN, HORIZ_MAX); @@ -3994,7 +3989,7 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3 int32_t pl=A_FindPlayer(s, &p); block_deletesprite++; - VM_OnEvent(EVENT_EGS, i, pl, p); + VM_OnEvent(EVENT_EGS, i, pl, p, 0); block_deletesprite--; } @@ -5728,7 +5723,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) if (apScriptGameEvent[EVENT_SPAWN]) { int32_t pl=A_FindPlayer(&sprite[i],&p); - VM_OnEvent(EVENT_SPAWN,i, pl, p); + VM_OnEvent(EVENT_SPAWN,i, pl, p, 0); } return i; } @@ -5958,7 +5953,7 @@ SPAWN_END: if (apScriptGameEvent[EVENT_SPAWN]) { int32_t pl=A_FindPlayer(&sprite[i],&p); - VM_OnEvent(EVENT_SPAWN,i, pl, p); + VM_OnEvent(EVENT_SPAWN,i, pl, p, 0); } // spawning is technically not allowed to fail in BUILD, so we just hide whatever @@ -6903,7 +6898,7 @@ skip: if (tsprite[j].owner < MAXSPRITES && tsprite[j].owner >= 0 && spriteext[tsprite[j].owner].flags & SPREXT_TSPRACCESS) { spriteext[tsprite[j].owner].tspr = (spritetype *)&tsprite[j]; - VM_OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); + VM_OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1, 0); } } while (j--); @@ -6914,7 +6909,7 @@ skip: if (tsprite[j].owner >= 0 && tsprite[j].owner < MAXSPRITES && spriteext[tsprite[j].owner].flags & SPREXT_TSPRACCESS) { spriteext[tsprite[j].owner].tspr = (spritetype *)&tsprite[j]; - VM_OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); + VM_OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1, 0); } } } @@ -6987,9 +6982,7 @@ enum cheatindex_t static void doinvcheat(int32_t invidx, int32_t defaultnum, int32_t event) { - Gv_SetVar(g_iReturnVarID, defaultnum, g_player[myconnectindex].ps->i, myconnectindex); - VM_OnEvent(event, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (aGameVars[g_iReturnVarID].val.lValue >=0) + if (VM_OnEvent(event, g_player[myconnectindex].ps->i, myconnectindex, -1, defaultnum) >= 0) { g_player[myconnectindex].ps->inv_amount[invidx] = aGameVars[g_iReturnVarID].val.lValue; @@ -9333,7 +9326,7 @@ static void G_DisplayLogo(void) } } - VM_OnEvent(EVENT_LOGO, -1, screenpeek, -1); + VM_OnEvent(EVENT_LOGO, -1, screenpeek, -1, 0); G_HandleAsync(); @@ -9486,7 +9479,7 @@ static void G_CompileScripts(void) Bmemset(sector, 0, MAXSECTORS*sizeof(sectortype)); Bmemset(wall, 0, MAXWALLS*sizeof(walltype)); - VM_OnEvent(EVENT_INIT, -1, -1, -1); + VM_OnEvent(EVENT_INIT, -1, -1, -1, 0); pathsearchmode = psm; } @@ -11646,7 +11639,7 @@ FRAGBONUS: else break; - VM_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); + VM_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek, -1, 0); nextpage(); } while (1); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index cc26a8e80..1f47322a9 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -93,14 +93,14 @@ void VM_ScriptInfo(void) initprintf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw); } -void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int32_t iPlayer, register int32_t lDist) +int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) { #ifdef LUNATIC_ENABLE if (El_IsInitialized(&g_ElState)) El_CallEvent(&g_ElState, iEventID); #endif if (!apScriptGameEvent[iEventID]) - return; + return iReturn; { intptr_t *oinsptr=insptr; @@ -114,6 +114,7 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue; int32_t backupEventExec = g_currentEventExec; + aGameVars[g_iReturnVarID].val.lValue = iReturn; g_currentEventExec = iEventID; insptr = apScriptGameEvent[iEventID]; @@ -135,7 +136,10 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int insptr = oinsptr; g_currentEventExec = backupEventExec; + iReturn = aGameVars[g_iReturnVarID].val.lValue; aGameVars[g_iReturnVarID].val.lValue = backupReturnVar; + + return iReturn; } } diff --git a/polymer/eduke32/source/gameexec.h b/polymer/eduke32/source/gameexec.h index 52160b8ce..fe416efd4 100644 --- a/polymer/eduke32/source/gameexec.h +++ b/polymer/eduke32/source/gameexec.h @@ -143,7 +143,7 @@ void G_RestoreMapState(mapstate_t *save); void G_SaveMapState(mapstate_t *save); void G_SaveMapState(mapstate_t *save); void Gv_RefreshPointers(void); -void VM_OnEvent(register int32_t iEventID,register int32_t iActor,register int32_t iPlayer,register int32_t lDist); +int32_t VM_OnEvent(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn); void VM_ScriptInfo(void); #endif diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 014695282..e0464d888 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -658,7 +658,7 @@ void M_DisplayMenus(void) return; } if (apScriptGameEvent[EVENT_DISPLAYMENU]) - VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1); + VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1, 0); g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); g_player[myconnectindex].ps->fta = 0; @@ -5480,7 +5480,7 @@ VOLUME_ALL_40x: break; } if (apScriptGameEvent[EVENT_DISPLAYMENUREST]) - VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[myconnectindex].ps->i, myconnectindex, -1); + VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[myconnectindex].ps->i, myconnectindex, -1, 0); if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 5ad73d5a2..54acefd46 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -73,11 +73,7 @@ static void P_IncurDamage(DukePlayer_t *p) { int32_t damage; - aGameVars[g_iReturnVarID].val.lValue = 0; - if (apScriptGameEvent[EVENT_INCURDAMAGE]) - VM_OnEvent(EVENT_INCURDAMAGE, p->i, sprite[p->i].yvel, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_INCURDAMAGE, p->i, sprite[p->i].yvel, -1, 0) == 0) { sprite[p->i].extra -= p->extra_extra8>>8; @@ -601,7 +597,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith) Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { @@ -623,7 +619,10 @@ int32_t A_Shoot(int32_t i,int32_t atwith) Gv_SetVar(g_iAngRangeVarID,angRange, i,p); Gv_SetVar(g_iZRangeVarID,zRange,i,p); - VM_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + + if (apScriptGameEvent[EVENT_GETSHOTRANGE]) + VM_OnEvent(EVENT_GETSHOTRANGE, i,p, -1, 0); + angRange=Gv_GetVar(g_iAngRangeVarID,i,p); zRange=Gv_GetVar(g_iZRangeVarID,i,p); @@ -950,7 +949,7 @@ DOSKIPBULLETHOLE: // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) @@ -1199,7 +1198,7 @@ DOSKIPBULLETHOLE: Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { @@ -1223,7 +1222,8 @@ DOSKIPBULLETHOLE: Gv_SetVar(g_iAngRangeVarID,angRange, i,p); Gv_SetVar(g_iZRangeVarID,zRange,i,p); - VM_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + if (apScriptGameEvent[EVENT_GETSHOTRANGE]) + VM_OnEvent(EVENT_GETSHOTRANGE, i,p, -1, 0); angRange=Gv_GetVar(g_iAngRangeVarID,i,p); zRange=Gv_GetVar(g_iZRangeVarID,i,p); @@ -1499,7 +1499,7 @@ SKIPBULLETHOLE: // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { @@ -1589,7 +1589,7 @@ SKIPBULLETHOLE: // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { @@ -1799,7 +1799,7 @@ SKIPBULLETHOLE: // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { @@ -1899,7 +1899,7 @@ SKIPBULLETHOLE: // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) - VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j=-1; if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { @@ -2139,12 +2139,7 @@ void P_FireWeapon(DukePlayer_t *p) { int32_t i, snum = sprite[p->i].yvel; - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DOFIRE]) - VM_OnEvent(EVENT_DOFIRE, p->i, snum, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DOFIRE, p->i, snum, -1, 0) == 0) { if (p->weapon_pos != 0) return; @@ -2356,11 +2351,7 @@ void P_DisplayWeapon(int32_t snum) g_kb=*kb; g_looking_angSR1=p->look_ang>>1; - aGameVars[g_iReturnVarID].val.lValue = 0; - if (apScriptGameEvent[EVENT_DISPLAYWEAPON]) - VM_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1, 0) == 0) { j = 14-p->quick_kick; if (j != 14 || p->last_quick_kick) @@ -2403,11 +2394,7 @@ void P_DisplayWeapon(int32_t snum) switch (cw) { case KNEE_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { if ((*kb) > 0) { @@ -2427,12 +2414,7 @@ void P_DisplayWeapon(int32_t snum) break; case TRIPBOMB_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { weapon_xoffset += 8; gun_pos -= 10; @@ -2460,12 +2442,7 @@ void P_DisplayWeapon(int32_t snum) break; case RPG_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; @@ -2482,12 +2459,7 @@ void P_DisplayWeapon(int32_t snum) break; case SHOTGUN_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { weapon_xoffset -= 8; @@ -2577,12 +2549,7 @@ void P_DisplayWeapon(int32_t snum) case CHAINGUN_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { if (*kb > 0) { @@ -2631,12 +2598,7 @@ void P_DisplayWeapon(int32_t snum) break; case PISTOL_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) { @@ -2700,12 +2662,7 @@ void P_DisplayWeapon(int32_t snum) break; case HANDBOMB_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { guniqhudid = cw; if ((*kb)) @@ -2732,12 +2689,7 @@ void P_DisplayWeapon(int32_t snum) break; case HANDREMOTE_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { static uint8_t remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; @@ -2752,12 +2704,7 @@ void P_DisplayWeapon(int32_t snum) break; case DEVISTATOR_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) { @@ -2794,12 +2741,7 @@ void P_DisplayWeapon(int32_t snum) break; case FREEZE_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) { @@ -2827,12 +2769,7 @@ void P_DisplayWeapon(int32_t snum) break; case GROW_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { weapon_xoffset += 28; looking_arc += 18; @@ -2872,12 +2809,7 @@ void P_DisplayWeapon(int32_t snum) break; case SHRINKER_WEAPON: - aGameVars[g_iReturnVarID].val.lValue = 0; - - if (apScriptGameEvent[EVENT_DRAWWEAPON]) - VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) { weapon_xoffset += 28; looking_arc += 18; @@ -3501,7 +3433,7 @@ void P_AddWeapon(DukePlayer_t *p,int32_t weapon) p->kickback_pic = 0; if (p->curr_weapon != weapon && apScriptGameEvent[EVENT_CHANGEWEAPON]) - VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); + VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, 0); p->curr_weapon = weapon; @@ -3579,7 +3511,7 @@ void P_CheckWeapon(DukePlayer_t *p) Gv_SetVar(g_iWorksLikeVarID, (unsigned)p->curr_weapon < MAX_WEAPONS ? aplWeaponWorksLike[p->curr_weapon][snum] : -1, p->i, snum); if (apScriptGameEvent[EVENT_CHANGEWEAPON]) - VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); + VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, 0); p->kickback_pic = 0; if (p->holster_weapon == 1) { @@ -3591,11 +3523,8 @@ void P_CheckWeapon(DukePlayer_t *p) void P_CheckTouchDamage(DukePlayer_t *p,int32_t j) { - aGameVars[g_iReturnVarID].val.lValue = j; - if (apScriptGameEvent[EVENT_CHECKTOUCHDAMAGE]) - VM_OnEvent(EVENT_CHECKTOUCHDAMAGE, p->i, sprite[p->i].yvel, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == -1) return; + if (VM_OnEvent(EVENT_CHECKTOUCHDAMAGE, p->i, sprite[p->i].yvel, -1, j) == -1) + return; if ((j&49152) == 49152) { @@ -3670,11 +3599,8 @@ int32_t P_CheckFloorDamage(DukePlayer_t *p, int32_t j) { spritetype *s = &sprite[p->i]; - aGameVars[g_iReturnVarID].val.lValue = j; - if (apScriptGameEvent[EVENT_CHECKFLOORDAMAGE]) - VM_OnEvent(EVENT_CHECKFLOORDAMAGE, p->i, sprite[p->i].yvel, -1); - - if ((unsigned)(j = aGameVars[g_iReturnVarID].val.lValue) >= MAXTILES) return 0; + if ((unsigned)(j = VM_OnEvent(EVENT_CHECKFLOORDAMAGE, p->i, sprite[p->i].yvel, -1, j)) >= MAXTILES) + return 0; switch (DYNAMICTILEMAP(j)) { @@ -3895,19 +3821,17 @@ void P_ProcessWeapon(int32_t snum) { Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_PRESSEDFIRE, p->i, snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue != 0) + + if (VM_OnEvent(EVENT_PRESSEDFIRE, p->i, snum, -1, 0) != 0) sb_snum &= ~BIT(SK_FIRE); } if (TEST_SYNC_KEY(sb_snum, SK_HOLSTER)) // 'Holster Weapon { - aGameVars[g_iReturnVarID].val.lValue = 0; Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); - VM_OnEvent(EVENT_HOLSTER, p->i, snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + + if (VM_OnEvent(EVENT_HOLSTER, p->i, snum, -1, 0) == 0) { if (*aplWeaponWorksLike[p->curr_weapon] != KNEE_WEAPON) { @@ -4006,17 +3930,13 @@ void P_ProcessWeapon(int32_t snum) } else { - aGameVars[g_iReturnVarID].val.lValue = 0; Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); - if (apScriptGameEvent[EVENT_FIRE]) - VM_OnEvent(EVENT_FIRE, p->i, snum, -1); - - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_FIRE, p->i, snum, -1, 0) == 0) { if (apScriptGameEvent[EVENT_FIREWEAPON]) // this event is deprecated - VM_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + VM_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1, 0); switch (aplWeaponWorksLike[p->curr_weapon][snum]) { @@ -4500,7 +4420,7 @@ void P_ProcessInput(int32_t snum) p->player_par++; - VM_OnEvent(EVENT_PROCESSINPUT, p->i, snum, -1); + VM_OnEvent(EVENT_PROCESSINPUT, p->i, snum, -1, 0); if (p->cheat_phase > 0) sb_snum = 0; @@ -4731,9 +4651,7 @@ void P_ProcessInput(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_LOOK_LEFT)) { // look_left - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_LOOKLEFT,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_LOOKLEFT,p->i,snum, -1, 0) == 0) { p->look_ang -= 152; p->rotscrnang += 24; @@ -4743,9 +4661,7 @@ void P_ProcessInput(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_LOOK_RIGHT)) { // look_right - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_LOOKRIGHT,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_LOOKRIGHT,p->i,snum, -1, 0) == 0) { p->look_ang += 152; p->rotscrnang -= 24; @@ -4814,9 +4730,7 @@ void P_ProcessInput(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_SWIMUP,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_SWIMUP,p->i,snum, -1, 0) == 0) { // jump if (p->vel.z > 0) p->vel.z = 0; @@ -4826,9 +4740,7 @@ void P_ProcessInput(int32_t snum) } else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_SWIMDOWN,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_SWIMDOWN,p->i,snum, -1, 0) == 0) { // crouch if (p->vel.z < 0) p->vel.z = 0; @@ -4904,9 +4816,7 @@ void P_ProcessInput(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) //A (soar high) { // jump - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_SOARUP,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_SOARUP,p->i,snum, -1, 0) == 0) { p->pos.z -= j; p->crack_time = 777; @@ -4916,9 +4826,7 @@ void P_ProcessInput(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) //Z (soar low) { // crouch - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_SOARDOWN,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_SOARDOWN,p->i,snum, -1, 0) == 0) { p->pos.z += j; p->crack_time = 777; @@ -5101,9 +5009,7 @@ void P_ProcessInput(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { // crouching - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_CROUCH,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_CROUCH,p->i,snum, -1, 0) == 0) { p->pos.z += (2048+768); p->crack_time = 777; @@ -5118,9 +5024,7 @@ void P_ProcessInput(int32_t snum) if (p->jumping_counter == 0) if ((fz-cz) > (56<<8)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_JUMP,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_JUMP,p->i,snum, -1, 0) == 0) { p->jumping_counter = 1; p->jumping_toggle = 1; @@ -5226,22 +5130,22 @@ void P_ProcessInput(int32_t snum) } if (g_player[snum].sync->extbits&(1)) - VM_OnEvent(EVENT_MOVEFORWARD,p->i,snum, -1); + VM_OnEvent(EVENT_MOVEFORWARD,p->i,snum, -1, 0); if (g_player[snum].sync->extbits&(1<<1)) - VM_OnEvent(EVENT_MOVEBACKWARD,p->i,snum, -1); + VM_OnEvent(EVENT_MOVEBACKWARD,p->i,snum, -1, 0); if (g_player[snum].sync->extbits&(1<<2)) - VM_OnEvent(EVENT_STRAFELEFT,p->i,snum, -1); + VM_OnEvent(EVENT_STRAFELEFT,p->i,snum, -1, 0); if (g_player[snum].sync->extbits&(1<<3)) - VM_OnEvent(EVENT_STRAFERIGHT,p->i,snum, -1); + VM_OnEvent(EVENT_STRAFERIGHT,p->i,snum, -1, 0); if (g_player[snum].sync->extbits&(1<<4) || g_player[snum].sync->avel < 0) - VM_OnEvent(EVENT_TURNLEFT,p->i,snum, -1); + VM_OnEvent(EVENT_TURNLEFT,p->i,snum, -1, 0); if (g_player[snum].sync->extbits&(1<<5) || g_player[snum].sync->avel > 0) - VM_OnEvent(EVENT_TURNRIGHT,p->i,snum, -1); + VM_OnEvent(EVENT_TURNRIGHT,p->i,snum, -1, 0); if (p->vel.x || p->vel.y || g_player[snum].sync->fvel || g_player[snum].sync->svel) { @@ -5416,18 +5320,12 @@ HORIZONLY: i = 0; if (TEST_SYNC_KEY(sb_snum, SK_CENTER_VIEW) || p->hard_landing) - { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_RETURNTOCENTER,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_RETURNTOCENTER,p->i,snum, -1, 0) == 0) p->return_to_center = 9; - } if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_LOOKUP,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_LOOKUP,p->i,snum, -1, 0) == 0) { p->return_to_center = 9; if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 12; @@ -5438,9 +5336,7 @@ HORIZONLY: if (TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_LOOKDOWN,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_LOOKDOWN,p->i,snum, -1, 0) == 0) { p->return_to_center = 9; if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 12; @@ -5451,9 +5347,7 @@ HORIZONLY: if (TEST_SYNC_KEY(sb_snum, SK_AIM_UP)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_AIMUP,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_AIMUP,p->i,snum, -1, 0) == 0) { if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 6; p->horiz += 6; @@ -5463,9 +5357,7 @@ HORIZONLY: if (TEST_SYNC_KEY(sb_snum, SK_AIM_DOWN)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_AIMDOWN,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_AIMDOWN,p->i,snum, -1, 0) == 0) { if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 6; p->horiz -= 6; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index c6f1e9807..3d55c7f76 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -344,10 +344,7 @@ static void G_DoLoadScreen(char *statustext, int32_t percent) if (ud.recstat != 2) { - /*Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1);*/ - aGameVars[g_iReturnVarID].val.lValue = LOADSCREEN; - VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1); - j = aGameVars[g_iReturnVarID].val.lValue; + j = VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1, LOADSCREEN); //g_player[myconnectindex].ps->palette = palette; P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0 /*1*/); // JBF 20040308 @@ -396,7 +393,7 @@ static void G_DoLoadScreen(char *statustext, int32_t percent) rotatesprite(158<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1); } - VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); + VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1, 0); nextpage(); if (!statustext) @@ -416,9 +413,7 @@ static void G_DoLoadScreen(char *statustext, int32_t percent) } /*Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1);*/ - aGameVars[g_iReturnVarID].val.lValue = LOADSCREEN; - VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1); - j = aGameVars[g_iReturnVarID].val.lValue; + j = VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1, LOADSCREEN); if ((uint32_t)j < 2*MAXTILES) { @@ -433,7 +428,7 @@ static void G_DoLoadScreen(char *statustext, int32_t percent) menutext(160,105,0,0,"Loading..."); if (statustext) gametext(160,180,statustext,0,2+8+16); - VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); + VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1, 0); nextpage(); } } @@ -733,7 +728,7 @@ void P_ResetPlayer(int32_t snum) g_player[snum].ps->movement_lock = 0; if (apScriptGameEvent[EVENT_RESETPLAYER]) - VM_OnEvent(EVENT_RESETPLAYER, g_player[snum].ps->i, snum, -1); + VM_OnEvent(EVENT_RESETPLAYER, g_player[snum].ps->i, snum, -1, 0); } void P_ResetStatus(int32_t snum) @@ -843,7 +838,7 @@ void P_ResetStatus(int32_t snum) p->frag_ps = snum; P_UpdateScreenPal(p); - VM_OnEvent(EVENT_RESETPLAYER, p->i, snum, -1); + VM_OnEvent(EVENT_RESETPLAYER, p->i, snum, -1, 0); } void P_ResetWeapons(int32_t snum) @@ -864,7 +859,7 @@ void P_ResetWeapons(int32_t snum) p->show_empty_weapon= 0; p->last_pissed_time = 0; p->holster_weapon = 0; - VM_OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1); + VM_OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1, 0); } void P_ResetInventory(int32_t snum) @@ -881,7 +876,7 @@ void P_ResetInventory(int32_t snum) p->inv_amount[GET_SHIELD] = g_startArmorAmount; p->inven_icon = 0; - VM_OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1); + VM_OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1, 0); } static void resetprestat(int32_t snum,int32_t g) @@ -1166,7 +1161,7 @@ static inline void prelevel(char g) nexti = nextspritestat[i]; A_ResetVars(i); A_LoadActor(i); - VM_OnEvent(EVENT_LOADACTOR, i, -1, -1); + VM_OnEvent(EVENT_LOADACTOR, i, -1, -1, 0); if (sprite[i].lotag == -1 && (sprite[i].cstat&16)) { g_player[0].ps->exitx = SX; @@ -1568,7 +1563,7 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk) display_mirror = 0; - VM_OnEvent(EVENT_NEWGAME, g_player[screenpeek].ps->i, screenpeek, -1); + VM_OnEvent(EVENT_NEWGAME, g_player[screenpeek].ps->i, screenpeek, -1, 0); } static void resetpspritevars(char g) @@ -2121,7 +2116,7 @@ int32_t G_EnterLevel(int32_t g) // variables are set by pointer... Bmemcpy(¤tboardfilename[0],&boardfilename[0],BMAX_PATH); - VM_OnEvent(EVENT_ENTERLEVEL, -1, -1, -1); + VM_OnEvent(EVENT_ENTERLEVEL, -1, -1, -1, 0); OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n",ud.volume_number+1,ud.level_number+1, MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name); diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 11af4ac9d..6338a9175 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -2514,9 +2514,7 @@ void P_HandleSharedKeys(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_QUICK_KICK) && p->quick_kick == 0) if (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum, -1, 0) == 0) { p->quick_kick = 14; if (p->fta == 0 || p->ftq == 80) @@ -2560,9 +2558,7 @@ void P_HandleSharedKeys(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_INVENTORY) && p->newowner == -1) // inventory button generates event for selected item { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum, -1, 0) == 0) { switch (p->inven_icon) { @@ -2587,9 +2583,7 @@ void P_HandleSharedKeys(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_NIGHTVISION)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0 + if (VM_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum, -1, 0) == 0 && p->inv_amount[GET_HEATS] > 0) { p->heat_on = !p->heat_on; @@ -2602,9 +2596,7 @@ void P_HandleSharedKeys(int32_t snum) if (TEST_SYNC_KEY(sb_snum, SK_STEROIDS)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum, -1, 0) == 0) { if (p->inv_amount[GET_STEROIDS] == 400) { @@ -2689,16 +2681,12 @@ CHECKINV1: if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left { /*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ - aGameVars[g_iReturnVarID].val.lValue = dainv; - VM_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1); - dainv=aGameVars[g_iReturnVarID].val.lValue; + dainv = VM_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1, dainv); } else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right { /*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ - aGameVars[g_iReturnVarID].val.lValue = dainv; - VM_OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1); - dainv=aGameVars[g_iReturnVarID].val.lValue; + dainv = VM_OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1, dainv); } if (dainv >= 1) @@ -2724,13 +2712,13 @@ CHECKINV1: case -1: break; default: - VM_OnEvent(EVENT_WEAPKEY1+j,p->i,snum, -1); + VM_OnEvent(EVENT_WEAPKEY1+j,p->i,snum, -1, 0); break; case 10: - VM_OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); + VM_OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1, 0); break; case 11: - VM_OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1); + VM_OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1, 0); break; } @@ -2809,10 +2797,7 @@ CHECKINV1: Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); Gv_SetVar(g_iWeaponVarID,j, p->i, snum); - aGameVars[g_iReturnVarID].val.lValue = j; - - VM_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1); - j = aGameVars[g_iReturnVarID].val.lValue; + j = VM_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1, j); if ((int32_t)j != -1 && j <= MAX_WEAPONS) { @@ -2905,9 +2890,7 @@ CHECKINV1: { if (p->holoduke_on == -1) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum, -1, 0) == 0) { if (p->inv_amount[GET_HOLODUKE] > 0) { @@ -2929,9 +2912,7 @@ CHECKINV1: } else { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum, -1, 0) == 0) { A_PlaySound(TELEPORTER,p->holoduke_on); p->holoduke_on = -1; @@ -2942,9 +2923,7 @@ CHECKINV1: if (TEST_SYNC_KEY(sb_snum, SK_MEDKIT)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum, -1, 0) == 0) { if (p->inv_amount[GET_FIRSTAID] > 0 && sprite[p->i].extra < p->max_player_health) { @@ -2969,9 +2948,7 @@ CHECKINV1: if (p->newowner == -1 && TEST_SYNC_KEY(sb_snum, SK_JETPACK)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + if (VM_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1, 0) == 0) { if (p->inv_amount[GET_JETPACK] > 0) { @@ -3004,14 +2981,8 @@ CHECKINV1: } if (TEST_SYNC_KEY(sb_snum, SK_TURNAROUND) && p->one_eighty_count == 0) - { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_TURNAROUND,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) - { + if (VM_OnEvent(EVENT_TURNAROUND,p->i,snum, -1, 0) == 0) p->one_eighty_count = -1024; - } - } } } @@ -3116,9 +3087,7 @@ void P_CheckSectors(int32_t snum) if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN)) { - aGameVars[g_iReturnVarID].val.lValue = 0; - VM_OnEvent(EVENT_USE, p->i, snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue != 0) + if (VM_OnEvent(EVENT_USE, p->i, snum, -1, 0) != 0) g_player[snum].sync->bits &= ~BIT(SK_OPEN); } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 2e5ff13ba..b22b38ef6 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -621,15 +621,13 @@ int32_t S_PlaySound(int32_t num) int32_t A_PlaySound(uint32_t num, int32_t i) { - aGameVars[g_iReturnVarID].val.lValue = num; - if (apScriptGameEvent[EVENT_SOUND]) - VM_OnEvent(EVENT_SOUND, i, myconnectindex, -1); + num = VM_OnEvent(EVENT_SOUND, i, myconnectindex, -1, num); - if ((unsigned)aGameVars[g_iReturnVarID].val.lValue > (unsigned)g_maxSoundPos) return -1; + if ((unsigned)num > (unsigned)g_maxSoundPos) return -1; - return i < 0 ? S_PlaySound(aGameVars[g_iReturnVarID].val.lValue) : - S_PlaySound3D(aGameVars[g_iReturnVarID].val.lValue, i, (vec3_t *)&sprite[i]); + return i < 0 ? S_PlaySound(num) : + S_PlaySound3D(num, i, (vec3_t *)&sprite[i]); } void S_StopEnvSound(int32_t num, int32_t i)