MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ArcadeScripted

Function ArcadeScripted

engine/Poseidon/AI/AIArcade.cpp:996–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

994// Scripted waypoint
995
996static void ArcadeScripted(AIGroupContext* context)
997{
998 STATE_PREFIX
999
1000 int& index = context->_fsm->Var(0);
1001 ArcadeWaypointInfo& wInfo = group->GetWaypoint(index);
1002
1003 GameArrayType position;
1004 position.Resize(3);
1005 position[0] = wInfo.position.X();
1006 position[1] = wInfo.position.Z();
1007 position[2] = 0.0f;
1008
1009 EntityAI* target = nullptr;
1010 if (wInfo.id >= 0 && wInfo.id < vehiclesMap.Size())
1011 {
1012 target = vehiclesMap[wInfo.id];
1013 }
1014 else if (wInfo.idStatic >= 0)
1015 {
1016 target = dyn_cast<EntityAI>(GLOB_LAND->FindObject(wInfo.idStatic));
1017 }
1018
1019 RString nameScript = wInfo.script;
1020 RString nameArgs;
1021 const char* space = strchr(nameScript, ' ');
1022 if (space)
1023 {
1024 nameArgs = space + 1;
1025 nameScript = nameScript.Substring(0, space - nameScript);
1026 }
1027
1028 GameArrayType arguments;
1029 arguments.Add(GameValueExt(group));
1030 arguments.Add(GameValue(position));
1031 arguments.Add(GameValueExt(target));
1032
1033 if (nameScript.GetLength() > 0)
1034 {
1035 GameState* gstate = GWorld->GetGameState();
1036 GameValue value = gstate->Evaluate(nameArgs);
1037 if (gstate->GetLastError() == EvalOK)
1038 {
1039 if (value.GetType() == GameArray)
1040 {
1041 GameArrayType& array = value;
1042 for (int i = 0; i < array.Size(); i++)
1043 {
1044 arguments.Add(array[i]);
1045 }
1046 }
1047 else
1048 {
1049 arguments.Add(value);
1050 }
1051 }
1052 }
1053

Callers

nothing calls this directly

Calls 15

GameValueExtClass · 0.85
VarMethod · 0.80
SubstringMethod · 0.80
GetLastErrorMethod · 0.80
SetScriptMethod · 0.80
GameValueClass · 0.70
ResizeMethod · 0.45
XMethod · 0.45
ZMethod · 0.45
SizeMethod · 0.45
FindObjectMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected