mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-05 02:00:34 +03:00
Merge pull request #182 from Petercov/mapbase-feature/dynint-loader-enhancement
NPCs can load dynamic interactions from all animation MDLs
This commit is contained in:
commit
d525ca02b8
@ -14733,9 +14733,13 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
||||
return;
|
||||
|
||||
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?
|
||||
KeyValues *pkvInteractions = modelKeyValues->FindKey("dynamic_interactions");
|
||||
KeyValues* pkvInteractions = pkvModelBlock->FindKey("dynamic_interactions");
|
||||
if (pkvInteractions)
|
||||
{
|
||||
KeyValues* pkvNode = pkvInteractions->GetFirstSubKey();
|
||||
@ -14744,7 +14748,13 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
||||
ScriptedNPCInteraction_t sInteraction;
|
||||
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.
|
||||
// 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;
|
||||
UTIL_StringToVector(sInteraction.vecRelativeVelocity.Base(), szValue);
|
||||
}
|
||||
#ifdef MAPBASE
|
||||
else if (!Q_strncmp(szName, "end_position", 12))
|
||||
{
|
||||
sInteraction.iFlags |= SCNPC_FLAG_TEST_END_POSITION;
|
||||
UTIL_StringToVector(sInteraction.vecRelativeEndPos.Base(), szValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (!Q_strncmp(szName, "entry_sequence", 14))
|
||||
sInteraction.sPhases[SNPCINT_ENTRY].iszSequence = AllocPooledString(szValue);
|
||||
@ -14908,7 +14916,29 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
||||
szCriteria += 1;
|
||||
sInteraction.MiscCriteria = AllocPooledString(szCriteria);
|
||||
}
|
||||
|
||||
|
||||
// Add it to the list
|
||||
AddScriptedNPCInteraction(&sInteraction);
|
||||
iszUsedNames.AddToTail(sInteraction.iszInteractionName);
|
||||
|
||||
// Move to next interaction
|
||||
pkvNode = pkvNode->GetNextKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
#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
|
||||
const char* pszTrigger = pkvNode->GetString("trigger", NULL);
|
||||
if (pszTrigger)
|
||||
@ -15058,7 +15088,6 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
||||
sInteraction.iFlags |= SCNPC_FLAG_NEEDS_WEAPON_THEM;
|
||||
sInteraction.iszTheirWeapon = AllocPooledString(pszWeaponName);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add it to the list
|
||||
AddScriptedNPCInteraction(&sInteraction);
|
||||
@ -15067,6 +15096,8 @@ void CAI_BaseNPC::ParseScriptedNPCInteractions( void )
|
||||
pkvNode = pkvNode->GetNextKey();
|
||||
}
|
||||
}
|
||||
#endif // MAPBASE
|
||||
|
||||
}
|
||||
|
||||
modelKeyValues->deleteThis();
|
||||
|
Loading…
x
Reference in New Issue
Block a user