// You never thought you needed this, did you? >=D // Yes, this has the specific purpose of completely screwing you up // to see if the consistency restoration code can fix you. // Don't enable this for normal builds... void Command_CauseCfail_f(void) { if (consoleplayer == serverplayer) { CONS_Printf("Your reality is everyone's reality. Therefore, you should not use this command.\n"); return; } P_UnsetThingPosition(players[consoleplayer].mo); P_Random(); P_Random(); P_Random(); players[consoleplayer].mo->x = 0; players[consoleplayer].mo->y = 123311; //cfail cansuled kthxbye players[consoleplayer].mo->z = 123311; players[consoleplayer].score = 1337; players[consoleplayer].health = 1337; players[consoleplayer].mo->destscale = 25; P_SetThingPosition(players[consoleplayer].mo); // CTF consistency test if (gametype == GT_CTF) { if (blueflag) P_SetMobjState(blueflag, S_DISS); if (redflag) { redflag->x = 423423; redflag->y = 666; redflag->z = 123311; } } }
boolean P_TeleportMove(mobj_t * thing, fixed_t x, fixed_t y) { int xl, xh, yl, yh, bx, by; subsector_t *newsubsec; // // kill anything occupying the position // tmthing = thing; tmflags = thing->flags; tmx = x; tmy = y; tmbbox[BOXTOP] = y + tmthing->radius; tmbbox[BOXBOTTOM] = y - tmthing->radius; tmbbox[BOXRIGHT] = x + tmthing->radius; tmbbox[BOXLEFT] = x - tmthing->radius; newsubsec = R_PointInSubsector(x, y); ceilingline = NULL; // // the base floor / ceiling is from the subsector that contains the // point. Any contacted lines the step closer together will adjust them // tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; validcount++; numspechit = 0; // // stomp on any things contacted // xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS) >> MAPBLOCKSHIFT; xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS) >> MAPBLOCKSHIFT; yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS) >> MAPBLOCKSHIFT; yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS) >> MAPBLOCKSHIFT; for (bx = xl; bx <= xh; bx++) for (by = yl; by <= yh; by++) if (!P_BlockThingsIterator(bx, by, PIT_StompThing)) return false; // // the move is ok, so link the thing into its new position // P_UnsetThingPosition(thing); thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; thing->x = x; thing->y = y; P_SetThingPosition(thing); return true; }
void P_RemoveMobj (mobj_t *mobj) { #ifndef MARS int spot; /* add to the respawnque for altdeath mode */ if ((mobj->flags & MF_SPECIAL) && !(mobj->flags & MF_DROPPED) && (mobj->type != MT_INV) && (mobj->type != MT_INS)) { spot = iquehead&(ITEMQUESIZE-1); itemrespawnque[spot].x = mobj->spawnx; itemrespawnque[spot].y = mobj->spawny; itemrespawnque[spot].type = mobj->spawntype; itemrespawnque[spot].angle = mobj->spawnangle; itemrespawntime[spot] = ticon; iquehead++; } #endif /* unlink from sector and block lists */ P_UnsetThingPosition (mobj); /* unlink from mobj list */ mobj->next->prev = mobj->prev; mobj->prev->next = mobj->next; Z_Free (mobj); }
// restore the players position -- sector must be the same shape void P_RestorePlayerPosition(void) { sector_t *sec; int secnum; // we always save and restore the psprites memcpy(save_player->psprites, save_psprites, sizeof(save_player->psprites)); // restore player position from x,y offset if(save_sectag == -1) return; // no sector relativeness if((secnum = P_FindSectorFromTag(save_sectag, -1)) < 0) { // invalid: sector not found return; } sec = §ors[secnum]; // restore position P_UnsetThingPosition(save_player->mo); save_player->mo->x = sec->soundorg.x + save_xoffset; save_player->mo->y = sec->soundorg.y + save_yoffset; // restore various other things save_player->mo->angle = save_mobj.angle; save_player->mo->momx = save_mobj.momx; // keep momentum save_player->mo->momy = save_mobj.momy; P_SetThingPosition(save_player->mo); }
/** \brief The P_MixUp function \param thing mobj_t to mix up \param x new x pos \param y new y pos \param z new y pos \param angle new angle to look at \return void */ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle) { // the move is ok, // so link the thing into its new position P_UnsetThingPosition(thing); // Remove touching_sectorlist from mobj. if (sector_list) { P_DelSeclist(sector_list); sector_list = NULL; } thing->x = x; thing->y = y; thing->z = z; if (thing->player) { if (thing->eflags & MFE_VERTICALFLIP) thing->player->viewz = thing->z + thing->height - thing->player->viewheight; else thing->player->viewz = thing->z + thing->player->viewheight; if (!thing->tracer) thing->reactiontime = TICRATE/2; // don't move for about half a second // absolute angle position if (thing == players[consoleplayer].mo) localangle = angle; if (splitscreen && thing == players[secondarydisplayplayer].mo) localangle2 = angle; // move chasecam at new player location if (splitscreen && cv_chasecam2.value && thing->player == &players[secondarydisplayplayer]) { P_ResetCamera(thing->player, &camera2); } else if (cv_chasecam.value && thing->player == &players[displayplayer]) P_ResetCamera(thing->player, &camera); // don't run in place after a teleport thing->player->cmomx = thing->player->cmomy = 0; thing->player->rmomx = thing->player->rmomy = 0; if (!thing->tracer) thing->player->speed = 0; P_ResetPlayer(thing->player); P_SetPlayerMobjState(thing, S_PLAY_STND); thing->player->bonuscount = 10; // flash the palette } thing->angle = angle; thing->momx = thing->momy = thing->momz = 0; }
void P_RepositionMace(mobj_t *mo) { int spot; subsector_t *ss; P_UnsetThingPosition(mo); spot = P_Random() % MaceSpotCount; mo->x = MaceSpots[spot].x; mo->y = MaceSpots[spot].y; ss = R_PointInSubsector(mo->x, mo->y); mo->z = mo->floorz = ss->sector->floorheight; mo->ceilingz = ss->sector->ceilingheight; P_SetThingPosition(mo); }
// // Attempt to move to a new position, crossing special lines unless MF_TELEPORT // is set. // void P_TryMove2(void) { trymove2 = false; floatok = false; oldx = tmthing->x; oldy = tmthing->y; PM_CheckPosition(); if(checkposonly) { checkposonly = false; return; } if(!trymove2) return; if(!(tmthing->flags & MF_NOCLIP)) { trymove2 = false; if(tmceilingz - tmfloorz < tmthing->height) return; // doesn't fit floatok = true; if(!(tmthing->flags & MF_TELEPORT) && tmceilingz - tmthing->z < tmthing->height) return; // mobj must lower itself to fit if(!(tmthing->flags & MF_TELEPORT) && tmfloorz - tmthing->z > 24*FRACUNIT) return; // too big a step up if(!(tmthing->flags & (MF_DROPOFF|MF_FLOAT)) && tmfloorz - tmdropoffz > 24*FRACUNIT) return; // don't stand over a dropoff } // the move is ok, so link the thing into its new position. P_UnsetThingPosition(tmthing); tmthing->floorz = tmfloorz; tmthing->ceilingz = tmceilingz; tmthing->x = tmx; tmthing->y = tmy; P_SetThingPosition(tmthing); trymove2 = true; }
static int mobj_set(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); enum mobj_e field = Lua_optoption(L, 2, mobj_opt[0], mobj_opt); lua_settop(L, 3); if (!mo) return LUA_ErrInvalid(L, "mobj_t"); if (hud_running) return luaL_error(L, "Do not alter mobj_t in HUD rendering code!"); switch(field) { case mobj_valid: return NOSET; case mobj_x: return NOSETPOS; case mobj_y: return NOSETPOS; case mobj_z: { // z doesn't cross sector bounds so it's okay. mobj_t *ptmthing = tmthing; mo->z = (fixed_t)luaL_checkinteger(L, 3); P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; P_SetTarget(&tmthing, ptmthing); break; } case mobj_snext: return NOSETPOS; case mobj_sprev: return UNIMPLEMENTED; case mobj_angle: mo->angle = (angle_t)luaL_checkinteger(L, 3); if (mo->player == &players[displayplayer]) localangle = mo->angle; else if (mo->player == &players[secondarydisplayplayer]) localangle2 = mo->angle; break; case mobj_sprite: mo->sprite = luaL_checkinteger(L, 3); break; case mobj_frame: mo->frame = (UINT32)luaL_checkinteger(L, 3); break; case mobj_touching_sectorlist: return UNIMPLEMENTED; case mobj_subsector: return NOSETPOS; case mobj_floorz: return NOSETPOS; case mobj_ceilingz: return NOSETPOS; case mobj_radius: { mobj_t *ptmthing = tmthing; mo->radius = (fixed_t)luaL_checkinteger(L, 3); if (mo->radius < 0) mo->radius = 0; P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; P_SetTarget(&tmthing, ptmthing); break; } case mobj_height: { mobj_t *ptmthing = tmthing; mo->height = (fixed_t)luaL_checkinteger(L, 3); if (mo->height < 0) mo->height = 0; P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; P_SetTarget(&tmthing, ptmthing); break; } case mobj_momx: mo->momx = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_momy: mo->momy = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_momz: mo->momz = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_pmomz: mo->pmomz = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_tics: mo->tics = luaL_checkinteger(L, 3); break; case mobj_state: // set state by enum if (mo->player) P_SetPlayerMobjState(mo, luaL_checkinteger(L, 3)); else P_SetMobjState(mo, luaL_checkinteger(L, 3)); break; case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR { UINT32 flags = luaL_checkinteger(L, 3); if ((flags & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (mo->flags & (MF_NOBLOCKMAP|MF_NOSECTOR))) { P_UnsetThingPosition(mo); mo->flags = flags; if (flags & MF_NOSECTOR && sector_list) { P_DelSeclist(sector_list); sector_list = NULL; } mo->snext = NULL, mo->sprev = NULL; mo->bnext = NULL, mo->bprev = NULL; P_SetThingPosition(mo); } else mo->flags = flags; break; } case mobj_flags2: mo->flags2 = (UINT32)luaL_checkinteger(L, 3); break; case mobj_eflags: mo->eflags = (UINT32)luaL_checkinteger(L, 3); break; case mobj_skin: // set skin by name { INT32 i; char skin[SKINNAMESIZE+1]; // all skin names are limited to this length strlcpy(skin, luaL_checkstring(L, 3), sizeof skin); strlwr(skin); // all skin names are lowercase for (i = 0; i < numskins; i++) if (fastcmp(skins[i].name, skin)) { mo->skin = &skins[i]; return 0; } return luaL_error(L, "mobj.skin '%s' not found!", skin); } case mobj_color: mo->color = ((UINT8)luaL_checkinteger(L, 3)) % MAXSKINCOLORS; break; case mobj_bnext: return NOSETPOS; case mobj_bprev: return UNIMPLEMENTED; case mobj_hnext: mo->hnext = luaL_checkudata(L, 3, META_MOBJ); break; case mobj_hprev: mo->hprev = luaL_checkudata(L, 3, META_MOBJ); break; case mobj_type: // yeah sure, we'll let you change the mobj's type. { mobjtype_t newtype = luaL_checkinteger(L, 3); if (newtype > MT_LASTFREESLOT) return luaL_error(L, "mobj.type %u is out of bounds.", newtype); mo->type = newtype; mo->info = &mobjinfo[newtype]; P_SetScale(mo, mo->scale); break; } case mobj_info: return NOSET; case mobj_health: mo->health = luaL_checkinteger(L, 3); break; case mobj_movedir: mo->movedir = (angle_t)luaL_checkinteger(L, 3); break; case mobj_movecount: mo->movecount = luaL_checkinteger(L, 3); break; case mobj_target: if (lua_isnil(L, 3)) P_SetTarget(&mo->target, NULL); else { mobj_t *target = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); P_SetTarget(&mo->target, target); } break; case mobj_reactiontime: mo->reactiontime = luaL_checkinteger(L, 3); break; case mobj_threshold: mo->threshold = luaL_checkinteger(L, 3); break; case mobj_player: return NOSET; case mobj_lastlook: mo->lastlook = luaL_checkinteger(L, 3); break; case mobj_spawnpoint: if (lua_isnil(L, 3)) mo->spawnpoint = NULL; else { mapthing_t *spawnpoint = *((mapthing_t **)luaL_checkudata(L, 3, META_MAPTHING)); mo->spawnpoint = spawnpoint; } break; case mobj_tracer: if (lua_isnil(L, 3)) P_SetTarget(&mo->tracer, NULL); else { mobj_t *tracer = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); P_SetTarget(&mo->tracer, tracer); } break; case mobj_friction: mo->friction = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_movefactor: mo->movefactor = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_fuse: mo->fuse = luaL_checkinteger(L, 3); break; case mobj_watertop: mo->watertop = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_waterbottom: mo->waterbottom = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_mobjnum: return UNIMPLEMENTED; case mobj_scale: { fixed_t scale = (fixed_t)luaL_checkinteger(L, 3); if (scale < FRACUNIT/100) scale = FRACUNIT/100; mo->destscale = scale; P_SetScale(mo, scale); break; } case mobj_destscale: { fixed_t scale = (fixed_t)luaL_checkinteger(L, 3); if (scale < FRACUNIT/100) scale = FRACUNIT/100; mo->destscale = scale; break; } case mobj_scalespeed: mo->scalespeed = (fixed_t)luaL_checkinteger(L, 3); break; case mobj_extravalue1: mo->extravalue1 = luaL_checkinteger(L, 3); break; case mobj_extravalue2: mo->extravalue2 = luaL_checkinteger(L, 3); break; case mobj_cusval: mo->cusval = luaL_checkinteger(L, 3); break; case mobj_cvmem: mo->cvmem = luaL_checkinteger(L, 3); break; default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); lua_pushlightuserdata(L, mo); lua_rawget(L, -2); if (lua_isnil(L, -1)) { // This index doesn't have a table for extra values yet, let's make one. lua_pop(L, 1); CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; adding it as Lua data.\n"), "mobj_t", lua_tostring(L, 2)); lua_newtable(L); lua_pushlightuserdata(L, mo); lua_pushvalue(L, -2); // ext value table lua_rawset(L, -4); // LREG_EXTVARS table } lua_pushvalue(L, 2); // key lua_pushvalue(L, 3); // value to store lua_settable(L, -3); lua_pop(L, 2); break; } return 0; }
// // P_TeleportMove // boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y, fixed_t z, boolean boss) { int xl; int xh; int yl; int yh; int bx; int by; subsector_t* newsubsec; // monsters don't stomp things except on boss level (30) if ((boss) || (thing->player) || (G_Access_MapInfoTab (gameepisode, gamemap) -> allow_monster_telefrags)) telefrag = true; else telefrag = false; // kill anything occupying the position tmthing = thing; tmflags = thing->flags; tmx = x; tmy = y; tmz = z; tmbbox[BOXTOP] = y + tmthing->radius; tmbbox[BOXBOTTOM] = y - tmthing->radius; tmbbox[BOXRIGHT] = x + tmthing->radius; tmbbox[BOXLEFT] = x - tmthing->radius; newsubsec = R_PointInSubsector (x,y); ceilingline = NULL; // The base floor/ceiling is from the subsector // that contains the point. // Any contacted lines the step closer together // will adjust them. tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; validcount++; numspechit = 0; // stomp on any things contacted xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockThingsIterator(bx,by,PIT_StompThing)) return false; // the move is ok, // so link the thing into its new position P_UnsetThingPosition (thing); thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; thing->x = x; thing->y = y; P_SetThingPosition (thing); return true; }
// // ACS_funcSetThingPosition // static void ACS_funcSetThingPosition(ACS_FUNCARG) { int32_t tid = args[0]; fixed_t x = args[1]; fixed_t y = args[2]; fixed_t z = args[3]; bool fog = args[4] ? true : false; Mobj *mo, *fogmo; if((mo = P_FindMobjFromTID(tid, NULL, thread->trigger))) { fixed_t oldx = mo->x; fixed_t oldy = mo->y; fixed_t oldz = mo->z; mo->z = z; if(P_CheckPositionExt(mo, x, y)) { subsector_t *newsubsec; newsubsec = R_PointInSubsector(x, y); // Set new position. P_UnsetThingPosition(mo); mo->floorz = mo->dropoffz = newsubsec->sector->floorheight; mo->ceilingz = newsubsec->sector->ceilingheight; mo->passfloorz = mo->secfloorz = mo->floorz; mo->passceilz = mo->secceilz = mo->ceilingz; mo->x = x; mo->y = y; mo->backupPosition(); P_SetThingPosition(mo); // Handle fog. if(fog) { // Teleport fog at source... fogmo = P_SpawnMobj(oldx, oldy, oldz + GameModeInfo->teleFogHeight, E_SafeThingName(GameModeInfo->teleFogType)); S_StartSound(fogmo, GameModeInfo->teleSound); // ... and destination. fogmo = P_SpawnMobj(x, y, z + GameModeInfo->teleFogHeight, E_SafeThingName(GameModeInfo->teleFogType)); S_StartSound(fogmo, GameModeInfo->teleSound); } *retn++ = 1; } else { mo->z = oldz; *retn++ = 0; } } else *retn++ = 0; }