scripted_sequence: support for 'killtarget' key
This commit is contained in:
parent
662e01c84d
commit
818a1a2155
3 changed files with 35 additions and 7 deletions
|
@ -256,13 +256,18 @@ scripted_sequence::RunOnEntity(entity targ)
|
|||
m_iValue = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* mark the state */
|
||||
f.m_iSequenceState = SEQUENCESTATE_ACTIVE;
|
||||
|
||||
/* seems to be active at all times? contrary to SS_TURNTOFACE existing? */
|
||||
f.m_vecSequenceAngle = GetAngles();
|
||||
f.m_iSequenceFlags = spawnflags;
|
||||
f.m_strSequenceKillTarget = m_strKillTarget;
|
||||
|
||||
if (m_strKillTarget) {
|
||||
readcmd(sprintf("watchpoint_ssqc %d.nextthink\n", num_for_edict(f)));
|
||||
NSAIScript_Log("\tKillTarget when finished: %S", m_strKillTarget);
|
||||
}
|
||||
|
||||
if (m_iMove == SS_NO) {
|
||||
f.m_vecSequenceAngle = f.angles;
|
||||
|
@ -279,7 +284,6 @@ scripted_sequence::RunOnEntity(entity targ)
|
|||
return;
|
||||
} else if (m_iMove == SS_INSTANTANEOUS) {
|
||||
f.SetOrigin(GetOrigin());
|
||||
f.DropToFloor();
|
||||
NSAIScript_Log("\tType: SS_INSTANTANEOUS (%i)", m_iMove);
|
||||
} else if (m_iMove == SS_TURNTOFACE) {
|
||||
NSAIScript_Log("\tType: SS_TURNTOFACE (%i)", m_iMove);
|
||||
|
@ -294,7 +298,6 @@ scripted_sequence::RunOnEntity(entity targ)
|
|||
}
|
||||
|
||||
duration = frameduration(f.modelindex, f.m_flSequenceEnd);
|
||||
f.SetNextThink(duration);
|
||||
NSAIScript_Log(
|
||||
"\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)",
|
||||
m_strActionAnim,
|
||||
|
@ -303,7 +306,7 @@ scripted_sequence::RunOnEntity(entity targ)
|
|||
f.m_flSequenceEnd
|
||||
);
|
||||
} else {
|
||||
f.SetNextThink(0.0f);
|
||||
duration = 0.0f;
|
||||
NSAIScript_Log(
|
||||
"\t^1WARNING: %s skipping animation on script type %i",
|
||||
f.targetname,
|
||||
|
@ -314,11 +317,11 @@ scripted_sequence::RunOnEntity(entity targ)
|
|||
f.m_iSequenceState = SEQUENCESTATE_ENDING;
|
||||
|
||||
if (HasSpawnFlags(SSFL_LEAVECORPSE))
|
||||
f.SetThink(NSMonster::FreeStateDead);
|
||||
f.ScheduleThink(f.FreeStateDead, duration);
|
||||
else if (HasSpawnFlags(SSFL_NOSCRIPTMOVE) || m_iMove == SS_NO)
|
||||
f.SetThink(NSMonster::FreeState);
|
||||
f.ScheduleThink(f.FreeState, duration);
|
||||
else
|
||||
f.SetThink(NSMonster::FreeStateMoved);
|
||||
f.ScheduleThink(f.FreeStateMoved, duration);
|
||||
|
||||
NSAIScript_Log("\tEnding: %f", f.GetNextThinkTime());
|
||||
|
||||
|
|
|
@ -474,6 +474,7 @@ private:
|
|||
vector m_vecSequenceAngle;
|
||||
int m_iSequenceFlags;
|
||||
movementState_t m_iMoveState;
|
||||
string m_strSequenceKillTarget;
|
||||
|
||||
int m_iTriggerCondition;
|
||||
string m_strTriggerTarget;
|
||||
|
|
|
@ -41,6 +41,7 @@ NSMonster::NSMonster(void)
|
|||
m_flSequenceSpeed = 0.0f;
|
||||
m_vecSequenceAngle = g_vec_null;
|
||||
m_iSequenceFlags = 0i;
|
||||
m_strSequenceKillTarget = __NULL__;
|
||||
m_iMoveState = 0i;
|
||||
m_iTriggerCondition = 0i;
|
||||
m_strTriggerTarget = __NULL__;
|
||||
|
@ -140,6 +141,7 @@ NSMonster::Save(float handle)
|
|||
SaveFloat(handle, "m_flSequenceSpeed", m_flSequenceSpeed);
|
||||
SaveVector(handle, "m_vecSequenceAngle", m_vecSequenceAngle);
|
||||
SaveInt(handle, "m_iSequenceFlags", m_iSequenceFlags);
|
||||
SaveString(handle, "m_strSequenceKillTarget", m_strSequenceKillTarget);
|
||||
SaveFloat(handle, "m_iMoveState", m_iMoveState);
|
||||
SaveInt(handle, "m_iTriggerCondition", m_iTriggerCondition);
|
||||
SaveString(handle, "m_strTriggerTarget", m_strTriggerTarget);
|
||||
|
@ -264,6 +266,9 @@ NSMonster::Restore(string strKey, string strValue)
|
|||
case "m_iSequenceFlags":
|
||||
m_iSequenceFlags = ReadInt(strValue);
|
||||
break;
|
||||
case "m_strSequenceKillTarget":
|
||||
m_strSequenceKillTarget = ReadString(strValue);
|
||||
break;
|
||||
case "m_iMoveState":
|
||||
m_iMoveState = ReadFloat(strValue);
|
||||
break;
|
||||
|
@ -1145,6 +1150,25 @@ NSMonster::FreeState(void)
|
|||
m_iSequenceState = SEQUENCESTATE_NONE;
|
||||
m_iSequenceFlags = 0;
|
||||
|
||||
/* scripted_sequence killtarget:
|
||||
We want to call this first. you may wonder why.
|
||||
Because a monster may call a scripted_sequence here
|
||||
which THEN sets its killtarget to be monster that triggers
|
||||
the scripted_sequence.
|
||||
If that happens, the monster will then killtarget itself right after. */
|
||||
if (m_strSequenceKillTarget != "") {
|
||||
NSEntity findKT = (NSEntity)find(world, ::targetname, m_strSequenceKillTarget);
|
||||
|
||||
if (findKT) {
|
||||
NSMonster_Log("^2%s::^3FreeState^7: Killing %S", classname, m_strSequenceKillTarget);
|
||||
findKT.Destroy();
|
||||
} else {
|
||||
error("Could not remove scripted killtarget!\n");
|
||||
}
|
||||
|
||||
m_strSequenceKillTarget = __NULL__;
|
||||
}
|
||||
|
||||
if (m_ssLast) {
|
||||
scripted_sequence seq = (scripted_sequence)m_ssLast;
|
||||
seq.m_iValue = TRUE;
|
||||
|
|
Loading…
Reference in a new issue