// // ACS_funcSetThingState // static void ACS_funcSetThingState(ACS_FUNCARG) { int32_t tid = args[0]; const char *statename = ACSVM::GetString(args[1]); statenum_t statenum = E_StateNumForName(statename); state_t *state; int32_t count = 0; Mobj *mo = NULL; while((mo = P_FindMobjFromTID(tid, mo, thread->trigger))) { // Look for the named state for that type. if((state = E_GetJumpInfo(mo->info, statename))) { P_SetMobjState(mo, state->index); ++count; } // Otherwise, fall back to the global name. else if(statenum >= 0) { P_SetMobjState(mo, statenum); ++count; } } *retn++ = count; }
// // A_SpidRefire // // Spider Mastermind line-of-sight checking. // void A_SpidRefire(actionargs_t *actionargs) { Mobj *actor = actionargs->actor; // keep firing unless target got out of sight A_FaceTarget(actionargs); // killough 12/98: Stop firing if a friend has gotten in the way if(actor->flags & MF_FRIEND && P_HitFriend(actor)) { P_SetMobjState(actor, actor->info->seestate); return; } if(P_Random(pr_spidrefire) < 10) return; // killough 11/98: prevent refiring on friends continuously if(!actor->target || actor->target->health <= 0 || actor->flags & actor->target->flags & MF_FRIEND || !P_CheckSight(actor, actor->target)) { P_SetMobjState(actor, actor->info->seestate); } }
static boolean DeactivateThing(mobj_t *mobj) { if(mobj->flags & MF_COUNTKILL) { // Monster if(!(mobj->flags2 & MF2_DORMANT)) { mobj->flags2 |= MF2_DORMANT; mobj->tics = -1; return true; } return false; } switch (mobj->type) { case MT_ZTWINEDTORCH: case MT_ZTWINEDTORCH_UNLIT: P_SetMobjState(mobj, S_ZTWINEDTORCH_UNLIT); break; case MT_ZWALLTORCH: case MT_ZWALLTORCH_UNLIT: P_SetMobjState(mobj, S_ZWALLTORCH_U); break; case MT_THRUSTFLOOR_UP: case MT_THRUSTFLOOR_DOWN: if(mobj->args[0] == 1) { S_StartSound(SFX_THRUSTSPIKE_RAISE, mobj); if(mobj->args[1]) P_SetMobjState(mobj, S_BTHRUSTLOWER); else P_SetMobjState(mobj, S_THRUSTLOWER); } break; case MT_ZFIREBULL: case MT_ZFIREBULL_UNLIT: P_SetMobjState(mobj, S_ZFIREBULL_DEATH); break; case MT_ZCAULDRON: case MT_ZCAULDRON_UNLIT: P_SetMobjState(mobj, S_ZCAULDRON_U); break; case MT_FLAME_SMALL: P_SetMobjState(mobj, S_FLAME_SDORM1); break; case MT_FLAME_LARGE: P_SetMobjState(mobj, S_FLAME_LDORM1); break; case MT_BAT_SPAWNER: P_SetMobjState(mobj, S_SPAWNBATS_OFF); break; default: return false; break; } return true; }
void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage) { mobj_t *th; z += ((P_Random()-P_Random())<<10); th = P_SpawnMobj (x,y,z, MT_BLOOD); th->momz = FRACUNIT*2; th->tics -= P_Random()&1; if (th->tics<1) th->tics = 1; if (damage <= 12 && damage >= 9) P_SetMobjState (th,S_BLOOD2); else if (damage < 9) P_SetMobjState (th,S_BLOOD3); }
// 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; } } }
void A_FireShotgun2(player_t *player, pspdef_t *psp) { int i; CHECK_WEAPON_CODEPOINTER("A_FireShotgun2", player); S_StartSound(player->mo, sfx_dshtgn); P_SetMobjState(player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo] -= 2; A_FireSomething(player,0); // phares P_BulletSlope(player->mo); for (i=0; i<20; i++) { int damage = 5*(P_Random(pr_shotgun)%3+1); angle_t angle = player->mo->angle; // killough 5/5/98: remove dependence on order of evaluation: int t = P_Random(pr_shotgun); angle += (t - P_Random(pr_shotgun))<<19; t = P_Random(pr_shotgun); P_LineAttack(player->mo, angle, MISSILERANGE, bulletslope + ((t - P_Random(pr_shotgun))<<5), damage); } }
void A_FireShotgun2(player_t* player, pspdef_t* psp) { int i; angle_t angle; int damage; S_StartSound(player->mo, sfx_sht2fire); P_SetMobjState(player->mo, S_007); player->ammo[weaponinfo[player->readyweapon].ammo] -= 2; P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate); P_BulletSlope(player->mo); player->recoilpitch = RECOILPITCH; if(player->onground) P_Thrust(player, player->mo->angle + ANG180, FRACUNIT); for(i = 0; i < 20; i++) { damage = 5 * (P_Random() % 3 + 1); angle = player->mo->angle; angle += P_RandomShift(ANGLETOFINESHIFT); P_LineAttack(player->mo, angle, MISSILERANGE, bulletslope + P_RandomShift(5), damage); } }
// // P_SpawnBrokenGlass // villsa [STRIFE] new function // static void P_SpawnBrokenGlass(line_t* line) { fixed_t x1; fixed_t x2; fixed_t y1; fixed_t y2; int i; mobj_t* glass; angle_t an; x1 = (line->v2->x + line->v1->x) / 2; y1 = (line->v2->y + line->v1->y) / 2; x2 = ((line->frontsector->soundorg.x - x1) / 5) + x1; y2 = ((line->frontsector->soundorg.y - y1) / 5) + y1; for(i = 0; i < 7; i++) { glass = P_SpawnMobj(x2, y2, ONFLOORZ, MT_JUNK); glass->z += (24*FRACUNIT); glass->flags |= (MF_SHADOW|MF_MVIS); P_SetMobjState(glass, P_Random() % 3 + S_SHRD_03); // 284 an = ((P_Random() << 13) / 255); glass->angle = (an << ANGLETOFINESHIFT); glass->momx = FixedMul(finecosine[an], (P_Random() & 3) << FRACBITS); glass->momy = FixedMul(finesine[an], (P_Random() & 3) << FRACBITS); glass->momz = (P_Random() & 7) << FRACBITS; glass->tics += (P_Random() + 7) & 7; } }
void A_FireCGun(player_t* player, pspdef_t* psp) { int ammo = player->ammo[weaponinfo[player->readyweapon].ammo]; int rand; if(!ammo) return; S_StartSound(player->mo, sfx_pistol); P_SetMobjState (player->mo, S_007); player->ammo[weaponinfo[player->readyweapon].ammo]--; // randomize sx rand = (((P_Random() & 1) << 1) - 1); psp->sx = (rand * FRACUNIT); // randomize sy rand = ((((ammo - 1) & 1) << 1) - 1); psp->sy = WEAPONTOP - (rand * (2*FRACUNIT)); player->psprites[ps_flash].alpha = 160; P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate + psp->state - &states[S_756]); player->recoilpitch = RECOILPITCH; P_BulletSlope(player->mo); P_GunShot(player->mo, !player->refire); }
// // A_GunFlash // void A_GunFlash (AActor *mo) { player_t *player = mo->player; P_SetMobjState (player->mo, S_PLAY_ATK2); P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate); }
// [crispy] from boom202s/M_CHEAT.C:467-498 static int ST_cheat_massacre() // jff 2/01/98 kill all monsters { // jff 02/01/98 'em' cheat - kill all monsters // partially taken from Chi's .46 port // // killough 2/7/98: cleaned up code and changed to use dprintf; // fixed lost soul bug (LSs left behind when PEs are killed) int killcount=0; thinker_t *currentthinker=&thinkercap; extern void A_PainDie(mobj_t *); while ((currentthinker=currentthinker->next)!=&thinkercap) if (currentthinker->function.acp1 == (actionf_p1) P_MobjThinker && (((mobj_t *) currentthinker)->flags & MF_COUNTKILL || ((mobj_t *) currentthinker)->type == MT_SKULL)) { // killough 3/6/98: kill even if PE is dead if (((mobj_t *) currentthinker)->health > 0) { killcount++; P_DamageMobj((mobj_t *)currentthinker, NULL, NULL, 10000); } if (((mobj_t *) currentthinker)->type == MT_PAIN) { A_PainDie((mobj_t *) currentthinker); // killough 2/8/98 P_SetMobjState ((mobj_t *) currentthinker, S_PAIN_DIE6); } } return (killcount); }
// // A_CounterSwitch // // This powerful codepointer can branch to one of N states // depending on the value of the indicated counter, and it // remains totally safe at all times. If the entire indicated // frame set is not valid, no actions will be taken. // // args[0] : counter # to use // args[1] : DeHackEd number of first frame in consecutive set // args[2] : number of frames in consecutive set // void A_CounterSwitch(Mobj *mo) { int cnum, startstate, numstates; int *counter; cnum = E_ArgAsInt(mo->state->args, 0, 0); startstate = E_ArgAsStateNumNI(mo->state->args, 1, mo); numstates = E_ArgAsInt(mo->state->args, 2, 0) - 1; // get counter if(cnum < 0 || cnum >= NUMMOBJCOUNTERS) return; // invalid counter = &(mo->counters[cnum]); // verify startstate if(startstate < 0) return; // verify last state is < NUMSTATES if(startstate + numstates >= NUMSTATES) return; // verify counter is in range if(*counter < 0 || *counter > numstates) return; // jump! P_SetMobjState(mo, startstate + *counter); }
// // P_ExplodeMissile // void P_ExplodeMissile (AActor* mo) { mo->momx = mo->momy = mo->momz = 0; P_SetMobjState (mo, mobjinfo[mo->type].deathstate); if (mobjinfo[mo->type].deathstate != S_NULL) { // [RH] If the object is already translucent, don't change it. // Otherwise, make it 66% translucent. //if (mo->translucency == FRACUNIT) // mo->translucency = TRANSLUC66; mo->translucency = FRACUNIT; mo->tics -= P_Random(mo)&3; if (mo->tics < 1) mo->tics = 1; mo->flags &= ~MF_MISSILE; if (mo->info->deathsound) S_Sound (mo, CHAN_VOICE, mo->info->deathsound, 1, ATTN_NORM); mo->effects = 0; // [RH] } }
// // A_CounterJump // // Parameterized codepointer for branching based on comparisons // against a thing's counter values. // // args[0] : state number // args[1] : comparison type // args[2] : immediate value OR counter number // args[3] : counter # to use // void A_CounterJump(Mobj *mo) { bool branch = false; int statenum, checktype, value, cnum; int *counter; statenum = E_ArgAsStateNumNI(mo->state->args, 0, mo); checktype = E_ArgAsKwd(mo->state->args, 1, &cpckwds, 0); value = E_ArgAsInt(mo->state->args, 2, 0); cnum = E_ArgAsInt(mo->state->args, 3, 0); // validate state if(statenum < 0) return; if(cnum < 0 || cnum >= NUMMOBJCOUNTERS) return; // invalid counter = &(mo->counters[cnum]); // 08/02/04: // support getting check value from a counter // if checktype is greater than the last immediate operator, // then the comparison value is actually a counter number if(checktype >= CPC_NUMIMMEDIATE) { // turn it into the corresponding immediate operation checktype -= CPC_NUMIMMEDIATE; if(value < 0 || value >= NUMMOBJCOUNTERS) return; // invalid counter number value = mo->counters[value]; } switch(checktype) { case CPC_LESS: branch = (*counter < value); break; case CPC_LESSOREQUAL: branch = (*counter <= value); break; case CPC_GREATER: branch = (*counter > value); break; case CPC_GREATEROREQUAL: branch = (*counter >= value); break; case CPC_EQUAL: branch = (*counter == value); break; case CPC_NOTEQUAL: branch = (*counter != value); break; case CPC_BITWISEAND: branch = !!(*counter & value); break; default: break; } if(branch) P_SetMobjState(mo, statenum); }
void A_GunFlash(player_t *player, pspdef_t *psp) { CHECK_WEAPON_CODEPOINTER("A_GunFlash", player); P_SetMobjState(player->mo, S_PLAY_ATK2); A_FireSomething(player,0); // phares }
// // A_GunFlash // void A_GunFlash(player_t* player, pspdef_t* psp) { P_SetMobjState(player->mo, S_007); // [d64] set alpha on flash frame if(player->readyweapon != wp_bfg) player->psprites[ps_flash].alpha = 100; P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate); }
OVERLAY void A_FirePistol(player_t *player, pspdef_t *psp) { S_StartSound(player->mo, sfx_pistol); P_SetMobjState(player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; A_FireSomething(player,0); // phares P_BulletSlope(player->mo); P_GunShot(player->mo, !player->refire); }
void P_ExplodeMissile (mobj_t *mo) { mo->momx = mo->momy = mo->momz = 0; P_SetMobjState (mo, mobjinfo[mo->type].deathstate); mo->tics -= P_Random()&1; if (mo->tics < 1) mo->tics = 1; mo->flags &= ~MF_MISSILE; if (mo->info->deathsound) S_StartSound (mo, mo->info->deathsound); }
// // P_AnimationTick // void P_AnimationTick(AActor *mo) { if (mo && mo->tics != -1) { mo->tics--; // you can cycle through multiple states in a tic if (!mo->tics) if (!P_SetMobjState (mo, mo->state->nextstate) ) return; // freed itself } }
static void P_FireWeapon(player_t *player) { statenum_t newstate; if (!P_CheckAmmo(player)) return; P_SetMobjState(player->mo, S_PLAY_ATK1); newstate = weaponinfo[player->readyweapon].atkstate; P_SetPsprite(player, ps_weapon, newstate); P_NoiseAlert(player->mo, player->mo); }
// // A_FirePistol // void A_FirePistol(player_t *player, pspdef_t *psp) { S_StartSound(player->mo, sfx_pistol); P_SetMobjState(player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; P_SetPsprite(player, ps_flash, (statenum_t)weaponinfo[player->readyweapon].flashstate); P_BulletSlope(player->mo); P_GunShot(player->mo, !player->refire); }
// // A_HealthJump // // Parameterized codepointer for branching based on comparisons // against a thing's health. // // args[0] : state number // args[1] : comparison type // args[2] : health value OR counter number // void A_HealthJump(Mobj *mo) { bool branch = false; int statenum, checktype, checkhealth; statenum = E_ArgAsStateNumNI(mo->state->args, 0, mo); checktype = E_ArgAsKwd(mo->state->args, 1, &cpckwds, 0); checkhealth = E_ArgAsInt(mo->state->args, 2, 0); // validate state if(statenum < 0) return; // 08/02/04: // support getting check value from a counter // if checktype is greater than the last immediate operator, // then the checkhealth value is actually a counter number if(checktype >= CPC_NUMIMMEDIATE) { // turn it into the corresponding immediate operation checktype -= CPC_NUMIMMEDIATE; if(checkhealth < 0 || checkhealth >= NUMMOBJCOUNTERS) return; // invalid counter number checkhealth = mo->counters[checkhealth]; } switch(checktype) { case CPC_LESS: branch = (mo->health < checkhealth); break; case CPC_LESSOREQUAL: branch = (mo->health <= checkhealth); break; case CPC_GREATER: branch = (mo->health > checkhealth); break; case CPC_GREATEROREQUAL: branch = (mo->health >= checkhealth); break; case CPC_EQUAL: branch = (mo->health == checkhealth); break; case CPC_NOTEQUAL: branch = (mo->health != checkhealth); break; case CPC_BITWISEAND: branch = !!(mo->health & checkhealth); break; default: break; } if(branch) P_SetMobjState(mo, statenum); }
// // P_ExplodeMissile // // [STRIFE] Removed randomization of deathstate tics // void P_ExplodeMissile (mobj_t* mo) { mo->momx = mo->momy = mo->momz = 0; P_SetMobjState (mo, mobjinfo[mo->type].deathstate); // villsa [STRIFE] removed tics randomization mo->flags &= ~MF_MISSILE; if (mo->info->deathsound) S_StartSound (mo, mo->info->deathsound); }
OVERLAY static void P_FireWeapon(player_t *player) { statenum_t newstate; if (!P_CheckAmmo(player)) return; P_SetMobjState(player->mo, S_PLAY_ATK1); newstate = (statenum_t)weaponinfo[player->readyweapon].atkstate; P_SetPsprite(player, ps_weapon, newstate); P_NoiseAlert(player->mo, player->mo); lastshottic = gametic; // killough 3/22/98 }
// // A_WeaponReady // The player can fire the weapon // or change to another weapon at this time. // Follows after getting weapon up, // or after previous attack/fire sequence. // void A_WeaponReady(player_t *player, pspdef_t *psp) { // get out of attack state if (player->mo->state == &states[S_PLAY_ATK1] || player->mo->state == &states[S_PLAY_ATK2]) P_SetMobjState(player->mo, S_PLAY); if (player->readyweapon == wp_chainsaw && psp->state == &states[S_SAW]) S_StartSound(player->mo, sfx_sawidl); // check for change // if player is dead, put the weapon away if (player->pendingweapon != wp_nochange || !player->health) { // change weapon (pending weapon should already be validated) P_SetPsprite(player, ps_weapon, (statenum_t)weaponinfo[player->readyweapon].downstate); return; } // check for fire // the missile launcher and bfg do not auto fire if (player->cmd.buttons & BT_ATTACK) { if (!player->attackdown || (player->readyweapon != wp_missile && player->readyweapon != wp_bfg)) { player->attackdown = true; P_FireWeapon(player); return; } } else player->attackdown = false; if (player->mo->momx || player->mo->momy || player->mo->momz) { // bob the weapon based on movement speed int angle = (128 * leveltime) & FINEMASK; int bob = player->bob; if (bob < FRACUNIT / 2) bob = 0; psp->sx = FixedMul(bob, finecosine[angle]); psp->sy = WEAPONTOP + FixedMul(bob, finesine[angle & FINEANGLES / 2 - 1]); } else { psp->sx = 0; psp->sy = WEAPONTOP; } }
// // A_WeaponReady // The player can fire the weapon // or change to another weapon at this time. // Follows after getting weapon up, // or after previous attack/fire sequence. // void A_WeaponReady(AActor *mo) { statenum_t newstate; player_t *player = mo->player; struct pspdef_s *psp = &player->psprites[player->psprnum]; // get out of attack state if (player->mo->state == &states[S_PLAY_ATK1] || player->mo->state == &states[S_PLAY_ATK2] ) { P_SetMobjState (player->mo, S_PLAY); } if (player->readyweapon == wp_chainsaw && psp->state == &states[S_SAW]) { A_FireSound(player, "weapons/sawidle"); } // check for change // if player is dead, put the weapon away if (player->pendingweapon != wp_nochange || player->health <= 0) { // change weapon // (pending weapon should already be validated) newstate = weaponinfo[player->readyweapon].downstate; P_SetPsprite (player, ps_weapon, newstate); return; } // check for fire // the missile launcher and bfg do not auto fire // [AM] Allow warmup to disallow weapon firing. if (player->cmd.ucmd.buttons & BT_ATTACK && warmup.checkfireweapon()) { if ( !player->attackdown || (player->readyweapon != wp_missile && player->readyweapon != wp_bfg) ) { player->attackdown = true; P_FireWeapon (player); return; } } else player->attackdown = false; // bob the weapon based on movement speed P_BobWeapon(player); }
// // A_FirePistol // Modded to be a musket pistol // -jukeri12 30.8.2015 // void A_FirePistol(player_t *player, pspdef_t *psp) { S_StartSound(player->mo, sfx_pistol); P_SetMobjState(player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; A_FireSomething(player,0); // phares P_BulletSlope(player->mo); P_MusketShot(player->mo, 19, 40); P_TraceFront(player->mo, player->mo->angle, MELEERANGE/2, bulletslope); }
void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z) { mobj_t *th; z += ((P_Random()-P_Random())<<10); th = P_SpawnMobj (x,y,z, MT_PUFF); th->momz = FRACUNIT; th->tics -= P_Random()&1; if (th->tics < 1) th->tics = 1; /* don't make punches spark on the wall */ if (attackrange == MELEERANGE) P_SetMobjState (th, S_PUFF3); }
OVERLAY void A_FireCGun(player_t *player, pspdef_t *psp) { S_StartSound(player->mo, sfx_pistol); if (!player->ammo[weaponinfo[player->readyweapon].ammo]) return; P_SetMobjState(player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; A_FireSomething(player,psp->state - &states[S_CHAIN1]); // phares P_BulletSlope(player->mo); P_GunShot(player->mo, !player->refire); }
OVERLAY void A_FireShotgun(player_t *player, pspdef_t *psp) { int i; S_StartSound(player->mo, sfx_shotgn); P_SetMobjState(player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; A_FireSomething(player,0); // phares P_BulletSlope(player->mo); for (i=0; i<7; i++) P_GunShot(player->mo, false); }