mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-26 13:41:11 +03:00
NPCs can load dynamic interactions from all animation MDLs
This commit is contained in:
parent
f8a8d49be7
commit
f9d88b15ac
@ -14733,9 +14733,13 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (modelKeyValues->LoadFromBuffer(modelinfo->GetModelName(GetModel()), buf))
|
if (modelKeyValues->LoadFromBuffer(modelinfo->GetModelName(GetModel()), buf))
|
||||||
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
CUtlVector<string_t> iszUsedNames;
|
||||||
|
for (KeyValues* pkvModelBlock = modelKeyValues; pkvModelBlock != nullptr; pkvModelBlock = pkvModelBlock->GetNextKey())
|
||||||
{
|
{
|
||||||
// Do we have a dynamic interactions section?
|
// Do we have a dynamic interactions section?
|
||||||
KeyValues *pkvInteractions = modelKeyValues->FindKey("dynamic_interactions");
|
KeyValues* pkvInteractions = pkvModelBlock->FindKey("dynamic_interactions");
|
||||||
if (pkvInteractions)
|
if (pkvInteractions)
|
||||||
{
|
{
|
||||||
KeyValues* pkvNode = pkvInteractions->GetFirstSubKey();
|
KeyValues* pkvNode = pkvInteractions->GetFirstSubKey();
|
||||||
@ -14744,7 +14748,13 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
|||||||
ScriptedNPCInteraction_t sInteraction;
|
ScriptedNPCInteraction_t sInteraction;
|
||||||
sInteraction.iszInteractionName = AllocPooledString(pkvNode->GetName());
|
sInteraction.iszInteractionName = AllocPooledString(pkvNode->GetName());
|
||||||
|
|
||||||
#ifdef MAPBASE
|
if (iszUsedNames.Find(sInteraction.iszInteractionName) != iszUsedNames.InvalidIndex())
|
||||||
|
{
|
||||||
|
DevMsg(2, "Scripted interaction %s already defined on %s\n", pkvNode->GetName(), GetClassname());
|
||||||
|
pkvNode = pkvNode->GetNextKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// The method for parsing dynamic interactions has been reworked.
|
// The method for parsing dynamic interactions has been reworked.
|
||||||
// Unknown values are now stored as response contexts to test against response criteria.
|
// Unknown values are now stored as response contexts to test against response criteria.
|
||||||
|
|
||||||
@ -14824,13 +14834,11 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
|||||||
sInteraction.iFlags |= SCNPC_FLAG_TEST_OTHER_VELOCITY;
|
sInteraction.iFlags |= SCNPC_FLAG_TEST_OTHER_VELOCITY;
|
||||||
UTIL_StringToVector(sInteraction.vecRelativeVelocity.Base(), szValue);
|
UTIL_StringToVector(sInteraction.vecRelativeVelocity.Base(), szValue);
|
||||||
}
|
}
|
||||||
#ifdef MAPBASE
|
|
||||||
else if (!Q_strncmp(szName, "end_position", 12))
|
else if (!Q_strncmp(szName, "end_position", 12))
|
||||||
{
|
{
|
||||||
sInteraction.iFlags |= SCNPC_FLAG_TEST_END_POSITION;
|
sInteraction.iFlags |= SCNPC_FLAG_TEST_END_POSITION;
|
||||||
UTIL_StringToVector(sInteraction.vecRelativeEndPos.Base(), szValue);
|
UTIL_StringToVector(sInteraction.vecRelativeEndPos.Base(), szValue);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
else if (!Q_strncmp(szName, "entry_sequence", 14))
|
else if (!Q_strncmp(szName, "entry_sequence", 14))
|
||||||
sInteraction.sPhases[SNPCINT_ENTRY].iszSequence = AllocPooledString(szValue);
|
sInteraction.sPhases[SNPCINT_ENTRY].iszSequence = AllocPooledString(szValue);
|
||||||
@ -14908,7 +14916,29 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
|||||||
szCriteria += 1;
|
szCriteria += 1;
|
||||||
sInteraction.MiscCriteria = AllocPooledString(szCriteria);
|
sInteraction.MiscCriteria = AllocPooledString(szCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add it to the list
|
||||||
|
AddScriptedNPCInteraction(&sInteraction);
|
||||||
|
iszUsedNames.AddToTail(sInteraction.iszInteractionName);
|
||||||
|
|
||||||
|
// Move to next interaction
|
||||||
|
pkvNode = pkvNode->GetNextKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
// Do we have a dynamic interactions section?
|
||||||
|
KeyValues* pkvInteractions = modelKeyValues->FindKey("dynamic_interactions");
|
||||||
|
if (pkvInteractions)
|
||||||
|
{
|
||||||
|
KeyValues* pkvNode = pkvInteractions->GetFirstSubKey();
|
||||||
|
while (pkvNode)
|
||||||
|
{
|
||||||
|
ScriptedNPCInteraction_t sInteraction;
|
||||||
|
sInteraction.iszInteractionName = AllocPooledString(pkvNode->GetName());
|
||||||
|
|
||||||
|
|
||||||
// Trigger method
|
// Trigger method
|
||||||
const char* pszTrigger = pkvNode->GetString("trigger", NULL);
|
const char* pszTrigger = pkvNode->GetString("trigger", NULL);
|
||||||
if (pszTrigger)
|
if (pszTrigger)
|
||||||
@ -15058,7 +15088,6 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
|||||||
sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM;
|
sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM;
|
||||||
sInteraction.iszTheirWeapon = AllocPooledString(pszWeaponName);
|
sInteraction.iszTheirWeapon = AllocPooledString(pszWeaponName);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Add it to the list
|
// Add it to the list
|
||||||
AddScriptedNPCInteraction(&sInteraction);
|
AddScriptedNPCInteraction(&sInteraction);
|
||||||
@ -15067,6 +15096,8 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
|||||||
pkvNode = pkvNode->GetNextKey();
|
pkvNode = pkvNode->GetNextKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // MAPBASE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modelKeyValues->deleteThis();
|
modelKeyValues->deleteThis();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user