- Converted all action functions be directly callable by the VM (though they are not yet

usable).

SVN r2154 (scripting)
This commit is contained in:
Randy Heit 2010-02-12 06:04:57 +00:00
commit 739e684549
108 changed files with 2827 additions and 1295 deletions

View file

@ -1688,10 +1688,12 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
//
DEFINE_ACTION_FUNCTION(AActor, A_Look)
{
PARAM_ACTION_PROLOGUE;
AActor *targ;
if (self->flags5 & MF5_INCONVERSATION)
return;
return 0;
// [RH] Set goal now if appropriate
if (self->special == Thing_SetGoal && self->args[0] == 0)
@ -1723,7 +1725,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
if (targ && targ->player && (targ->player->cheats & CF_NOTARGET))
{
return;
return 0;
}
}
@ -1767,7 +1769,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
}
if (!P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND, NULL))
return;
return 0;
// go into chase state
seeyou:
@ -1793,6 +1795,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
{
self->SetState (self->SeeState);
}
return 0;
}
@ -1805,30 +1808,32 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
{
ACTION_PARAM_START(6);
ACTION_PARAM_INT(flags, 0);
ACTION_PARAM_FIXED(minseedist, 1);
ACTION_PARAM_FIXED(maxseedist, 2);
ACTION_PARAM_FIXED(maxheardist, 3);
ACTION_PARAM_ANGLE(fov, 4);
ACTION_PARAM_STATE(seestate, 5);
PARAM_ACTION_PROLOGUE;
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_FIXED_OPT (minseedist) { minseedist = 0; }
PARAM_FIXED_OPT (maxseedist) { maxseedist = 0; }
PARAM_FIXED_OPT (maxheardist) { maxheardist = 0; }
PARAM_ANGLE_OPT (fov) { fov = 0; }
PARAM_STATE_OPT (seestate) { seestate = NULL; }
AActor *targ = NULL; // Shuts up gcc
fixed_t dist;
FLookExParams params = {fov, minseedist, maxseedist, maxheardist, flags, seestate };
FLookExParams params = { fov, minseedist, maxseedist, maxheardist, flags, seestate };
if (self->flags5 & MF5_INCONVERSATION)
return;
return 0;
// [RH] Set goal now if appropriate
if (self->special == Thing_SetGoal && self->args[0] == 0)
{
NActorIterator iterator (NAME_PatrolPoint, self->args[1]);
NActorIterator iterator(NAME_PatrolPoint, self->args[1]);
self->special = 0;
self->goal = iterator.Next ();
self->reactiontime = self->args[2] * TICRATE + level.maptime;
if (self->args[3] == 0) self->flags5 &=~ MF5_CHASEGOAL;
else self->flags5 |= MF5_CHASEGOAL;
if (self->args[3] == 0)
self->flags5 &= ~MF5_CHASEGOAL;
else
self->flags5 |= MF5_CHASEGOAL;
}
self->threshold = 0; // any shot will wake up
@ -1851,8 +1856,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
}
else
{
dist = P_AproxDistance (targ->x - self->x,
targ->y - self->y);
dist = P_AproxDistance (targ->x - self->x, targ->y - self->y);
// [KS] If the target is too far away, don't respond to the sound.
if (maxheardist && dist > maxheardist)
@ -1866,7 +1870,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
if (targ && targ->player && (targ->player->cheats & CF_NOTARGET))
{
return;
return 0;
}
}
@ -1923,8 +1927,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
{
if (self->flags & MF_AMBUSH)
{
dist = P_AproxDistance (self->target->x - self->x,
self->target->y - self->y);
dist = P_AproxDistance (self->target->x - self->x, self->target->y - self->y);
if (P_CheckSight (self, self->target, 2) &&
(!minseedist || dist > minseedist) &&
(!maxseedist || dist < maxseedist))
@ -1941,11 +1944,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
if (!(flags & LOF_NOSIGHTCHECK))
{
if (!P_LookForPlayers(self, true, &params))
return;
return 0;
}
else
{
return;
return 0;
}
// go into chase state
@ -1979,6 +1982,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
self->SetState (self->SeeState);
}
}
return 0;
}
// [KS] *** End additions by me ***
@ -1990,20 +1994,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_Wander)
{
PARAM_ACTION_PROLOGUE;
// [RH] Strife probably clears this flag somewhere, but I couldn't find where.
// This seems as good a place as any.
self->flags4 &= ~MF4_INCOMBAT;
if (self->flags5 & MF5_INCONVERSATION)
return;
return 0;
if (self->flags4 & MF4_STANDSTILL)
return;
return 0;
if (self->reactiontime != 0)
{
self->reactiontime--;
return;
return 0;
}
// turn towards movement direction if not there yet
@ -2026,6 +2032,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander)
P_RandomChaseDir (self);
self->movecount += 5;
}
return 0;
}
@ -2036,10 +2043,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander)
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_Look2)
{
PARAM_ACTION_PROLOGUE;
AActor *targ;
if (self->flags5 & MF5_INCONVERSATION)
return;
return 0;
self->threshold = 0;
targ = self->LastHeard;
@ -2062,7 +2071,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2)
self->target = targ;
self->threshold = 10;
self->SetState (self->SeeState);
return;
return 0;
}
else
{
@ -2070,7 +2079,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2)
goto nosee;
self->SetState (self->SeeState);
self->flags4 |= MF4_INCOMBAT;
return;
return 0;
}
}
nosee:
@ -2082,6 +2091,7 @@ nosee:
{
self->SetState (self->SpawnState + 3);
}
return 0;
}
//=============================================================================
@ -2097,7 +2107,7 @@ nosee:
//=============================================================================
#define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT
void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove)
void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove)
{
int delta;
@ -2607,53 +2617,60 @@ enum ChaseFlags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase)
{
ACTION_PARAM_START(3);
ACTION_PARAM_STATE(melee, 0);
ACTION_PARAM_STATE(missile, 1);
ACTION_PARAM_INT(flags, 2);
PARAM_ACTION_PROLOGUE;
PARAM_STATE_OPT (melee) { melee = NULL; }
PARAM_STATE_OPT (missile) { missile = NULL; }
PARAM_INT_OPT (flags) { flags = 0; }
if (melee != (FState*)-1)
if (numparam >= NAP + 1)
{
if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return;
if ((flags & CHF_RESURRECT) && P_CheckForResurrection(self, false))
return 0;
A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE),
A_DoChase(stack, self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE),
!!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE));
}
else // this is the old default A_Chase
{
A_DoChase (self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false);
A_DoChase(stack, self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false);
}
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_FastChase)
{
A_DoChase (self, true, self->MeleeState, self->MissileState, true, true, false);
PARAM_ACTION_PROLOGUE;
A_DoChase(stack, self, true, self->MeleeState, self->MissileState, true, true, false);
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_VileChase)
{
PARAM_ACTION_PROLOGUE;
if (!P_CheckForResurrection(self, true))
A_DoChase (self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false);
A_DoChase(stack, self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false);
return 0;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase)
{
ACTION_PARAM_START(4);
ACTION_PARAM_BOOL(domelee, 0);
ACTION_PARAM_BOOL(domissile, 1);
ACTION_PARAM_BOOL(playactive, 2);
ACTION_PARAM_BOOL(nightmarefast, 3);
PARAM_ACTION_PROLOGUE;
PARAM_BOOL (domelee);
PARAM_BOOL (domissile);
PARAM_BOOL_OPT (playactive) { playactive = true; }
PARAM_BOOL_OPT (nightmarefast) { nightmarefast = false; }
// Now that A_Chase can handle state label parameters, this function has become rather useless...
A_DoChase(self, false,
domelee ? self->MeleeState:NULL, domissile ? self->MissileState:NULL,
A_DoChase(stack, self, false,
domelee ? self->MeleeState : NULL, domissile ? self->MissileState : NULL,
playactive, nightmarefast, false);
return 0;
}
// for internal use
void A_Chase(AActor *self)
void A_Chase(VMFrameStack *stack, AActor *self)
{
A_DoChase (self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false);
A_DoChase(stack, self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false);
}
//=============================================================================
@ -2673,8 +2690,7 @@ void A_FaceTarget (AActor *self)
}
self->flags &= ~MF_AMBUSH;
self->angle = R_PointToAngle2 (self->x, self->y,
self->target->x, self->target->y);
self->angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y);
if (self->target->flags & MF_SHADOW)
{
@ -2684,7 +2700,9 @@ void A_FaceTarget (AActor *self)
DEFINE_ACTION_FUNCTION(AActor, A_FaceTarget)
{
PARAM_ACTION_PROLOGUE;
A_FaceTarget(self);
return 0;
}
//===========================================================================
@ -2696,8 +2714,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FaceTarget)
//===========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
{
PARAM_ACTION_PROLOGUE;
if (!self->target)
return;
return 0;
// [RH] Andy Baker's stealth monsters
if (self->flags & MF_STEALTH)
@ -2726,10 +2746,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
}
P_RailAttack (self, self->GetMissileDamage (0, 1), 0);
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_Scream)
{
PARAM_ACTION_PROLOGUE;
if (self->DeathSound)
{
// Check for bosses.
@ -2743,14 +2765,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_Scream)
S_Sound (self, CHAN_VOICE, self->DeathSound, 1, ATTN_NORM);
}
}
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_XScream)
{
PARAM_ACTION_PROLOGUE;
if (self->player)
S_Sound (self, CHAN_VOICE, "*gibbed", 1, ATTN_NORM);
else
S_Sound (self, CHAN_VOICE, "misc/gibbed", 1, ATTN_NORM);
return 0;
}
//===========================================================================
@ -2761,8 +2786,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_XScream)
DEFINE_ACTION_FUNCTION(AActor, A_ScreamAndUnblock)
{
PARAM_ACTION_PROLOGUE;
CALL_ACTION(A_Scream, self);
CALL_ACTION(A_NoBlocking, self);
return 0;
}
//===========================================================================
@ -2773,10 +2800,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ScreamAndUnblock)
DEFINE_ACTION_FUNCTION(AActor, A_ActiveSound)
{
PARAM_ACTION_PROLOGUE;
if (self->ActiveSound)
{
S_Sound (self, CHAN_VOICE, self->ActiveSound, 1, ATTN_NORM);
}
return 0;
}
//===========================================================================
@ -2787,8 +2816,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_ActiveSound)
DEFINE_ACTION_FUNCTION(AActor, A_ActiveAndUnblock)
{
PARAM_ACTION_PROLOGUE;
CALL_ACTION(A_ActiveSound, self);
CALL_ACTION(A_NoBlocking, self);
return 0;
}
//---------------------------------------------------------------------------
@ -2921,6 +2952,8 @@ void P_TossItem (AActor *item)
DEFINE_ACTION_FUNCTION(AActor, A_Pain)
{
PARAM_ACTION_PROLOGUE;
// [RH] Vary player pain sounds depending on health (ala Quake2)
if (self->player && self->player->morphTics == 0)
{
@ -2962,15 +2995,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
{
S_Sound (self, CHAN_VOICE, self->PainSound, 1, ATTN_NORM);
}
return 0;
}
// killough 11/98: kill an object
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Die)
{
ACTION_PARAM_START(1);
ACTION_PARAM_NAME(damagetype, 0);
PARAM_ACTION_PROLOGUE;
PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; }
P_DamageMobj (self, NULL, NULL, self->health, damagetype, DMG_FORCED);
return 0;
}
//
@ -2980,12 +3015,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Die)
DEFINE_ACTION_FUNCTION(AActor, A_Detonate)
{
int damage = self->GetMissileDamage (0, 1);
PARAM_ACTION_PROLOGUE;
int damage = self->GetMissileDamage(0, 1);
P_RadiusAttack (self, self->target, damage, damage, self->DamageType, true);
if (self->z <= self->floorz + (damage << FRACBITS))
{
P_HitFloor (self);
}
return 0;
}
bool CheckBossDeath (AActor *actor)
@ -3022,7 +3059,7 @@ bool CheckBossDeath (AActor *actor)
// A_BossDeath
// Possibly trigger special effects if on a boss level
//
DEFINE_ACTION_FUNCTION(AActor, A_BossDeath)
void A_BossDeath(AActor *self)
{
FName mytype = self->GetClass()->TypeName;
@ -3118,6 +3155,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_BossDeath)
G_ExitLevel (0, false);
}
DEFINE_ACTION_FUNCTION(AActor, A_BossDeath)
{
PARAM_ACTION_PROLOGUE;
A_BossDeath(self);
return 0;
}
//----------------------------------------------------------------------------
//
// PROC P_Massacre
@ -3191,6 +3235,7 @@ bool A_RaiseMobj (AActor *actor, fixed_t speed)
DEFINE_ACTION_FUNCTION(AActor, A_ClassBossHealth)
{
PARAM_ACTION_PROLOGUE;
if (multiplayer && !deathmatch) // co-op only
{
if (!self->special1)
@ -3199,4 +3244,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClassBossHealth)
self->special1 = true; // has been initialized
}
}
return 0;
}