| 994 | // Scripted waypoint |
| 995 | |
| 996 | static 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 |
nothing calls this directly
no test coverage detected