diff -urN sourceold/AntiSpawnKill/AntiSpawnKill.vcxproj source/AntiSpawnKill/AntiSpawnKill.vcxproj --- sourceold/AntiSpawnKill/AntiSpawnKill.vcxproj 2020-09-26 09:00:03.253003000 +1000 +++ source/AntiSpawnKill/AntiSpawnKill.vcxproj 2022-02-13 10:20:09.761885800 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/CTF/ctf.vcxproj source/CTF/ctf.vcxproj --- sourceold/CTF/ctf.vcxproj 2020-09-26 09:00:03.254025700 +1000 +++ source/CTF/ctf.vcxproj 2022-02-13 10:20:09.763083700 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/CharacterRefund/CharacterRefund.vcxproj source/CharacterRefund/CharacterRefund.vcxproj --- sourceold/CharacterRefund/CharacterRefund.vcxproj 2020-09-26 09:00:03.254025700 +1000 +++ source/CharacterRefund/CharacterRefund.vcxproj 2022-02-13 10:20:09.764081700 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/ExtraConsoleCommands/ExtraConsoleCommands.cpp source/ExtraConsoleCommands/ExtraConsoleCommands.cpp --- sourceold/ExtraConsoleCommands/ExtraConsoleCommands.cpp 2018-10-27 22:04:54.453400000 +1000 +++ source/ExtraConsoleCommands/ExtraConsoleCommands.cpp 2022-02-13 10:20:09.765078500 +1000 @@ -36,50 +36,6 @@ } -class CommandGIVECREDITS : - public ConsoleFunctionClass -{ -public: - const char* Get_Name() - { - return "GiveCredits"; - } - const char* Get_Help() - { - return "GIVECREDITS - Gives a client the specified amount of credits (can only be a positive amount)."; - } - void Activate(const char* argumentsString) - { - CommandLineParser arguments(argumentsString); - const char* clientIdentifier = arguments.getString(); - - if (!clientIdentifier || clientIdentifier[0] == '\0') - Console_Output("Please enter a client identifier."); - else - { - const int clientId = getClientIdByIdentifier(clientIdentifier); - if (!isClientId(clientId)) - { - Console_Output("Please enter a valid client identifier."); - } - else - { - int amount = arguments.getInt(); - if(!amount) - { - Console_Output("Please enter an amount of credits (int) for the client to receive."); - } - else - { - Commands->Give_Money(Get_GameObj(clientId), (float)amount, false); - Console_Output("Credits have been given."); - } - } - } - } -}; - - class CommandTAKECREDITS : public ConsoleFunctionClass @@ -177,96 +133,6 @@ -class CommandFLY : - public ConsoleFunctionClass -{ -public: - const char* Get_Name() - { - return "Fly"; - } - const char* Get_Help() - { - return "Fly - Toggles on/off whether a player can fly or not."; - } - void Activate(const char* argumentsString) - { - CommandLineParser arguments(argumentsString); - const char* clientIdentifier = arguments.getString(); - - if (!clientIdentifier || clientIdentifier[0] == '\0') - Console_Output("Please enter a client identifier."); - else - { - const int clientId = getClientIdByIdentifier(clientIdentifier); - if (!isClientId(clientId)) - { - Console_Output("Please enter a valid client identifier."); - } - else - { - if(Get_Fly_Mode(Get_GameObj(clientId))) - { - Toggle_Fly_Mode(Get_GameObj(clientId)); - Console_Output("Player can no longer fly.\n"); - } - else - { - Toggle_Fly_Mode(Get_GameObj(clientId)); - Console_Output("Player can now fly.\n"); - } - } - } - } -}; - - - -class CommandGIVEPOINTS : - public ConsoleFunctionClass -{ -public: - const char* Get_Name() - { - return "GivePoints"; - } - const char* Get_Help() - { - return "GIVEPOINTS - Gives a client the specified amount of points (can only be a positive amount)."; - } - void Activate(const char* argumentsString) - { - CommandLineParser arguments(argumentsString); - const char* clientIdentifier = arguments.getString(); - - if (!clientIdentifier || clientIdentifier[0] == '\0') - Console_Output("Please enter a client identifier."); - else - { - const int clientId = getClientIdByIdentifier(clientIdentifier); - if (!isClientId(clientId)) - { - Console_Output("Please enter a valid client identifier."); - } - else - { - int amount = arguments.getInt(); - if(!amount) - { - Console_Output("Please enter an amount of points (int) for the client to receive."); - } - else - { - Commands->Give_Points(Get_GameObj(clientId), (float)amount, false); - Console_Output("Points have been given."); - } - } - } - } -}; - - - class CommandTAKEPOINTS : public ConsoleFunctionClass { @@ -358,51 +224,6 @@ -class CommandCHANGECHAR : - public ConsoleFunctionClass -{ -public: - const char* Get_Name() - { - return "ChangeChar"; - } - const char* Get_Help() - { - return "CHANGECHAR - Changes the player's character to the one specified."; - } - void Activate(const char* argumentsString) - { - CommandLineParser arguments(argumentsString); - const char* clientIdentifier = arguments.getString(); - - if (!clientIdentifier || clientIdentifier[0] == '\0') - Console_Output("Please enter a client identifier."); - else - { - const int clientId = getClientIdByIdentifier(clientIdentifier); - if (!isClientId(clientId)) - { - Console_Output("Please enter a valid client identifier."); - } - else - { - const char* character = arguments.getString(); - if (!character || character[0] == '\0') - { - Console_Output("Please enter a character string to change the player into."); - } - else - { - Change_Character(Get_GameObj(clientId), character); - Console_Output("Player has been changed."); - } - } - } - } -}; - - - class CommandATTACHSCRIPT : public ConsoleFunctionClass { @@ -613,13 +434,10 @@ public: EXTRACONSOLECOMMANDS() { - ConsoleFunctionList.Add(new CommandGIVECREDITS); ConsoleFunctionList.Add(new CommandTAKECREDITS); ConsoleFunctionList.Add(new CommandKILL); - ConsoleFunctionList.Add(new CommandFLY); - ConsoleFunctionList.Add(new CommandGIVEPOINTS); + ConsoleFunctionList.Add(new CommandTAKEPOINTS); ConsoleFunctionList.Add(new CommandGIVEPOW); - ConsoleFunctionList.Add(new CommandCHANGECHAR); ConsoleFunctionList.Add(new CommandATTACHSCRIPT); ConsoleFunctionList.Add(new CommandUNATTACHSCRIPT); ConsoleFunctionList.Add(new CommandFREEZEPLAYER); @@ -632,14 +450,10 @@ ~EXTRACONSOLECOMMANDS() { Console_Output("Un-loading Extra Console Commands Plugin; written by Reborn from MP-Gaming.COM\n"); - Delete_Console_Function("GiveCredits"); Delete_Console_Function("TakeCredits"); Delete_Console_Function("Kill"); - Delete_Console_Function("Fly"); - Delete_Console_Function("GivePoints"); Delete_Console_Function("TakePoints"); Delete_Console_Function("GivePow"); - Delete_Console_Function("ChangeChar"); Delete_Console_Function("AttachScript"); Delete_Console_Function("UnAttachScript"); Delete_Console_Function("FreezePlayer"); diff -urN sourceold/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj source/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj --- sourceold/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj 2020-09-26 09:00:03.255035400 +1000 +++ source/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj 2022-02-13 10:20:09.766101100 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/FirstBlood/FirstBlood.vcxproj source/FirstBlood/FirstBlood.vcxproj --- sourceold/FirstBlood/FirstBlood.vcxproj 2020-09-26 09:00:03.255035400 +1000 +++ source/FirstBlood/FirstBlood.vcxproj 2022-02-13 10:20:09.767097600 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/MemoryManager/MemoryManager.vcxproj source/MemoryManager/MemoryManager.vcxproj --- sourceold/MemoryManager/MemoryManager.vcxproj 2020-09-26 09:00:03.260402700 +1000 +++ source/MemoryManager/MemoryManager.vcxproj 2022-02-13 10:20:09.767097600 +1000 @@ -111,7 +111,6 @@ MultiThreadedDebugDLL - AssemblyAndSourceCode Level4 ProgramDatabase true diff -urN sourceold/Mute/Mute.vcxproj source/Mute/Mute.vcxproj --- sourceold/Mute/Mute.vcxproj 2020-09-26 09:00:03.260402700 +1000 +++ source/Mute/Mute.vcxproj 2022-02-13 10:20:09.768070800 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/NoPoints/NoPoints.vcxproj source/NoPoints/NoPoints.vcxproj --- sourceold/NoPoints/NoPoints.vcxproj 2020-09-26 09:00:03.261400000 +1000 +++ source/NoPoints/NoPoints.vcxproj 2022-02-13 10:20:09.769068100 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/PointsDistribution/PointsDistribution.vcxproj source/PointsDistribution/PointsDistribution.vcxproj --- sourceold/PointsDistribution/PointsDistribution.vcxproj 2020-09-26 09:00:03.262426400 +1000 +++ source/PointsDistribution/PointsDistribution.vcxproj 2022-02-13 10:20:09.772463500 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/Spectate/General.cpp source/Spectate/General.cpp --- sourceold/Spectate/General.cpp 2018-11-17 10:23:56.398600000 +1000 +++ source/Spectate/General.cpp 1970-01-01 10:00:00.000000000 +1000 @@ -1,12 +0,0 @@ -/* Renegade Scripts.dll - Copyright 2013 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ -#include "general.h" diff -urN sourceold/Spectate/General.h source/Spectate/General.h --- sourceold/Spectate/General.h 2018-11-17 10:23:56.399600000 +1000 +++ source/Spectate/General.h 1970-01-01 10:00:00.000000000 +1000 @@ -1,18 +0,0 @@ -/* Renegade Scripts.dll - Copyright 2013 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ -#ifndef SPECTATE_INCLUDE__GENERAL_H -#define SPECTATE_INCLUDE__GENERAL_H - -#include "Defines.h" -#include "Standard.h" - -#endif diff -urN sourceold/Spectate/Spectate.cpp source/Spectate/Spectate.cpp --- sourceold/Spectate/Spectate.cpp 2018-10-27 22:04:54.656400000 +1000 +++ source/Spectate/Spectate.cpp 1970-01-01 10:00:00.000000000 +1000 @@ -1,188 +0,0 @@ -/* Renegade Scripts.dll - Copyright 2013 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ -#include "General.h" -#include "Spectate.h" -#include "gmgame.h" -#include "Iterator.h" -#include "CommandLineParser.h" -#include "engine_tt.h" -#include "SoldierGameObj.h" -#include "VehicleGameObj.h" -#include "WeaponBagClass.h" -#include "engine_weap.h" -#include "engine_obj2.h" - -static int getClientIdByIdentifier(const char* clientIdentifier) -{ - TT_ASSERT(clientIdentifier); - const cPlayer* player = Find_Player(atoi(clientIdentifier)); - int result; - if (player) - result = player->Get_Id(); - else - result = -1; - return result; -} - -static bool isClientId(const int id) -{ - return id > 0 && id < 128 && Find_Player(id); -} - - -class CommandSPECTATE : - public ConsoleFunctionClass -{ -public: - const char* Get_Name() - { - return "Spectate"; - } - const char* Get_Help() - { - return "SPECTATE - Allows a client to enter spectate mode."; - } - void Activate(const char* argumentsString) - { - CommandLineParser arguments(argumentsString); - const char* clientIdentifier = arguments.getString(); - - if (!clientIdentifier || clientIdentifier[0] == '\0') - Console_Output("Please enter a client identifier."); - else - { - const int clientId = getClientIdByIdentifier(clientIdentifier); - if (!isClientId(clientId)) - { - Console_Output("Please enter a valid client identifier."); - } - else - { - Spectate(Get_GameObj(clientId),clientId); - } - } - } -}; - -class CommandSPECTATESPEED : - public ConsoleFunctionClass -{ -public: - const char* Get_Name() - { - return "SpectateSpeed"; - } - const char* Get_Help() - { - return "SPECTATESPEED - Sets the max speed of a spectating player"; - } - void Activate(const char* argumentsString) - { - CommandLineParser arguments(argumentsString); - const char* clientIdentifier = arguments.getString(); - - if (!clientIdentifier || clientIdentifier[0] == '\0') - Console_Output("Please enter a client identifier."); - else - { - const int clientId = getClientIdByIdentifier(clientIdentifier); - if (!isClientId(clientId)) - { - Console_Output("Please enter a valid client identifier."); - } - else - { - double speed = arguments.getDouble(); - GameObject *obj = Get_GameObj(clientId); - int team = Get_Team(Get_Player_ID(obj)); - if(team == -4) - { - obj->As_SoldierGameObj()->Set_Max_Speed((float)speed); - } - } - } - } -}; - -class SPECTATE : public Plugin -{ -public: - SPECTATE() - { - ConsoleFunctionList.Add(new CommandSPECTATE); - ConsoleFunctionList.Add(new CommandSPECTATESPEED); - Sort_Function_List(); - Verbose_Help_File(); - Console_Output("Loading Spectate Plugin; written by Reborn from MP-Gaming.COM\n"); - } - ~SPECTATE() - { - Console_Output("Un-loading Spectate Plugin; written by Reborn from MP-Gaming.COM\n"); - Delete_Console_Function("Spectate"); - Delete_Console_Function("SpectateSpeed"); - } - -}; - -SPECTATE spectate; -void Spectate(GameObject *obj,int id) -{ - SoldierGameObj *soldier = obj->As_SoldierGameObj(); - int team = soldier->Get_Player_Type(); - if(team != -4) - { - if (soldier->Get_Vehicle()) - { - Console_Output("Can't enable spectate mode when in a vehicle\n"); - return; - } - if (!Get_Fly_Mode(soldier)) - { - Toggle_Fly_Mode(soldier); - } - soldier->Set_Player_Type(-4); - Commands->Set_Model(soldier,"NULL"); - Commands->Clear_Weapons(soldier); - Commands->Disable_All_Collisions(soldier); - Commands->Set_Is_Visible(soldier,false); - Commands->Set_Is_Rendered(soldier,false); - Commands->Set_Shield_Type(soldier,"Blamo"); - Disarm_All_C4_Beacons(id); - for (SLNode* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next()) - { - cPlayer *p = PlayerIter->Data(); - if (!p->Is_Active()) continue; - if (p->Get_Id() == id) - { - Update_Network_Object_Player(obj,p->Get_Id()); - } - else - { - bool pending = obj->Is_Delete_Pending(); - obj->Set_Is_Delete_Pending(true); - Update_Network_Object_Player(obj,p->Get_Id()); - obj->Set_Is_Delete_Pending(pending); - } - } - soldier->Clear_Object_Dirty_Bits(); - } - else - { - obj->Set_Delete_Pending(); - } -} - - -extern "C" __declspec(dllexport) Plugin* Plugin_Init() -{ - return &spectate; -} diff -urN sourceold/Spectate/Spectate.h source/Spectate/Spectate.h --- sourceold/Spectate/Spectate.h 2018-11-17 10:23:56.400600000 +1000 +++ source/Spectate/Spectate.h 1970-01-01 10:00:00.000000000 +1000 @@ -1,16 +0,0 @@ -/* Renegade Scripts.dll - Copyright 2013 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ -#pragma once - -#include "gmplugin.h" - -void Spectate(GameObject *obj,int id); diff -urN sourceold/Spectate/Spectate.vcxproj source/Spectate/Spectate.vcxproj --- sourceold/Spectate/Spectate.vcxproj 2020-09-26 09:00:03.263394900 +1000 +++ source/Spectate/Spectate.vcxproj 1970-01-01 10:00:00.000000000 +1000 @@ -1,245 +0,0 @@ - - - - - Debug SSGM - Win32 - - - Release SSGM - Win32 - - - - {DD84D0B5-C445-481B-80DA-367D414E41BA} - Win32Proj - exampleplugin - - - - DynamicLibrary - MultiByte - false - v110 - - - DynamicLibrary - MultiByte - true - v110 - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)temp\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)temp\$(ProjectName)\$(Configuration)\ - true - AllRules.ruleset - - - AllRules.ruleset - - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)scripts.tlb - - - - - MaxSpeed - AnySuitable - true - Speed - true - .;..\MemoryManager;..\scripts;%(AdditionalIncludeDirectories) - MEMORY_MANAGER;NDEBUG;SPECTATE_EXPORTS;WIN32;_CRT_SECURE_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_SECURE_SCL=0;_WINDOWS;SSGMPLUGIN;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - Precise - false - Use - General.h - $(IntDir)$(TargetName).$(Configuration).pch - Level4 - true - ProgramDatabase - true - false - StreamingSIMDExtensions2 - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c09 - - - ws2_32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetName)$(TargetExt) - %(IgnoreSpecificDefaultLibraries) - true - true - $(TargetDir)$(TargetName).map - Windows - true - true - true - 0x11000000 - MachineX86 - ..\bin\release SSGM;..\bin\release - false - 6.01 - - - if defined RenPath ( -del "%RenPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -move "%RenPath%\$(TargetFileName)" "%RenPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -del "%RenPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -) - -if defined RenServerPath ( -del "%RenServerPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -move "%RenServerPath%\$(TargetFileName)" "%RenServerPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -del "%RenServerPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -) - -verify >NUL - -if defined RenPath ( -copy "$(TargetPath)" "%RenPath%\$(TargetFileName)" -) -if defined RenServerPath ( -copy "$(TargetPath)" "%RenServerPath%\$(TargetFileName)" -) - - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)scripts.tlb - - - - - Disabled - true - .;..\MemoryManager;..\scripts;%(AdditionalIncludeDirectories) - D3D_DEBUG_INFO;DEBUG;MEMORY_MANAGER;SPECTATE_EXPORTS;WIN32;_CRT_SECURE_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_WINDOWS;SSGMPLUGIN;%(PreprocessorDefinitions) - true - false - - - MultiThreadedDebugDLL - false - true - StreamingSIMDExtensions2 - Precise - true - Use - General.h - $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode - Level4 - true - EditAndContinue - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c09 - - - ws2_32.lib;%(AdditionalDependencies) - $(OutDir)$(TargetName)$(TargetExt) - %(IgnoreSpecificDefaultLibraries) - true - true - $(TargetDir)$(TargetName).map - Windows - false - false - 0x11000000 - MachineX86 - ..\bin\debug SSGM;..\bin\debug - false - 6.01 - - - if defined RenPath ( -del "%RenPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -move "%RenPath%\$(TargetFileName)" "%RenPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -del "%RenPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -) - -if defined RenServerPath ( -del "%RenServerPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -move "%RenServerPath%\$(TargetFileName)" "%RenServerPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -del "%RenServerPath%\$(TargetFileName).removeme" 1>NUL 2>NUL -) - -verify >NUL - -if defined RenPath ( -copy "$(TargetPath)" "%RenPath%\$(TargetFileName)" -) -if defined RenServerPath ( -copy "$(TargetPath)" "%RenServerPath%\$(TargetFileName)" -) - - - - - - - Create - Create - Create - Create - - - - - - - - - {2fef1c76-9e4a-4921-b2d3-e536da918810} - false - - - {6636E311-E860-4F52-9D23-FE38E38D6020} - false - - - {9B549C98-0BF4-4092-AE2A-AD7F780F8405} - false - - - - - - \ No newline at end of file diff -urN sourceold/Spectate/Spectate.vcxproj.filters source/Spectate/Spectate.vcxproj.filters --- sourceold/Spectate/Spectate.vcxproj.filters 2018-10-27 22:04:54.658400000 +1000 +++ source/Spectate/Spectate.vcxproj.filters 1970-01-01 10:00:00.000000000 +1000 @@ -1,33 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - \ No newline at end of file diff -urN sourceold/SuddenDeath/SuddenDeath.vcxproj source/SuddenDeath/SuddenDeath.vcxproj --- sourceold/SuddenDeath/SuddenDeath.vcxproj 2020-09-26 09:00:03.263394900 +1000 +++ source/SuddenDeath/SuddenDeath.vcxproj 2022-02-13 10:20:09.773267200 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/bansystem/bansystem.vcxproj source/bansystem/bansystem.vcxproj --- sourceold/bansystem/bansystem.vcxproj 2020-09-26 09:00:03.268381300 +1000 +++ source/bansystem/bansystem.vcxproj 2022-02-13 10:20:09.774984600 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/crates/crates.vcxproj source/crates/crates.vcxproj --- sourceold/crates/crates.vcxproj 2020-09-26 09:00:03.269381100 +1000 +++ source/crates/crates.vcxproj 2022-02-13 10:20:09.776352800 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/example-plugin/example-plugin.vcxproj source/example-plugin/example-plugin.vcxproj --- sourceold/example-plugin/example-plugin.vcxproj 2020-09-26 09:00:03.271374200 +1000 +++ source/example-plugin/example-plugin.vcxproj 2022-02-13 10:20:09.841869300 +1000 @@ -73,7 +73,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/makemix/Program.cs source/makemix/Program.cs --- sourceold/makemix/Program.cs 2016-10-31 07:17:12.284013500 +1000 +++ source/makemix/Program.cs 2022-02-13 10:20:09.845846600 +1000 @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -171,7 +172,7 @@ var entry = new IndexEntry(); entry.path = path; entry.name = NormalizeFilename(Path.GetFileName(path)); - entry.id = CRC.Compute(entry.name.ToUpper()); + entry.id = CRC.Compute(entry.name.ToUpper(CultureInfo.InvariantCulture)); if (used_ids.Contains(entry.id)) throw new ArgumentOutOfRangeException(); used_ids.Add(entry.id); diff -urN sourceold/randomstartingcredits/RandomStartingCredits.vcxproj source/randomstartingcredits/RandomStartingCredits.vcxproj --- sourceold/randomstartingcredits/RandomStartingCredits.vcxproj 2020-09-26 09:00:03.274365300 +1000 +++ source/randomstartingcredits/RandomStartingCredits.vcxproj 2022-02-13 10:20:09.848385000 +1000 @@ -163,7 +163,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/scripts/DBIKScripts.cpp source/scripts/DBIKScripts.cpp --- sourceold/scripts/DBIKScripts.cpp 2021-07-27 14:44:22.785005900 +1000 +++ source/scripts/DBIKScripts.cpp 2022-02-13 10:20:09.850412400 +1000 @@ -1931,6 +1931,15 @@ void DB_Force_Fire::Created(GameObject *obj) { + float startDelay = Get_Float_Parameter("StartDelay"); + if(!startDelay) + Start_Attack(obj); + else + Commands->Start_Timer(obj,this,startDelay,2); +} + +void DB_Force_Fire::Start_Attack(GameObject *obj) +{ if(obj && obj->As_SmartGameObj()) { ActionParamsStruct action; @@ -1951,6 +1960,8 @@ { if(number == 1) Commands->Action_Reset(obj,101); + else if(number == 2) + Start_Attack(obj); } void DB_Force_Fire::Detach(GameObject *obj) @@ -1961,4 +1972,4 @@ } } -ScriptRegistrantDB_Force_Fire_Registrant("DB_Force_Fire","UseSecondaryFire=0:int,ResetTime=0:float"); \ No newline at end of file +ScriptRegistrantDB_Force_Fire_Registrant("DB_Force_Fire","UseSecondaryFire=0:int,ResetTime=0:float,StartDelay=0:float"); \ No newline at end of file diff -urN sourceold/scripts/DBIKScripts.h source/scripts/DBIKScripts.h --- sourceold/scripts/DBIKScripts.h 2021-07-27 14:44:22.786003000 +1000 +++ source/scripts/DBIKScripts.h 2022-02-13 10:20:09.850412400 +1000 @@ -276,6 +276,7 @@ class DB_Force_Fire : public ScriptImpClass { void Created(GameObject *obj); + void Start_Attack(GameObject *obj); void Timer_Expired(GameObject *obj, int number); void Detach(GameObject *obj); }; \ No newline at end of file diff -urN sourceold/scripts/DBScripts.cpp source/scripts/DBScripts.cpp --- sourceold/scripts/DBScripts.cpp 2021-07-27 14:44:22.786003000 +1000 +++ source/scripts/DBScripts.cpp 2022-02-13 10:20:09.851411100 +1000 @@ -1195,38 +1195,64 @@ if(beacon && beacon->As_PhysicalGameObj()->As_BeaconGameObj()) { int IsNuke = beacon->As_PhysicalGameObj()->As_BeaconGameObj()->Get_Definition().Is_Nuke(); - if(DetTime>52) + if(DetTime>72) { Commands->Start_Timer(obj,this,DetTime-(float)67,3575); // countdown initiated if(IsNuke) { - if(DetTime>62) - { - Commands->Start_Timer(obj,this,DetTime-(float)52.5,3585); // Nuclear Strike in 50 seconds - if(DetTime>72) - { - Commands->Start_Timer(obj,this,DetTime-(float)62.5,3583); // Nuclear Strike in 60 seconds - } - } + Commands->Start_Timer(obj,this,DetTime-(float)62.5,3583); // Nuclear Strike in 60 seconds + Commands->Start_Timer(obj,this,DetTime-(float)52.5,3585); // Nuclear Strike in 50 seconds Commands->Start_Timer(obj,this,DetTime-(float)42.5,3587); // Nuclear Strike in 40 seconds Commands->Start_Timer(obj,this,DetTime-(float)32.5,3589); // Nuclear Strike in 30 seconds } else { - if(DetTime>62) - { - Commands->Start_Timer(obj,this,DetTime-(float)52.5,3586); // Nuclear Strike in 50 seconds - if(DetTime>72) - { - Commands->Start_Timer(obj,this,DetTime-(float)62.5,3584); // Nuclear Strike in 60 seconds - } - } + Commands->Start_Timer(obj,this,DetTime-(float)62.5,3584); // Nuclear Strike in 60 seconds + Commands->Start_Timer(obj,this,DetTime-(float)52.5,3586); // Nuclear Strike in 50 seconds Commands->Start_Timer(obj,this,DetTime-(float)42.5,3588); // Ion Cannon Strike in 40 seconds Commands->Start_Timer(obj,this,DetTime-(float)32.5,3590); // Ion Cannon Strike in 30 seconds } - Commands->Start_Timer(obj,this,DetTime-25,3579); - Commands->Start_Timer(obj,this,DetTime-20,3580); - Commands->Start_Timer(obj,this,DetTime-15,3581); + Commands->Start_Timer(obj,this,DetTime-25,3579); // 25 + Commands->Start_Timer(obj,this,DetTime-20,3580); // 20 + Commands->Start_Timer(obj,this,DetTime-15,3581); // 15 + } + + else if(DetTime>62) + { + Commands->Start_Timer(obj,this,DetTime-(float)57,3575); // countdown initiated + if(IsNuke) + { + Commands->Start_Timer(obj,this,DetTime-(float)52.5,3585); // Nuclear Strike in 50 seconds + Commands->Start_Timer(obj,this,DetTime-(float)42.5,3587); // Nuclear Strike in 40 seconds + Commands->Start_Timer(obj,this,DetTime-(float)32.5,3589); // Nuclear Strike in 30 seconds + } + else + { + Commands->Start_Timer(obj,this,DetTime-(float)52.5,3586); // Nuclear Strike in 50 seconds + Commands->Start_Timer(obj,this,DetTime-(float)42.5,3588); // Ion Cannon Strike in 40 seconds + Commands->Start_Timer(obj,this,DetTime-(float)32.5,3590); // Ion Cannon Strike in 30 seconds + } + Commands->Start_Timer(obj,this,DetTime-25,3579); // 25 + Commands->Start_Timer(obj,this,DetTime-20,3580); // 20 + Commands->Start_Timer(obj,this,DetTime-15,3581); // 15 + } + + else if(DetTime>52) + { + Commands->Start_Timer(obj,this,DetTime-(float)47,3575); // countdown initiated + if(IsNuke) + { + Commands->Start_Timer(obj,this,DetTime-(float)42.5,3587); // Nuclear Strike in 40 seconds + Commands->Start_Timer(obj,this,DetTime-(float)32.5,3589); // Nuclear Strike in 30 seconds + } + else + { + Commands->Start_Timer(obj,this,DetTime-(float)42.5,3588); // Ion Cannon Strike in 40 seconds + Commands->Start_Timer(obj,this,DetTime-(float)32.5,3590); // Ion Cannon Strike in 30 seconds + } + Commands->Start_Timer(obj,this,DetTime-25,3579); // 25 + Commands->Start_Timer(obj,this,DetTime-20,3580); // 20 + Commands->Start_Timer(obj,this,DetTime-15,3581); // 15 } else if(DetTime>25) @@ -1335,7 +1361,7 @@ { //Console_Input("msg Beacon will detonate in 60 Seconds"); Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0023i1evan_snd.wav",0); - Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0024i1evag_snd.wav",1); + Create_2D_WAV_Sound_Team_Dialog("evagion60.wav",1); } if(number==3585) @@ -1349,7 +1375,7 @@ { //Console_Input("msg Beacon will detonate in 50 Seconds"); Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0022i1evan_snd.wav",0); - Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0023i1evag_snd.wav",1); + Create_2D_WAV_Sound_Team_Dialog("evagion50.wav",1); } if(number==3587) @@ -1363,7 +1389,7 @@ { //Console_Input("msg Beacon will detonate in 40 Seconds"); Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0021i1evan_snd.wav",0); - Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0022i1evag_snd.wav",1); + Create_2D_WAV_Sound_Team_Dialog("evagion40.wav",1); } if(number==3589) @@ -1377,7 +1403,7 @@ { //Console_Input("msg Beacon will detonate in 30 Seconds"); Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0020i1evan_snd.wav",0); - Create_2D_WAV_Sound_Team_Dialog("mxxdsgn_dsgn0021i1evag_snd.wav",1); + Create_2D_WAV_Sound_Team_Dialog("evagion30.wav",1); } } diff -urN sourceold/scripts/DB_Research_Terminals.cpp source/scripts/DB_Research_Terminals.cpp --- sourceold/scripts/DB_Research_Terminals.cpp 2020-09-26 08:59:57.384166200 +1000 +++ source/scripts/DB_Research_Terminals.cpp 2022-02-13 10:20:09.852539600 +1000 @@ -19,6 +19,7 @@ #include "GameObjManager.h" #include "DB_Research_Terminals.h" #include "DB_General.h" +#include "dp88_custom_timer_defines.h" #include "SoldierGameObjDef.h" #include "PowerupGameObjDef.h" @@ -841,6 +842,11 @@ } } +void DB_DeployableTank_Upgradeable::KeyHook() +{ + Commands->Send_Custom_Event(Owner(),Owner(),923572385,0,0); +} + void DB_DeployableTank_Upgradeable::Custom(GameObject *obj,int type,int param,GameObject *sender) { if (!Upgraded && type == Research_Technology::UPGRADE_INFANTRY_ARMOR_CUSTOM && param==UpgradeID) @@ -979,6 +985,7 @@ Commands->Enable_Vehicle_Transitions(obj,true); Commands->Enable_Innate_Conversations(obj,true); Commands->Send_Custom_Event(obj,obj,DEPLOY_COMPLETE_CUSTOM,0,0); + Commands->Send_Custom_Event(obj,obj,CUSTOM_DEPLOY_STATE_CHANGED,1,0); return; } //tank redeploy @@ -997,6 +1004,7 @@ Commands->Enable_Vehicle_Transitions(obj,true); Commands->Enable_Engine(obj,true); Commands->Send_Custom_Event(obj,obj,UNDEPLOY_COMPLETE_CUSTOM,0,0); + Commands->Send_Custom_Event(obj,obj,CUSTOM_DEPLOY_STATE_CHANGED,0,0); return; } } diff -urN sourceold/scripts/DB_Research_Terminals.h source/scripts/DB_Research_Terminals.h --- sourceold/scripts/DB_Research_Terminals.h 2017-11-23 05:41:45.153800000 +1000 +++ source/scripts/DB_Research_Terminals.h 2022-02-13 10:20:09.852539600 +1000 @@ -163,13 +163,14 @@ void Entered(GameObject *obj, GameObject *enterer); }; -class DB_DeployableTank_Upgradeable : public ScriptImpClass { +class DB_DeployableTank_Upgradeable : public JFW_Key_Hook_Base { int UpgradeID; bool Upgraded; int PilotID,mode; StringClass model; void Created(GameObject *obj); void Animation_Complete(GameObject *obj,const char *animation_name); + void KeyHook(); void Custom(GameObject *obj,int type,int param,GameObject *sender); void Destroyed(GameObject *obj); public: void Register_Auto_Save_Variables(); diff -urN sourceold/scripts/MasterCan_Scripts.cpp source/scripts/MasterCan_Scripts.cpp --- sourceold/scripts/MasterCan_Scripts.cpp 2020-09-26 08:59:57.384166200 +1000 +++ source/scripts/MasterCan_Scripts.cpp 1970-01-01 10:00:00.000000000 +1000 @@ -1,1940 +0,0 @@ -//MasterCan's Scripts for Public TT Release - v3 -//Made by The Unstoppable (MasterCan) -//This version includes 40 scripts. - -//39 Working -//1 Buggy -//0 Not Working -//0 Not Tested - -#include "General.h" -#include "engine.h" -#include "engine_common.h" -#include "engine_def.h" -#include "engine_game.h" -#include "engine_player.h" -#include "engine_tt.h" -#include "engine_script.h" -#include "engine_player.h" -#include "engine_io.h" -#include "engine_obj.h" -#include "gmgame.h" -#include "gmplugin.h" -#include "WeaponClass.h" -#include "SoldierGameObj.h" -#include "WeaponBagClass.h" -#include "VehicleGameObj.h" -#include "SimpleGameObj.h" -#include "BuildingGameObj.h" -#include "PowerupGameObj.h" -#include "cPlayer.h" -#include -#include -#include -#include - -class MC_Teleport : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - //BxoID: Script Zone ID - //ArrowID: Daves Arrow (to teleport) ID - //TeleportSound: The sound that will be played after teleportation done. - //Changelog: 1.0 - First Release - // 1.1 - Gonna Make This Two-Way Teleportation - if (enterer->As_SoldierGameObj() || enterer->As_VehicleGameObj()) - { - Commands->Set_Position(enterer, Commands->Get_Position(Commands->Find_Object(Get_Int_Parameter("ArrowID")))); - if (Get_Parameter("TeleportSound")) - { - Create_2D_WAV_Sound_Player(enterer, Get_Parameter("TeleportSound")); - } - } - } -}; - - -class MC_HUD_Message_Zone : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - //BoxID: Script Zone ID - //Message: The message that will be shown on HUD. - //Sound: The sound that will be played. - //Changelog: 1.0 - First Release - // 1.1 - No plans right now. - - if (Commands->Find_Object(Get_Int_Parameter("BoxID"))) - { - if (enterer->As_SoldierGameObj()) - { - SoldierGameObj *Soldier = enterer->As_SoldierGameObj(); - if (Get_Parameter("Message")) - { - Set_HUD_Help_Text_Player_Text(Soldier, 8269, Get_Parameter("Message"), Vector3(Get_Float_Parameter("Red"), Get_Float_Parameter("Green"), Get_Float_Parameter("Blue"))); - } - - if (Get_Parameter("Sound")) - { - Create_2D_WAV_Sound_Player(Soldier, Get_Parameter("Sound")); - } - } - } - } -}; - -class MC_Stop_Vehicle_Engine : public ScriptImpClass -{ - GameObject *Vehicle; - bool Disabled; - void Created(GameObject *obj) - { - //Duration: The amount of time - //Changelog: 1.0 - First release - // 1.1 - Planning to spawn a ciematic (like how EMP has) when script activated. - Vehicle = obj; - if (Vehicle->As_VehicleGameObj()) - { - Disabled = true; - Commands->Start_Timer(Vehicle, this, Get_Float_Parameter("Duration"), 1); - Commands->Enable_Engine(Vehicle, false); - Vehicle->As_VehicleGameObj()->Set_Immovable(true); - } - else - { - Destroy_Script(); - } - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == CUSTOM_EVENT_VEHICLE_ENTERED) - { - if (Disabled) - { - Commands->Enable_Engine(Vehicle, false); - Vehicle->As_VehicleGameObj()->Set_Immovable(true); - } - } - } - - void Timer_Expired(GameObject *obj, int number) - { - Disabled = false; - Commands->Enable_Engine(obj, true); - Vehicle->As_VehicleGameObj()->Set_Immovable(false); - Destroy_Script(); - } -}; - -class MC_Change_Vehicle_Weapon : public ScriptImpClass -{ - void Created(GameObject *obj) - { - //Preset: The preset which will be changed. - //Rounds: The amount of ammo which will be granted. - if (obj->As_VehicleGameObj()) - { - Commands->Clear_Weapons(obj); - Grant_Weapon(obj, Get_Parameter("Preset"), true, Get_Int_Parameter("Rounds"), false); - Commands->Select_Weapon(obj, Get_Parameter("Preset")); - } - - Destroy_Script(); - } -}; - -class MC_MCTMainSyncObject : public ScriptImpClass -{ - GameObject *MCTObj; - void Created(GameObject *obj) - { - MCTObj = Commands->Find_Object(Get_Int_Parameter("MCT_ObjectID")); - - float MaxS = Commands->Get_Max_Shield_Strength(obj); - float MaxH = Commands->Get_Max_Health(obj); - Set_Max_Shield_Strength(MCTObj, MaxS); - Set_Max_Health(MCTObj, MaxH); - } - - void Damaged(GameObject *obj, GameObject *damager, float amount) - { - Set_Max_Shield_Strength(MCTObj, Commands->Get_Max_Shield_Strength(obj)); - Set_Max_Health(MCTObj, Commands->Get_Max_Health(obj)); - Commands->Apply_Damage(MCTObj, amount, "None", 0); - } -}; - -class MC_MasterControlTerminal_Object : public ScriptImpClass -{ - GameObject *MainStructure; - float Multiplier; - bool SameHealth; - DefenseObjectClass *MCT; - DefenseObjectClass *Main; - //Object: The object which will be main structure. - //Multiply: The multiplier of amount which will be applied. - //SameHealthWithMain: Makes MCT health same with main object. - void Created(GameObject *obj) - { - MainStructure = Commands->Find_Object(Get_Int_Parameter("Object")); - Multiplier = Get_Float_Parameter("Multiply"); - Commands->Start_Timer(obj, this, 1.0f, 1); - } - - void Damaged(GameObject *obj, GameObject *damager, float amount) - { - Commands->Apply_Damage(MainStructure, amount * Multiplier, "None", damager); - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 1) - { - Change_Team_2(obj, Commands->Get_Player_Type(MainStructure)); - Commands->Start_Timer(obj, this, 1.0f, 1); - } - } -}; - -class MC_Change_Vehicle_Weapon_Zone : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - //Preset: The preset which will be changed. - //Rounds: The amount of ammo which will be granted. - if (enterer->As_VehicleGameObj()) - { - Commands->Clear_Weapons(enterer); - Grant_Weapon(enterer, Get_Parameter("Preset"), true, Get_Int_Parameter("Rounds"), false); - Commands->Select_Weapon(enterer, Get_Parameter("Preset")); - } - } -}; - -class MC_Grant_Weapon : public ScriptImpClass -{ - void Created(GameObject *obj) - { - //Preset: The preset which will be granted. - //Rounds: The amount of ammo which will be granted. - Grant_Weapon(obj, Get_Parameter("Preset"), true, Get_Int_Parameter("Rounds"), false); - Destroy_Script(); - } -}; - -class MC_Grant_Weapon_Zone : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - //Preset: The preset which will be granted. - //Rounds: The amount of ammo which will be granted. - Grant_Weapon(enterer, Get_Parameter("Preset"), true, Get_Int_Parameter("Rounds"), false); - } -}; - -class MC_Spawn_When_Death : public ScriptImpClass -{ - void Killed(GameObject *obj, GameObject *killer) - { - //Preset: The preset which will be spawned when object is killed. - GameObject *Spawned = Commands->Create_Object(Get_Parameter("Preset"), Commands->Get_Position(obj)); - Commands->Set_Facing(Spawned, Commands->Get_Facing(obj)); - Destroy_Script(); - } -}; - - -class MC_GameOver_When_Kill : public ScriptImpClass -{ - void Killed(GameObject *obj, GameObject *killer) - { - Console_Input("gameover"); - Destroy_Script(); - } -}; - -class MC_Grant_Character : public ScriptImpClass -{ - void Created(GameObject *obj) - { - //Preset: The character preset which will be granted. - if (obj->As_SoldierGameObj()) - { - Change_Character(obj, Get_Parameter("Preset")); - } - Destroy_Script(); - } -}; - -class MC_Grant_Character_Zone : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - //Preset: The character preset which will be granted. - if (enterer->As_SoldierGameObj()) - { - Change_Character(enterer, Get_Parameter("Preset")); - } - } -}; - -class MC_Spawn_When_Fully_Repaired : public ScriptImpClass -{ - void Damaged(GameObject *obj, GameObject *damager, float amount) - { - //Preset: The preset which will be spawned when the object is fully repaired. - if (amount < 0) - { - float CurrentHealth = Commands->Get_Health(obj) + Commands->Get_Shield_Strength(obj); - const float MaxHealth = Commands->Get_Max_Health(obj) + Commands->Get_Max_Shield_Strength(obj); - if (CurrentHealth == MaxHealth) - { - Commands->Create_Object(Get_Parameter("Preset"), Commands->Get_Position(obj)); - Commands->Destroy_Object(obj); - Destroy_Script(); - } - } - } - - void Killed(GameObject *obj, GameObject *damager) - { - Destroy_Script(); - } -}; - - -class MC_Refinery_Object : public ScriptImpClass -{ - int Team; - void Created(GameObject *obj) - { - //Interval: The interval of the grant credits. - //Amount: The amount of credits will be granted. - Team = Get_Int_Parameter("Team"); - Commands->Set_Player_Type(obj, Team); - Commands->Start_Timer(obj, this, Get_Float_Parameter("Interval"), 5); - } - - void Timer_Expired(GameObject *obj, int number) - { - for (SLNode *z = Get_Player_List()->Head(); z; z = z->Next()) - { - cPlayer *Player = z->Data(); - GameObject *PlayerObject = Player->Get_GameObj(); - if (Commands->Get_Player_Type(PlayerObject) == Team) - { - Commands->Give_Money(PlayerObject, Get_Float_Parameter("Amount"), false); - } - } - } -}; - -class MC_Vehicle_Purchase_Terminal : public ScriptImpClass -{ - bool Pokeable; - Vector3 SpawnLocation; - float Facing; - GameObject *Terminal; - const char *Preset; - int Amount; - void Created(GameObject *obj) - { - //Team: The team of the PT. - //VehiclePreset: The tank preset. - //SpawnerID: Location that the object will be spawned. - //Credits: The amount of credits that needed to purchase this object. - Commands->Enable_HUD_Pokable_Indicator(obj, true); - Preset = Get_Parameter("VehiclePreset"); - SpawnLocation = Commands->Get_Position(Commands->Find_Object(Get_Int_Parameter("SpawnerID"))); - Facing = Commands->Get_Facing(Commands->Find_Object(Get_Int_Parameter("SpawnerID"))); - Terminal = obj; - Pokeable = true; - Amount = Get_Int_Parameter("Credits"); - } - - void Poked(GameObject *obj, GameObject *poker) - { - if (Pokeable) - { - if (poker->As_SoldierGameObj()) - { - SoldierGameObj *Player = poker->As_SoldierGameObj(); - if (Commands->Get_Player_Type(Player) == Get_Int_Parameter("Team")) - { - if (Commands->Get_Money(Player) >= Amount) - { - GameObject *Vehicle = Commands->Create_Object(Preset, SpawnLocation); - Commands->Set_Facing(Vehicle, Facing); - Send_Message_Player(Player, 255, 255, 255, "Purchase request granted!"); - Create_2D_WAV_Sound_Player(Player, "M00GBMG_SECX0002I1GBMG_snd.wav"); - Commands->Give_Money(Player, Amount * -1.0f, false); - Pokeable = false; - Commands->Enable_HUD_Pokable_Indicator(obj, false); - Commands->Start_Timer(obj, this, 5.0f, 1); - } - else - { - Send_Message_Player(Player, 255, 255, 255, "Insufficient funds!"); - if (Get_Player_Type(poker) == 0) - { - Create_2D_WAV_Sound_Player(poker, "m00evan_dsgn0024i1evan_snd.wav"); - } - if (Get_Player_Type(poker) == 1) - { - Create_2D_WAV_Sound_Player(poker, "m00evag_dsgn0028i1evag_snd.wav"); - } - } - } - else - { - Send_Message_Player(Player, 255, 255, 255, StringClass::getFormattedString("Access Denied! You aren't in team %s", Get_Team_Name(Get_Int_Parameter("Team")))); - } - } - } - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 1) - { - Pokeable = true; - Commands->Enable_HUD_Pokable_Indicator(obj, true); - } - } -}; - -class MC_Character_Purchase_Terminal : public ScriptImpClass -{ - bool Pokeable; - GameObject *Terminal; - const char *Preset; - int Amount; - void Created(GameObject *obj) - { - //Team: The team of the PT. - //VehiclePreset: The tank preset. - //SpawnerID: Location that the object will be spawned. - //Credits: The amount of credits that needed to purchase this object. - Commands->Enable_HUD_Pokable_Indicator(obj, true); - Preset = Get_Parameter("CharacterPreset"); - Terminal = obj; - Pokeable = true; - Amount = Get_Int_Parameter("Credits"); - } - - void Poked(GameObject *obj, GameObject *poker) - { - if (Pokeable) - { - if (poker->As_SoldierGameObj()) - { - SoldierGameObj *Player = poker->As_SoldierGameObj(); - if (Commands->Get_Player_Type(Player) == Get_Int_Parameter("Team")) - { - if (Commands->Get_Money(poker) >= Amount) - { - Change_Character(poker, Preset); - Send_Message_Player(Player, 255, 255, 255, "Purchase request granted!"); - Create_2D_WAV_Sound_Player(Player, "M00GBMG_SECX0002I1GBMG_snd.wav"); - Commands->Give_Money(Player, Amount * -1.0f, false); - Pokeable = false; - Commands->Enable_HUD_Pokable_Indicator(obj, false); - Commands->Start_Timer(obj, this, 5.0f, 1); - } - else - { - Send_Message_Player(Player, 255, 255, 255, "Insufficient funds!"); - if (Get_Player_Type(poker) == 0) - { - Create_2D_WAV_Sound_Player(poker, "m00evan_dsgn0024i1evan_snd.wav"); - } - if (Get_Player_Type(poker) == 1) - { - Create_2D_WAV_Sound_Player(poker, "m00evag_dsgn0028i1evag_snd.wav"); - } - } - } - else - { - Send_Message_Player(Player, 255, 255, 255, StringClass::getFormattedString("Access Denied! You aren't in team %s", Get_Team_Name(Get_Int_Parameter("Team")))); - } - } - } - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 1) - { - Pokeable = true; - Commands->Enable_HUD_Pokable_Indicator(obj, true); - } - } -}; - -class MC_Set_Team_When_Exit : public ScriptImpClass -{ - int Team; - void Created(GameObject *obj) - { - Team = Get_Int_Parameter("Team"); - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == CUSTOM_EVENT_VEHICLE_EXITED) - { - Set_Object_Type(obj, Team); - Commands->Start_Timer(obj, this, 0.2f, 1); - } - } - - void Timer_Expired(GameObject *obj, int number) - { - Set_Object_Type(obj, Team); - } -}; - -class MC_IonExplosion_When_Death : public ScriptImpClass -{ - void Killed(GameObject *obj, GameObject *killer) - { - Vector3 Pos = Commands->Get_Position(obj); - Create_Explosion_Extended("Explosion_IonCannonBeacon", Pos, obj); - Commands->Create_Object("Beacon_Ion_Cannon_Anim_Post", Commands->Get_Position(obj)); - Destroy_Script(); - } -}; - -class MC_Capturable_Object : public ScriptImpClass -{ - GameObject *Building; - const char *Repair_Sound; - const char *Destroy_Sound; - unsigned int Red; - unsigned int Green; - unsigned int Blue; - const char *Repair_Message; - const char *Destroy_Message; - bool Killed; - void Created(GameObject *obj) - { - Building = obj; - Red = Get_Int_Parameter("Red"); - Green = Get_Int_Parameter("Green"); - Blue = Get_Int_Parameter("Blue"); - Repair_Sound = Get_Parameter("RepairSound"); - Destroy_Sound = Get_Parameter("DestroySound"); - Repair_Message = Get_Parameter("RepairMessage"); - Destroy_Message = Get_Parameter("DestroyMessage"); - Set_Object_Type(Building, Get_Int_Parameter("InitialTeam")); - if (Get_Int_Parameter("InitialTeam") == -2) - { - Killed = true; - } - else - { - Killed = false; - } - } - - void Damaged(GameObject *obj, GameObject *damager, float amount) - { - if (amount < 0.0f) //Repair - { - if (Commands->Get_Player_Type(Building) == -2 && Commands->Get_Health(Building) + Commands->Get_Shield_Strength(Building) == Commands->Get_Max_Health(Building) + Commands->Get_Max_Shield_Strength(Building) && Commands->Get_Player_Type(damager) != -2) - { - Set_Object_Type(Building, Commands->Get_Player_Type(damager)); - Send_Message_Team(Commands->Get_Player_Type(damager), Red, Green, Blue, Repair_Message); - Create_2D_WAV_Sound_Team(Repair_Sound, Commands->Get_Player_Type(damager)); - Killed = false; - } - } - else if (amount > Commands->Get_Health(Building)) - { - if (!Killed) - { - Send_Message(Red, Green, Blue, Destroy_Message); - Create_2D_WAV_Sound_Team(Repair_Sound, 0); - Create_2D_WAV_Sound_Team(Repair_Sound, 1); - Commands->Set_Health(Building, 1.0f); - Set_Object_Type(Building, -2); - } - else - { - Commands->Set_Health(Building, 1.0f); - Set_Object_Type(Building, -2); - } - } - } -}; - -class MC_FlyMode_On : public ScriptImpClass -{ - void Created(GameObject *obj) - { - if (!Get_Fly_Mode(obj)) - { - Toggle_Fly_Mode(obj); - } - Destroy_Script(); - } -}; - -class MC_FlyMode_Off : public ScriptImpClass -{ - void Created(GameObject *obj) - { - if (Get_Fly_Mode(obj)) - { - Toggle_Fly_Mode(obj); - } - Destroy_Script(); - } -}; - -class MC_FlyModeZone_On : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - if (!Get_Fly_Mode(enterer)) - { - Toggle_Fly_Mode(enterer); - } - } -}; - -class MC_FlyModeZone_Off : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - if (Get_Fly_Mode(enterer)) - { - Toggle_Fly_Mode(enterer); - } - } -}; - -class MC_Spectate : public ScriptImpClass -{ - void Created(GameObject *obj) - { - SoldierGameObj *Soldier = obj->As_SoldierGameObj(); - int Team = Soldier->Get_Player_Type(); - if (Team != -4) - { - if (Soldier->Get_Vehicle()) - { - Destroy_Script(); - } - if (!Get_Fly_Mode(Soldier)) - { - Toggle_Fly_Mode(Soldier); - } - Soldier->Set_Player_Type(-4); - Commands->Set_Model(Soldier, "NULL"); - Commands->Clear_Weapons(Soldier); - Commands->Disable_All_Collisions(Soldier); - Commands->Set_Is_Visible(Soldier, false); - Commands->Set_Is_Rendered(Soldier, false); - Commands->Set_Shield_Type(Soldier, "Blamo"); - Disarm_All_C4_Beacons(Get_Player_ID(Soldier)); - for (SLNode* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next()) - { - cPlayer *p = PlayerIter->Data(); - if (!p->Is_Active()) continue; - if (p->Get_Id() == Get_Player_ID(Soldier)) - { - Update_Network_Object_Player(Soldier, p->Get_Id()); - } - else - { - bool pending = Soldier->Is_Delete_Pending(); - Soldier->Set_Is_Delete_Pending(true); - Update_Network_Object_Player(Soldier, p->Get_Id()); - Soldier->Set_Is_Delete_Pending(pending); - } - } - Soldier->Clear_Object_Dirty_Bits(); - } - Destroy_Script(); - } -}; - -class MC_Spectate_Zone : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - SoldierGameObj *Soldier = enterer->As_SoldierGameObj(); - int Team = Soldier->Get_Player_Type(); - if (Team != -4) - { - if (Soldier->Get_Vehicle()) - { - return; - } - if (!Get_Fly_Mode(Soldier)) - { - Toggle_Fly_Mode(Soldier); - } - Soldier->Set_Player_Type(-4); - Commands->Set_Model(Soldier, "NULL"); - Commands->Clear_Weapons(Soldier); - Commands->Disable_All_Collisions(Soldier); - Commands->Set_Is_Visible(Soldier, false); - Commands->Set_Is_Rendered(Soldier, false); - Commands->Set_Shield_Type(Soldier, "Blamo"); - Disarm_All_C4_Beacons(Get_Player_ID(Soldier)); - for (SLNode* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next()) - { - cPlayer *p = PlayerIter->Data(); - if (!p->Is_Active()) continue; - if (p->Get_Id() == Get_Player_ID(Soldier)) - { - Update_Network_Object_Player(Soldier, p->Get_Id()); - } - else - { - bool pending = Soldier->Is_Delete_Pending(); - Soldier->Set_Is_Delete_Pending(true); - Update_Network_Object_Player(Soldier, p->Get_Id()); - Soldier->Set_Is_Delete_Pending(pending); - } - } - Soldier->Clear_Object_Dirty_Bits(); - } - } -}; - -class MC_Beacon_Block_Zone : public ScriptImpClass -{ - //const char *BeaconPresets[6]; - void Created(GameObject *obj) - { - - } - - void Entered(GameObject *obj, GameObject *enterer) - { - SoldierGameObj *Soldier; - if (enterer->As_VehicleGameObj()) - { - Soldier = enterer->As_VehicleGameObj()->Get_Driver(); - } - else - { - Soldier = enterer->As_SoldierGameObj(); - } - Commands->Start_Timer(obj, this, 0.2f, Commands->Get_ID(Soldier)); - } - - void Exited(GameObject *obj, GameObject *exiter) - { - //Reserved for next update :))) - } - - void Timer_Expired(GameObject *obj, int number) - { - const char *BeaconPresets[6] = { "CnC_Weapon_IonCannonBeacon_Player", "Weapon_IonCannonBeacon_Player", "Weapon_IonCannonBeacon_Ai", "CnC_Weapon_IonCannonBeacon_Player", "CnC_Weapon_NukeBeacon_Player", "Weapon_NukeBeacon_Ai" }; - if (IsInsideZone(obj, Commands->Find_Object(number))) - { - SoldierGameObj *Soldier = Commands->Find_Object(number)->As_SoldierGameObj(); - unsigned int Red = Get_Int_Parameter("Red"); - unsigned int Green = Get_Int_Parameter("Green"); - unsigned int Blue = Get_Int_Parameter("Blue"); - for (size_t i = 0; i < 6; i++) - { - if (Get_Current_Weapon(Soldier) == BeaconPresets[i]) - { - Commands->Select_Weapon(Soldier, ""); - Send_Message_Player(Soldier, Red, Green, Blue, Get_Parameter("BlockMessage")); - } - } - Commands->Start_Timer(obj, this, 0.2f, number); - } - } -}; - -class MC_Open_Mutant_PT : public ScriptImpClass -{ - void Created(GameObject *obj) - { - if (obj->As_SoldierGameObj()) - { - Commands->Display_Mutant_Player_Terminal(); - } - Destroy_Script(); - } -}; - -class MC_Open_GDI_PT : public ScriptImpClass -{ - void Created(GameObject *obj) - { - if (obj->As_SoldierGameObj()) - { - Display_GDI_Player_Terminal_Player(obj); - } - Destroy_Script(); - } -}; - -class MC_Open_Nod_PT : public ScriptImpClass -{ - void Created(GameObject *obj) - { - if (obj->As_SoldierGameObj()) - { - Display_NOD_Player_Terminal_Player(obj); - } - Destroy_Script(); - } -}; - - -class MC_Objective_Message_Sender : public ScriptImpClass -{ - static StringClass Underscore_To_Space(StringClass strtext) - { - std::string text = std::string(strtext); - int length = text.size(); - int x = 0; - std::string fixed; - while (x != length) { - std::string letter = text.substr(x, 1); - if (letter == "_") { - letter = " "; - } - fixed = fixed + letter; - x = x + 1; - } - return StringClass(fixed.c_str()); - } - - bool Pokeable; - StringClass Message; - void Created(GameObject *obj) - { - Commands->Enable_HUD_Pokable_Indicator(obj, true); - Message = StringClass(Underscore_To_Space(Get_Parameter("Message"))); - Send_Message(90, 231, 114, StringClass::getFormattedString("New Objective: %s", Message)); - WideStringClass Send; - Send.Format(L"j\n90\n8269\n%hs\n%f\n%f\n%f\n,", "New Objective Available", 214 / 255.0f, 0 / 255.0f, 255 / 255.0f); - Send_Client_Text(Send, TEXT_MESSAGE_PUBLIC, false, -2, -1, true, true); - Create_2D_WAV_Sound_Team("paging_attention_1.wav", 0); - Create_2D_WAV_Sound_Team("paging_attention_1.wav", 1); - Commands->Start_Timer(obj, this, 3.0f, 2); - Pokeable = true; - } - - void Poked(GameObject *obj, GameObject *poker) - { - if (Pokeable) - { - if (Commands->Is_A_Star(poker)) - { - Send_Message_Player(poker, 90, 231, 114, StringClass::getFormattedString("Current Objective: %s", Message)); - Pokeable = false; - Commands->Enable_HUD_Pokable_Indicator(obj, false); - Commands->Start_Timer(obj, this, 3.0f, 1); - } - } - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 1) - { - Pokeable = true; - Commands->Enable_HUD_Pokable_Indicator(obj, true); - } - if (number == 2) - { - Commands->Start_Timer(obj, this, 90.0f, 2); - WideStringClass Send; - Send.Format(L"j\n90\n8269\n%hs\n%f\n%f\n%f\n,", Message, 214 / 255.0f, 0 / 255.0f, 255 / 255.0f); - Send_Client_Text(Send, TEXT_MESSAGE_PUBLIC, false, -2, -1, true, true); - } - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == 734638724) - { - Destroy_Script(); - } - } -}; - -class MC_Objective : public ScriptImpClass -{ -public: - StringClass Message; - int Order; - const char *OverType; //Valid: KILLOBJECT, ENTER, POKE, NONE - GameObject *ParameterObject; - GameObject *Listener; - GameObject *This; - int StarTrigger; - int CustomTriggerID; - - void Send_Debug_Message(const char *String) - { - if (Get_Int_Parameter("Debug") == 1) - { - Send_Message(255, 255, 255, StringClass::getFormattedString("[MCDBG] %s", String)); - Console_Output(StringClass::getFormattedString("[MCDBG] %s\n", String)); - } - } - - void Created(GameObject *obj) - { - - CustomTriggerID = 7236527; - Message = StringClass::getFormattedString("%s", Get_Parameter("Message")); - Order = Get_Int_Parameter("ObjectiveOrder"); - OverType = Get_Parameter("ObjectiveCompleteType"); - StarTrigger = Get_Int_Parameter("StarTrigger"); - Listener = Commands->Find_Object(Get_Int_Parameter("Listener")); - This = obj; - Send_Debug_Message(StringClass::getFormattedString("Over Type is %s", OverType)); - if (!strstr(OverType, "NONE")) - { - ParameterObject = Commands->Find_Object(Get_Int_Parameter("ParameterObject")); - if (ParameterObject) - { - if (std::string(OverType).find("KILLOBJECT") != std::string::npos) - { - Send_Debug_Message("Created listener with type KILLOBJECT."); - Attach_Script_Once(ParameterObject, "MC_Objective_Listener", StringClass::getFormattedString("%i,%s,%i,%i", Commands->Get_ID(obj), OverType, CustomTriggerID, StarTrigger)); - } - else if (std::string(OverType).find("ENTER") != std::string::npos) - { - Send_Debug_Message("Created listener with type ENTER."); - Attach_Script_Once(ParameterObject, "MC_Objective_Listener", StringClass::getFormattedString("%i,%s,%i,%i", Commands->Get_ID(obj), OverType, CustomTriggerID, StarTrigger)); - } - else if (std::string(OverType).find("POKE") != std::string::npos) - { - Send_Debug_Message("Created listener with type POKE."); - Attach_Script_Once(ParameterObject, "MC_Objective_Listener", StringClass::getFormattedString("%i,%s,%i,%i", Commands->Get_ID(obj), OverType, CustomTriggerID, StarTrigger)); - } - else - { - Send_Debug_Message("Can't create listener. Event is unknown."); - } - } - } - else - { - Send_Debug_Message("Created listener with type NONE."); - } - //MC_Objective_Controller::Scripts->Add_Head(this); //FIX - Commands->Start_Timer(obj, this, 2.0f, 129); - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (ParameterObject) - { - if (sender == ParameterObject) - { - if (type == CustomTriggerID) - { - Commands->Send_Custom_Event(obj, Listener, 777888994, Order, 0.0f); - Destroy_Script(); - } - } - } - } -}; -class MC_Objective_Controller : public ScriptImpClass -{ - GameObject *MC_Objective_Controller::ObjectiveMessageSender; //nvm - DynamicVectorClass MC_Objective_Controller::Objectives; - SList MC_Objective_Controller::Scripts; - int Current_Objective; - -public: - - void Send_Debug_Message(const char *String) - { - if (Get_Int_Parameter("Debug") == 1) - { - Send_Message(255, 255, 255, StringClass::getFormattedString("[MCDBG] %s", String)); - Console_Output(StringClass::getFormattedString("[MCDBG] %s\n", String)); - } - } - - void Created(GameObject *obj) - { - Send_Debug_Message("Controller created."); - ObjectiveMessageSender = Commands->Find_Object(Get_Int_Parameter("MessageObject")); - //Objectives = /*&std::vector();*/ &DynamicVectorClass(); - Scripts = (SList()); - Current_Objective = 0; - const char *ObjectiveList = Get_Parameter("Objectives"); - std::vector Objects = split(std::string(ObjectiveList), '-'); - for (size_t i = 0; i < Objects.size(); i++) - { - int ObjectID = stoi(Objects[i]); - GameObject *obj = Commands->Find_Object(ObjectID); - Objectives.Insert(0, obj); - } - Send_Debug_Message(StringClass::getFormattedString("%i objectives found and included.", Objects.size())); - //Starting first objective. - CurrentObjective = Get_Objective(0); - Send_Debug_Message("Started first objective."); - if (CurrentObjective) - { - Attach_Script_V(ObjectiveMessageSender, "MC_Objective_Message_Sender", CurrentObjective->Message); - Send_Debug_Message("Attached message sender."); - } - else - { - Commands->Start_Timer(obj, this, 0.2f, 2); - } - } - - MC_Objective *CurrentObjective; - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == 777888994) - { - if (Current_Objective == param) - { - Send_Debug_Message("Received finish objective custom from listener."); - CurrentObjective = Get_Objective(Current_Objective + 1); - if (CurrentObjective) - { - Current_Objective++; - Send_Debug_Message("Found a new objective to start."); - Commands->Send_Custom_Event(obj, ObjectiveMessageSender, 734638724, 0, 0.0f); - Commands->Start_Timer(obj, this, 0.2f, 1); - } - else - { - Send_Debug_Message("No new objectives detected."); - Commands->Send_Custom_Event(obj, ObjectiveMessageSender, 734638724, 0, 0.0f); - Commands->Start_Timer(obj, this, 0.2f, 2); - } - } - } - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number != 2) - { - if (!Is_Script_Attached(ObjectiveMessageSender, "MC_Objective_Message_Sender")) - { - Attach_Script_V(ObjectiveMessageSender, "MC_Objective_Message_Sender", StringClass::getFormattedString("%s", CurrentObjective->Message)); - Send_Debug_Message("Started a new objective."); - } - else - { - Commands->Start_Timer(obj, this, 0.2f, 1); - } - } - else - { - if (!Is_Script_Attached(ObjectiveMessageSender, "MC_Objective_Message_Sender")) - { - GameObject *NoObjective = Commands->Create_Object("Daves Arrow", Vector3(0.0f, 0.0f, 0.0f)); - Commands->Set_Model(NoObjective, "NULL"); - Attach_Script_V(NoObjective, "MC_Objective", "There_are_no_new_objectives_detected._Game_might_be_ended.,%i,NONE,0,%i,0", Current_Objective, Commands->Get_ID(obj)); - Objectives.Insert(0, NoObjective); - Attach_Script_V(ObjectiveMessageSender, "MC_Objective_Message_Sender", StringClass::getFormattedString("There_are_no_new_objectives_detected._Game_might_be_ended.")); - Send_Debug_Message("Attached no objectives message."); - } - else - { - Commands->Start_Timer(obj, this, 0.2f, 2); - } - } - } - - std::vector split(std::string strToSplit, char delimeter) - { - std::stringstream ss(strToSplit); - std::string item; - std::vector splittedStrings; - while (std::getline(ss, item, delimeter)) - { - splittedStrings.push_back(item); - } - return splittedStrings; - } - MC_Objective *Get_Objective(int Index) - { - //int ind = 0; - for (int i = 0; i < Objectives.Count(); i++) //Unreachable code - { - if (Objectives[i]) - { - MC_Objective *Objective = (MC_Objective*)Find_Script_On_Object(Objectives[i], "MC_Objective"); //this was nullptr. - if (Objective) - { - int obj_order = Objective->Order; - if (Index == obj_order) - { - return Objective; - } - } - } - else - { - - } - } - return 0; - } - - MC_Objective *Get_Objective_Script(GameObject *obj) - { - for (SLNode *z = Scripts.Head(); z; z = z->Next()) - { - if (z->Data()) - { - if (z->Data()->This == obj) - { - return (z->Data()); - } - } - else - { - - } - } - return 0; - /*SimpleDynVecClass Observers = obj->Get_Observers(); - for (size_t i = 0; i < Observers.Count; i++) - { - if (Observers[i]->Get_Name() == "MC_Objective") - { - return Observers[i]; - } - }*/ - } - -}; - -class MC_Objective_Listener : public ScriptImpClass -{ - GameObject *Objective; - const char *TriggerType; - int CustomToSend; - int OnlyStarTriggered; - void Send_Debug_Message(const char *String) - { - if (Get_Int_Parameter("Debug") == 1) - { - Send_Message(255, 255, 255, StringClass::getFormattedString("[MCDBG] %s", String)); - Console_Output(StringClass::getFormattedString("[MCDBG] %s\n", String)); - } - } - - void Created(GameObject *obj) - { - Send_Debug_Message(StringClass::getFormattedString("LISTENER: Created listener at %i...", Commands->Get_ID(obj))); - Objective = Commands->Find_Object(Get_Int_Parameter("Objective")); - TriggerType = Get_Parameter("Trigger"); - CustomToSend = Get_Int_Parameter("CustomID"); - OnlyStarTriggered = Get_Int_Parameter("OnlyStarCanTrigger"); - } - - void Killed(GameObject *obj, GameObject *killer) - { - if (std::string(TriggerType).find("KILLOBJECT") != std::string::npos) - { - Commands->Send_Custom_Event(obj, Objective, CustomToSend, 0, 0.0f); - Destroy_Script(); - } - } - - void Destroyed(GameObject *obj) - { - if (std::string(TriggerType).find("KILLOBJECT") != std::string::npos) - { - Commands->Send_Custom_Event(obj, Objective, CustomToSend, 0, 0.0f); - Destroy_Script(); - } - } - - void Poked(GameObject *obj, GameObject *poker) - { - if (std::string(TriggerType).find("POKE") != std::string::npos) - { - if (OnlyStarTriggered == 1) - { - if (Commands->Is_A_Star(poker)) - { - Commands->Send_Custom_Event(obj, Objective, CustomToSend, 0, 0.0f); - Destroy_Script(); - } - } - else - { - Commands->Send_Custom_Event(obj, Objective, CustomToSend, 0, 0.0f); - Destroy_Script(); - } - } - } - - void Entered(GameObject *obj, GameObject *enterer) - { - if (std::string(TriggerType).find("ENTER") != std::string::npos) - { - if (OnlyStarTriggered == 1) - { - if (Commands->Is_A_Star(enterer)) - { - Commands->Send_Custom_Event(obj, Objective, CustomToSend, 0, 0.0f); - Destroy_Script(); - } - } - else - { - Commands->Send_Custom_Event(obj, Objective, CustomToSend, 0, 0.0f); - Destroy_Script(); - } - } - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (sender) - { - if (sender == Objective) - { - if (type == 4222957) //Destroy listener if objective cancelled. - { - Send_Debug_Message(StringClass::getFormattedString("LISTENER: Received end objective event from Controller. Destroying listener at %i...", Commands->Get_ID(obj))); - Destroy_Script(); - } - } - } - } -}; - - -class MC_Destroy_When_Objective_Completed : public ScriptImpClass -{ - GameObject *ObjectiveObject; - - void Created(GameObject *obj) - { - ObjectiveObject = Commands->Find_Object(Get_Int_Parameter("ObjectiveArrow")); - Commands->Start_Timer(obj, this, 2.0f, 1); - } - - void Timer_Expired(GameObject *obj, int number) - { - if (Is_Script_Attached(ObjectiveObject, "MC_Objective")) - { - - } - else - { - obj->Set_Delete_Pending(); - Destroy_Script(); - } - Commands->Start_Timer(obj, this, 2.0f, 1); - } -}; - -class MC_Select_Weapon_On_Zone_Enter : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - Commands->Select_Weapon(enterer, Get_Parameter("WeaponPreset")); - } -}; - -class MC_Select_Weapon_On_Zone_Exit : public ScriptImpClass -{ - void Exited(GameObject *obj, GameObject *exiter) - { - Commands->Select_Weapon(exiter, Get_Parameter("WeaponPreset")); - } -}; - -class MC_Select_Weapon_On_Zone : public ScriptImpClass -{ - void Entered(GameObject *obj, GameObject *enterer) - { - Commands->Select_Weapon(enterer, Get_Parameter("EnterWeaponPreset")); - } - - void Exited(GameObject *obj, GameObject *exiter) - { - Commands->Select_Weapon(exiter, Get_Parameter("ExitWeaponPreset")); - } -}; - -class MC_Chinook_Reinforcements_Paradrop : public ScriptImpClass -{ - //Taken from Single Player scriot M03_Chinook_ParaDrop and modified to drop 3 different soldiers. -public: - void Register_Auto_Save_Variables() - { - Auto_Save_Variable(&this->nodTransportHelicopterObjId, sizeof(this->nodTransportHelicopterObjId), 1); - Auto_Save_Variable(&this->chinookKilled, sizeof(this->chinookKilled), 2); - Auto_Save_Variable(&this->paratrooperIndex, sizeof(this->paratrooperIndex), 3); - } - -private: - int nodTransportHelicopterObjId; - bool chinookKilled; - int paratrooperIndex; - GameObject *presetObj1; - GameObject *presetObj2; - GameObject *presetObj3; - GameObject *nodTransportHelicopterObj; - GameObject *MaintrajectoryObj; - int SoundObj; - - void Send_Debug_Message(const char *String, ...) - { - if (Get_Int_Parameter("Debug") == 1) - { - Send_Message(255, 255, 255, StringClass::getFormattedString("[MCDBG] %s", String)); - Console_Output(StringClass::getFormattedString("[MCDBG] %s\n", String)); - } - } - - bool Check_Object(GameObject *obj) - { - if (obj) - { - if (obj->As_SmartGameObj()) - { - if (obj->As_SoldierGameObj()) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - - void Created(GameObject *obj) - { - presetObj1 = 0; - presetObj2 = 0; - presetObj3 = 0; - Vector3 pos = Commands->Get_Position(obj); - float facing = Commands->Get_Facing(obj); - Send_Debug_Message("Chinook Drop script is now initializing..."); - GameObject *MaintrajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Model(MaintrajectoryObj, "X5D_Chinookfly"); - Commands->Set_Facing(MaintrajectoryObj, facing); - Commands->Set_Animation(MaintrajectoryObj, "X5D_Chinookfly.X5D_Chinookfly", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message("Created main Trajectory object."); - if (Get_Object_Type(obj) == 0) - { - - Send_Debug_Message("Creating Nod Chinook..."); - nodTransportHelicopterObj = Commands->Create_Object("Nod_Transport_Helicopter_Flyover", pos); - Set_Max_Health(nodTransportHelicopterObj, 100000.0f); - Set_Max_Shield_Strength(nodTransportHelicopterObj, 100000.0f); - Commands->Set_Health(nodTransportHelicopterObj, 100000.0f); - Commands->Set_Shield_Strength(nodTransportHelicopterObj, 100000.0f); - Commands->Set_Facing(nodTransportHelicopterObj, facing); - Commands->Disable_Physical_Collisions(nodTransportHelicopterObj); - Commands->Set_Animation(nodTransportHelicopterObj, "v_Nod_trnspt.v_Nod_trnspt", true, NULL, 0.0f, -1.0f, false); - Commands->Attach_To_Object_Bone(nodTransportHelicopterObj, MaintrajectoryObj, "BN_Chinook_1"); - Send_Debug_Message("Chinook creation succesful."); - } - else - { - Send_Debug_Message("Creating GDI Chinook..."); - nodTransportHelicopterObj = Commands->Create_Object("GDI_Transport_Helicopter_Flyover", pos); - Set_Max_Health(nodTransportHelicopterObj, 100000.0f); - Set_Max_Shield_Strength(nodTransportHelicopterObj, 100000.0f); - Commands->Set_Health(nodTransportHelicopterObj, 100000.0f); - Commands->Set_Shield_Strength(nodTransportHelicopterObj, 100000.0f); - Commands->Set_Facing(nodTransportHelicopterObj, facing); - Commands->Disable_Physical_Collisions(nodTransportHelicopterObj); - Commands->Set_Animation(nodTransportHelicopterObj, "v_GDI_trnspt.v_GDI_trnspt", true, NULL, 0.0f, -1.0f, false); - Commands->Attach_To_Object_Bone(nodTransportHelicopterObj, MaintrajectoryObj, "BN_Chinook_1"); - Send_Debug_Message("Chinook creation succesful."); - } - Send_Debug_Message("Finishing initialization..."); - this->chinookKilled = false; - this->paratrooperIndex = 0; - - int objId = Commands->Get_ID(obj); - char buffer[16]; - sprintf(buffer, "%d", objId); - Commands->Attach_Script(nodTransportHelicopterObj, "M03_Reinforcement_Chinook", buffer); - - this->nodTransportHelicopterObjId = Commands->Get_ID(nodTransportHelicopterObj); - Send_Debug_Message("Starting timers..."); - Commands->Start_Timer(obj, this, 300 / 30.0f, 0); - Commands->Start_Timer(obj, this, 169 / 30.0f, 1); - Commands->Start_Timer(obj, this, 179 / 30.0f, 2); - Commands->Start_Timer(obj, this, 198 / 30.0f, 3); - Commands->Start_Timer(obj, this, 145 / 30.0f, 4); - Commands->Start_Timer(obj, this, 155 / 30.0f, 5); - Commands->Start_Timer(obj, this, 165 / 30.0f, 6); - Commands->Start_Timer(obj, this, 25 / 30.0f, 7); - Commands->Start_Timer(obj, this, 280 / 30.0f, 8); - Send_Debug_Message("Script is now enabled and playing cinematic..."); - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == 23000 && param == 23000) - { - this->chinookKilled = true; - } - - if (type == 15730) - { - GameObject *Attach = Commands->Find_Object(param); - if (Attach) - { - presetObj1 = Attach; - Send_Debug_Message(StringClass::getFormattedString("Object at Slot 1 has changed to object ID %i by a custom.", param)); - } - else - { - Send_Debug_Message(StringClass::getFormattedString("Object at Slot 1 was tried to change with object %i but object was unable to found.", param)); - } - } - if (type == 15731) - { - GameObject *Attach = Commands->Find_Object(param); - if (Attach) - { - presetObj2 = Attach; - Send_Debug_Message(StringClass::getFormattedString("Object at Slot 2 has changed to object ID %i by a custom.", param)); - } - else - { - Send_Debug_Message(StringClass::getFormattedString("Object at Slot 2 was tried to change with object %i but object was unable to found.", param)); - } - } - if (type == 15732) - { - GameObject *Attach = Commands->Find_Object(param); - if (Attach) - { - presetObj3 = Attach; - Send_Debug_Message(StringClass::getFormattedString("Object at Slot 3 has changed to object ID %i by a custom.", param)); - } - else - { - Send_Debug_Message(StringClass::getFormattedString("Object at Slot 3 was tried to change with object %i but object was unable to found.", param)); - } - } - } - - void Timer_Expired(GameObject *obj, int number) - { - Vector3 pos = Commands->Get_Position(obj); - const char *preset1 = Get_Parameter("FirstPreset"); - const char *preset2 = Get_Parameter("SecondPreset"); - const char *preset3 = Get_Parameter("ThirdPreset"); - float facing = Commands->Get_Facing(obj); - - if (number == 0) - { - Send_Debug_Message("Cinematic ended and now scripts is being detached..."); - Commands->Send_Custom_Event(0, presetObj1, 1248753, 0, 0.0f); - Commands->Send_Custom_Event(0, presetObj2, 1248753, 0, 0.0f); - Commands->Send_Custom_Event(0, presetObj3, 1248753, 0, 0.0f); - Send_Debug_Message("Cinematic played successfully! Detaching script..."); - Destroy_Script(); - } - - else if (number == 8) - { - GameObject *nodTransportHelicopterObj = Commands->Find_Object(this->nodTransportHelicopterObjId); - if (nodTransportHelicopterObj) - { - Commands->Destroy_Object(nodTransportHelicopterObj); - Send_Debug_Message("Destroyed Chinook."); - } - else - { - Send_Debug_Message("Couldn't destroy Chinook: Object did not found."); - } - } - - else if (number == 7) - { - if (nodTransportHelicopterObj) - { - Commands->Enable_Engine(nodTransportHelicopterObj, true); - Send_Debug_Message("Enabled Chinook engine."); - } - else - { - Send_Debug_Message("Couldn't enable Chinook engine: Object did not found."); - } - } - - else if (number == 1) - { - if (this->paratrooperIndex > 0) - { - if (presetObj1) - { - GameObject *cinObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Facing(cinObj, facing); - Commands->Set_Model(cinObj, "X5D_Parachute"); - Commands->Set_Animation(cinObj, "X5D_Parachute.X5D_ParaC_1", false, NULL, 0.0f, -1.0f, false); - Commands->Create_3D_Sound_At_Bone("parachute_open", cinObj, "ROOTTRANSFORM"); - Commands->Attach_Script(cinObj, "M03_No_More_Parachute", ""); - Send_Debug_Message("Enabled chute for the object at slot 1."); - } - else - { - Send_Debug_Message("Couldn't enabled chute for the object at slot 1: Object did not found."); - } - } - } - - else if (number == 2) - { - if (this->paratrooperIndex > 1) - { - if (presetObj2) - { - GameObject *cinObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Facing(cinObj, facing); - Commands->Set_Model(cinObj, "X5D_Parachute"); - Commands->Set_Animation(cinObj, "X5D_Parachute.X5D_ParaC_2", false, NULL, 0.0f, -1.0f, false); - Commands->Create_3D_Sound_At_Bone("parachute_open", cinObj, "ROOTTRANSFORM"); - Commands->Attach_Script(cinObj, "M03_No_More_Parachute", ""); - Send_Debug_Message("Enabled chute for the object at slot 2."); - } - else - { - Send_Debug_Message("Couldn't enabled chute for the object at slot 2: Object did not found."); - } - } - } - - else if (number == 3) - { - if (this->paratrooperIndex == 3) - { - if (presetObj3) - { - GameObject *cinObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Facing(cinObj, facing); - Commands->Set_Model(cinObj, "X5D_Parachute"); - Commands->Set_Animation(cinObj, "X5D_Parachute.X5D_ParaC_3", false, NULL, 0.0f, -1.0f, false); - Commands->Create_3D_Sound_At_Bone("parachute_open", cinObj, "ROOTTRANSFORM"); - Commands->Attach_Script(cinObj, "M03_No_More_Parachute", ""); - Send_Debug_Message("Enabled chute for the object at slot 3."); - } - else - { - Send_Debug_Message("Couldn't enabled chute for the object at slot 3: Object did not found."); - } - } - } - - else if (number == 4) - { - if (!this->chinookKilled) - { - if (Is_Valid_Preset(preset1) || presetObj1) - { - Send_Debug_Message("Initializing drop animation for object at slot 1..."); - GameObject *trajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Model(trajectoryObj, "X5D_Box01"); - Commands->Set_Facing(trajectoryObj, facing); - Commands->Set_Animation(trajectoryObj, "X5D_Box01.X5D_Box01", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message(" Animation created! Attaching object..."); - if (!presetObj1) - { - presetObj1 = Commands->Create_Object_At_Bone(trajectoryObj, preset1, "Box01"); - Send_Debug_Message(" The object have been created."); - } - else - { - Send_Debug_Message(" Object is already attached by a custom event!"); - } - - if (presetObj1) - { - if (Check_Object(presetObj1)) - { - Commands->Set_Facing(presetObj1, facing); - Send_Debug_Message(" Facing adjusted."); - Attach_Script_Once(presetObj1, "DB_Innate_Soldier", "0.5,0,0,0"); - Attach_Script_Once(presetObj1, "MC_Unkillable_Until_Custom", "1248753"); - Commands->Attach_Script(presetObj1, "RMV_Trigger_Killed", "1144444, 1000, 1000"); - Commands->Attach_Script(presetObj1, "M03_Killed_Sound", ""); - Commands->Attach_Script(presetObj1, "DLS_Volcano_Stumble", ""); - Send_Debug_Message(" Scripts attached."); - Commands->Set_Animation(presetObj1, "s_a_human.H_A_X5D_ParaT_1", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message(" Animation set."); - } - Commands->Attach_To_Object_Bone(presetObj1, trajectoryObj, "Box01"); - Send_Debug_Message(" Object attached to trajectory."); - } - Send_Debug_Message(" This slot has completed it's initialization."); - } - else - { - Send_Debug_Message("Initialization of slot 1 has cancelled: Invalid preset and object is nothing, object cannot be useable."); - } - this->paratrooperIndex++; - } - } - - else if (number == 5) - { - if (!this->chinookKilled) - { - if (Is_Valid_Preset(preset2) || presetObj2) - { - Send_Debug_Message("Initializing drop animation for object at slot 2..."); - GameObject *trajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Model(trajectoryObj, "X5D_Box02"); - Commands->Set_Facing(trajectoryObj, facing); - Commands->Set_Animation(trajectoryObj, "X5D_Box02.X5D_Box02", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message(" Animation created! Attaching object..."); - if (!presetObj2) - { - presetObj2 = Commands->Create_Object_At_Bone(trajectoryObj, preset2, "Box02"); - Send_Debug_Message(" The object have been created."); - } - else - { - Send_Debug_Message(" Object is already attached by a custom event!"); - } - - if (presetObj2) - { - if (Check_Object(presetObj2)) - { - Commands->Set_Facing(presetObj2, facing); - Send_Debug_Message(" Facing adjusted."); - Attach_Script_Once(presetObj2, "DB_Innate_Soldier", "0.5,0,0,0"); - Attach_Script_Once(presetObj2, "MC_Unkillable_Until_Custom", "1248753"); - Commands->Attach_Script(presetObj2, "RMV_Trigger_Killed", "1144444, 1000, 1000"); - Commands->Attach_Script(presetObj2, "M03_Killed_Sound", ""); - Commands->Attach_Script(presetObj2, "DLS_Volcano_Stumble", ""); - Send_Debug_Message(" Scripts attached."); - Commands->Set_Animation(presetObj2, "s_a_human.H_A_X5D_ParaT_2", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message(" Animation set."); - } - Commands->Attach_To_Object_Bone(presetObj2, trajectoryObj, "Box02"); - Send_Debug_Message(" Object attached to trajectory."); - } - Send_Debug_Message(" This slot has completed it's initialization."); - } - else - { - Send_Debug_Message("Initialization of slot 2 has cancelled: Invalid preset and object is nothing, object cannot be useable."); - } - this->paratrooperIndex++; - } - } - - else if (number == 6) - { - if (!this->chinookKilled) - { - if (Is_Valid_Preset(preset3) || presetObj3) - { - Send_Debug_Message("Initializing drop animation for object at slot 3..."); - GameObject *trajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); - Commands->Set_Model(trajectoryObj, "X5D_Box03"); - Commands->Set_Facing(trajectoryObj, facing); - Commands->Set_Animation(trajectoryObj, "X5D_Box03.X5D_Box03", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message(" Animation created! Attaching object..."); - - if (!presetObj3) - { - presetObj3 = Commands->Create_Object_At_Bone(trajectoryObj, preset3, "Box03"); - Send_Debug_Message(" The object have been created."); - } - else - { - Send_Debug_Message(" Object is already attached by a custom event!"); - } - - if (presetObj3) - { - if (Check_Object(presetObj3)) - { - Commands->Set_Facing(presetObj3, facing); - Send_Debug_Message(" Facing adjusted."); - Attach_Script_Once(presetObj3, "DB_Innate_Soldier", "0.5,0,0,0"); - Attach_Script_Once(presetObj3, "MC_Unkillable_Until_Custom", "1248753"); - Commands->Attach_Script(presetObj3, "RMV_Trigger_Killed", "1144444, 1000, 1000"); - Commands->Attach_Script(presetObj3, "M03_Killed_Sound", ""); - Commands->Attach_Script(presetObj3, "DLS_Volcano_Stumble", ""); - Send_Debug_Message(" Scripts attached."); - Commands->Set_Animation(presetObj3, "s_a_human.H_A_X5D_ParaT_3", false, NULL, 0.0f, -1.0f, false); - Send_Debug_Message(" Animation set."); - } - Commands->Attach_To_Object_Bone(presetObj3, trajectoryObj, "Box03"); - Send_Debug_Message(" Object attached to trajectory."); - } - Send_Debug_Message(" This slot has completed it's initialization."); - } - else - { - Send_Debug_Message("Initialization of slot 3 has cancelled: Invalid preset and object is nothing, object cannot be useable."); - } - this->paratrooperIndex++; - } - } - } -}; - -class MC_Unkillable_Until_Custom : public ScriptImpClass -{ - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == Get_Int_Parameter("Message")) - { - Destroy_Script(); - } - } - - void Damaged(GameObject *obj, GameObject *damager, float amount) - { - float maxHealth = Commands->Get_Max_Health(obj); - Commands->Set_Health(obj, maxHealth); - } -}; - -class MC_AttachScript_On_Kill : public ScriptImpClass -{ - void Killed(GameObject *obj, GameObject *killer) - { - Attach_Script_Once(Commands->Find_Object(Get_Int_Parameter("ObjectID")), Get_Parameter("Script"), Get_Parameter("Parameters")); - Destroy_Script(); - } - - void Destroyed(GameObject *obj) - { - Attach_Script_Once(Commands->Find_Object(Get_Int_Parameter("ObjectID")), Get_Parameter("Script"), Get_Parameter("Parameters")); - Destroy_Script(); - } -}; - -class MC_AttachScript_Interval_Self : public ScriptImpClass -{ - const char *Script; - const char *Parameters; - float Interval; - int LoopCount; - int Looped; - void Created(GameObject *obj) - { - Script = Get_Parameter("Script"); - Parameters = Get_Parameter("Parameters"); - Commands->Start_Timer(obj, this, Interval, 234245); - LoopCount = Get_Int_Parameter("LoopCount"); - Looped = 0; - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 234245) - { - Attach_Script_Once(obj, Script, Parameters); - if (LoopCount != -1) - { - if (Looped >= LoopCount) - { - Destroy_Script(); - } - else - { - Commands->Start_Timer(obj, this, Interval, 234245); - } - } - else - { - Commands->Start_Timer(obj, this, Interval, 234245); - } - } - } -}; - -class MC_AttachScript_Interval : public ScriptImpClass -{ - const char *Script; - const char *Parameters; - GameObject *Target; - float Interval; - int LoopCount; - int Looped; - void Created(GameObject *obj) - { - Target = Commands->Find_Object(Get_Int_Parameter("ObjectID")); - Script = Get_Parameter("Script"); - Parameters = Get_Parameter("Parameters"); - Commands->Start_Timer(obj, this, Interval, 234244); - LoopCount = Get_Int_Parameter("LoopCount"); - Looped = 0; - - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 234244) - { - Attach_Script_Once(Target, Script, Parameters); - if (LoopCount != -1) - { - if (Looped >= LoopCount) - { - Destroy_Script(); - } - else - { - Commands->Start_Timer(obj, this, Interval, 234244); - } - } - else - { - Commands->Start_Timer(obj, this, Interval, 234244); - } - } - } -}; - -class MC_Object_Follower_AI : public ScriptImpClass -{ - int TargetChangeCustom; - int DestroyScriptCustom; - GameObject *TargetObject; - - void Created(GameObject *obj) - { - TargetChangeCustom = Get_Int_Parameter("TargetChangeCustomID"); - DestroyScriptCustom = Get_Int_Parameter("DestroyScriptCustomID"); - } - - void Custom(GameObject *obj, int type, int param, GameObject *sender) - { - if (type == TargetChangeCustom) - { - GameObject *Target = Commands->Find_Object(param); - if (Target) - { - TargetObject = Target; - ActionParamsStruct Parameters; - Parameters.Set_Basic(this, 100.0f, 20000); - Parameters.Set_Movement(Target, 0.8f, 2.5f); - } - } - else if (type == DestroyScriptCustom) - { - Destroy_Script(); - } - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 12314178) - { - if (TargetObject) - { - ActionParamsStruct Parameters; - Parameters.Set_Basic(this, 100.0f, 20000); - Parameters.Set_Movement(TargetObject, 0.8f, 2.5f); - } - } - } -}; - -class MC_Private_Color_Message_On_Poke : public ScriptImpClass -{ - bool Pokeable; - void Created(GameObject *obj) - { - Pokeable = true; - Commands->Enable_HUD_Pokable_Indicator(obj, true); - } - - void Timer_Expired(GameObject *obj, int number) - { - if (number == 1) - { - Pokeable = true; - Commands->Enable_HUD_Pokable_Indicator(obj, true); - } - } - - void Poked(GameObject *obj, GameObject *poker) - { - if (Pokeable) - { - Send_Message_Player(poker, Get_Int_Parameter("Red"), Get_Int_Parameter("Green"), Get_Int_Parameter("Blue"), Get_Parameter("Message")); - Pokeable = false; - Commands->Enable_HUD_Pokable_Indicator(obj, false); - Commands->Start_Timer(obj, this, 5.0f, 1); - } - } -}; - -/* NotTest: Not tested yet */ -/* Working: Completely working */ -/* HasBugs: Has at least 1 bug */ -/* NotWork: Not working. Going to be fixed */ -/* Working */ ScriptRegistrant MC_Stop_Vehicle_Engine_Registrant("MC_Stop_Vehicle_Engine", "Duration=0:float"); -/* Working */ ScriptRegistrant MC_Vehicle_Purchase_Terminal_Registrant("MC_Vehicle_Purchase_Terminal", "Team=0:int,SpawnerID=0:int,VehiclePreset:string,Credits=400:int"); -/* Working */ ScriptRegistrant MC_Character_Purchase_Terminal_Registrant("MC_Character_Purchase_Terminal", "Team=0:int,CharacterPreset:string,Credits=400:int"); -/* Working */ ScriptRegistrant MC_HUD_Message_Zone_Registrant("MC_HUD_Message_Zone", "Message=YourMessage:string,Sound=SoundName.wav:string,Red=16.0:float,Green=255.0:float,Blue=16.0:float"); -/* Working */ ScriptRegistrant MC_Teleport_Registrant("MC_Teleport", "ArrowID=0:int,TeleportSound=SoundName.wav:string"); -/* Working */ ScriptRegistrant MC_Change_Vehicle_Weapon_Registrant("MC_Change_Vehicle_Weapon", "Preset=Weapon:string,Rounds=1:int"); -/* Working */ ScriptRegistrant MC_Change_Vehicle_Weapon_Zone_Registrant("MC_Change_Vehicle_Weapon_Zone", "Preset=Weapon:string,Rounds=1:int"); -/* Working */ ScriptRegistrant MC_Grant_Weapon_Registrant("MC_Grant_Weapon", "Preset=Weapon:string,Rounds=1:int"); -/* Working */ ScriptRegistrant MC_Grant_Weapon_Zone_Registrant("MC_Grant_Weapon_Zone", "Preset=Weapon:string,Rounds=1:int"); -/* Working */ ScriptRegistrant MC_Grant_Character_Registrant("MC_Grant_Character", "Preset=Character:string"); -/* Working */ ScriptRegistrant MC_Grant_Character_Zone_Registrant("MC_Grant_Character_Zone", "Preset=Character:string"); -/* Working */ ScriptRegistrant MC_Spawn_When_Fully_Repaired_Registrant("MC_Spawn_When_Fully_Repaired", "Preset=Weapon:string"); -/* Working */ ScriptRegistrant MC_Refinery_Object_Registrant("MC_Refinery_Object", "Team=0:int,Interval=1.0:float,Amount=2.0:float"); -/* Working */ ScriptRegistrant MC_GameOver_When_Kill_Registrant("MC_GameOver_When_Kill", ""); -/* Working */ ScriptRegistrant MC_Spawn_When_Death_Registrant("MC_Spawn_When_Death", "Preset=Object:string"); -/* Working */ ScriptRegistrant MC_MasterControlTerminal_Object_Registrant("MC_MasterControlTerminal_Object", "Object:int,Multiply=1.00:int"); -/* Working */ ScriptRegistrant MC_MCTMainSyncObject_Registrant("MC_MCTMainSyncObject", "MCT_ObjectID:int"); -/* Working */ ScriptRegistrant MC_Set_Team_When_Exit_Registrant("MC_Set_Team_When_Exit", "Team=-1:int"); -/* Working */ ScriptRegistrant MC_IonExplosion_When_Death_Registrant("MC_IonExplosion_When_Death", ""); -/* Working */ ScriptRegistrant MC_Capturable_Object_Registrant("MC_Capturable_Object", "Red=16:int,Green=255:int,Blue=16:int,RepairSound:string,DestroySound:string,RepairMessage:string,DestroyMessage:string,InitialTeam=-2:int"); -/* Working */ ScriptRegistrant MC_FlyMode_On_Registrant("MC_FlyMode_On", ""); -/* Working */ ScriptRegistrant MC_FlyMode_Off_Registrant("MC_FlyMode_Off", ""); -/* Working */ ScriptRegistrant MC_FlyModeZone_On_Registrant("MC_FlyModeZone_On", ""); -/* Working */ ScriptRegistrant MC_FlyModeZone_Off_Registrant("MC_FlyModeZone_Off", ""); -/* Working */ ScriptRegistrant MC_Spectate_Registrant("MC_Spectate", ""); -/* Working */ ScriptRegistrant MC_Spectate_Zone_Registrant("MC_Spectate_Zone", ""); -/* HasBugs */ ScriptRegistrant MC_Beacon_Block_Zone_Registrant("MC_Beacon_Block_Zone", "Red=16:int,Green=255:int,Blue=16:int,BlockMessage:string"); -/* Working */ ScriptRegistrant MC_Objective_Message_Sender_Registrant("MC_Objective_Message_Sender", "Message=Use_Underscore_For_Space:string"); -/* Working */ ScriptRegistrant MC_Objective_Controller_Registrant("MC_Objective_Controller", "Objectives=Objective-Objects-IDs-Here-Minus-Is-Delimeter:string,MessageObject=100000:int,Debug=1:int"); -/* Working */ ScriptRegistrant MC_Objective_Listener_Registrant("MC_Objective_Listener", "Objective=100000:int,Trigger:string,CustomID:int,OnlyStarCanTrigger:int,Debug=1:int"); -/* Working */ ScriptRegistrant MC_Objective_Registrant("MC_Objective", "Message=Use_Underscore_For_Space:string,ObjectiveOrder=0:int,ObjectiveCompleteType=Must_be_KILLOBJECT_ENTER_POKE_or_NONE:string,StarTrigger=0:int,Listener=100000:int,ParameterObject=100000:int,Debug=1:int"); -/* Working */ ScriptRegistrant MC_Destroy_When_Objective_Completed_Registrant("MC_Destroy_When_Objective_Completed", "ObjectiveArrow=100000:int"); -/* Working */ ScriptRegistrant MC_Select_Weapon_On_Zone_Registrant("MC_Select_Weapon_On_Zone", "EnterWeaponPreset:string,ExitWeaponPreset:string"); -/* Working */ ScriptRegistrant MC_Select_Weapon_On_Zone_Enter_Registrant("MC_Select_Weapon_On_Zone_Enter", "WeaponPreset:string"); -/* Working */ ScriptRegistrant MC_Select_Weapon_On_Zone_Exit_Registrant("MC_Select_Weapon_On_Zone_Exit", "WeaponPreset:string"); -/* Working */ ScriptRegistrant MC_Chinook_Reinforcements_Paradrop_Registrant("MC_Chinook_Reinforcements_Paradrop", "FirstPreset:string,SecondPreset:string,ThirdPreset:string,Debug=1:int"); -/* Working */ ScriptRegistrant MC_Unkillable_Until_Custom_Registrant("MC_Unkillable_Until_Custom", "Message:int"); -/* Working */ ScriptRegistrant MC_AttachScript_On_Kill_Registrant("MC_AttachScript_On_Kill", "ObjectID:int,Script:string,Parameters:string"); -/* Working */ ScriptRegistrant MC_AttachScript_Interval_Self_Registrant("MC_AttachScript_Interval_Self", "Script:string,Parameters:string,LoopCount=-1:int"); -/* Working */ ScriptRegistrant MC_AttachScript_Interval_Registrant("MC_AttachScript_Interval", "ObjectID:int,Script:string,Parameters:string,LoopCount=-1:int"); -/* Working */ ScriptRegistrant MC_Private_Color_Message_On_Poke_Registrant("MC_Private_Color_Message_On_Poke", "Red=255:int,Green=255:int,Blue=255:int,Message=Message:string"); \ No newline at end of file diff -urN sourceold/scripts/WeaponClass.h source/scripts/WeaponClass.h --- sourceold/scripts/WeaponClass.h 2018-11-17 10:23:57.121600000 +1000 +++ source/scripts/WeaponClass.h 2022-02-13 10:20:09.853929700 +1000 @@ -155,6 +155,7 @@ //new SCRIPTS_API float Get_Targeting_Range(void); bool Tilt_Gun_While_Reloading(){return tiltGunWhileReloading && Definition->DoTiltWhileReloading;} + float Get_Charge_Time(); private: void Fire_C4( const AmmoDefinitionClass *ammo_def ); bool Fire_Beacon( const AmmoDefinitionClass *ammo_def ); diff -urN sourceold/scripts/dp88_ar.cpp source/scripts/dp88_ar.cpp --- sourceold/scripts/dp88_ar.cpp 2020-09-10 09:08:27.950898100 +1000 +++ source/scripts/dp88_ar.cpp 2022-02-13 10:20:09.855344300 +1000 @@ -532,14 +532,9 @@ float distance = Commands->Get_Distance(Commands->Get_Position(deployedObject),Commands->Get_Position(obj)); // If more than 3m away, undeploy - if ( deployedObject != NULL && distance > 1.5f ) + if ( !deployedObject || distance > 1.5f ) { Undeploy(obj); - - // Remove script to punish abusers - Send_Message_Player(obj, DP88_RGB_ERROR_MSG, StringClass::getFormattedString("Deployment abuse detected, disabling deploy script... (distance from deployment: %.2fm)", distance)); - RemoveHook(); - Destroy_Script(); return; } diff -urN sourceold/scripts/engine_pt.cpp source/scripts/engine_pt.cpp --- sourceold/scripts/engine_pt.cpp 2020-09-10 09:08:27.956842600 +1000 +++ source/scripts/engine_pt.cpp 2022-02-13 10:20:09.857265300 +1000 @@ -49,6 +49,14 @@ if (!cost) { cost = Get_Team_Cost(def_id,1); + if (!cost) + { + cost = Get_Team_Cost(def_id,2); + if (!cost) + { + cost = Get_Team_Cost(def_id,3); + } + } } return cost; } diff -urN sourceold/scripts/jmgBearHunter.cpp source/scripts/jmgBearHunter.cpp --- sourceold/scripts/jmgBearHunter.cpp 2021-07-27 14:44:22.790989600 +1000 +++ source/scripts/jmgBearHunter.cpp 2022-02-13 10:20:09.861087100 +1000 @@ -25,7 +25,7 @@ #include "jmgUtility.h" #include "jmgBearHunter.h" - +//Current Objective 28 void JMG_Bear_Hunter_Player_Soldier::Created(GameObject *obj) { Attach_Script_Once(obj,"JMG_Bear_Hunter_Kill_Score_Tracker",""); @@ -231,15 +231,17 @@ case 0:break; case 1:Commands->Set_Model(obj,"c_masterbleat");break; case 2:Commands->Set_Model(obj,"c_knight_deer");break; - case 3:Commands->Set_Model(obj,"c_fremen_deer");break; + case 3:Commands->Set_Model(obj,"c_bfd_deer");break; case 4:Commands->Set_Model(obj,"c_gz_deer");break; case 5:Commands->Set_Model(obj,"c_apb_deer");break; case 6:Commands->Set_Model(obj,"c_gi_deer");break; case 7:Commands->Set_Model(obj,"c_ia_deer");break; case 8:Commands->Set_Model(obj,"c_cmd_deer");break; case 9:Commands->Set_Model(obj,"c_ren_deer");break; - case 10:Commands->Set_Model(obj,"c_hobo_deer");break; + case 10:Commands->Set_Model(obj,"c_ecw_deer");break; case 11:Commands->Set_Model(obj,"c_tsr_deer");break; + case 12:Commands->Set_Model(obj,"c_okt_deer");break; + case 13:Commands->Set_Model(obj,"c_pilgrim_deer");break; } GrantSpecialUnlocks(obj); } @@ -499,6 +501,7 @@ int BearHunterVoiceSystem::voiceId[128] = {0}; void JMG_Bear_Hunter_Game_Control::Created(GameObject *obj) { + hasReturnedTurkeys = false; bonusObjectiveCount = 0; hasBeenInjured = false; spawnKarma = 0; @@ -524,6 +527,8 @@ playerAlive[x] = true; wanderingAiIgnorePlayers[x] = 0; BearHunterVoiceSystem::voiceId[x] = 0; + playerReturnedTurkeys[x] = 0; + playerReturnedTurkeysDelay[x] = 0; } bossRabitDead = 0; bearTransition = 0; @@ -855,6 +860,24 @@ } } } + for (int x = 1;x < 128;x++) + { + if (playerReturnedTurkeysDelay[x]) + { + playerReturnedTurkeysDelay[x]--; + if (!playerReturnedTurkeysDelay[x]) + { + char turkeyCash[220]; + sprintf(turkeyCash,"Bear Rug Co: Here is $%.2f for collecting turkeys!",playerReturnedTurkeys[x]*100.0f); + BearHunterVoiceSystem::PlayVoice(Get_GameObj(x),"BH100.mp3",turkeyCash); + Commands->Give_Money(Get_GameObj(x),playerReturnedTurkeys[x]*100.0f,false); + BearHunterScoreSystem::BHScoreNode *node = bearHunterScoreSystem.Get_Current_Player_Score_Node(x); + if (node) + node->ReturnedTurkey += playerReturnedTurkeys[x]; + playerReturnedTurkeys[x] = 0; + } + } + } Commands->Start_Timer(obj,this,1.0f,1); } if (number == 2) @@ -949,6 +972,13 @@ IncreaseBonusObjectiveCount(15); NewObjectiveSystemControl.Add_Objective(15,NewObjectiveSystem::Bonus,NewObjectiveSystem::Pending,12741,"",12741,bonusObjectiveCount); } + if (gameTime == 1690) + { + turkeysExist = true; + GameObject *turkeySpawnControl = Commands->Find_Object(100284); + if (turkeySpawnControl) + Commands->Send_Custom_Event(turkeySpawnControl,turkeySpawnControl,100284,1,0.0f); + } if (gameTime == 1500) { BearHunterVoiceSystem::PlayVoice("BH16.mp3","Bear Rug Co: Half way there, you guys better get those bears while you can, because they won't be worth much when we hit our quota!"); @@ -1148,6 +1178,33 @@ Commands->Set_Is_Rendered(cinematic,false); Commands->Attach_Script(cinematic,"Test_Cinematic","medicine_drop.txt"); } + if (gameTime == 300) + { + GameObject *turkeySpawnControl = Commands->Find_Object(100284); + if (turkeySpawnControl) + Commands->Send_Custom_Event(turkeySpawnControl,turkeySpawnControl,100284,0,0.0f); + } + if (gameTime < 300 && turkeysExist) + { + turkeysExist = false; + for (SLNode *current = GameObjManager::SmartGameObjList.Head();current;current = current->Next()) + { + SmartGameObj* o = current->Data(); + if (o && Is_Script_Attached(o,"JMG_Bear_Hunter_Turkey") && Commands->Get_Health(o)) + { + Commands->Apply_Damage(o,1.0f,"None",0); + turkeysExist = true; + } + } + if (!turkeysExist && NewObjectiveSystemControl.Get_Objective_Status(28) == NewObjectiveSystem::Status::Pending) + { + BearHunterVoiceSystem::PlayVoice("BH101.mp3","Bear Rug Co: Looks like the turkeys are all gone!"); + if (hasReturnedTurkeys) + NewObjectiveSystemControl.Set_Objective_Status(28,NewObjectiveSystem::Status::Accomplished); + else + NewObjectiveSystemControl.Set_Objective_Status(28,NewObjectiveSystem::Status::Failed); + } + } if (gameTime == 240) { if (NewObjectiveSystemControl.Get_Objective_Status(21) == NewObjectiveSystem::Pending && NewObjectiveSystemControl.Get_Mission_Text_Id(21) != 12790) @@ -1966,6 +2023,16 @@ Grant_Weapon(player,"Weapon_Milk_2Percent",true,500,true); } } + if (message == 100287) + { + GameObject *player = Commands->Find_Object(param); + if (!player) + return; + hasReturnedTurkeys = true; + int playerId = JmgUtility::JMG_Get_Player_ID(player); + playerReturnedTurkeysDelay[playerId] = 2; + playerReturnedTurkeys[playerId]++; + } } void JMG_Bear_Hunter_Game_Control::Destroyed(GameObject *obj) { @@ -6051,6 +6118,7 @@ case 1000000036:case 1000000038:case 1000000040:node->KilledMutantCougars++;break; case 1000000249:case 1000000263:case 1000000265:node->KilledCows++;break; case 1000000260:case 1000000267:case 1000000269:node->KilledMice++;break; + case 1000000587:case 1000000589:case 1000000591:node->KilledTurkey++;break; default:node->KilledHumanAi++;break; } } @@ -8382,8 +8450,10 @@ bool JMG_Utility_AI_Skittish_Herd_Animal::Get_A_Wander_Point(Vector3 *position,int wanderPointGroup) { Rp2SimplePositionSystem::SimplePositionNode *node = NULL; - if (wanderPointGroup != -1) + if (wanderPointGroup == -1) node = JMG_Wandering_AI_Controller::wanderPoints.GetNearest(*position); + else + node = JMG_Wandering_AI_Controller::wanderPoints.GetNearestFromGroup(wanderPointGroup,*position); if (!node) { Console_Input("msg JMG_Utility_AI_Skittish_Herd_Animal ERROR: No wander points could be found for that group!"); @@ -8485,6 +8555,20 @@ *position = node->position; return true; } +bool JMG_Utility_AI_Goto_Target_Script::GetRandomPosition(Vector3 *position) +{ + Rp2SimplePositionSystem::SimplePositionNode *node = NULL; + if (wanderingAiGroupId != -1) + node = JMG_Wandering_AI_Controller::wanderPoints.GetRandomFromGroup(wanderingAiGroupId); + if (!node) + { + Console_Input("msg JMG_Utility_AI_Goto_Target_Script ERROR: No wander points could be found for that group!"); + *position = Vector3(); + return false; + } + *position = node->position; + return true; +} bool JMG_Utility_AI_Engineer::Get_Random_Wander_Point(Vector3 *position) { Rp2SimplePositionSystem::SimplePositionNode *node = NULL; @@ -9367,6 +9451,13 @@ } return NULL; } +void JMG_Bear_Hunter_Turkey::Killed(GameObject *obj,GameObject *killer) +{ + if (killer == NULL || !Commands->Is_A_Star(killer) || NewObjectiveSystemControl.Get_Objective_Status(28) != NewObjectiveSystem::NotDefined) + return; + BearHunterVoiceSystem::PlayVoice("BH102.mp3","Bear Rug Co: Looks like you found some turkeys, bring them to the processing plant for market price."); + NewObjectiveSystemControl.Add_Objective(28,NewObjectiveSystem::Bonus,NewObjectiveSystem::Pending,12864,"",12864); +} ScriptRegistrant JMG_Bear_Hunter_Player_Soldier_Registrant("JMG_Bear_Hunter_Player_Soldier",""); ScriptRegistrant JMG_Rp2_Dedicated_Server_Sound_Emulator_Registrant("JMG_Rp2_Dedicated_Server_Sound_Emulator",""); ScriptRegistrant JMG_Bear_Hunter_Game_Control_Registrant("JMG_Bear_Hunter_Game_Control","PositionFile=DhSwampDeerPositions.ecw:string"); @@ -9469,4 +9560,4 @@ ScriptRegistrant JMG_Bear_Hunter_AI_Guardian_Generic_Registrant("JMG_Bear_Hunter_AI_Guardian_Generic","WanderingAIGroupID:int,WanderSpeed=1.0:float,FireRange=-1.0:float,FaceTarget=1:int,CheckBlocked=1:int,ArriveDistance=1.0:float,FlightHeight=0.0:float,TurnOffEngineOnArrival=1:int,UseSecondaryAttack=0:int,StealthModeOverride=0:int"); ScriptRegistrant JMG_Bear_Hunter_Give_AI_Cash_For_Kills_Registrant("JMG_Bear_Hunter_Give_AI_Cash_For_Kills",""); ScriptRegistrant JMG_Wandering_AI_Wander_Point_Follow_Weapon_Or_Obj_Registrant("JMG_Wandering_AI_Wander_Point_Follow_Weapon_Or_Obj","GroupId:int,PresetName:string,WeaponName:string"); - \ No newline at end of file +ScriptRegistrant JMG_Bear_Hunter_Turkey_Registrant("JMG_Bear_Hunter_Turkey",""); diff -urN sourceold/scripts/jmgBearHunter.h source/scripts/jmgBearHunter.h --- sourceold/scripts/jmgBearHunter.h 2021-07-27 14:44:22.791987200 +1000 +++ source/scripts/jmgBearHunter.h 2022-02-13 10:20:09.862085500 +1000 @@ -977,6 +977,10 @@ int wildMountainLionsPet; int cowId; int cowWanderId; + int playerReturnedTurkeys[128]; + int playerReturnedTurkeysDelay[128]; + bool turkeysExist; + bool hasReturnedTurkeys; void Created(GameObject *obj); void Timer_Expired(GameObject *obj,int number); void Custom(GameObject *obj,int message,int param,GameObject *sender); @@ -1090,7 +1094,7 @@ struct BearHunterScoreSystem { public: - #define BHHighScoreListCount 122 + #define BHHighScoreListCount 124 struct BHScoreNode { char PlayerName[256]; @@ -1218,6 +1222,8 @@ unsigned long PumpJackMoney; unsigned long MobilePumpJackMoney; unsigned long Rank; + unsigned long KilledTurkey; + unsigned long ReturnedTurkey; bool startedRound; unsigned long totalObjectivesCompleted; @@ -1364,6 +1370,8 @@ PumpJackMoney = 0; MobilePumpJackMoney = 0; Rank = 0; + KilledTurkey = 0; + ReturnedTurkey = 0; startedRound = JMG_Bear_Hunter_Game_Control::gameState >= JMG_Bear_Hunter_Game_Control::HuntBears ? true : false; totalObjectivesCompleted = 0; @@ -1574,14 +1582,14 @@ Current->SupportReceivedHpVehicleSelf += (unsigned long)Current->tmpSupportReceivedHpVehicleSelf; Current->Rank = ++currentRank; char EncryptString[2048]; - sprintf(EncryptString,"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu 0", + sprintf(EncryptString,"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu 0", Current->PlayTime,Current->PreGameTime,Current->IdleTime,Current->RoundsPlayed,Current->RoundsCompleted,Current->RoundsQuit,Current->RoundsWon,Current->RoundsLost,Current->MostKillsInARound,Current->MostDeathsInARound,Current->MostBonusObjectivesCompletedInARound,Current->Deaths,Current->Kills,Current->VehicleKills,Current->KilledSelf,Current->KilledPlayers,Current->KilledPresident,Current->KilledTurrets,Current->KilledBears,Current->KilledBlackBears,Current->KilledMutantBears,Current->KilledMutantDeer,Current->KilledMutantCats,Current->KilledMutantCatsB, Current->KilledMutantCatsR,Current->KilledMutantRabbits,Current->ObjectiveActivatedAlarm,Current->ObjectiveTurretTruck,Current->ObjectiveTurretTruckAlarm,Current->ObjectiveOilRigsActivated,Current->ObjectiveOilRigsRepaired,Current->ObjectiveEngineersSaved,Current->ObjectiveWeaponsFound,Current->ObjectiveWeaponsReturned,Current->ObjectivePlasmaRifleReturned,Current->BonusObjectivesCompleted,Current->PickedupHealthPowerups,Current->PickedupArmorPowerups,Current->PickedupCashPowerups,Current->PickedupAmmoPowerups,Current->PickedupHealthTotal,Current->PickedupArmorTotal, Current->PickedupCashTotal,Current->PickedupAmmoTotal,Current->PickedupTotalPowerups,Current->PickedupTotalPowerupsInARound,Current->KilledHumanAi,Current->VehiclesDestroyed,Current->VehiclesLost,Current->JazzsLost,Current->CleasansLost,Current->TrucksLost,Current->TanksLost,Current->TurretTruckLost,Current->C4VestPowerups,Current->ActivatedCommTower,Current->PlayedGamesWithDefenseTurrets,Current->PlayedGamesWithGuardianHelicopter,Current->TimesDrown,Current->TimesFallen,Current->KillsWithSentryTurret,Current->KilledSentryTurrets,Current->SentryTurretsPlaced, Current->SentryTurretsLost,Current->PickedUpMedicalNeedle,Current->ReturnedMedicalNeedle,Current->RepairedSubstation,Current->SubstationOnLineAtEnd,Current->SubstationNotDamaged,Current->GiantDeerKilled,Current->SurvivedAlarm,Current->WolfKilled,Current->MutantDogKilled,Current->BlueDeerKilled,Current->CheatedRounds,Current->NeverInjured,Current->MooseKilled,Current->MooseKilled,Current->EatenByRabbit,Current->EatenByRabbit,Current->PickedUpDeerStatue,Current->DroppedDeerStatue,Current->ReturnedDeerStatue,Current->TinyDeerKilled,Current->MutantSquirrelsKilled, Current->WildDeerKilled,Current->WildSquirrelsKilled,Current->ArmoredCarsLost,Current->WarriorsLost,Current->TimeOnFoot,Current->TimeInAJazzs,Current->TimeInACleasans,Current->TimeInASecurityTruck,Current->TimeInArmoredCars,Current->TimeInAUDVs,Current->TimeInGatlingTanks,Current->TimeInIFVs,Current->FriendlyTinyDeerKilled,Current->LastPlayTime.day,Current->LastPlayTime.month,Current->LastPlayTime.year,Current->LastPlayTime.second,Current->LastPlayTime.minute,Current->LastPlayTime.hour,Current->LastPlayTime.lTime,Current->SupportReceivedInfantryHp, Current->SupportReceivedVehicleHp,Current->SupportReceivedAmmo,Current->SupportGrantedHpInfantry,Current->SupportGrantedHpVehicle,Current->SupportGrantedAmmo,Current->SupportReceivedHpInfantrySelf,Current->SupportReceivedHpVehicleSelf,Current->SupportReceivedAmmoSelf,Current->PettedCougars,Current->KilledCougars,Current->KilledMutantCougars,Current->FailedPettingCougars,Current->KilledFriendlyCougars,Current->DiedTryingToEscapeBase,Current->RescuedCows,Current->KilledCows,Current->LostCows,Current->CompletedCowObjective,Current->KilledMice, - Current->CompledMiceObjective,Current->KilledPortablePumpJacks,Current->PortablePumpJacksPlaced,Current->PortablePumpJacksLost,Current->PumpJackMoney,Current->MobilePumpJackMoney,Current->Rank); + Current->CompledMiceObjective,Current->KilledPortablePumpJacks,Current->PortablePumpJacksPlaced,Current->PortablePumpJacksLost,Current->PumpJackMoney,Current->MobilePumpJackMoney,Current->Rank,Current->KilledTurkey,Current->ReturnedTurkey); fprintf(SaveScores2,"%s\n%s\n",Current->PlayerName,EncryptString); fprintf(SaveScores,"%s\n%s",JmgUtility::Rp2Encrypt(Current->PlayerName,25,5),JmgUtility::Rp2Encrypt2(EncryptString,Current->PlayerName[0],Current->PlayerName[1])); fprintf(SaveScores,"\n%s",JmgUtility::Rp2Encrypt(EncryptString,Current->PlayerName[1],Current->PlayerName[0])); @@ -1635,14 +1643,14 @@ break; } if (match) - sscanf(decryptedString,"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", + sscanf(decryptedString,"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", &Current->PlayTime,&Current->PreGameTime,&Current->IdleTime,&Current->RoundsPlayed,&Current->RoundsCompleted,&Current->RoundsQuit,&Current->RoundsWon,&Current->RoundsLost,&Current->MostKillsInARound,&Current->MostDeathsInARound,&Current->MostBonusObjectivesCompletedInARound,&Current->Deaths,&Current->Kills,&Current->VehicleKills,&Current->KilledSelf,&Current->KilledPlayers,&Current->KilledPresident,&Current->KilledTurrets,&Current->KilledBears,&Current->KilledBlackBears,&Current->KilledMutantBears,&Current->KilledMutantDeer,&Current->KilledMutantCats,&Current->KilledMutantCatsB, &Current->KilledMutantCatsR,&Current->KilledMutantRabbits,&Current->ObjectiveActivatedAlarm,&Current->ObjectiveTurretTruck,&Current->ObjectiveTurretTruckAlarm,&Current->ObjectiveOilRigsActivated,&Current->ObjectiveOilRigsRepaired,&Current->ObjectiveEngineersSaved,&Current->ObjectiveWeaponsFound,&Current->ObjectiveWeaponsReturned,&Current->ObjectivePlasmaRifleReturned,&Current->BonusObjectivesCompleted,&Current->PickedupHealthPowerups,&Current->PickedupArmorPowerups,&Current->PickedupCashPowerups,&Current->PickedupAmmoPowerups,&Current->PickedupHealthTotal,&Current->PickedupArmorTotal, &Current->PickedupCashTotal,&Current->PickedupAmmoTotal,&Current->PickedupTotalPowerups,&Current->PickedupTotalPowerupsInARound,&Current->KilledHumanAi,&Current->VehiclesDestroyed,&Current->VehiclesLost,&Current->JazzsLost,&Current->CleasansLost,&Current->TrucksLost,&Current->TanksLost,&Current->TurretTruckLost,&Current->C4VestPowerups,&Current->ActivatedCommTower,&Current->PlayedGamesWithDefenseTurrets,&Current->PlayedGamesWithGuardianHelicopter,&Current->TimesDrown,&Current->TimesFallen,&Current->KillsWithSentryTurret,&Current->KilledSentryTurrets,&Current->SentryTurretsPlaced, &Current->SentryTurretsLost,&Current->PickedUpMedicalNeedle,&Current->ReturnedMedicalNeedle,&Current->RepairedSubstation,&Current->SubstationOnLineAtEnd,&Current->SubstationNotDamaged,&Current->GiantDeerKilled,&Current->SurvivedAlarm,&Current->WolfKilled,&Current->MutantDogKilled,&Current->BlueDeerKilled,&Current->CheatedRounds,&Current->NeverInjured,&Current->MooseKilled,&Current->MooseKilled,&Current->EatenByRabbit,&Current->EatenByRabbit,&Current->PickedUpDeerStatue,&Current->DroppedDeerStatue,&Current->ReturnedDeerStatue,&Current->TinyDeerKilled,&Current->MutantSquirrelsKilled, &Current->WildDeerKilled,&Current->WildSquirrelsKilled,&Current->ArmoredCarsLost,&Current->WarriorsLost,&Current->TimeOnFoot,&Current->TimeInAJazzs,&Current->TimeInACleasans,&Current->TimeInASecurityTruck,&Current->TimeInArmoredCars,&Current->TimeInAUDVs,&Current->TimeInGatlingTanks,&Current->TimeInIFVs,&Current->FriendlyTinyDeerKilled,&Current->LastPlayTime.day,&Current->LastPlayTime.month,&Current->LastPlayTime.year,&Current->LastPlayTime.second,&Current->LastPlayTime.minute,&Current->LastPlayTime.hour,&Current->LastPlayTime.lTime,&Current->SupportReceivedInfantryHp, &Current->SupportReceivedVehicleHp,&Current->SupportReceivedAmmo,&Current->SupportGrantedHpInfantry,&Current->SupportGrantedHpVehicle,&Current->SupportGrantedAmmo,&Current->SupportReceivedHpInfantrySelf,&Current->SupportReceivedHpVehicleSelf,&Current->SupportReceivedAmmoSelf,&Current->PettedCougars,&Current->KilledCougars,&Current->KilledMutantCougars,&Current->FailedPettingCougars,&Current->KilledFriendlyCougars,&Current->DiedTryingToEscapeBase,&Current->RescuedCows,&Current->KilledCows,&Current->LostCows,&Current->CompletedCowObjective,&Current->KilledMice,&Current->CompledMiceObjective, - &Current->KilledPortablePumpJacks,&Current->PortablePumpJacksPlaced,&Current->PortablePumpJacksLost,&Current->PumpJackMoney,&Current->MobilePumpJackMoney,&Current->Rank); + &Current->KilledPortablePumpJacks,&Current->PortablePumpJacksPlaced,&Current->PortablePumpJacksLost,&Current->PumpJackMoney,&Current->MobilePumpJackMoney,&Current->Rank,&Current->KilledTurkey,&Current->ReturnedTurkey); } fclose(LoadScores); } @@ -1787,6 +1795,8 @@ case 119: return EveluateHighestScore(High->PortablePumpJacksLost,Current->PortablePumpJacksLost,High,Current); case 120: return EveluateHighestScore(High->PumpJackMoney,Current->PumpJackMoney,High,Current); case 121: return EveluateHighestScore(High->MobilePumpJackMoney,Current->MobilePumpJackMoney,High,Current); + case 122: return EveluateHighestScore(High->KilledTurkey,Current->KilledTurkey,High,Current); + case 123: return EveluateHighestScore(High->ReturnedTurkey,Current->ReturnedTurkey,High,Current); default: return High; } } @@ -1918,6 +1928,8 @@ case 119: return Node->PortablePumpJacksLost ? true : false; case 120: return Node->PumpJackMoney ? true : false; case 121: return Node->MobilePumpJackMoney ? true : false; + case 122: return Node->KilledTurkey ? true : false; + case 123: return Node->ReturnedTurkey ? true : false; default: Console_Input("msg SCORE SYSTEM ERROR: Out of bounds!");return false; } } @@ -2050,6 +2062,8 @@ case 119: sprintf(RetChar,"Server Record: %s has lost %s Portable Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PortablePumpJacksLost));return RetChar; case 120: sprintf(RetChar,"Server Record: %s has made $%s.00 from Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PumpJackMoney));return RetChar; case 121: sprintf(RetChar,"Server Record: %s has made $%s.00 from Portable Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MobilePumpJackMoney));return RetChar; + case 122: sprintf(RetChar,"Server Record: %s has killed %s turkeys.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledTurkey));return RetChar; + case 123: sprintf(RetChar,"Server Record: %s has made $%s.00 from bringing turkeys back to base.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ReturnedTurkey));return RetChar; default: sprintf(RetChar,"Server Record ERROR: Record index out of bounds!"); return RetChar; } } @@ -3695,4 +3709,8 @@ void Created(GameObject *obj); void Timer_Expired(GameObject *obj,int number); GameObject *FindTargetObject(GameObject *obj); +}; + +class JMG_Bear_Hunter_Turkey : public ScriptImpClass { + void Killed(GameObject *obj,GameObject *killer); }; \ No newline at end of file diff -urN sourceold/scripts/jmgMetroid.cpp source/scripts/jmgMetroid.cpp --- sourceold/scripts/jmgMetroid.cpp 2021-07-27 14:44:22.795007700 +1000 +++ source/scripts/jmgMetroid.cpp 2022-02-13 10:20:09.864907300 +1000 @@ -195,7 +195,7 @@ void JMG_Metroid_Game_Control::Created(GameObject *obj) { JMG_Metroid_Game_Control::gameRemainingTime = 0; - MetroidObjectiveSystemControl.Add_Objective(1,NewObjectiveSystem::Primary,NewObjectiveSystem::Pending,12781,"",12781,Commands->Get_Position(Commands->Find_Object(100126)),"null"); + MetroidObjectiveSystemControl.Add_Objective(1,NewObjectiveSystem::Primary,NewObjectiveSystem::Pending,12781,"",12781,Commands->Get_Position(Commands->Find_Object(100126))); MetroidRoomObjectives.Add_Objective(1,NewObjectiveSystem::Primary,NewObjectiveSystem::Pending,0,"",0,Commands->Get_Position(Commands->Find_Object(100126))); JMG_Metroid_Game_Control::currentBriefingId = 12766; for (int x = 1;x < 128;x++) diff -urN sourceold/scripts/jmgUtility.cpp source/scripts/jmgUtility.cpp --- sourceold/scripts/jmgUtility.cpp 2021-07-27 14:44:22.798967900 +1000 +++ source/scripts/jmgUtility.cpp 2022-02-13 10:20:09.868724900 +1000 @@ -1246,25 +1246,21 @@ } GameObject *JMG_Utility_AI_Vehicle::GetClosest(GameObject *obj,GameObject *new_target,GameObject *old_target) { - Vector3 obj_pos = Commands->Get_Position(obj); - Vector3 target1_pos = Commands->Get_Position(new_target); - Vector3 target2_pos = Commands->Get_Position(old_target); - float dist1 = JmgUtility::SimpleDistance(obj_pos,target1_pos); - float dist2 = JmgUtility::SimpleDistance(obj_pos,target2_pos); - if(dist1 < dist2) + Vector3 objPos = Commands->Get_Position(obj); + if(JmgUtility::SimpleDistance(objPos,Commands->Get_Position(new_target)) < JmgUtility::SimpleDistance(objPos,Commands->Get_Position(old_target))) return new_target; else return old_target; } int JMG_Utility_AI_Vehicle::SelectAmmo(GameObject *target) { - if(target) + if (target) { - if(target->As_SoldierGameObj()) + if (target->As_SoldierGameObj()) return Get_Int_Parameter("vsSoldier"); - if(target->As_VehicleGameObj()) + if (target->As_VehicleGameObj()) { - if(Is_VTOL(target)) + if (Is_VTOL(target)) return Get_Int_Parameter("vsAircraft"); return Get_Int_Parameter("vsVehicle"); } @@ -2620,6 +2616,8 @@ { if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Ignored")) return; + if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Aircraft_Ignored")) + return; if (!JmgUtility::CanSeeStealth(stealthModeOverride,obj,seen)) return; if (!Commands->Get_Health(seen)) @@ -3828,7 +3826,7 @@ if (Get_Int_Parameter("NewObjectiveID")) { int objectiveMarkerId = Get_Int_Parameter("ObjectiveMarkerObjectID"); - GameObject *ObjectiveMarker = objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); + GameObject *ObjectiveMarker = BasicObjectiveSystem.GetObjectiveMarker(objectiveMarkerId,sender,Get_Int_Parameter("NewObjectiveID")); if (!ObjectiveMarker && objectiveMarkerId) { Console_Input("msg JMG_Utility_Objective_System_Objective_Update_Enter ERROR: Could not find objective marker object!"); @@ -3840,7 +3838,7 @@ else added = BasicObjectiveSystem.Add_Objective(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"),NewObjectiveSystem::Pending,Get_Int_Parameter("NewObjectiveStringID"),"",Get_Int_Parameter("NewObjectiveStringID")); if (added) - JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); + JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); } } } @@ -3861,7 +3859,7 @@ BasicObjectiveSystem.Set_Objective_Status(Get_Int_Parameter("CompleteObjectiveID"),NewObjectiveSystem::Accomplished); } int objectiveMarkerId = Get_Int_Parameter("ObjectiveMarkerObjectID"); - GameObject *ObjectiveMarker = objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); + GameObject *ObjectiveMarker = BasicObjectiveSystem.GetObjectiveMarker(objectiveMarkerId,sender,Get_Int_Parameter("NewObjectiveID")); if (!ObjectiveMarker && objectiveMarkerId) { Console_Input("msg JMG_Utility_Objective_System_Objective_Update_Pickup ERROR: Could not find objective marker object!"); @@ -3873,7 +3871,7 @@ else added = BasicObjectiveSystem.Add_Objective(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"),NewObjectiveSystem::Pending,Get_Int_Parameter("NewObjectiveStringID"),"",Get_Int_Parameter("NewObjectiveStringID")); if (added) - JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); + JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); } } void JMG_Utility_Objective_System_Objective_Update_Killed::Killed(GameObject *obj, GameObject *damager) @@ -3903,7 +3901,7 @@ else added = BasicObjectiveSystem.Add_Objective(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"),NewObjectiveSystem::Pending,Get_Int_Parameter("NewObjectiveStringID"),"",Get_Int_Parameter("NewObjectiveStringID")); if (added) - JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); + JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); } void JMG_Utility_Objective_System_Objective_Update_Custom::Custom(GameObject *obj,int message,int param,GameObject *sender) { @@ -3920,7 +3918,7 @@ BasicObjectiveSystem.Set_Objective_Status(Get_Int_Parameter("CompleteObjectiveID"),NewObjectiveSystem::Accomplished); } int objectiveMarkerId = Get_Int_Parameter("ObjectiveMarkerObjectID"); - GameObject *ObjectiveMarker = objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); + GameObject *ObjectiveMarker = BasicObjectiveSystem.GetObjectiveMarker(objectiveMarkerId,sender,Get_Int_Parameter("NewObjectiveID")); if (!ObjectiveMarker && objectiveMarkerId) { Console_Input("msg JMG_Utility_Objective_System_Objective_Update_Custom ERROR: Could not find objective marker object!"); @@ -3932,7 +3930,7 @@ else added = BasicObjectiveSystem.Add_Objective(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"),NewObjectiveSystem::Pending,Get_Int_Parameter("NewObjectiveStringID"),"",Get_Int_Parameter("NewObjectiveStringID")); if (added) - JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); + JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); } } void JMG_Utility_Destroyed_Apply_Damage::Destroyed(GameObject *obj) @@ -4257,6 +4255,8 @@ return; if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Ignored")) return; + if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Infantry_Ignored")) + return; if (!JmgUtility::CanSeeStealth(stealthModeOverride,obj,seen)) return; if (!EnemyID || !EnemyTimeOutTime) @@ -5204,7 +5204,7 @@ else added = BasicObjectiveSystem.Add_Objective(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"),NewObjectiveSystem::Pending,Get_Int_Parameter("NewObjectiveStringID"),"",Get_Int_Parameter("NewObjectiveStringID")); if (added) - JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); + JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); } } } @@ -5216,7 +5216,10 @@ { if (message == custom) { - BasicObjectiveSystem.Remove_Objective(Get_Int_Parameter("ObjectiveID")); + int objectiveId = Get_Int_Parameter("ObjectiveID"); + if (Get_Int_Parameter("OnlyRemovePending") && BasicObjectiveSystem.Get_Objective_Status(objectiveId) != NewObjectiveSystem::Pending) + return; + BasicObjectiveSystem.Remove_Objective(objectiveId); } } void JMG_Utility_Delay_Then_Rotate_Camera::Created(GameObject *obj) @@ -6453,6 +6456,8 @@ return; if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Ignored")) return; + if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Vehicle_Ignored")) + return; if (!JmgUtility::CanSeeStealth(stealthModeOverride,obj,seen)) return; if (!EnemyID || !EnemyTimeOutTime) @@ -8133,9 +8138,11 @@ int totalBullets = Get_Total_Bullets(enter,weaponName); int id = Get_Int_Parameter("ID"); GameObject *object = id ? (id == -1 ? enter : Commands->Find_Object(id)) : obj; + int param = Get_Int_Parameter("Param"); + param = param == -1 ? Commands->Get_ID(enter) : param; if (object && totalBullets) for (int x = 0;x < totalBullets;x++) - Commands->Send_Custom_Event(obj,object,Get_Int_Parameter("Custom"),Get_Int_Parameter("Param"),Get_Float_Parameter("Delay")); + Commands->Send_Custom_Event(obj,object,Get_Int_Parameter("Custom"),param,Get_Float_Parameter("Delay")); if (Get_Int_Parameter("RemoveWeapon")) Remove_Weapon(enter,weaponName); if (Get_Int_Parameter("TriggerOnce")) @@ -8228,7 +8235,7 @@ } void JMG_Utility_Destroyed_Drop_Powerup::Destroyed(GameObject *obj) { - if (!Has_Weapon(obj,Get_Parameter("WeaponPreset"))) + if (_stricmp(Get_Parameter("RequiredWeaponPreset"),"") && !Has_Weapon(obj,Get_Parameter("RequiredWeaponPreset"))) return; Vector3 pos = Commands->Get_Position(obj); pos.Z += Get_Float_Parameter("HeightAdjust"); @@ -8260,7 +8267,7 @@ } int objectiveId = Get_Int_Parameter("ObjectiveID"); int objectiveMarkerId = Get_Int_Parameter("NewObjectiveMarkerObjectID"); - GameObject *ObjectiveMarker = objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); + GameObject *ObjectiveMarker = BasicObjectiveSystem.GetObjectiveMarker(objectiveMarkerId,sender,objectiveId); if (!ObjectiveMarker && objectiveMarkerId) { Console_Input("msg JMG_Utility_Objective_System_Objective_Status_Update_Custom ERROR: Could not find objective marker object!"); @@ -8273,7 +8280,7 @@ BasicObjectiveSystem.Set_Radar_Blip(objectiveId,ObjectiveMarker,NULL); else if (!objectiveMarkerId) BasicObjectiveSystem.Remove_Radar_Blip(objectiveId); - JmgUtility::SetHUDHelpText(stringId,BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)BasicObjectiveSystem.Get_Objective_Priority(objectiveId))); + JmgUtility::SetHUDHelpText(stringId,BasicObjectiveSystem.Get_Hud_Help_Text_Color(objectiveId,(NewObjectiveSystem::Priority)BasicObjectiveSystem.Get_Objective_Priority(objectiveId))); } } void JMG_Utility_Objective_System_Objective_Failed_Custom::Created(GameObject *obj) @@ -8370,6 +8377,8 @@ return; if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Ignored")) return; + if (Is_Script_Attached(seen,"JMG_Utility_AI_Guardian_Generic_Ignored")) + return; if (!JmgUtility::CanSeeStealth(stealthModeOverride,obj,seen)) return; if (!EnemyID || !EnemyTimeOutTime) @@ -9095,6 +9104,7 @@ { Commands->Give_Money(sender,-cost,0); Change_Character(sender,preset); + obj->As_SoldierGameObj()->Set_Collision_Group(7); Commands->Create_Sound(Get_Parameter("SuccessSound"),Commands->Get_Position(sender),sender); } else @@ -9305,6 +9315,7 @@ bool JMG_Utility_Spawn_With_Last_Selected_Gun_Control::controllerPlaced = false; char JMG_Utility_Spawn_With_Last_Selected_Gun_Control::playerWeapons[128][256]; char JMG_Utility_Spawn_With_Last_Selected_Gun_Control::playerNames[128][256]; +SList JMG_Utility_Spawn_With_Last_Selected_Gun_Control::ignoredWeapons; void JMG_Utility_Spawn_With_Last_Selected_Gun_Control::Created(GameObject *obj) { for (int x = 0;x < 128;x++) @@ -9353,8 +9364,12 @@ void JMG_Utility_Spawn_With_Last_Selected_Gun_Player::Destroyed(GameObject *obj) { const char *weapon = Get_Current_Weapon(obj); - if (weapon) - sprintf(JMG_Utility_Spawn_With_Last_Selected_Gun_Control::playerWeapons[playerId],"%s",weapon); + if (!weapon) + return; + for (SLNode *node = JMG_Utility_Spawn_With_Last_Selected_Gun_Control::ignoredWeapons.Head();node;node = node->Next()) + if (node->Data() && !_stricmp(node->Data()->preset,weapon)) + return; + sprintf(JMG_Utility_Spawn_With_Last_Selected_Gun_Control::playerWeapons[playerId],"%s",weapon); } void JMG_Utility_Spawn_With_Last_Selected_Gun_Player::GrantPlayersWeapon(GameObject *obj) { @@ -9476,7 +9491,7 @@ } int objectiveId = Get_Int_Parameter("ObjectiveID"); int objectiveMarkerId = Get_Int_Parameter("NewObjectiveMarkerObjectID"); - GameObject *ObjectiveMarker = objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); + GameObject *ObjectiveMarker = BasicObjectiveSystem.GetObjectiveMarker(objectiveMarkerId,sender,objectiveId); if (!ObjectiveMarker && objectiveMarkerId) { Console_Input("msg JMG_Utility_Objective_System_Objective_Marker_Update_Custom ERROR: Could not find objective marker object!"); @@ -10620,6 +10635,7 @@ float dist = Commands->Get_Random(minRetreatRange,maxRetreatRange); if (Commands->Get_Random(0.0f,1.0f) < runTowardThreatChance) dist *= -1.0f; + pos = Commands->Get_Position(obj); pos.X += cos(TempRotation)*dist; pos.Y += sin(TempRotation)*dist; if (Get_A_Wander_Point(&pos,wanderPointGroup)) @@ -12606,7 +12622,7 @@ BasicObjectiveSystem.Set_Objective_Status(Get_Int_Parameter("CompleteObjectiveID"),NewObjectiveSystem::Accomplished); } int objectiveMarkerId = Get_Int_Parameter("ObjectiveMarkerObjectID"); - GameObject *ObjectiveMarker = objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); + GameObject *ObjectiveMarker = BasicObjectiveSystem.GetObjectiveMarker(objectiveMarkerId,sender,Get_Int_Parameter("NewObjectiveID")); if (!ObjectiveMarker && objectiveMarkerId) { Console_Input("msg JMG_Utility_Objective_System_Objective_Update_Custom ERROR: Could not find objective marker object!"); @@ -12625,7 +12641,7 @@ else added = BasicObjectiveSystem.Add_Objective(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"),NewObjectiveSystem::Pending,Get_Int_Parameter("NewObjectiveStringID"),"",Get_Int_Parameter("NewObjectiveStringID")); if (added) - JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color((NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); + JmgUtility::SetHUDHelpText(Get_Int_Parameter("NewObjectiveStringID"),BasicObjectiveSystem.Get_Hud_Help_Text_Color(Get_Int_Parameter("NewObjectiveID"),(NewObjectiveSystem::Priority)Get_Int_Parameter("NewObjectivePriority"))); } } } @@ -13576,12 +13592,12 @@ { controllerId = 0; } -void JMG_Utility_Control_Point_Assault_Mode::SendCustom(GameObject* obj,int custom,int frontLineGroup) +void JMG_Utility_Control_Point_Assault_Mode::SendCustom(GameObject* obj,int custom,int thisFrontLineGroup) { if (!custom) return; GameObject *object = id ? Commands->Find_Object(id) : obj; - Commands->Send_Custom_Event(obj,object,custom,frontLineGroup,0.0f); + Commands->Send_Custom_Event(obj,object,custom,thisFrontLineGroup,0.0f); } void JMG_Utility_Control_Point_Wander_Point::Created(GameObject *obj) { @@ -13662,30 +13678,39 @@ if (!selectedCpId) Commands->Start_Timer(obj,this,0.1f,1); else + { + if (spawnTime) + DisplaySpawnTime(obj); Timer_Expired(obj,2); + } } if (number == 2) { if (selectedCpId) { GameObject *controlPoint = Commands->Find_Object(selectedCpId); - float spawnTimeRatio = spawnTime/(float)maxSpawnTime; - Vector3 spawnScreenColors = Vector3(spawnTimeRatio*0.75f,abs((spawnTimeRatio*0.75f)-((1-spawnTimeRatio)*0.39f)),(1-spawnTimeRatio)*0.78f); - float tempSimpDist = JmgUtility::SimpleDistance(Commands->Get_Position(controlPoint),Commands->Get_Position(obj)); - float tempDistCalc = min(max(tempSimpDist-startFadeRange,0.0f)/(maxWanderRange-startFadeRange),1.0f); - spawnScreenColors *= (1-tempDistCalc); - Set_Screen_Fade_Color_Player(obj,min(tempDistCalc+spawnScreenColors.X,1.0f),spawnScreenColors.Y,spawnScreenColors.Z,0.1f); - if (tempSimpDist > maxWanderRange) - MoveToControlledWanderPointForCp(obj,selectedCpId); + JMG_Utility_Control_Point *cpScript = (JMG_Utility_Control_Point*)Find_Script_On_Object(controlPoint,"JMG_Utility_Control_Point"); + if (cpScript && cpScript->setupComplete && (!cpScript->captured || cpScript->controllingTeamId != teamId)) + { + lastSpawnGroup = -1; + Custom(obj,groupChangeCustom,0,obj); + } + else + { + float spawnTimeRatio = spawnTime/(float)maxSpawnTime; + Vector3 spawnScreenColors = Vector3(spawnTimeRatio*0.75f,abs((spawnTimeRatio*0.75f)-((1-spawnTimeRatio)*0.39f)),(1-spawnTimeRatio)*0.78f); + float tempSimpDist = JmgUtility::SimpleDistance(Commands->Get_Position(controlPoint),Commands->Get_Position(obj)); + float tempDistCalc = min(max(tempSimpDist-startFadeRange,0.0f)/(maxWanderRange-startFadeRange),1.0f); + spawnScreenColors *= (1-tempDistCalc); + Set_Screen_Fade_Color_Player(obj,min(tempDistCalc+spawnScreenColors.X,1.0f),spawnScreenColors.Y,spawnScreenColors.Z,0.1f); + if (tempSimpDist > maxWanderRange) + MoveToControlledWanderPointForCp(obj,selectedCpId); + } } if (spawnTime) { if ((spawnTime <= 100 && !(spawnTime%10)) || (spawnTime > 100 && !(spawnTime%100))) - { - char disString[220]; - sprintf(disString,"%d",spawnTime/10); - Set_HUD_Help_Text_Player_Text(obj,stringId,disString,Vector3(1.0f,0.5f,0.0f)); - } + DisplaySpawnTime(obj); spawnTime--; if (!spawnTime) { @@ -13715,6 +13740,7 @@ Set_HUD_Help_Text_Player_Text(obj,stringId,"",Vector3(1.0f,0.5f,0.0f)); Set_Screen_Fade_Opacity_Player(obj,0.0f,0.1f); Change_Character(obj,Get_Parameter("SpawnPreset")); + obj->As_SoldierGameObj()->Set_Collision_Group(Collision_Group_Type::SOLDIER_GHOST_COLLISION_GROUP); } if (message == groupChangeCustom) { @@ -13787,7 +13813,7 @@ if (!o || !Is_Script_Attached(o,"JMG_Utility_Control_Point_Wander_Point")) goto JMG_UTILITY_CONTROL_POINT_SELECT_SPAWN_SYSTEM_LOOP_END; JMG_Utility_Control_Point_Wander_Point *wanderScript = (JMG_Utility_Control_Point_Wander_Point*)Find_Script_On_Object(o,"JMG_Utility_Control_Point_Wander_Point"); - if (!wanderScript || !wanderScript->teamId != teamId || wanderScript->controlPointId != cpId) + if (!wanderScript || wanderScript->teamId != teamId) goto JMG_UTILITY_CONTROL_POINT_SELECT_SPAWN_SYSTEM_LOOP_END; if (randomPoint) randomPoint--; @@ -13801,6 +13827,7 @@ Commands->Set_Position(obj,pos); Force_Position_Update(obj); Toggle_Fly_Mode(obj); + Lock_Soldier_Collision_Group(obj,Collision_Group_Type::SOLDIER_GHOST_COLLISION_GROUP); char params[220]; sprintf(params,"0.1,%.2f",Commands->Get_Facing(o)); Commands->Attach_Script(obj,"JMG_Utility_Delay_Then_Rotate_Camera",params); @@ -13818,6 +13845,12 @@ } return false; } +void JMG_Utility_Control_Point_Select_Spawn_System::DisplaySpawnTime(GameObject *obj) +{ + char disString[220]; + sprintf(disString,"%d",spawnTime/10); + Set_HUD_Help_Text_Player_Text(obj,stringId,disString,Vector3(1.0f,0.5f,0.0f)); +} void JMG_Utility_Custom_And_Param_Send_Custom::Created(GameObject *obj) { recieveMessage = Get_Int_Parameter("Custom"); @@ -14476,13 +14509,13 @@ Commands->Set_Animation(obj,useAltAnimation ? animation2 : animation,false,0,1,5,false); useAltAnimation = !useAltAnimation; } -void JMG_Utility_Sync_String_With_Random_NumberPad_Control::Created(GameObject *obj) +void JMG_Utility_Security_System_Sync_String_Random_NumberPad_Control::Created(GameObject *obj) { delim = Get_Parameter("Delim")[0]; stringId = Get_Int_Parameter("StringID"); Commands->Start_Timer(obj,this,0.1f,1); } -void JMG_Utility_Sync_String_With_Random_NumberPad_Control::Timer_Expired(GameObject *obj,int number) +void JMG_Utility_Security_System_Sync_String_Random_NumberPad_Control::Timer_Expired(GameObject *obj,int number) { if (number == 1) { @@ -15609,7 +15642,7 @@ void JMG_Utility_Timer_Death_If_Not_Damaged_Over_Peroid::Created(GameObject *obj) { time = originalTime = Get_Int_Parameter("Time"); - damage = Get_Float_Parameter("Damage"); + giveDamage = Get_Float_Parameter("Damage"); sprintf(warhead,"%s",Get_Parameter("Warhead")); Timer_Expired(obj,1); } @@ -15621,7 +15654,7 @@ { time--; if (!time) - Commands->Apply_Damage(obj,damage,warhead,obj); + Commands->Apply_Damage(obj,giveDamage,warhead,obj); } Commands->Start_Timer(obj,this,1.0f,1); } @@ -16091,6 +16124,1210 @@ } return -1; } +int JMG_Utility_Global_Custom_Send_Custom_Flag_Controller::globalFlag = -1; +void JMG_Utility_Global_Custom_Send_Custom_Flag_Controller::Created(GameObject *obj) +{ + globalFlag = Get_Int_Parameter("GlobalFlag"); +} +void JMG_Utility_Global_Custom_Send_Custom_Flag_Custom::Created(GameObject *obj) +{ + custom = Get_Int_Parameter("Custom"); + globalFlag = Get_Int_Parameter("GlobalFlag"); +} +void JMG_Utility_Global_Custom_Send_Custom_Flag_Custom::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (message == custom) + { + JMG_Utility_Global_Custom_Send_Custom_Flag_Controller::globalFlag = globalFlag; + } +} +void JMG_Utility_Global_Custom_Send_Custom_Flag::Created(GameObject *obj) +{ + globalFlag = Get_Int_Parameter("GlobalFlag"); + recieveMessage = Get_Int_Parameter("Custom"); + id = Get_Int_Parameter("ID"); + custom = Get_Int_Parameter("SendCustom"); + Param = Get_Int_Parameter("Param"); + delay = Get_Float_Parameter("Delay"); + randomDelay = Get_Float_Parameter("RandomDelay"); + randomChance = Get_Float_Parameter("RandomChance"); +} +void JMG_Utility_Global_Custom_Send_Custom_Flag::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (message == recieveMessage && JMG_Utility_Global_Custom_Send_Custom_Flag_Controller::globalFlag == globalFlag) + { + if (randomChance && randomChance < Commands->Get_Random(0.0f,1.0f)) + return; + GameObject *object = id ? (id == -1 ? sender : Commands->Find_Object(id)) : obj; + Commands->Send_Custom_Event(obj,object,custom,Param == -1 ? param : Param,delay+(randomDelay > 0 ? Commands->Get_Random(0.0f,randomDelay) : 0.0f)); + } +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::Created(GameObject *obj) +{ + const char *weap = Get_Current_Weapon(obj); + if (weap) + { + primary = DefineAmmo(Get_Weapon_Ammo_Definition(weap,true)); + secondary = DefineAmmo(Get_Weapon_Ammo_Definition(weap,true)); + } + gotoObjectId = Get_Int_Parameter("GotoObjectId"); + gotoLocation = Get_Vector3_Parameter("GotoLocation"); + maxPlayerDistance = Get_Float_Parameter("MaxPlayerDistance")*Get_Float_Parameter("MaxPlayerDistance"); + minDistanceSquared = Get_Float_Parameter("MinAttackRange")*Get_Float_Parameter("MinAttackRange"); + lastHealth = 0; + moving = false; + attacking = false; + reverseTime = 0; + stuckCount = 0; + drivingBackward = false; + badDestAttempt = 0; + doNotUsePathfind = 0; + currentAction.position = homepos = Commands->Get_Position(obj); + myteam = Commands->Get_Player_Type(obj); + Commands->Enable_Enemy_Seen(obj,true); + Commands->Innate_Disable(obj); + Commands->Enable_Hibernation(obj,false); + minAttackRange = Get_Float_Parameter("MinAttackRange"); + definedWeaponError = Get_Float_Parameter("WeaponError"); + forceFire = Get_Int_Parameter("ForceFire"); + vtolHover = Get_Float_Parameter("VTOLHover"); + vsSoldier = Get_Int_Parameter("vsSoldier"); + vsAircraft = Get_Int_Parameter("vsAircraft"); + vsVehicle = Get_Int_Parameter("vsVehicle"); + overrideSpeed = Get_Float_Parameter("OverrideSpeed"); + playerType = Get_Int_Parameter("PlayerType"); + if (obj->As_VehicleGameObj()) + { + Commands->Enable_Vehicle_Transitions(obj,false); + Commands->Enable_Engine(obj,true); + } + if (Get_Int_Parameter("OverrideFireMode")) + { + overrideFireMode = true; + overridePrimary = Get_Int_Parameter("OverrideFireMode") == 1 ? true : false; + } + Commands->Start_Timer(obj,this,1.0,1); + Commands->Start_Timer(obj,this,1.0,2); + Commands->Start_Timer(obj,this,0.1f,8); +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::Action_Complete(GameObject *obj,int action,ActionCompleteReason reason) +{ + if (reason == ACTION_COMPLETE_PATH_BAD_START) + { + bool refreshAction = false; + if (!doNotUsePathfind) + refreshAction = true; + doNotUsePathfind = 3; + if (refreshAction) + Commands->Start_Timer(obj,this,0.1f,7); + } + if (reason == ACTION_COMPLETE_PATH_BAD_DEST) + { + if (!badDestAttempt) + Commands->Start_Timer(obj,this,0.25f,5); + else + Commands->Start_Timer(obj,this,0.25f,6); + } + Commands->Action_Reset(obj,action*1.0f); + Commands->Action_Reset(obj,100*1.0f); +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::Damaged(GameObject *obj,GameObject *damager,float damage) +{ + if (damage <= 0 || Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj)) + return; + if (Is_Script_Attached(damager,"JMG_Utility_AI_Goto_Location_While_Player_Nearby_Ignored")) + return; + if (!_stricmp(Get_Skin(damager),"Blamo") || !_stricmp(Get_Shield_Type(damager),"Blamo")) + return; + if(!attacking) + RunAttack(obj,SetTarget(damager)); + else + RunAttack(obj,SelectTarget(obj,damager)); + lastSeenCount = Commands->Get_Random_Int(6,15); +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::Enemy_Seen(GameObject *obj,GameObject *seen) +{ + if (Is_Script_Attached(seen,"JMG_Utility_AI_Goto_Location_While_Player_Nearby_Ignored")) + return; + Vector3 enemyPos = Commands->Get_Position(seen); + float dist = JmgUtility::SimpleDistance(Commands->Get_Position(obj),enemyPos); + if (!_stricmp(Get_Skin(seen),"Blamo") || !_stricmp(Get_Shield_Type(seen),"Blamo")) + return; + if (minAttackRange && dist < minDistanceSquared) + return; + if (!Commands->Get_Health(seen)) + return; + if (seen->As_SmartGameObj() && seen->As_SmartGameObj()->Is_Stealthed()) + if (seen->As_SoldierGameObj() && dist > seen->As_SoldierGameObj()->Get_Stealth_Fade_Distance()*seen->As_SoldierGameObj()->Get_Stealth_Fade_Distance()) + return; + else if (seen->As_VehicleGameObj() && dist > seen->As_VehicleGameObj()->Get_Stealth_Fade_Distance()*seen->As_VehicleGameObj()->Get_Stealth_Fade_Distance()) + return; + else if (dist > seen->As_SmartGameObj()->Get_Stealth_Fade_Distance()*seen->As_SmartGameObj()->Get_Stealth_Fade_Distance()) + return; + if (Commands->Get_ID(seen) == currentAction.targetId) + lastSeenCount = Commands->Get_Random_Int(3,16); + if(!attacking) + RunAttack(obj,SetTarget(seen)); + else + RunAttack(obj,SelectTarget(obj,seen)); +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + StuckCheck(obj); + if (lastSeenCount) + { + lastSeenCount--; + if (!lastSeenCount) + currentAction.targetId = -1; + } + if (doNotUsePathfind) + doNotUsePathfind--; + Commands->Start_Timer(obj,this,1.0,1); + } + if (number == 2) + { + Vector3 targetSpot = gotoLocation; + if (gotoObjectId) + targetSpot = Commands->Get_Position(Commands->Find_Object(gotoObjectId)); + Vector3 myPos = Commands->Get_Position(obj); + GameObject *player = Commands->Get_A_Star(myPos); + if (player && JmgUtility::SimpleDistance(Commands->Get_Position(player),myPos) <= maxPlayerDistance && !CheckPlayerType(player,playerType) && JmgUtility::SimpleDistance(myPos,targetSpot) > 6.25f && Commands->Get_Player_Type(player) != -4) + { + if (!moving) + { + moving = true; + AttackMove(obj,Commands->Find_Object(lastAction.targetId),gotoObjectId ? true : false,gotoLocation,useAmmo,0.0f,true,2.5f); + } + } + else if (moving) + { + moving = false; + AttackMove(obj,Commands->Find_Object(lastAction.targetId),false,myPos,useAmmo,0.0f,true,1000.0f); + } + Commands->Start_Timer(obj,this,0.25f,2); + } + if (number == 3) + { + if(attacking) + { + attacking = false; + if (!lastSeenCount && currentAction.targetId) + currentAction.targetId = 0; + GameObject *target = Commands->Find_Object(currentAction.targetId); + if(target && Commands->Get_Health(target)) + RunAttack(obj,SetTarget(target)); + else + { + currentAction.useAmmo = 1; + currentAction.targetId = 0; + AttackMove(obj,NULL,currentAction.following,currentAction.position,currentAction.useAmmo,0.0f,false,currentAction.arriveDistance); + } + } + else + AttackMove(obj,Commands->Find_Object(currentAction.targetId),currentAction.following,currentAction.position,currentAction.useAmmo,0.0f,false,currentAction.arriveDistance); + } + if (number == 4) + { + if (Get_Vehicle_Occupant_Count(obj)) + Force_Occupants_Exit(obj); + } + if (number == 5) + { + badDestAttempt = 1; + AttackMove(obj,Commands->Find_Object(currentAction.targetId),currentAction.following,Commands->Get_Position(obj),currentAction.useAmmo,0.0f,false,currentAction.arriveDistance); + } + if (number == 6) + { + badDestAttempt = 0; + AttackMove(obj,Commands->Find_Object(currentAction.targetId),currentAction.following,homepos,currentAction.useAmmo,0.0f,false,currentAction.arriveDistance); + } + if (number == 7) + { + AttackMove(obj,Commands->Find_Object(currentAction.targetId),currentAction.following,currentAction.position,currentAction.useAmmo,0.0f,true,currentAction.arriveDistance); + } +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::RunAttack(GameObject *obj,GameObject *target) +{ + if (target) + { + int ammo = SelectAmmo(target); + if (ammo == -1) + { + attacking = false; + useAmmo = 1; + currentAction.targetId = 0; + return; + } + if (ammo == 2) + { + if (lastHealth == Commands->Get_Health(target)) + useAmmo = useAmmo == 1 ? 0 : 1; + ammo = useAmmo; + } + useAmmo = ammo; + lastHealth = Commands->Get_Health(target); + attacking = true; + AttackMove(obj,target,currentAction.following,currentAction.position,useAmmo,0.0f,false,currentAction.arriveDistance); + Commands->Start_Timer(obj,this,1.0f,3); + } +} +int JMG_Utility_AI_Goto_Location_While_Player_Nearby::GetThreatRating(GameObject * obj) +{ + if (obj == NULL) + return 0; + int rating=0; + if(Commands->Is_A_Star(obj)) + { + rating += 1; + GameObject *vehicle = Get_Vehicle(obj); + if (vehicle) + rating += 3; + } + if (obj->As_SoldierGameObj()) + rating += 1; + if (obj->As_VehicleGameObj()) + rating += 3; + return rating; +} +GameObject * JMG_Utility_AI_Goto_Location_While_Player_Nearby::GetAttackObject(GameObject * obj) +{ + if (obj == NULL) + return NULL; + if(Commands->Is_A_Star(obj)) + { + GameObject *vehicle = Get_Vehicle(obj); + if(vehicle) + return vehicle; + else + return obj; + } + return obj; +} +GameObject *JMG_Utility_AI_Goto_Location_While_Player_Nearby::SelectTarget(GameObject *obj,GameObject *target) +{ + GameObject *old = currentAction.targetId ? Commands->Find_Object(currentAction.targetId) : NULL; + if (!target || !Commands->Get_ID(target)) + return GetAttackObject(old); + if (!old) + { + currentAction.targetId = Commands->Get_ID(target); + return GetAttackObject(target); + } + int trOld = GetThreatRating(old); + int trNew = GetThreatRating(target); + if (trOld > trNew) + return GetAttackObject(old); + if (trNew > trOld) + { + currentAction.targetId = Commands->Get_ID(target); + return GetAttackObject(target); + } + GameObject * closest = GetClosest(obj,target,old); + currentAction.targetId = Commands->Get_ID(closest); + return GetAttackObject(closest); +} +GameObject *JMG_Utility_AI_Goto_Location_While_Player_Nearby::SetTarget(GameObject *target) +{ + currentAction.targetId = Commands->Get_ID(target); + if(!attacking) + return GetAttackObject(target); + return 0; +} +GameObject *JMG_Utility_AI_Goto_Location_While_Player_Nearby::GetClosest(GameObject *obj,GameObject *new_target,GameObject *old_target) +{ + Vector3 objPos = Commands->Get_Position(obj); + if(JmgUtility::SimpleDistance(objPos,Commands->Get_Position(new_target)) < JmgUtility::SimpleDistance(objPos,Commands->Get_Position(old_target))) + return new_target; + else + return old_target; +} +int JMG_Utility_AI_Goto_Location_While_Player_Nearby::SelectAmmo(GameObject *target) +{ + if (target) + { + if (target->As_SoldierGameObj()) + return vsSoldier; + if (target->As_VehicleGameObj()) + { + if (Is_VTOL(target)) + return vsAircraft; + return vsVehicle; + } + } + return -1; +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::StuckCheck(GameObject *obj) +{ + Vector3 current = Commands->Get_Position(obj); + if (reverseTime) + { + reverseTime--; + stuckCount = 0; + lastPos = current; + drivingBackward = false; + AttackMove(obj,Commands->Find_Object(lastAction.targetId),lastAction.following,lastAction.position,lastAction.useAmmo,0.0f,true,0.0f); + return; + } + if (!moving) + { + drivingBackward = false; + return; + } + if(JmgUtility::SimpleDistance(lastPos,current) < 1.0f) + { + if(stuckCount > 2) + { + reverseTime = Commands->Get_Random_Int(2,6); + stuckCount = 0; + drivingBackward = true; + AttackMove(obj,Commands->Find_Object(lastAction.targetId),lastAction.following,lastAction.position,lastAction.useAmmo,0.0f,true,currentAction.arriveDistance); + } + stuckCount++; + } + else + { + stuckCount = 0; + lastPos = current; + } +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby::AttackMove(GameObject *obj,GameObject *target,bool gotoObject,Vector3 targetLocation,int fireMode,float weaponError,bool forceUpdate,float arriveDistance) +{ + Vector3 myPos = Commands->Get_Position(obj); + float dist = 9999.9f; + GameObject *followingObject = Commands->Find_Object(gotoObjectId); + if (gotoObject && followingObject) + dist = JmgUtility::SimpleDistance(Commands->Get_Position(followingObject),myPos); + else + dist = JmgUtility::SimpleDistance(currentAction.position,myPos); + if (!gotoObject) + currentAction.position = targetLocation; + currentAction.useAmmo = fireMode; + currentAction.following = gotoObject; + currentAction.backward = drivingBackward; + currentAction.arriveDistance = arriveDistance; + if (lastAction == currentAction && !forceUpdate) + return; + lastAction = currentAction; + Commands->Action_Reset(obj,10.0f); + ActionParamsStruct params; + if (target) + { + JMGVehicleAmmo ammo = (fireMode ? primary : secondary); + weaponError = 0.0f; + if (definedWeaponError != -1.00f) + weaponError = definedWeaponError; + else if (ammo.allowError) + weaponError = JmgUtility::SimpleDistance(Commands->Get_Position(target),myPos)/ammo.speed*5.0f; + params.Set_Attack(target,ammo.range,weaponError,!overrideFireMode ? (fireMode ? true : false) : overridePrimary); + if (forceFire) + { + params.AttackCheckBlocked = false; + params.AttackForceFire = true; + } + } + if (Is_VTOL(obj) && vtolHover) + targetLocation.Z += vtolHover; + if (gotoObject) + params.Set_Movement(followingObject,overrideSpeed == -1.0 ? JmgUtility::MathClamp(dist,1.0f,100.0f) : overrideSpeed,arriveDistance,false); + else + params.Set_Movement(targetLocation,overrideSpeed == -1.0 ? JmgUtility::MathClamp(dist,1.0f,100.0f) : overrideSpeed,arriveDistance,false); + params.MoveBackup = currentAction.backward; + if (Is_VTOL(obj)) + params.MovePathfind = false; + else + { + params.ShutdownEngineOnArrival = true; + params.MovePathfind = !doNotUsePathfind ? true : false; + } + if (!target) + params.Set_Basic(this,10,10); + Commands->Action_Goto(obj,params); + if (target) + { + params.Set_Basic(this,10,10); + Commands->Action_Attack(obj,params); + } +} +JMG_Utility_AI_Goto_Location_While_Player_Nearby::JMGVehicleAmmo JMG_Utility_AI_Goto_Location_While_Player_Nearby::DefineAmmo(const AmmoDefinitionClass *ammo) +{ + JMGVehicleAmmo theammo; + if (ammo) + { + theammo.range = ammo->Range; + if (ammo->Velocity >= 400.0f || (ammo->IsTracking && ammo->TurnRate)) + theammo.allowError = false; + else + theammo.allowError = true; + theammo.speed = ammo->Velocity*ammo->Velocity; + } + return theammo; +} +void JMG_Utility_AI_Goto_Location_While_Player_Nearby_Ignored::Created(GameObject *obj) +{ +} +void JMG_Utility_Killed_Drop_Powerup_Become_Corpse::Killed(GameObject *obj,GameObject *killer) +{ + if (Get_Float_Parameter("Chance") >= 1.0f || Commands->Get_Random(0.0f,1.0f) < Get_Float_Parameter("Chance")) + Commands->Start_Timer(obj,this,0.0f,1); +} +void JMG_Utility_Killed_Drop_Powerup_Become_Corpse::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + if (_stricmp(Get_Parameter("RequiredWeaponPreset"),"") && !Has_Weapon(obj,Get_Parameter("RequiredWeaponPreset"))) + return; + Vector3 pos = Commands->Get_Position(obj); + GameObject *powerup = Commands->Create_Object(Get_Parameter("PowerupName"),pos); + Commands->Set_Facing(powerup,Commands->Get_Facing(obj)); + Commands->Set_Model(powerup,Get_Model(obj)); + if (!obj->As_SmartGameObj()) + return; + AnimControlClass *control = obj->As_SmartGameObj()->Get_Anim_Control(); + if (!control || control->Get_Animation_Name() == NULL || !_stricmp(control->Get_Animation_Name(),"")) + return; + Commands->Set_Animation(powerup,control->Get_Animation_Name(),false,0,control->Get_Current_Frame(),-1,true); + Commands->Destroy_Object(obj); + } +} +void JMG_Utility_Objective_System_Objectives_Complete_Send_Custom::Created(GameObject *obj) +{ + id = Get_Int_Parameter("ID"); + custom = Get_Int_Parameter("SendCustom"); + Param = Get_Int_Parameter("Param"); + delay = Get_Float_Parameter("Delay"); + randomDelay = Get_Float_Parameter("RandomDelay"); + char completedObjectives[256]; + sprintf(completedObjectives,"%s",Get_Parameter("CompletedObjectives")); + char delim[2]; + int count = 0; + sprintf(delim,"%s",Get_Parameter("Delim")); + char *token = strtok(completedObjectives, delim); + while( token != NULL ) + { + objectiveIds[count] = atoi(token); + token = strtok(NULL,delim); + count++; + } + objectiveCount = count; + repeat = Get_Int_Parameter("Repeat") ? true : false; + Commands->Start_Timer(obj,this,0.25f,1); +} +void JMG_Utility_Objective_System_Objectives_Complete_Send_Custom::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + if (BasicObjectiveSystem.Check_If_All_Objectives_Are_Complete(objectiveIds,objectiveCount)) + { + GameObject *object = id ? Commands->Find_Object(id) : obj; + Commands->Send_Custom_Event(obj,object,custom,Param,delay+(randomDelay > 0 ? Commands->Get_Random(0.0f,randomDelay) : 0.0f)); + if (!repeat) + { + Destroy_Script(); + return; + } + } + Commands->Start_Timer(obj,this,0.25f,1); + } +} +void JMG_Utility_Damage_Update_Animation_Frame::Created(GameObject *obj) +{ + if (_stricmp(Get_Parameter("Model"),"")) + Commands->Set_Model(obj,Get_Parameter("Model")); + sprintf(animation,"%s",Get_Parameter("Animation")); + maxFrame = Get_Float_Parameter("MaxFrame"); + lastCalculation = -1; + Damaged(obj,NULL,0); +} +void JMG_Utility_Damage_Update_Animation_Frame::Damaged(GameObject *obj,GameObject *damager,float damage) +{ + float percent = Get_Hitpoints(obj)/Get_Max_Hitpoints(obj); + float frame = JmgUtility::MathClamp(percent*maxFrame,0.0f,maxFrame); + if (frame != lastCalculation) + { + Commands->Set_Animation(obj,animation,false,0,frame,frame,true); + lastCalculation = frame; + } +} +void JMG_Utility_Security_System_Sync_Model_Random_NumberPad_Control::Created(GameObject *obj) +{ + Commands->Start_Timer(obj,this,0.1f,1); +} +void JMG_Utility_Security_System_Sync_Model_Random_NumberPad_Control::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + GameObject *keypad = Commands->Find_Object(Get_Int_Parameter("KeypadID")); + JMG_Utility_Security_System_Random_NumberPad_Control *script = (JMG_Utility_Security_System_Random_NumberPad_Control*)Find_Script_On_Object(keypad,"JMG_Utility_Security_System_Random_NumberPad_Control"); + if (!script) + return; + char theModel[16]; + sprintf(theModel,"%s%c",Get_Parameter("BaseModel"),script->combination[Get_Int_Parameter("Index")]); + Commands->Set_Model(obj,theModel); + } +} +void JMG_Utility_AI_Goto_Target_Script::Created(GameObject *obj) +{ + state = IDLE; + moveBackward = false; + lastPosition = homeLocation = Commands->Get_Position(obj); + targetId = 0; + lastSeenTime = 0; + huntingEnemyId = 0; + stuckTime = 0; + reverseTime = 0; + huntStealth = Get_Int_Parameter("HuntStealth") ? true : false; + removeIgnoreTime = 0; + ignoreEnemyId = 0; + wanderingAiGroupId = Get_Int_Parameter("WanderingAIGroupID"); + wanderSpeed = Get_Float_Parameter("WanderSpeed"); + huntSpeed = Get_Float_Parameter("HuntSpeed"); + attackSpeed = Get_Float_Parameter("AttackSpeed"); + returnHomeSpeed = Get_Float_Parameter("ReturnHomeSpeed"); + changeWanderGroupCustom = Get_Int_Parameter("ChangeWanderGroupCustom"); + changeWanderSpeedCustom = Get_Int_Parameter("ChangeWanderSpeedCustom"); + changeHuntDistanceCustom = Get_Int_Parameter("ChangeHuntDistanceCustom"); + changeHuntSpeedCustom = Get_Int_Parameter("ChangeHuntSpeedCustom"); + changeReturnHomeSpeedCustom = Get_Int_Parameter("ChangeReturnHomeSpeedCustom"); + changeMaxSightFromHomeLocationCustom = Get_Int_Parameter("ChangeMaxSightFromHomeLocationCustom"); + changeAttackSpeedCustom = Get_Int_Parameter("ChangeAttackSpeedCustom"); + maxSightFromHomeLocation = Get_Float_Parameter("MaxSightRangeFromHome"); + maxSightFromHomeLocation *= maxSightFromHomeLocation; + huntSearchDistance = Get_Float_Parameter("HuntSearchDistance") < 0.0f ? Get_Float_Parameter("HuntSearchDistance") : Get_Float_Parameter("HuntSearchDistance")*Get_Float_Parameter("HuntSearchDistance"); + const AmmoDefinitionClass *ammo = Get_Weapon_Ammo_Definition(Get_Current_Weapon(obj),true); + if (ammo) + { + weaponRange = ammo->Range; + weaponEffectiveRange = ammo->Range < ammo->EffectiveRange ? ammo->Range : ammo->EffectiveRange; + } + attackArriveDistance = Get_Float_Parameter("AttackDistance") >= 0 ? Get_Float_Parameter("AttackDistance") : weaponEffectiveRange; + huntArriveDistance = Get_Float_Parameter("HuntArriveDistance"); + wanderDistanceOverride = Get_Float_Parameter("WanderDistanceOverride"); + wanderDistanceOverride *= wanderDistanceOverride; + Commands->Enable_Enemy_Seen(obj,true); + Commands->Start_Timer(obj,this,1.0f,1); + Commands->Start_Timer(obj,this,1.0f,2); + if (Get_Float_Parameter("RandomAttackDistance")) + Commands->Start_Timer(obj,this,0.0f,3); + if (Get_Float_Parameter("RandomHuntArriveDistance")) + Commands->Start_Timer(obj,this,0.0f,4); +} +void JMG_Utility_AI_Goto_Target_Script::Enemy_Seen(GameObject *obj,GameObject *seen) +{ + if (!Commands->Get_Health(seen)) + return; + if (Is_Script_Attached(seen,"JMG_Utility_AI_Goto_Target_Script_Ignore_Object")) + return; + if (!_stricmp(Get_Skin(seen),"Blamo") || !_stricmp(Get_Shield_Type(seen),"Blamo")) + return; + if (Get_Int_Parameter("CanSeeStealth") != 2 && seen->As_SmartGameObj() && seen->As_SmartGameObj()->Is_Stealthed()) + { + if (!Get_Int_Parameter("CanSeeStealth")) + return; + float dist = JmgUtility::SimpleDistance(Commands->Get_Position(obj),Commands->Get_Position(seen)); + if (seen->As_SoldierGameObj() && dist > seen->As_SoldierGameObj()->Get_Stealth_Fade_Distance()*seen->As_SoldierGameObj()->Get_Stealth_Fade_Distance()) + return; + else if (seen->As_VehicleGameObj() && dist > seen->As_VehicleGameObj()->Get_Stealth_Fade_Distance()*seen->As_VehicleGameObj()->Get_Stealth_Fade_Distance()) + return; + else if (dist > seen->As_SmartGameObj()->Get_Stealth_Fade_Distance()*seen->As_SmartGameObj()->Get_Stealth_Fade_Distance()) + return; + } + if (maxSightFromHomeLocation > 0.0f && JmgUtility::SimpleDistance(homeLocation,Commands->Get_Position(seen)) > maxSightFromHomeLocation) + return; + if (!targetId || !lastSeenTime || Choose_Target(obj,seen)) + { + targetId = Commands->Get_ID(seen); + lastSeenTime = Commands->Get_Random_Int(30,60); + state = ATTACKING_TARGET; + Attack_Move(obj,seen,Vector3(),attackSpeed,attackArriveDistance,true,false); + } + if (targetId == Commands->Get_ID(seen)) + lastSeenTime = Commands->Get_Random_Int(30,60); +} +void JMG_Utility_AI_Goto_Target_Script::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (changeWanderGroupCustom != 0 && changeWanderGroupCustom == message) + { + wanderingAiGroupId = param; + if (state == WANDERING_GROUP) + { + Vector3 wanderPos = Vector3(); + if (GetRandomPosition(&wanderPos)) + { + homeLocation = wanderPos; + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),homeLocation,lastAction.speed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } + } + } + if (changeWanderSpeedCustom != 0 && changeWanderSpeedCustom == message) + { + wanderSpeed = param/100.0f; + if (state == WANDERING_GROUP) + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,wanderSpeed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } + if (changeHuntDistanceCustom != 0 && changeHuntDistanceCustom == message) + { + huntSearchDistance = param/100.0f; + if (huntSearchDistance > 0) + huntSearchDistance *= huntSearchDistance; + } + if (changeHuntSpeedCustom != 0 && changeHuntSpeedCustom == message) + { + huntSpeed = param/100.0f; + if (state == HUNTING_STAR) + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,huntSpeed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } + if (changeReturnHomeSpeedCustom != 0 && changeReturnHomeSpeedCustom == message) + { + returnHomeSpeed = param/100.0f; + if (state == RETURNING_HOME) + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,returnHomeSpeed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } + if (changeMaxSightFromHomeLocationCustom != 0 && changeMaxSightFromHomeLocationCustom == message) + { + maxSightFromHomeLocation = param/100.0f; + maxSightFromHomeLocation *= maxSightFromHomeLocation; + } + if (changeAttackSpeedCustom != 0 && changeAttackSpeedCustom == message) + { + attackSpeed = param/100.0f; + if (state == ATTACKING_TARGET) + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,attackSpeed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } +} +void JMG_Utility_AI_Goto_Target_Script::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + Vector3 targetPos = Commands->Get_Position(obj); + if (lastSeenTime) + { + lastSeenTime--; + if (!lastSeenTime) + { + Return_Home(obj,ValidLastLocation(targetId)); + targetId = 0; + } + } + if (targetId) + { + GameObject *target = Commands->Find_Object(targetId); + targetPos = Commands->Get_Position(target); + if (!target || !Commands->Get_Health(target) || (Commands->Get_Player_Type(obj) != -2 && Commands->Get_Player_Type(target) == Commands->Get_Player_Type(obj)) || Is_Script_Attached(target,"JMG_Utility_AI_Goto_Target_Script_Ignore_Object")) + { + lastSeenTime = 0; + Return_Home(obj,ValidLastLocation(targetId)); + targetId = 0; + } + } + if (state == HUNTING_STAR) + { + GameObject *star = Commands->Find_Object(huntingEnemyId); + if (!star || !Commands->Get_Health(star) || (huntSearchDistance >= 0.0f && JmgUtility::SimpleDistance(Commands->Get_Position(star),Commands->Get_Position(obj)) > huntSearchDistance) || Is_Script_Attached(star,"JMG_Utility_AI_Goto_Target_Script_Ignore_Object")) + Return_Home(obj,false); + } + if (state == IDLE || state == RETURNING_HOME || state == WANDERING_GROUP) + { + GameObject *star = findClosestStar(obj); + if (star) + { + state = HUNTING_STAR; + Attack_Move(obj,star,Vector3(),huntSpeed,huntArriveDistance,false,false); + } + } + if (state == IDLE && wanderingAiGroupId != -1) + { + Vector3 wanderPos = Vector3(); + if (GetRandomPosition(&wanderPos)) + { + state = WANDERING_GROUP; + homeLocation = wanderPos; + Attack_Move(obj,NULL,wanderPos,wanderSpeed,1.0f,false,false); + } + } + if (state == RETURNING_HOME || state == WANDERING_GROUP) + if (JmgUtility::SimpleDistance(lastAction.location,Commands->Get_Position(obj)) <= (wanderDistanceOverride != 0 ? wanderDistanceOverride : (obj->As_VehicleGameObj() ? 25.0f : 1.0f))) + state = IDLE; + if (state == ACTION_BADPATH) + Cant_Get_To_target(obj); + if (state != IDLE) + Stuck_Check(obj,targetPos); + Commands->Start_Timer(obj,this,0.1f,1); + } + if (number == 2) + { + if (removeIgnoreTime) + { + removeIgnoreTime--; + if (!removeIgnoreTime) + ignoreEnemyId = 0; + } + Commands->Start_Timer(obj,this,1.0f,2); + } + if (number == 3) + { + attackArriveDistance = Get_Float_Parameter("AttackDistance") >= 0 ? Get_Float_Parameter("AttackDistance") : weaponEffectiveRange; + attackArriveDistance += Commands->Get_Random(Get_Float_Parameter("RandomAttackDistance"),Get_Float_Parameter("RandomAttackDistance")); + } + if (number == 4) + { + huntArriveDistance = Get_Float_Parameter("HuntArriveDistance"); + huntArriveDistance += Commands->Get_Random(Get_Float_Parameter("RandomHuntArriveDistance"),Get_Float_Parameter("RandomHuntArriveDistance")); + } +} +void JMG_Utility_AI_Goto_Target_Script::Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason) +{ + if (reason == ACTION_COMPLETE_PATH_BAD_DEST) + { + if (state == HUNTING_STAR) + { + ignoreEnemyId = huntingEnemyId; + removeIgnoreTime = 10; + state = ACTION_BADPATH; + } + else if (state == WANDERING_GROUP) + state = ACTION_BADPATH; + else if (state == ATTACKING_TARGET) + state = ACTION_BADPATH; + } +} +void JMG_Utility_AI_Goto_Target_Script::Damaged(GameObject *obj,GameObject *damager,float damage) +{ + if (damage <= 0.0f || Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj)) + return; + if (!_stricmp(Get_Skin(damager),"Blamo") || !_stricmp(Get_Shield_Type(damager),"Blamo")) + return; + if (!targetId || !lastSeenTime || Choose_Target(obj,damager)) + { + targetId = Commands->Get_ID(damager); + lastSeenTime = Commands->Get_Random_Int(30,60); + state = ATTACKING_TARGET; + Attack_Move(obj,damager,Vector3(),attackSpeed,attackArriveDistance,true,false); + } +} +void JMG_Utility_AI_Goto_Target_Script::Attack_Move(GameObject *obj,GameObject *target,Vector3 location,float speed,float distance,bool attack,bool overrideLocation) +{ + lastAction.location = location; + Commands->Action_Reset(obj,100); + lastAction = LastAction(targetId,location,speed,distance,attack,overrideLocation); + ActionParamsStruct params; + params.ObserverID = this->Get_ID(); + if (target && !overrideLocation) + { + params.Set_Movement(target,speed,distance,false); + params.MoveFollow = true; + } + else + { + params.Set_Movement(location,speed,distance,false); + params.MoveFollow = false; + } + params.MoveBackup = moveBackward; + params.MovePathfind = true; + if (Get_Int_Parameter("ShutdownEngineOnArrival")) + params.ShutdownEngineOnArrival = true; + Commands->Action_Goto(obj,params); + params.Set_Basic(this,100,100,AI_STATE_COMBAT); + params.AttackCheckBlocked = Get_Int_Parameter("AttackCheckBlocked") ? true : false; + if (target && attack) + { + params.Set_Attack(target,weaponRange,0.0f,true); + Commands->Action_Attack(obj,params); + } +} +GameObject *JMG_Utility_AI_Goto_Target_Script::findClosestStar(GameObject *obj) +{ + if (Commands->Get_Player_Type(obj) == -2) + return NULL; + GameObject *nearest = NULL; + float nearDist = -1.0f; + Vector3 pos = Commands->Get_Position(obj); + int myPlayerType = Commands->Get_Player_Type(obj); + for (SLNode *current = GameObjManager::SmartGameObjList.Head();current;current = current->Next()) + { + SmartGameObj* o = current->Data(); + int oPlayerType = Commands->Get_Player_Type(o); + int enemyId = Commands->Get_ID(o); + if (!Is_Script_Attached(o,"JMG_Utility_AI_Goto_Target_Script_Target")) + continue; + if (!(o->As_SoldierGameObj() || o->As_VehicleGameObj())) + continue; + if (!Commands->Get_Health(o) || oPlayerType == -4 || oPlayerType == -2 || oPlayerType == myPlayerType || enemyId == ignoreEnemyId) + continue; + if (!_stricmp(Get_Skin(o),"Blamo") || !_stricmp(Get_Shield_Type(o),"Blamo")) + continue; + if (!huntStealth) + { + GameObject *vehicle = Get_Vehicle(o); + if (vehicle && vehicle->As_SmartGameObj() && vehicle->As_SmartGameObj()->Is_Stealthed()) + continue; + else if (o->As_SmartGameObj() && o->As_SmartGameObj()->Is_Stealthed()) + continue; + } + if (maxSightFromHomeLocation > 0 && JmgUtility::SimpleDistance(homeLocation,Commands->Get_Position(o)) > maxSightFromHomeLocation) + continue; + float tempDist = JmgUtility::SimpleDistance(pos,Commands->Get_Position(o)); + if (huntSearchDistance >= 0.0f && tempDist > huntSearchDistance) + continue; + if (!nearest || (tempDist < nearDist)) + { + nearest = o; + nearDist = tempDist; + huntingEnemyId = enemyId; + } + } + return nearest; +} +void JMG_Utility_AI_Goto_Target_Script::Return_Home(GameObject *obj,ValidLastLocation goNearLastWanderPoint) +{ + Vector3 wanderPos; + if (goNearLastWanderPoint.valid && Commands->Get_Random(0.0f,1.0f) < Get_Float_Parameter("ChanceToInvestigateLastSeenLocation")) + { + state = WANDERING_GROUP; + Attack_Move(obj,NULL,goNearLastWanderPoint.location,wanderSpeed,1.0f,false,false); + } + else if (wanderingAiGroupId != -1 && GetRandomPosition(&wanderPos)) + { + state = WANDERING_GROUP; + Attack_Move(obj,NULL,wanderPos,wanderSpeed,1.0f,false,false); + } + else if (Get_Int_Parameter("ReturnHome")) + { + state = RETURNING_HOME; + Attack_Move(obj,NULL,homeLocation,returnHomeSpeed,1.0f,false,false); + } + else + { + state = IDLE; + Attack_Move(obj,NULL,Commands->Get_Position(obj),1.0f,1.0f,false,false); + } +} +void JMG_Utility_AI_Goto_Target_Script::Stuck_Check(GameObject *obj,Vector3 targetPos) +{ + if (obj->As_VehicleGameObj()) + { + Vector3 pos = Commands->Get_Position(obj); + if (JmgUtility::SimpleDistance(pos,lastPosition) < 1.0f) + { + if (targetId && JmgUtility::SimpleDistance(pos,targetPos) <= attackArriveDistance*attackArriveDistance) + { + stuckTime = 0; + return; + } + if (!reverseTime) + { + stuckTime++; + if (stuckTime > 30) + { + moveBackward = true; + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,lastAction.speed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + reverseTime = Commands->Get_Random_Int(10,60); + stuckTime = 0; + } + } + } + else + { + stuckTime = 0; + lastPosition = pos; + } + if (reverseTime) + { + reverseTime--; + if (!reverseTime) + { + moveBackward = false; + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,lastAction.speed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } + } + } + else + { + Vector3 pos = Commands->Get_Position(obj); + if (JmgUtility::SimpleDistance(pos,lastPosition) < 1.0f) + { + if (targetId && JmgUtility::SimpleDistance(pos,targetPos) <= attackArriveDistance*attackArriveDistance) + { + stuckTime = 0; + return; + } + stuckTime++; + if (stuckTime > 30) + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),lastAction.location,lastAction.speed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + if (stuckTime > 60) + Attack_Move(obj,NULL,homeLocation,lastAction.speed,lastAction.distance,lastAction.attack,lastAction.overrideLocation); + } + else + { + stuckTime = 0; + lastPosition = pos; + } + } +} +void JMG_Utility_AI_Goto_Target_Script::Cant_Get_To_target(GameObject *obj) +{ + Vector3 wanderPos = Vector3(); + GameObject *star = findClosestStar(obj); + if (star && Commands->Get_ID(star) != ignoreEnemyId) + { + state = HUNTING_STAR; + Attack_Move(obj,Commands->Find_Object(lastAction.targetId),Commands->Get_Position(star),huntSpeed,huntArriveDistance,true,true); + } + else if (wanderingAiGroupId != -1 && GetRandomPosition(&wanderPos)) + { + state = WANDERING_GROUP; + Attack_Move(obj,NULL,wanderPos,wanderSpeed,1.0f,true,true); + } + else + { + state = RETURNING_HOME; + Attack_Move(obj,NULL,homeLocation,returnHomeSpeed,1.0f,true,true); + } +} +bool JMG_Utility_AI_Goto_Target_Script::Choose_Target(GameObject *obj,GameObject *target) +{ + Vector3 pos = Commands->Get_Position(obj); + GameObject *currentTarget = Commands->Find_Object(targetId); + if (!currentTarget) + return true; + if (JmgUtility::SimpleDistance(pos,Commands->Get_Position(target)) < JmgUtility::SimpleDistance(pos,Commands->Get_Position(currentTarget))) + return true; + return false; +} +JMG_Utility_AI_Goto_Target_Script::ValidLastLocation::ValidLastLocation(int enemyId) +{ + GameObject *target = Commands->Find_Object(enemyId); + if (!target || !Commands->Get_Health(target)) + { + this->valid = false; + return; + } + this->location = Commands->Get_Position(target); + this->valid = true; +} +void JMG_Utility_AI_Goto_Target_Script_Ignore_Object::Created(GameObject *obj) +{ +} +void JMG_Utility_AI_Goto_Target_Script_Target::Created(GameObject *obj) +{ +} +void JMG_Utility_Custom_Send_Custom_If_Script_Count::Created(GameObject *obj) +{ + recieveMessage = Get_Int_Parameter("Custom"); + id = Get_Int_Parameter("ID"); + custom = Get_Int_Parameter("SendCustom"); + Param = Get_Int_Parameter("Param"); + delay = Get_Float_Parameter("Delay"); + randomDelay = Get_Float_Parameter("RandomDelay"); + randomChance = Get_Float_Parameter("RandomChance"); + sprintf(script,"%s",Get_Parameter("Script")); + maxCount = Get_Int_Parameter("MaxCount"); + playerAddMaxCount = Get_Float_Parameter("PlayerAddMaxCount"); +} +void JMG_Utility_Custom_Send_Custom_If_Script_Count::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (message == recieveMessage) + { + int count = 0; + for (SLNode *current = GameObjManager::SmartGameObjList.Head();current;current = current->Next()) + { + SmartGameObj *o = current->Data(); + if (!o || !o->As_ScriptableGameObj() || !Is_Script_Attached(o,script)) + continue; + count++; + } + if (count >= maxCount+((int)playerAddMaxCount*Get_Player_Count())) + return; + if (randomChance && randomChance < Commands->Get_Random(0.0f,1.0f)) + return; + GameObject *object = id ? (id == -1 ? sender : Commands->Find_Object(id)) : obj; + Commands->Send_Custom_Event(obj,object,custom,Param == -1 ? param : Param,delay+(randomDelay > 0 ? Commands->Get_Random(0.0f,randomDelay) : 0.0f)); + } +} +void JMG_Utility_Created_Trigger_Create_Vehicle::Created(GameObject *obj) +{ + int ownerId = Get_Int_Parameter("OwnerID"); + GameObject *owner = ownerId ? (ownerId == -1 ? obj : Commands->Find_Object(ownerId)) : NULL; + Create_Vehicle(Get_Parameter("PresetName"),Get_Float_Parameter("Delay"),owner,Get_Int_Parameter("TeamID")); +} +void JMG_Utility_Custom_Remove_And_Attach_Script::Created(GameObject *obj) +{ + custom = Get_Int_Parameter("Custom"); + const char *parameters = Get_Parameter("Params"); + params = newstr(parameters); + char delim = Get_Parameter("Delim")[0]; + unsigned int length = strlen(parameters); + for (unsigned int x = 0;x < length;x++) + if (params[x] == delim) + params[x] = ','; + attachScript = newstr(Get_Parameter("AttachScript")); + removeScript = newstr(Get_Parameter("RemoveScript")); + repeat = Get_Int_Parameter("Repeat") ? true : false; + requiresRemoveScript = Get_Int_Parameter("RequiresRemoveScript") ? true : false; +} +void JMG_Utility_Custom_Remove_And_Attach_Script::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (message == custom) + { + if (requiresRemoveScript && !Is_Script_Attached(obj,removeScript)) + return; + Remove_Script(obj,removeScript); + Commands->Attach_Script(obj,attachScript,params); + if (!repeat) + { + Destroy_Script(); + return; + } + } +} +void JMG_Utility_AI_Guardian_Aircraft_Ignored::Created(GameObject *obj) +{ +} +void JMG_Utility_AI_Guardian_Infantry_Ignored::Created(GameObject *obj) +{ +} +void JMG_Utility_AI_Guardian_Vehicle_Ignored::Created(GameObject *obj) +{ +} +void JMG_Utility_AI_Guardian_Generic_Ignored::Created(GameObject *obj) +{ +} +void JMG_Utility_Objective_System_Objective_Marker::Created(GameObject *obj) +{ + objectiveId = Get_Int_Parameter("ObjectiveID"); +} +GameObject *NewObjectiveSystem::GetObjectiveMarker(int objectiveMarkerId,GameObject *sender,int objectiveId) +{ + if (objectiveMarkerId == -2) + { + for (SLNode *current = GameObjManager::GameObjList.Head();current;current = current->Next()) + { + GameObject* o = current->Data()->As_ScriptableGameObj(); + if (!o || !o->As_ScriptableGameObj()) + continue; + JMG_Utility_Objective_System_Objective_Marker *script = (JMG_Utility_Objective_System_Objective_Marker*)Find_Script_On_Object(o,"JMG_Utility_Objective_System_Objective_Marker"); + if (!script) + continue; + if (script->objectiveId != objectiveId) + continue; + return o; + } + } + return objectiveMarkerId == -1 ? sender : Commands->Find_Object(objectiveMarkerId); +} +void JMG_Utility_Remove_Script_If_Doesnt_Have_Weapon::Created(GameObject *obj) +{ + sprintf(weaponName,"%s",Get_Parameter("WeaponName")); + rate = Get_Float_Parameter("Rate"); + sprintf(script,"%s",Get_Parameter("Script")); + const char *parameters = Get_Parameter("Params"); + params = newstr(parameters); + char delim = Get_Parameter("Delim")[0]; + unsigned int length = strlen(parameters); + for (unsigned int x = 0;x < length;x++) + if (params[x] == delim) + params[x] = ','; + Commands->Start_Timer(obj,this,rate,1); +} +void JMG_Utility_Remove_Script_If_Doesnt_Have_Weapon::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + if (Has_Weapon(obj,weaponName)) + Attach_Script_Once(obj,script,params); + else if (!Is_Script_Attached(obj,script)) + Remove_Script(obj,script); + Commands->Start_Timer(obj,this,rate,1); + } +} +void JMG_Utility_Spawn_With_Last_Selected_Gun_Ignore::Created(GameObject *obj) +{ + Commands->Start_Timer(obj,this,0.25f,1); +} +void JMG_Utility_Spawn_With_Last_Selected_Gun_Ignore::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + JMG_Utility_Spawn_With_Last_Selected_Gun_Control::ignoredWeapons.Add_Tail(new JMG_Utility_Spawn_With_Last_Selected_Gun_Control::StringNode(Get_Parameter("WeaponPreset"))); + } +} +void JMG_Utility_Objective_System_Override_Visible_Settings::Created(GameObject *obj) +{ + Commands->Start_Timer(obj,this,0.25f,1); +} +void JMG_Utility_Objective_System_Override_Visible_Settings::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + NewObjectiveSystem::ObjectiveVisibleSettingOverride *overrideObject = new NewObjectiveSystem::ObjectiveVisibleSettingOverride(Get_Int_Parameter("ObjectiveID"),Get_Parameter("MarkerModel"),Get_Int_Parameter("MarkerColor"),Get_Parameter("AttachBone"),Get_Int_Parameter("OverrideTextColor") ? true : false,Get_Vector3_Parameter("TextColor"),Get_Int_Parameter("OverrideHudColor") ? true : false,Get_Vector3_Parameter("HudColor")); + BasicObjectiveSystem.overrideVisibleObjectiveSettings.Add_Tail(overrideObject); + } +} +void JMG_Utility_Custom_Create_Object_At_Bone::Created(GameObject *obj) +{ + custom = Get_Int_Parameter("Custom"); + repeat = Get_Int_Parameter("Repeat") ? true : false; +} +void JMG_Utility_Custom_Create_Object_At_Bone::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (message == custom) + { + GameObject *object = Commands->Create_Object(Get_Parameter("Preset"),Commands->Get_Position(obj)); + Commands->Attach_To_Object_Bone(object,obj,Get_Parameter("Bone")); + Vector3 targetPos = Commands->Get_Position(object); + MoveablePhysClass *mphys = object->As_PhysicalGameObj() ? object->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass() : NULL; + Commands->Attach_To_Object_Bone(object,NULL,""); + if (mphys && mphys->Find_Teleport_Location(targetPos,Get_Float_Parameter("MaxDistance"),&targetPos)) + { + Commands->Set_Position(object,targetPos); + Force_Position_Update(object); + } + if (!repeat) + Destroy_Script(); + } +} +void JMG_Utility_Killed_Send_Custom_When_Killed_By_Nothing::Killed(GameObject *obj,GameObject *killer) +{ + if (killer != NULL) + return; + int id = Get_Int_Parameter("ID"); + GameObject *object = id ? Commands->Find_Object(id) : obj; + Commands->Send_Custom_Event(obj,object,Get_Int_Parameter("Custom"),Get_Int_Parameter("Param"),Get_Float_Parameter("Delay")); + Destroy_Script(); +} +void JMG_Utility_Custom_Drop_Corpse::Created(GameObject *obj) +{ + custom = Get_Int_Parameter("Custom"); + repeat = Get_Int_Parameter("Repeat") ? true : false; + sprintf(powerupName,"%s",Get_Parameter("PowerupName")); +} +void JMG_Utility_Custom_Drop_Corpse::Custom(GameObject *obj,int message,int param,GameObject *sender) +{ + if (message == custom) + { + Commands->Start_Timer(obj,this,0.0f,1); + } +} +void JMG_Utility_Custom_Drop_Corpse::Timer_Expired(GameObject *obj,int number) +{ + if (number == 1) + { + Vector3 pos = Commands->Get_Position(obj); + GameObject *powerup = Commands->Create_Object(powerupName,pos); + Commands->Set_Facing(powerup,Commands->Get_Facing(obj)); + Commands->Set_Model(powerup,Get_Model(obj)); + if (!obj->As_SmartGameObj()) + return; + AnimControlClass *control = obj->As_SmartGameObj()->Get_Anim_Control(); + if (!control || control->Get_Animation_Name() == NULL || !_stricmp(control->Get_Animation_Name(),"")) + return; + Commands->Set_Animation(powerup,control->Get_Animation_Name(),false,0,control->Get_Current_Frame(),-1,true); + Commands->Destroy_Object(obj); + if (!repeat) + Destroy_Script(); + } +} ScriptRegistrant JMG_Utility_Check_If_Script_Is_In_Library_Registrant("JMG_Utility_Check_If_Script_Is_In_Library","ScriptName:string,CppName:string"); ScriptRegistrant JMG_Send_Custom_When_Custom_Sequence_Matched_Registrant("JMG_Send_Custom_When_Custom_Sequence_Matched","Success_Custom=0:int,Correct_Step_Custom=0:int,Partial_Failure_Custom=0:int,Failure_Custom=0:int,Send_To_ID=0:int,Custom_0=0:int,Custom_1=0:int,Custom_2=0:int,Custom_3=0:int,Custom_4=0:int,Custom_5=0:int,Custom_6=0:int,Custom_7=0:int,Custom_8=0:int,Custom_9=0:int,Disable_On_Success=1:int,Disable_On_Failure=0:int,Starts_Enabled=1:int,Enable_Custom=0:int,Correct_Step_Saftey=0:int,Failure_Saftey=1:int,Max_Failures=1:int"); ScriptRegistrant JMG_Utility_Change_Model_On_Timer_Registrant("JMG_Utility_Change_Model_On_Timer","Model=null:string,Time=0:float"); @@ -16204,7 +17441,7 @@ ScriptRegistrant JMG_Utility_Custom_Display_Briefing_Message_Registrant("JMG_Utility_Custom_Display_Briefing_Message","Custom=0:int,FileName=null:string,TextTag=[]:string,MessageColor=239.0 228.0 176.0:Vector3,LineDelayTime=10.0:float,UISound=null:string"); ScriptRegistrant JMG_Utility_Zone_Set_Player_Team_Registrant("JMG_Utility_Zone_Set_Player_Team","SetPlayerTeam=0:int,RequiredPlayerTeam=2:int"); ScriptRegistrant JMG_Utility_Objective_System_Objective_Update_Create_Registrant("JMG_Utility_Objective_System_Objective_Update_Create","NewObjectiveID:int,NewObjectiveStringID:int,ObjectiveMarkerObjectID:int,CompleteObjectiveID:int,Delay:float,NewObjectivePriority=1:int"); -ScriptRegistrant JMG_Utility_Objective_System_Objective_Remove_Custom_Registrant("JMG_Utility_Objective_System_Objective_Remove_Custom","Custom:int,ObjectiveID:int"); +ScriptRegistrant JMG_Utility_Objective_System_Objective_Remove_Custom_Registrant("JMG_Utility_Objective_System_Objective_Remove_Custom","Custom:int,ObjectiveID:int,OnlyRemovePending=0:int"); ScriptRegistrant JMG_Utility_Delay_Then_Rotate_Camera_Registrant("JMG_Utility_Delay_Then_Rotate_Camera","Delay:float,Facing:float"); ScriptRegistrant JMG_Utility_Damage_SmartGameObjects_In_Range_Registrant("JMG_Utility_Damage_SmartGameObjects_In_Range","Range=1.0:float,Damage=1.0:float,Warhead=None:string,Rate=0.1:float"); ScriptRegistrant JMG_Utility_Unstick_Infantry_If_Stuck_Registrant("JMG_Utility_Unstick_Infantry_If_Stuck","Rate=0.25:float,Distance=1.25:float"); @@ -16271,7 +17508,7 @@ ScriptRegistrant JMG_Utility_Custom_Destroy_All_Presets_By_Name_Registrant("JMG_Utility_Custom_Destroy_All_Presets_By_Name","Custom:int,PresetName:string"); ScriptRegistrant JMG_Utility_Send_Custom_When_Damage_Exceedes_Threshold_Registrant("JMG_Utility_Send_Custom_When_Damage_Exceedes_Threshold","DamageThreshold:float,LockoutTime:float,ID:int,Custom:int,Param:int,Delay:float"); ScriptRegistrant JMG_Utility_Custom_Send_Translated_String_To_All_Players_Registrant("JMG_Utility_Custom_Send_Translated_String_To_All_Players","Custom:int,StringID:string,ColorRGB:Vector3,Repeatable=1:int"); -ScriptRegistrant JMG_Utility_Destroyed_Drop_Powerup_Registrant("JMG_Utility_Destroyed_Drop_Powerup","WeaponPreset:string,PowerupName:string,HeightAdjust=0.0:float"); +ScriptRegistrant JMG_Utility_Destroyed_Drop_Powerup_Registrant("JMG_Utility_Destroyed_Drop_Powerup","RequiredWeaponPreset:string,PowerupName:string,HeightAdjust=0.0:float"); ScriptRegistrant JMG_Utility_Pickup_Attach_Script_Registrant("JMG_Utility_Pickup_Attach_Script","Script:string,Params:string,Delim=@:string"); ScriptRegistrant JMG_Utility_Objective_System_Objective_Status_Update_Custom_Registrant("JMG_Utility_Objective_System_Objective_Status_Update_Custom","Custom:int,ObjectiveID:int,NewObjectiveStringID:int,NewObjectiveMarkerObjectID:int"); ScriptRegistrant JMG_Utility_Objective_System_Objective_Failed_Custom_Registrant("JMG_Utility_Objective_System_Objective_Failed_Custom","Custom:int,ObjectiveID:int"); @@ -16345,8 +17582,8 @@ ScriptRegistrant JMG_Utility_AI_Skittish_Herd_Animal_Ignore_Registrant("JMG_Utility_AI_Skittish_Herd_Animal_Ignore",""); ScriptRegistrant JMG_Utility_AI_Skittish_Herd_Animal_Controller_Registrant("JMG_Utility_AI_Skittish_Herd_Animal_Controller",""); ScriptRegistrant JMG_Utility_Custom_Display_Dialog_Box_Registrant("JMG_Utility_Custom_Display_Dialog_Box","Custom:int,Message:string,Delim=@:string"); -ScriptRegistrant JMG_Utility_Custom_Send_Custom_On_Preset_Count_Registrant("JMG_Utility_Custom_Send_Custom_On_Preset_Count","Custom:int,PresetID:int,MinCount=1,MaxCount=-1:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); -ScriptRegistrant JMG_Utility_Custom_Send_Custom_On_Script_Count_Registrant("JMG_Utility_Custom_Send_Custom_On_Script_Count","Custom:int,Script:string,MinCount=1,MaxCount=-1:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); +ScriptRegistrant JMG_Utility_Custom_Send_Custom_On_Preset_Count_Registrant("JMG_Utility_Custom_Send_Custom_On_Preset_Count","Custom:int,PresetID:int,MinCount=1:int,MaxCount=-1:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); +ScriptRegistrant JMG_Utility_Custom_Send_Custom_On_Script_Count_Registrant("JMG_Utility_Custom_Send_Custom_On_Script_Count","Custom:int,Script:string,MinCount=1:int,MaxCount=-1:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); ScriptRegistrant JMG_Utility_Poke_Send_Custom_From_Poker_Registrant("JMG_Utility_Poke_Send_Custom_From_Poker","ID=0:int,Custom=0:int,Param=0:int,Delay=0.0:float,TriggerOnce=1:int,PlayerType=2:int"); ScriptRegistrant JMG_Utility_Custom_Grant_Scaled_Score_Registrant("JMG_Utility_Custom_Grant_Scaled_Score","GrantCustom:int,Score:float,ScoreMultiplier:float,EntireTeam=0:int,MaxPlayerCount=-1:int,Repeat=1:int,GrantToSender=0:int,UpdateScaleCustom=0:int,StopUpdateCustom=0:int"); ScriptRegistrant JMG_Utility_Custom_Set_Infantry_Height_Registrant("JMG_Utility_Custom_Set_Infantry_Height","Custom:int,Height=-9999.0:float"); @@ -16391,7 +17628,7 @@ ScriptRegistrant JMG_Utility_Dynamic_Script_Custom_Add_Update_Parameter_Registrant("JMG_Utility_Dynamic_Script_Custom_Add_Update_Parameter","Custom:int,ScriptID:int,Index:int,Param:string,Delim:string"); ScriptRegistrant JMG_Utility_Dynamic_Script_Custom_Attach_Registrant("JMG_Utility_Dynamic_Script_Custom_Attach","Custom:int,ScriptID:int"); ScriptRegistrant JMG_Utility_Objective_System_Custom_Add_Objective_Send_Custom_Registrant("JMG_Utility_Objective_System_Custom_Add_Objective_Send_Custom","Custom:int,NewObjectiveID:int,NewObjectiveStringID:int,ObjectiveMarkerObjectID:int,CompleteObjectiveID:int,Delay:float,NewObjectivePriority=1:int,SendCustom:int,Param:int,CustomDelay:float"); -ScriptRegistrant JMG_Utility_Objective_System_Custom_Send_Custom_Status_Registrant("JMG_Utility_Objective_System_Custom_Send_Custom_Status","Custom:int,ObjectiveID:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); +ScriptRegistrant JMG_Utility_Objective_System_Custom_Send_Custom_Status_Registrant("JMG_Utility_Objective_System_Custom_Send_Custom_Status","Custom:int,ObjectiveID:int,Status:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); ScriptRegistrant JMG_Utility_Objective_System_Custom_Send_Custom_Does_Not_Exist_Registrant("JMG_Utility_Objective_System_Custom_Send_Custom_Does_Not_Exist","Custom:int,ObjectiveID:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); ScriptRegistrant JMG_Utility_Objective_System_Send_Random_Objective_As_Custom_Registrant("JMG_Utility_Objective_System_Send_Random_Objective_As_Custom","Custom:int,ObjectiveID0=-999:int,ObjectiveID1=-999:int,ObjectiveID2=-999:int,ObjectiveID3=-999:int,ObjectiveID4=-999:int,ObjectiveID5=-999:int,ObjectiveID6=-999:int,ObjectiveID7=-999:int,ObjectiveID8=-999:int,ObjectiveID9=-999:int,ID=0:int,Param:int,Delay=0.0:float"); ScriptRegistrant JMG_Utility_Objective_System_Custom_Send_Custom_Not_Status_Registrant("JMG_Utility_Objective_System_Custom_Send_Custom_Not_Status","Custom:int,ObjectiveID:int,Status:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float"); @@ -16437,7 +17674,7 @@ ScriptRegistrant JMG_Utility_Security_System_Random_NumberPad_Control_Registrant("JMG_Utility_Security_System_Random_NumberPad_Control","RandomCombinationDigits:int,ID:int,Success_Custom=0:int,Partial_Failure_Custom=0:int,Failure_Custom=0:int,Disable_On_Success=1:int,Disable_On_Failure=0:int,Starts_Enabled=1:int,Enable_Custom=0:int,Failure_Safty=1:int,Max_Failures=1:int,Sound_Name_Base:string"); ScriptRegistrant JMG_Utility_Custom_Combination_Lock_Registrant("JMG_Utility_Custom_Combination_Lock","ID:int,Combination:string,Input_Number_Custom:int,Input_Enter_Custom:int,Input_Clear_Custom:int,Success_Custom=0:int,Partial_Failure_Custom=0:int,Failure_Custom=0:int,Disable_On_Success=1:int,Disable_On_Failure=0:int,Starts_Enabled=1:int,Enable_Custom=0:int,Failure_Safty=1:int,Max_Failures=1:int,Sound_Name_Base:string"); ScriptRegistrant JMG_Utility_Custom_Combination_Lock_Key_Registrant("JMG_Utility_Custom_Combination_Lock_Key","ID=0:int,Message:int,Param=0:int,Sound_Name=null:string"); -ScriptRegistrant JMG_Utility_Sync_String_With_Random_NumberPad_Control_Registrant("JMG_Utility_Sync_String_With_Random_NumberPad_Control","StringID:int,Delim=@:string"); +ScriptRegistrant JMG_Utility_Security_System_Sync_String_Random_NumberPad_Control_Registrant("JMG_Utility_Security_System_Sync_String_Random_NumberPad_Control","StringID:int,Delim=@:string"); ScriptRegistrant JMG_Utility_Created_Animate_SubObject_On_Join_Registrant("JMG_Utility_Created_Animate_SubObject_On_Join","SubObject:string,Animation:string"); ScriptRegistrant JMG_Utility_Custom_Play_Animation_Send_Custom_When_Complete_Registrant("JMG_Utility_Custom_Play_Animation_Send_Custom_When_Complete","ReceivedCustom:int,Animation:string,StartFrame:float,EndFrame:float,ID:int,Custom:int,Param:int,Delay:float"); ScriptRegistrant JMG_Utility_Created_Play_Locked_Infantry_Animation_Registrant("JMG_Utility_Created_Play_Locked_Infantry_Animation","Animation:string"); @@ -16453,7 +17690,7 @@ ScriptRegistrant JMG_Utility_Custom_Create_Random_Explosions_Registrant("JMG_Utility_Custom_Create_Random_Explosions","Custom:int,ExplosionPreset:string,Count:int,MaxDistance:float,KillerID:int"); ScriptRegistrant JMG_Utility_Custom_Enable_Incrementally_Spawners_In_Range_Registrant("JMG_Utility_Custom_Enable_Spawners_Incrementally_In_Range","StartID:int,EndID:int,Custom:int,Enable=1:int"); ScriptRegistrant JMG_Utility_Control_Point_Team_Target_Wander_Point_Registrant("JMG_Utility_Control_Point_Team_Target_Wander_Point","ControlPointID:int,TeamID:int,TargetGroupID:int,NonTargetGroupId:int"); -ScriptRegistrant JMG_Utility_AI_Control_Point_Registrant("JMG_Utility_AI_Control_Point","CaptureCpGroupId:int,CaptureCpChance=0.33:float,CaptureSpeed=1.0:float,CaptureDistance=5.0:float,DefendCpGroupId:int,DefendSpeed=1.0:float,DefendDistance=1.0:float,CloseDefendDistance=25.0:float,ChooseFarDefendChance=0.1:float,AttackSpeed=1.0:float,AttackDistance=-1.0:float,RandomAttackDistance=0.0:float,AttackDistractFromCaptureChance=0.25,ChanceToInvestigateLastSeenLocation=0.66:float,AttackCheckBlocked=1:int,CanSeeStealth=1:int,ShutdownEngineOnArrival=0:int"); +ScriptRegistrant JMG_Utility_AI_Control_Point_Registrant("JMG_Utility_AI_Control_Point","CaptureCpGroupId:int,CaptureCpChance=0.33:float,CaptureSpeed=1.0:float,CaptureDistance=5.0:float,DefendCpGroupId:int,DefendSpeed=1.0:float,DefendDistance=1.0:float,CloseDefendDistance=25.0:float,ChooseFarDefendChance=0.1:float,AttackSpeed=1.0:float,AttackDistance=-1.0:float,RandomAttackDistance=0.0:float,AttackDistractFromCaptureChance=0.25:float,ChanceToInvestigateLastSeenLocation=0.66:float,AttackCheckBlocked=1:int,CanSeeStealth=1:int,ShutdownEngineOnArrival=0:int"); ScriptRegistrant JMG_Utility_Objective_System_Set_Infantry_Attach_Bone_Registrant("JMG_Utility_Objective_System_Set_Infantry_Attach_Bone","InfantryAttachBone:string"); ScriptRegistrant JMG_Utility_Security_System_Fixed_NumberPad_Control_Registrant("JMG_Utility_Security_System_Fixed_NumberPad_Control","KeyCode:string,ID:int,Success_Custom=0:int,Partial_Failure_Custom=0:int,Failure_Custom=0:int,Disable_On_Success=1:int,Disable_On_Failure=0:int,Starts_Enabled=1:int,Enable_Custom=0:int,Failure_Safty=1:int,Max_Failures=1:int,Sound_Name_Base:string"); ScriptRegistrant JMG_Utility_Custom_Teleport_Sender_Wanderpoint_Registrant("JMG_Utility_Custom_Teleport_Sender_Wanderpoint","Custom:int,WanderingAIGroupID=-1:int,SafeTeleportDistance=1.5:float,RetryOnFailure=0:int"); @@ -16477,3 +17714,29 @@ ScriptRegistrant JMG_Utility_Global_Set_Random_Model_Custom_Registrant("JMG_Utility_Global_Set_Random_Model_Custom","Custom:int,Extension:string"); ScriptRegistrant JMG_Utility_Global_Set_Random_Model_Registrant("JMG_Utility_Global_Set_Random_Model","BaseName:string,FinalModelNumber:int"); ScriptRegistrant JMG_Utility_Swimming_Infantry_Advanced_AI_Registrant("JMG_Utility_Swimming_Infantry_Advanced_AI","WeaponsGroupID=0:int,WeaponPreset=Weapon_Swimming_Animations:string,ForceDefinedWeapons=0:int,DefaultHoldStyle=4:int,DefaultSwimSpeed=1.0:float,DrownTime=10.0:float,StartDrownSequence=3.0:float,GaspForBreath=SFX.SwimmingGaspForBreath:string,PantingSoundEmitterModel=s_panting:string,HeartBeatSoundEmitterModel=s_heartBeat:string,DrownDamageRate=2.5:float,CatchBreathRate=0.33:float,WaterDamageAmount=0.0:float,WaterDamageDelayTime=0:int,WaterDamageDelayTimeRecover=0:int,WaterDamageWarhead=None:string,SwimmingSkin:string,SwimmingArmor:string,SwimmingModel:string,SwimmingHeightScale=999.99:float,SwimmingWidthScale=999.99:float"); +ScriptRegistrant JMG_Utility_Global_Custom_Send_Custom_Flag_Controller_Registrant("JMG_Utility_Global_Custom_Send_Custom_Flag_Controller","GlobalFlag:int"); +ScriptRegistrant JMG_Utility_Global_Custom_Send_Custom_Flag_Custom_Registrant("JMG_Utility_Global_Custom_Send_Custom_Flag_Custom","Custom:int,GlobalFlag:int"); +ScriptRegistrant JMG_Utility_Global_Custom_Send_Custom_Registrant("JMG_Utility_Global_Custom_Send_Custom_Flag","GlobalFlag:int,Custom:int,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float,RandomDelay=0.0:float,RandomChance=0.0:float"); +ScriptRegistrant JMG_Utility_AI_Goto_Location_While_Player_Nearby_Registrant("JMG_Utility_AI_Goto_Location_While_Player_Nearby","GotoObjectId:int,GotoLocation:Vector3,MaxPlayerDistance:float,MinAttackRange=0.0:float,ForceFire=0:int,VTOLHover=0.0:float,vsSoldier=1:int,vsVehicle=1:int,vsAircraft=1:int,WeaponError=-1.0:float,OverrideFireMode=0:int,OverrideSpeed=-1.0:float,PlayerType=2:int"); +ScriptRegistrant JMG_Utility_AI_Goto_Location_While_Player_Nearby_Ignored_Registrant("JMG_Utility_AI_Goto_Location_While_Player_Nearby_Ignored",""); +ScriptRegistrant JMG_Utility_Killed_Drop_Powerup_Become_Corpse_Registrant("JMG_Utility_Killed_Drop_Powerup_Become_Corpse","PowerupName:string,RequiredWeaponPreset:string,Chance=1.0:float"); +ScriptRegistrant JMG_Utility_Objective_System_Objectives_Complete_Send_Custom_Registrant("JMG_Utility_Objective_System_Objectives_Complete_Send_Custom","CompletedObjectives:string,Delim=@:string,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float,RandomDelay=0.0:float,Repeat=0:int"); +ScriptRegistrant JMG_Utility_Damage_Update_Animation_Frame_Registrant("JMG_Utility_Damage_Update_Animation_Frame","Animation:string,MaxFrame:float,Model:string"); +ScriptRegistrant JMG_Utility_Security_System_Sync_Model_Random_NumberPad_Control_Registrant("JMG_Utility_Security_System_Sync_Model_Random_NumberPad_Control","KeypadID:int,BaseModel:string,Index:int"); +ScriptRegistrant JMG_Utility_AI_Goto_Target_Script_Registrant("JMG_Utility_AI_Goto_Target_Script","HuntSearchDistance=-1.0:float,HuntSpeed=1.0:float,HuntArriveDistance=1.0:float,RandomHuntArriveDistance=0.0:float,HuntStealth=0:int,AttackSpeed=1.0:float,AttackDistance=-1.0:float,RandomAttackDistance=0.0:float,ReturnHome=1:int,ReturnHomeSpeed=1.0:float,WanderingAIGroupID=-1:int,WanderSpeed=1.0:float,CanSeeStealth=1:int,ShutdownEngineOnArrival=0:int,AttackCheckBlocked=1:int,MaxSightRangeFromHome=0.0:float,WanderDistanceOverride=0.0:float,ChangeWanderGroupCustom=0:int,ChangeWanderSpeedCustom=0:int,ChangeHuntDistanceCustom=0:int,ChangeHuntSpeedCustom=0:int,ChangeReturnHomeSpeedCustom=0:int,ChangeMaxSightFromHomeLocationCustom=0:int,ChangeAttackSpeedCustom=0:int,ChanceToInvestigateLastSeenLocation=0.66:float"); +ScriptRegistrant JMG_Utility_AI_Goto_Target_Script_Ignore_Object_Registrant("JMG_Utility_AI_Goto_Target_Script_Ignore_Object",""); +ScriptRegistrant JMG_Utility_AI_Goto_Target_Script_Target_Registrant("JMG_Utility_AI_Goto_Target_Script_Target",""); +ScriptRegistrant JMG_Utility_Custom_Send_Custom_If_Script_Count_Registrant("JMG_Utility_Custom_Send_Custom_If_Script_Count","Custom:int,Script:string,MaxCount:int,PlayerAddMaxCount:float,ID=0:int,SendCustom:int,Param:int,Delay=0.0:float,RandomDelay=0.0:float,RandomChance=0.0:float"); +ScriptRegistrant JMG_Utility_Created_Trigger_Create_Vehicle_Registrant("JMG_Utility_Created_Trigger_Create_Vehicle","PresetName:string,Delay:float,OwnerID:int,TeamID:int"); +ScriptRegistrant JMG_Utility_Custom_Remove_And_Attach_Script_Registrant("JMG_Utility_Custom_Remove_And_Attach_Script","Custom:int,RemoveScript:string,AttachScript:string,Params:string,Delim:string,Repeat:int,RequiresRemoveScript:int"); +ScriptRegistrant JMG_Utility_AI_Guardian_Aircraft_Ignored_Registrant("JMG_Utility_AI_Guardian_Aircraft_Ignored",""); +ScriptRegistrant JMG_Utility_AI_Guardian_Infantry_Ignored_Registrant("JMG_Utility_AI_Guardian_Infantry_Ignored",""); +ScriptRegistrant JMG_Utility_AI_Guardian_Vehicle_Ignored_Registrant("JMG_Utility_AI_Guardian_Vehicle_Ignored",""); +ScriptRegistrant JMG_Utility_AI_Guardian_Generic_Ignored_Registrant("JMG_Utility_AI_Guardian_Generic_Ignored",""); +ScriptRegistrant JMG_Utility_Objective_System_Objective_Marker_Registrant("JMG_Utility_Objective_System_Objective_Marker","ObjectiveID:int"); +ScriptRegistrant JMG_Utility_Remove_Script_If_Doesnt_Have_Weapon_Registrant("JMG_Utility_Remove_Script_If_Doesnt_Have_Weapon","WeaponName:string,Script:string,Params:string,Delim=@:string,Rate=0.1:float"); +ScriptRegistrant JMG_Utility_Spawn_With_Last_Selected_Gun_Ignore_Registrant("JMG_Utility_Spawn_With_Last_Selected_Gun_Ignore","WeaponPreset:string"); +ScriptRegistrant JMG_Utility_Objective_System_Override_Visible_Settings_Registrant("JMG_Utility_Objective_System_Override_Visible_Settings","ObjectiveID:int,MarkerModel:string,MarkerColor=-1:int,AttachBone:string,OverrideTextColor=0:int,TextColor:vector3,OverrideHudColor=0:int,HudColor:vector3"); +ScriptRegistrant JMG_Utility_Custom_Create_Object_At_Bone_Registrant("JMG_Utility_Custom_Create_Object_At_Bone","Custom:int,Preset:string,Bone:string,MaxDistance=1.5:float,Repeat=0:int"); +ScriptRegistrant JMG_Utility_Killed_Send_Custom_When_Killed_By_Nothing_Registrant("JMG_Utility_Killed_Send_Custom_When_Killed_By_Nothing","ID:int,Custom:int,Param:int,Delay:float"); +ScriptRegistrant JMG_Utility_Custom_Drop_Corpse_Registrant("JMG_Utility_Custom_Drop_Corpse","Custom:int,PowerupName:string,Repeat=0:int"); diff -urN sourceold/scripts/jmgUtility.h source/scripts/jmgUtility.h --- sourceold/scripts/jmgUtility.h 2021-07-27 14:44:22.800963900 +1000 +++ source/scripts/jmgUtility.h 2022-02-13 10:20:09.872310800 +1000 @@ -914,6 +914,29 @@ enum Status{Removed=-2,NotDefined=-1,Pending,Accomplished,Failed,Hidden}; int controllerId; char infantryAttachBone[32]; + struct ObjectiveVisibleSettingOverride + { + int objectiveId; + char markerModel[16]; + int markerColor; + char attachBone[16]; + bool overrideTextColor; + Vector3 textColor; + bool overrideHudColor; + Vector3 hudColor; + ObjectiveVisibleSettingOverride(int objectiveId,const char *model,int markerColor,const char *attachBone,bool overrideTextColor,Vector3 textColor,bool overrideHudColor,Vector3 hudColor) + { + this->objectiveId = objectiveId; + sprintf(this->markerModel,"%s",model); + this->markerColor = markerColor; + sprintf(this->attachBone,"%s",attachBone); + this->overrideTextColor = overrideTextColor; + this->textColor = textColor; + this->overrideHudColor = overrideHudColor; + this->hudColor = hudColor; + } + }; + SList overrideVisibleObjectiveSettings; private: struct ObjectiveNode { @@ -967,15 +990,19 @@ objectiveUpdateObjectiveStringNumbered = Get_Translated_String(Get_String_ID_By_Desc("IDS_OBJ2_UPDATED_NUMBERED")); objectiveStringIdsLoaded = true; } - void selectMessageAndColor(const char *format,Priority priority) + void selectMessageAndColor(int objectiveId,const char *format,Priority priority) { - switch (priority) - { - case Primary: JmgUtility::MessageTeamPlayersAndType(50,255,50,team,format); break; - case Secondary: JmgUtility::MessageTeamPlayersAndType(50,150,250,team,format); break; - case Tertiary:case Unknown: JmgUtility::MessageTeamPlayersAndType(150,50,150,team,format); break; - default: JmgUtility::MessageTeamPlayersAndType(125,150,150,team,format); break; - } + ObjectiveVisibleSettingOverride *overrideMarker = FindOverrideForObjective(objectiveId); + if (overrideMarker && overrideMarker->overrideTextColor) + JmgUtility::MessageTeamPlayersAndType((int)overrideMarker->textColor.X,(int)overrideMarker->textColor.Y,(int)overrideMarker->textColor.Z,team,format); + else + switch (priority) + { + case Primary: JmgUtility::MessageTeamPlayersAndType(50,255,50,team,format); break; + case Secondary: JmgUtility::MessageTeamPlayersAndType(50,150,250,team,format); break; + case Tertiary:case Unknown: JmgUtility::MessageTeamPlayersAndType(150,50,150,team,format); break; + default: JmgUtility::MessageTeamPlayersAndType(125,150,150,team,format); break; + } } void messagePlayerAndColor(GameObject *player,const char *format,Priority priority) { @@ -1037,11 +1064,11 @@ objectiveCounts++; if (status != Hidden && descriptionId) { - selectMessageAndColor(formatObjectiveString(objectiveNewString,objectivePrioritieStrings[priority]),priority); + selectMessageAndColor(id,formatObjectiveString(objectiveNewString,objectivePrioritieStrings[priority]),priority); if (objectiveNumber) - selectMessageAndColor(formatObjectiveString(Get_Translated_String(descriptionId),objectiveNumber),priority); + selectMessageAndColor(id,formatObjectiveString(Get_Translated_String(descriptionId),objectiveNumber),priority); else - selectMessageAndColor(Get_Translated_String(descriptionId),priority); + selectMessageAndColor(id,Get_Translated_String(descriptionId),priority); } return true; } @@ -1053,13 +1080,21 @@ return; Commands->Destroy_Object(marker); } - GameObject *Create_Radar_Marker(Vector3 pos, Priority priority,int objectiveId,const char *modelOverride) + ObjectiveVisibleSettingOverride *FindOverrideForObjective(int objectiveId) + { + for (SLNode *node = overrideVisibleObjectiveSettings.Head();node;node = node->Next()) + if (node->Data() && node->Data()->objectiveId == objectiveId) + return node->Data(); + return NULL; + } + GameObject *Create_Radar_Marker(Vector3 pos, Priority priority,int objectiveId) { GameObject *radarMarker = Commands->Create_Object("Daves Arrow",pos); Commands->Set_Player_Type(radarMarker,team); Commands->Set_Is_Visible(radarMarker,false); - if (modelOverride) - Commands->Set_Model(radarMarker,modelOverride); + ObjectiveVisibleSettingOverride *overrideMarker = FindOverrideForObjective(objectiveId); + if (overrideMarker && _stricmp(overrideMarker->markerModel,"")) + Commands->Set_Model(radarMarker,overrideMarker->markerModel); else switch (priority) { @@ -1071,9 +1106,12 @@ if (showRadarStars) { Commands->Set_Obj_Radar_Blip_Shape(radarMarker,RADAR_BLIP_SHAPE_OBJECTIVE); - Commands->Set_Obj_Radar_Blip_Color(radarMarker,priority == Primary ? RADAR_BLIP_COLOR_PRIMARY_OBJECTIVE : priority == Secondary ? RADAR_BLIP_COLOR_SECONDARY_OBJECTIVE : RADAR_BLIP_COLOR_TERTIARY_OBJECTIVE); + if (overrideMarker && overrideMarker->markerColor != -1) + Commands->Set_Obj_Radar_Blip_Color(radarMarker,overrideMarker->markerColor); + else + Commands->Set_Obj_Radar_Blip_Color(radarMarker,priority == Primary ? RADAR_BLIP_COLOR_PRIMARY_OBJECTIVE : priority == Secondary ? RADAR_BLIP_COLOR_SECONDARY_OBJECTIVE : RADAR_BLIP_COLOR_TERTIARY_OBJECTIVE); } - Create_Objective_GameObject(radarMarker,objectiveId,priority); + Create_Objective_GameObject(radarMarker,objectiveId,priority,overrideMarker); return radarMarker; } public: @@ -1088,6 +1126,7 @@ sprintf(this->tertiaryObjectiveModel,"%s",tertiaryObjectiveModel); this->showRadarStars = showRadarStars; objectiveNodeList = NULL; + overrideVisibleObjectiveSettings.Remove_All(); } ~NewObjectiveSystem() { @@ -1102,19 +1141,23 @@ } objectiveNodeList = NULL; } - bool Add_Objective(int objectiveId, Priority priority, Status status, unsigned long nameId, char *soundFilename, unsigned long descriptionId,GameObject *blipUnit,const char *modelOverride = NULL,int objectiveNumber = 0) + bool Add_Objective(int objectiveId, Priority priority, Status status, unsigned long nameId, char *soundFilename, unsigned long descriptionId,GameObject *blipUnit,int objectiveNumber = 0) { if (!blipUnit) return false; - GameObject *radarMarker = Create_Radar_Marker(Commands->Get_Position(blipUnit),priority,objectiveId,modelOverride); + GameObject *radarMarker = Create_Radar_Marker(Commands->Get_Position(blipUnit),priority,objectiveId); if (!radarMarker) return false; - Commands->Attach_To_Object_Bone(radarMarker,blipUnit,blipUnit->As_SoldierGameObj() ? infantryAttachBone : "origin"); + ObjectiveVisibleSettingOverride *overrideMarker = FindOverrideForObjective(objectiveId); + if (overrideMarker && _stricmp(overrideMarker->attachBone,"")) + Commands->Attach_To_Object_Bone(radarMarker,blipUnit,overrideMarker->attachBone); + else + Commands->Attach_To_Object_Bone(radarMarker,blipUnit,blipUnit->As_SoldierGameObj() ? infantryAttachBone : "origin"); return addObjective(objectiveId,priority,status,nameId,soundFilename,descriptionId,Commands->Get_ID(radarMarker),objectiveNumber); } - bool Add_Objective(int objectiveId, Priority priority, Status status, unsigned long nameId, char *soundFilename, unsigned long descriptionId,Vector3 blipPosition,const char *modelOverride = NULL,int objectiveNumber = 0) + bool Add_Objective(int objectiveId, Priority priority, Status status, unsigned long nameId, char *soundFilename, unsigned long descriptionId,Vector3 blipPosition,int objectiveNumber = 0) { - GameObject *radarMarker = Create_Radar_Marker(blipPosition,priority,objectiveId,modelOverride); + GameObject *radarMarker = Create_Radar_Marker(blipPosition,priority,objectiveId); if (!radarMarker) return false; return addObjective(objectiveId,priority,status,nameId,soundFilename,descriptionId,Commands->Get_ID(radarMarker),objectiveNumber); @@ -1148,7 +1191,7 @@ if (current->id == objectiveId) { Destroy_Radar_Marker(current->radarMarkerId); - GameObject *radarMarker = Create_Radar_Marker(Commands->Get_Position(blipUnit),current->priority,objectiveId,modelOverride); + GameObject *radarMarker = Create_Radar_Marker(Commands->Get_Position(blipUnit),current->priority,objectiveId); if (!radarMarker) return; Commands->Attach_To_Object_Bone(radarMarker,blipUnit,blipUnit->As_SoldierGameObj() ? infantryAttachBone : "origin"); @@ -1179,7 +1222,7 @@ if (current->id == objectiveId) { Destroy_Radar_Marker(current->radarMarkerId); - GameObject *radarMarker = Create_Radar_Marker(blipPosition,current->priority,objectiveId,modelOverride); + GameObject *radarMarker = Create_Radar_Marker(blipPosition,current->priority,objectiveId); if (!radarMarker) return; current->radarMarkerId = Commands->Get_ID(radarMarker); @@ -1214,9 +1257,9 @@ objectiveCounts--; if (current->status == Pending && current->nameId) if (current->objectiveNumber) - selectMessageAndColor(formatObjectiveString(objectiveCancelledStringNumbered,objectivePrioritieStrings[current->priority],current->objectiveNumber),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(objectiveCancelledStringNumbered,objectivePrioritieStrings[current->priority],current->objectiveNumber),current->priority); else - selectMessageAndColor(formatObjectiveString(objectiveCancelledString,objectivePrioritieStrings[current->priority]),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(objectiveCancelledString,objectivePrioritieStrings[current->priority]),current->priority); Destroy_Radar_Marker(current->radarMarkerId); current->active = false; return true; @@ -1237,9 +1280,9 @@ { if (status != Hidden && current->status != Hidden && current->nameId) if (current->objectiveNumber) - selectMessageAndColor(formatObjectiveString(objectiveStatusChangedStringNumbered,objectivePrioritieStrings[current->priority],current->objectiveNumber,objectiveStatusStrings[status]),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(objectiveStatusChangedStringNumbered,objectivePrioritieStrings[current->priority],current->objectiveNumber,objectiveStatusStrings[status]),current->priority); else - selectMessageAndColor(formatObjectiveString(objectiveStatusChangedString,objectivePrioritieStrings[current->priority],objectiveStatusStrings[status]),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(objectiveStatusChangedString,objectivePrioritieStrings[current->priority],objectiveStatusStrings[status]),current->priority); GameObject *marker = Commands->Find_Object(current->radarMarkerId); if (marker) { @@ -1280,13 +1323,13 @@ { if (current->objectiveNumber) { - selectMessageAndColor(formatObjectiveString(objectiveUpdateObjectiveStringNumbered,objectivePrioritieStrings[current->priority],current->objectiveNumber),current->priority); - selectMessageAndColor(formatObjectiveString(Get_Translated_String(descriptionStringId),current->objectiveNumber),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(objectiveUpdateObjectiveStringNumbered,objectivePrioritieStrings[current->priority],current->objectiveNumber),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(Get_Translated_String(descriptionStringId),current->objectiveNumber),current->priority); } else { - selectMessageAndColor(formatObjectiveString(objectiveUpdateObjectiveString,objectivePrioritieStrings[current->priority]),current->priority); - selectMessageAndColor(Get_Translated_String(descriptionStringId),current->priority); + selectMessageAndColor(objectiveId,formatObjectiveString(objectiveUpdateObjectiveString,objectivePrioritieStrings[current->priority]),current->priority); + selectMessageAndColor(objectiveId,Get_Translated_String(descriptionStringId),current->priority); } } return true; @@ -1353,7 +1396,11 @@ { if (current->active && current->status == Pending && current->priority == Priority::Primary && current->nameId) { - Set_HUD_Help_Text_Player(obj,current->nameId,Vector3(0,1,0)); + ObjectiveVisibleSettingOverride *overrideMarker = FindOverrideForObjective(current->id); + if (overrideMarker && overrideMarker->overrideHudColor) + Set_HUD_Help_Text_Player(obj,current->nameId,Vector3(overrideMarker->hudColor.X/255.0f,overrideMarker->hudColor.Y/255.0f,overrideMarker->hudColor.Z/255.0f)); + else + Set_HUD_Help_Text_Player(obj,current->nameId,Vector3(0,1,0)); return; } current = current->next; @@ -1397,8 +1444,11 @@ } return 0; } - Vector3 Get_Hud_Help_Text_Color(Priority priority) + Vector3 Get_Hud_Help_Text_Color(int objectiveId,Priority priority) { + ObjectiveVisibleSettingOverride *overrideMarker = FindOverrideForObjective(objectiveId); + if (overrideMarker && overrideMarker->overrideHudColor) + return Vector3(overrideMarker->hudColor.X/255.0f,overrideMarker->hudColor.Y/255.0f,overrideMarker->hudColor.Z/255.0f); switch (priority) { case Priority::Primary: @@ -1411,7 +1461,7 @@ return Vector3(1.0f,1.0f,1.0f); } } - void Create_Objective_GameObject(GameObject *radarMarker,int objectiveId,int objectivePriority) + void Create_Objective_GameObject(GameObject *radarMarker,int objectiveId,int objectivePriority,ObjectiveVisibleSettingOverride *overrideMarker) { GameObject *obj = Commands->Find_Object(controllerId); if (!obj) @@ -1425,7 +1475,10 @@ { GameObject *object = Commands->Create_Object(script->preset,Commands->Get_Position(radarMarker)); if (script->attach) - Commands->Attach_To_Object_Bone(object,radarMarker,"origin"); + if (overrideMarker && _stricmp(overrideMarker->attachBone,"")) + Commands->Attach_To_Object_Bone(object,radarMarker,overrideMarker->attachBone); + else + Commands->Attach_To_Object_Bone(object,radarMarker,"origin"); char params[128]; sprintf(params,"%d,%d",Commands->Get_ID(object),Commands->Get_ID(radarMarker)); Commands->Attach_Script(obj,"JMG_Utility_Objective_System_Objective_GameObject_Tracker",params); @@ -1451,6 +1504,16 @@ } } } + bool Check_If_All_Objectives_Are_Complete(int objectiveIds[],int count) + { + for (int x = 0;x < count;x++) + { + if (Get_Objective_Status(objectiveIds[x]) != Status::Accomplished) + return false; + } + return true; + } + GameObject *GetObjectiveMarker(int objectiveMarkerId,GameObject *sender,int objectiveId); }; class ClientNetworkObjectPositionSync @@ -4234,6 +4297,7 @@ * \brief Used to remove an objective on custom * \Custom - Custom to trigger this script * \ObjectiveID - ID of the new objective to remove +* \OnlyRemovePending - Can only remove an objective if its pending * \author jgray * \ingroup JmgUtility */ @@ -5774,7 +5838,7 @@ * \WeaponName - Name of the weapon needed to trigger the zone * \ID - ID to send the custom to, 0 sends to self, -1 sends to enter * \Custom - Custom message to send -* \Param - Param to send +* \Param - Param to send, -1 sends the object ID * \Delay - Delay to add before sending custom * \RemoveWeapon - Should the weapon be removed when entering the zone * \TriggerOnce - Allows the script only to trigger the first time the zone is entered @@ -5857,7 +5921,7 @@ /*! * \brief Creates a powerup at the objects origin when it is destroyed if it has that weapon -* \WeaponPreset - Weapon that is needed to do the drop +* \RequiredWeaponPreset - Weapon that is needed to do the drop, if blank always drops * \PowerupName - Powerup to create * \HeightAdjust - Height to add to the object's origin to create the powerup at * \author jgray @@ -6582,9 +6646,22 @@ void Destroyed(GameObject *obj); void Detach(GameObject *obj); public: + struct StringNode + { + char preset[128]; + StringNode(const char *preset) + { + sprintf(this->preset,"%s",preset); + } + }; static bool controllerPlaced; static char playerWeapons[128][256]; static char playerNames[128][256]; + static SList ignoredWeapons; + JMG_Utility_Spawn_With_Last_Selected_Gun_Control() + { + ignoredWeapons.Remove_All(); + } }; /*! @@ -7972,8 +8049,6 @@ void Killed(GameObject *obj,GameObject *killer); }; - - /*! * \brief This script makes for a rather cruddy emulation of sound_heard on a dedicated server. The script * \ must be attached to a soldier which can emulate sounds and only notifies to scripts on other objects. @@ -9624,7 +9699,7 @@ void Created(GameObject *obj); void Timer_Expired(GameObject *obj,int number); void Destroyed(GameObject *obj); - void SendCustom(GameObject* obj,int custom,int frontLineGroup); + void SendCustom(GameObject* obj,int custom,int thisFrontLineGroup); public: static int teamId; static int frontLineGroup; @@ -9696,6 +9771,7 @@ void Custom(GameObject *obj,int message,int param,GameObject *sender); int SelectCpToSpawnFrom(GameObject *obj,int cpId,bool assaultLines); bool MoveToControlledWanderPointForCp(GameObject *obj,int cpId); + void DisplaySpawnTime(GameObject *obj); }; /*! @@ -10119,7 +10195,7 @@ * \author jgray * \ingroup JmgUtility */ -class JMG_Utility_Sync_String_With_Random_NumberPad_Control : public ScriptImpClass { +class JMG_Utility_Security_System_Sync_String_Random_NumberPad_Control : public ScriptImpClass { char delim; int stringId; void Created(GameObject *obj); @@ -10704,7 +10780,7 @@ */ class JMG_Utility_Timer_Death_If_Not_Damaged_Over_Peroid : public ScriptImpClass { char warhead[128]; - float damage; + float giveDamage; int time; int originalTime; void Created(GameObject *obj); @@ -10929,4 +11005,571 @@ currentWeaponId = 0; currentWeapon = NULL; } +}; + +/*! +* \brief Controls if JMG_Utility_Global_Custom_Send_Custom_Flag can send a custom, default flag is -1 +* \Custom - Custom to flip if sending is allowed, the param is what to set the flag to +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Global_Custom_Send_Custom_Flag_Controller : public ScriptImpClass +{ + void Created(GameObject *obj); +public: + JMG_Utility_Global_Custom_Send_Custom_Flag_Controller() + { + globalFlag = -1; + } + static int globalFlag; +}; + +/*! +* \brief Changes what the global flag is on custom +* \Custom - Custom to flip if sending is allowed +* \GlobalFlag - What to set the global flag to +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Global_Custom_Send_Custom_Flag_Custom : public ScriptImpClass +{ + int custom; + int globalFlag; + void Created(GameObject *obj); + void Custom(GameObject *obj,int message,int param,GameObject *sender); +}; + +/*! +* \brief Sends a custom if the global flag matches the specified +* \GlobalFlag - Value needed to match in order to send the custom +* \Custom - Custom to watch for +* \ID - ID to send to, 0 sends to self, -1 sends to sender +* \SendCustom - custom to send +* \Param - param to send (-1 sends the param that was received) +* \Delay - delay to add +* \RandomDelay - Max amount of random delay that can be added to the delay +* \RandomChance - If non-zero this will be the chance that the custom can send 0.0-1.0, 1 will always send +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Global_Custom_Send_Custom_Flag : public ScriptImpClass +{ + int globalFlag; + int recieveMessage; + int id; + int custom; + int Param; + float delay; + float randomDelay; + float randomChance; + void Created(GameObject *obj); + void Custom(GameObject *obj,int message,int param,GameObject *sender); +}; +/*! +* \brief AI that will attempt to go to a location as long as a player is near it +* \GotoObjectId - Object that the AI will chase around the map, overrides location +* \GotoLocation - Location the vehicle will attempt to move to +* \MaxPlayerDistance - Furthest the nearest player can be for the unit to continue to be "escorted" +* \MinAttackRange - How close can a target be before it can no longer be fired upon, if the target is too close the vehicle will attempt to back up to a previous position or return to a wander point/home position if either are available. +* \ForceFire - Tells the AI to fire weapons even if the turret isn't aimed at the target, useful for vehicles like the MRLS. +* \VTOLHover - Used for Aircraft, tells the AI how high to fly above its target spots +* \vsSoldier - Tells the AI what fire mode to use against infantry, -1 means it can't attack them, 2 means auto, 0 is secondary fire, 1 is primary fire. +* \vsVehicle - Tells the AI what fire mode to use against vehicles, -1 means it can't attack them, 2 means auto, 0 is secondary fire, 1 is primary fire. +* \vsAircraft - Tells the AI what fire mode to use against aircraft, -1 means it can't attack them, 2 means auto, 0 is secondary fire, 1 is primary fire. +* \WeaponError - This tells the max weapon error the vehicle can use, if weapon error is -1 it dynamically determines a weapon error to use, this calculation has to do with bullet speed and enemy distance. +* \OverrideFireMode - If 1 primary is forced, if 2 secondary is forced, otherwise use built in fire modes +* \OverrideSpeed - If -1 the default speed calculations take place, if anything else the speed value is used +* \PlayerType - Requires the team of the closest player to match in order for the script to one 0 Nod 1 GDI 2 Any +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Goto_Location_While_Player_Nearby : public ScriptImpClass { + struct JMGVehicleAmmo + { + bool allowError; + float range; + float speed; + JMGVehicleAmmo() + { + allowError = false; + range = 0.0f; + speed = 400.0f; + } + }; + Vector3 gotoLocation; + int gotoObjectId; + float maxPlayerDistance; + JMGVehicleAmmo primary; + JMGVehicleAmmo secondary; + JMGVehicleAction currentAction; + JMGVehicleAction lastAction; + bool overrideFireMode; + bool overridePrimary; + int lastSeenCount; + int reverseTime; + int stuckCount; + int useAmmo; + int doNotUsePathfind; + float lastHealth; + float minDistanceSquared; + bool moving; + bool attacking; + int badDestAttempt; + Vector3 lastPos; + Vector3 homepos; + int myteam; + bool inRange; + bool drivingBackward; + float minAttackRange; + float definedWeaponError; + int forceFire; + float vtolHover; + int vsSoldier; + int vsAircraft; + int vsVehicle; + float overrideSpeed; + int playerType; + void Created(GameObject *obj); + void Action_Complete(GameObject *obj,int action,ActionCompleteReason reason); + void Enemy_Seen(GameObject *obj,GameObject *seen); + void Damaged(GameObject *obj,GameObject *damager,float damage); + void Timer_Expired(GameObject *obj,int number); + void RunAttack(GameObject *obj,GameObject *target); + int GetThreatRating(GameObject * obj); + GameObject *GetAttackObject(GameObject * obj); + GameObject *SelectTarget(GameObject *obj,GameObject *target); + GameObject *SetTarget(GameObject *target); + GameObject *GetClosest(GameObject *obj,GameObject *new_target,GameObject *old_target); + int SelectAmmo(GameObject *target); + void StuckCheck(GameObject *obj); + void AttackMove(GameObject *obj,GameObject *target,bool gotoObject,Vector3 targetLocation,int fireMode,float weaponError,bool forceUpdate,float arriveDistance); + JMGVehicleAmmo DefineAmmo(const AmmoDefinitionClass *ammo); +}; +/*! +* \brief Any object this is attached to will not be shot at by JMG_Utility_AI_Goto_Location_While_Player_Nearby +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Goto_Location_While_Player_Nearby_Ignored : public ScriptImpClass +{ + void Created(GameObject *obj); +}; + +/*! +* \brief Creates a powerup at the objects origin when it is killed, then turns the powerup into the parent object and steals its animation, basically it turns the powerup into the parent's corpse +* \PowerupName - Powerup to create +* \RequiredWeaponPreset - Weapon that is needed to do the drop, if blank drops anyways drops +* \Chance - Chance that the drop will occur +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Killed_Drop_Powerup_Become_Corpse : public ScriptImpClass +{ + void Killed(GameObject *obj,GameObject *killer); + void Timer_Expired(GameObject *obj,int number); +}; + +/*! +* \brief Sends a custom once all objectives in the required list are complete, (Not instant, only scans 4 times a second) +* \CompletedObjectives - Id's that need to be complete +* \Delim - Character to split the list of objectives with +* \ID - ID to send to, 0 sends to self +* \SendCustom - custom to send +* \Param - param to send +* \Delay - delay to add +* \RandomDelay - Max amount of random delay that can be added to the delay +* \RandomChance - If non-zero this will be the chance that the custom can send 0.0-1.0, 1 will always send +* \Repeat - Can this script fire more than once +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Objective_System_Objectives_Complete_Send_Custom : public ScriptImpClass { + int id; + int custom; + int Param; + float delay; + float randomDelay; + int objectiveIds[128]; + int objectiveCount; + bool repeat; + void Created(GameObject *obj); + void Timer_Expired(GameObject *obj,int number); +}; + +/*! +* \brief Changes the animation frame as an object is damaged +* \ (Math is (currentHP/MaxHP)*MaxFrame +* \Animation - Animation to use +* \MaxFrame - Length of the animation +* \Model - Changes the model when attached if not blank +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Damage_Update_Animation_Frame : public ScriptImpClass { + char animation[32]; + float maxFrame; + float lastCalculation; + void Created(GameObject *obj); + void Damaged(GameObject *obj,GameObject *damager,float damage); +}; + +/*! +* \brief Takes model and replaces it with the number slot generated by JMG_Utility_Security_System_Random_NumberPad_Control +* \KeypadID - ID of the object that has JMG_Utility_Security_System_Random_NumberPad_Control attached +* \Index - Index in the combo to use, for example if the combo is 34563 and the index is 2 the model this will display will be 4 +* \BaseModel - Base name of the model, index is tacked to the end (EX: If the index is 4 and the model is named BaseNumber_ the result will be BaseNumber_4) +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Security_System_Sync_Model_Random_NumberPad_Control : public ScriptImpClass { + void Created(GameObject *obj); + void Timer_Expired(GameObject *obj,int number); +}; + +/*! +* \brief This script makes the AI hunt down the nearest object with JMG_Utility_AI_Goto_Target_Script_Target attached, it works for infantry and vehicles +* \HuntSearchDistance - Distance to scan for players to magically find and move to, -1 means infinite range +* \HuntSpeed - Speed at which the bot moves once its moving to a player +* \HuntArriveDistance - Distance at which to arrive from the player +* \RandomHuntArriveDistance - Random amount to arrive from the player +* \HuntStealth - Can the bot magically know where invisible players are +* \AttackSpeed - Speed to move at once an attack is begun +* \AttackDistance - Distance to arrive from a target when attacking, -1 uses the weapon effective distance +* \RandomAttackDistance - Random amount to add or subtract from the Attack distance +* \ReturnHome - Return to the create location when the action completes? (If wanderpoints are enabled this will never be used) +* \ReturnHomeSpeed - Speed to move at when going home +* \WanderingAIGroupID - Group of wander points to use when nothing else is going on +* \WanderSpeed - Speed to move at between the points +* \CanSeeStealth - Can the AI see stealth targets? 0 = No at all, 1 is within the ranges set in LE globals file, 2 means it can see stealth everywhere, think of stock AI. +* \ShutdownEngineOnArrival - Used for vehicles, turn on if you have issues with your vehicle rolling away from its move positions after it arrives +* \AttackCheckBlocked - Defines whether they should check if they can actually hit the player before shooting +* \MaxSightRangeFromHome - Maximum range the AI can see from its nearest wander point/home location, useful to keep them from wandering off after a trail of enemies, 0 to not use +* \WanderDistanceOverride - Overrides the default wander arrive distance (1 meter for infantry and 5 for vehicles) +* \ChangeWanderGroupCustom - If this custom is received the wander group will be set to the param, -1 param to disable the wander group code +* \ChangeWanderSpeedCustom - If this custom is received the wander speed will be updated to the param/100 +* \ChangeHuntDistanceCustom - If this custom is received the hunt range will be updated to the param/100 (-1 means infinite range) +* \ChangeHuntSpeedCustom - If this custom is received the hunt speed will be updated to the param/100 +* \ChangeReturnHomeSpeedCustom - If this custom is received the return home speed will be updated to the param/100 +* \ChangeMaxSightFromHomeLocationCustom - If this custom is received the AI won't be able to see targets past the specified range of the param/100, 0 means don't use +* \ChangeAttackSpeedCustom - If this custom is received the attack speed will be updated to the param/100 +* \ChanceToInvestigateLastSeenLocation - The percent chance (0.0-1.0) of checking out the last spot an enemy/target was seen +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Goto_Target_Script : public ScriptImpClass { + enum aiState{IDLE,HUNTING_STAR,ATTACKING_TARGET,RETURNING_HOME,WANDERING_GROUP,ACTION_BADPATH}; + struct LastAction + { + int targetId; + Vector3 location; + float speed; + float distance; + bool attack; + bool overrideLocation; + LastAction() + { + } + LastAction(int targetId,Vector3 location,float speed,float distance,bool attack,bool overrideLocation) + { + this->targetId = targetId; + this->location = location; + this->speed = speed; + this->distance = distance; + this->attack = attack; + this->overrideLocation = overrideLocation; + } + bool operator == (LastAction l) + { + return (targetId == l.targetId && JmgUtility::SimpleDistance(location,l.location) <= 0.0f && speed == l.speed && distance == l.distance && attack == l.attack && overrideLocation == l.overrideLocation); + } + }; + struct ValidLastLocation + { + bool valid; + Vector3 location; + ValidLastLocation(bool valid) + { + this->valid = valid; + } + ValidLastLocation(int enemyId); + }; + LastAction lastAction; + aiState state; + Vector3 homeLocation; + float maxSightFromHomeLocation; + bool huntStealth; + int targetId; + int lastSeenTime; + float weaponRange; + float weaponEffectiveRange; + int huntingEnemyId; + int removeIgnoreTime; + int ignoreEnemyId; + float huntSearchDistance; + float huntArriveDistance; + float attackArriveDistance; + int stuckTime; + int reverseTime; + Vector3 lastPosition; + bool moveBackward; + float wanderDistanceOverride; + int wanderingAiGroupId; + float wanderSpeed; + float huntSpeed; + float attackSpeed; + float returnHomeSpeed; + int changeWanderGroupCustom; + int changeWanderSpeedCustom; + int changeHuntDistanceCustom; + int changeReturnHomeSpeedCustom; + int changeHuntSpeedCustom; + int changeMaxSightFromHomeLocationCustom; + int changeAttackSpeedCustom; + void Created(GameObject *obj); + void Enemy_Seen(GameObject *obj,GameObject *seen); + void Timer_Expired(GameObject *obj,int number); + void Custom(GameObject *obj,int message,int param,GameObject *sender); + void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason); + void Damaged(GameObject *obj,GameObject *damager,float damage); + void Attack_Move(GameObject *obj,GameObject *target,Vector3 location,float speed,float distance,bool attack,bool overrideLocation); + GameObject *findClosestStar(GameObject *obj); + void Return_Home(GameObject *obj,ValidLastLocation goNearLastWanderPoint); + void Stuck_Check(GameObject *obj,Vector3 targetPos); + void Cant_Get_To_target(GameObject *obj); + bool GetRandomPosition(Vector3 *position); + bool Choose_Target(GameObject *obj,GameObject *target); +}; + +/*! +* \brief Tell objects with JMG_Utility_AI_Goto_Player to ignore this object +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Goto_Target_Script_Ignore_Object : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief Tell objects with JMG_Utility_AI_Goto_Target_Script that this is a target +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Goto_Target_Script_Target : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief Sends a custom on a custom if the count of objects with the specified script is less than the count +* \Custom - Custom to watch for +* \Script - Script being scanned for +* \MaxCount - Max objects with the specified script +* \PlayerAddMaxCount - Each player adds this much to the max count +* \ID - ID to send to, 0 sends to self, -1 sends to sender +* \SendCustom - custom to send +* \Param - param to send (-1 sends the param that was received) +* \Delay - delay to add +* \RandomDelay - Max amount of random delay that can be added to the delay +* \RandomChance - If non-zero this will be the chance that the custom can send 0.0-1.0, 1 will always send +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Custom_Send_Custom_If_Script_Count : public ScriptImpClass { + int maxCount; + float playerAddMaxCount; + char script[256]; + int recieveMessage; + int id; + int custom; + int Param; + float delay; + float randomDelay; + float randomChance; + void Created(GameObject *obj); + void Custom(GameObject *obj,int message,int param,GameObject *sender); +}; + +/*! +* \brief Creates the preset from the specified team's vehicle factory on create +* \PresetName - Vehicle preset to make +* \Delay - Creation Delay +* \OwnerID - ID of the object that ends up owning it, -1 makes it this object +* \TeamID - Team to build for +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Created_Trigger_Create_Vehicle : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief Removes a script and then attaches another script on custom +* \Custom - Custom that triggers the script +* \RemoveScript - Script to remove +* \AttachScript - Script to attach +* \Params - Params to use for the attached script +* \Delim - char to use in place of , +* \Repeat - Should the script fire more than once +* \RequiresRemoveScript - If the remove script isn't on the object this script can't fire +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Custom_Remove_And_Attach_Script : public ScriptImpClass +{ + int custom; + bool repeat; + bool requiresRemoveScript; + char *params; + char *attachScript; + char *removeScript; + void Created(GameObject *obj); + void Custom(GameObject *obj,int message,int param,GameObject *sender); +}; + +/*! +* \brief Makes this unit ignored by JMG_Utility_AI_Guardian_Aircraft +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Guardian_Aircraft_Ignored : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief Makes this unit ignored by JMG_Utility_AI_Guardian_Infantry +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Guardian_Infantry_Ignored : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief Makes this unit ignored by JMG_Utility_AI_Guardian_Vehicle +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Guardian_Vehicle_Ignored : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief Makes this unit ignored by JMG_Utility_AI_Guardian_Generic +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_AI_Guardian_Generic_Ignored : public ScriptImpClass { + void Created(GameObject *obj); +}; + +/*! +* \brief This allows the objective system to search through all the game objects to find the object that is needed to be the marker (tell the objective system by using -2 for the marker ID) +* \ObjectiveID - ID of the objective this belongs to +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Objective_System_Objective_Marker : public ScriptImpClass { + void Created(GameObject *obj); +public: + JMG_Utility_Objective_System_Objective_Marker() + { + objectiveId = -1; + } + int objectiveId; +}; + +/*! +* \brief Removes a script while if the attached doesn't have a weapon, gives it back when they have the weapon +* \WeaponName - Name of the weapon to check for +* \Script - Name of the script to attach +* \Params - The parameters to use for the script +* \Delim - The character to use in place of a ',' swapped at script creation +* \Rate - Rate at which the script scans +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Remove_Script_If_Doesnt_Have_Weapon : public ScriptImpClass { + char weaponName[128]; + char *params; + char script[128]; + float rate; + void Created(GameObject *obj); + void Timer_Expired(GameObject *obj,int number); +}; + +/*! +* \brief Tells the game that this weapon shouldn't be used with the JMG_Utility_Spawn_With_Last_Selected_Gun system +* \WeaponPreset - Name of weapon to ignore from the system +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Spawn_With_Last_Selected_Gun_Ignore : public ScriptImpClass { + void Created(GameObject *obj); + void Timer_Expired(GameObject *obj,int number); +}; + +/*! +* \brief Allows the visible marker, text color, and radar blip color to be overridden for a specific objective +* \ObjectiveID - ID of the objective to override +* \MarkerModel - Model to use instead, leave blank if you don't want it to override +* \MarkerColor - Radar color to make use of, leave -1 if you don't want it to override +* \AttachBone - Bone to attach to, leave blank if you don't want it to override +* \OverrideTextColor - 0 means don't override text color, any other number will override +* \TextColor - Color to use for the objective text, 0-255 +* \OverrideHudColor - 0 means don't override HUD color, any other number will override +* \HudColor - Color to use for the objective HUD message, 0-255 +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Objective_System_Override_Visible_Settings : public ScriptImpClass { + void Created(GameObject *obj); + void Timer_Expired(GameObject *obj,int number); +}; + +/*! +* \brief Basic creates an object at the bone position when a custom is received +* \Custom - Custom message needed to trigger the script +* \Preset - Preset to create +* \Bone - Bone to create the preset at +* \MaxDistance - Once the object is created it can be displaced if another object is in its position, this is how far it can be moved +* \Repeat - Allows the script to run more than once +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Custom_Create_Object_At_Bone : public ScriptImpClass +{ + int custom; + bool repeat; + void Created(GameObject *obj); + void Custom(GameObject *obj,int message,int param,GameObject *sender); +}; + +/*! +* \brief Sends the custom message from the itself when its killed by nothing +* \ID - Id of the object to send the custom to, 0 sends to itself +* \Message - Custom to send +* \Param - parameter to send with the custom +* \Delay - Time amount to wait before sending the custom +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Killed_Send_Custom_When_Killed_By_Nothing : public ScriptImpClass { + void Killed(GameObject *obj,GameObject *killer); +}; + +/*! +* \brief Works like JMG_Utility_Killed_Drop_Powerup_Become_Corpse but triggers on custom +* \Custom - Custom message needed to trigger the script +* \PowerupName - Powerup to create +* \Repeat - Allows the script to run more than once +* \author jgray +* \ingroup JmgUtility +*/ +class JMG_Utility_Custom_Drop_Corpse : public ScriptImpClass +{ + int custom; + bool repeat; + char powerupName[128]; + void Created(GameObject *obj); + void Custom(GameObject *obj,int message,int param,GameObject *sender); + void Timer_Expired(GameObject *obj,int number); }; \ No newline at end of file diff -urN sourceold/scripts/ms_ai.cpp source/scripts/ms_ai.cpp --- sourceold/scripts/ms_ai.cpp 2021-07-27 14:44:22.801960500 +1000 +++ source/scripts/ms_ai.cpp 2022-02-13 10:20:09.874407900 +1000 @@ -55,6 +55,8 @@ int Radio_Message_Type::DEFEND_THAT_STRUCTURE; +#define BOT_VERY_LONG_WEAPON_RANGE 160 + /*------------------------ Branch differences to eliminate false diff positives @@ -341,6 +343,44 @@ // ------------------------------------------------------------------------------------------------- +void Calculate_Ammo_Preferences(const AmmoDefinitionClass* ammo, int& maxAttackRange, int& preferredAttackRange) +{ + maxAttackRange = ammo ? (int)ammo->Range() : maxAttackRange; + preferredAttackRange = maxAttackRange / 2 + 1; + + // Make sure it's not zero or bigger than max + if (preferredAttackRange == 0 || preferredAttackRange > maxAttackRange) + preferredAttackRange = maxAttackRange; + // Long range units: snipers/artilleries, should not try to come as close + if (maxAttackRange >= BOT_VERY_LONG_WEAPON_RANGE) + preferredAttackRange = maxAttackRange - 10; +} + +// ------------------------------------------------------------------------------------------------- + +void Get_Equipped_Weapon_Range_Preferences(GameObject* obj, int& maxAttackRange, int& preferredAttackRange, int& maxAttackRangeSecondary, int& preferredAttackRangeSecondary) +{ + if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_ArmedGameObj()) + { + auto armedObj = obj->As_PhysicalGameObj()->As_ArmedGameObj(); + if (auto weapon = armedObj->Get_Weapon()) + { + Calculate_Ammo_Preferences(weapon->PrimaryAmmoDefinition, maxAttackRange, preferredAttackRange); + if (weapon->SecondaryAmmoDefinition) + { + Calculate_Ammo_Preferences(weapon->SecondaryAmmoDefinition, maxAttackRangeSecondary, preferredAttackRangeSecondary); + } + else + { + maxAttackRangeSecondary = maxAttackRange; + preferredAttackRangeSecondary = preferredAttackRange; + } + } + } +} + +// ------------------------------------------------------------------------------------------------- + int Create_Timed_Objective(int team, float seconds, Vector3 position, int range, int type = 0, int attachObjID = 0) { auto timedObjective = Commands->Create_Object("Invisible_Object", position); @@ -2291,13 +2331,16 @@ } } // COPIED ORIGINAL FUNCTION, ADDED REACHABLE CHECK - else if (!needsRotating && (m_bMovingToTarget || pathfindFailCount > 4) && !isTargetFlying) + else if (!needsRotating && (m_bMovingToTarget || pathfindFailCount > 4) && (isVTOL || !isTargetFlying)) { // COPIED ORIGINAL FUNCTION, MODIFIED FROM HERE // Choose random position around the position between me and target within preferred range // Get current distance and wanted distance to get the required ratio - float ratio = preferredRange / currentDistance2; - Vector3 pos = Lerp(targetPos, Commands->Get_Position(obj), ratio); + const float ratio = preferredRange / currentDistance2; + + // Lerped position of fliers will be in the air, out of pathfind grid, correct this + Vector3 pos = isVTOL && isTurretRotationLimited ? (targetPos + (Vector3(objPos.X, objPos.Y, targetPos.Z) - targetPos).Normalized() * (float)preferredRange) : Lerp(targetPos, objPos, ratio); + // If building target type, make sure this pos is not something stupid unreachable (BAD_DEST when big vehicles get a position inside a building interior for example) if (targetType == BUILDING) { @@ -2306,10 +2349,12 @@ } else { + float teleportZCorrection = obj->As_VehicleGameObj() ? obj->As_VehicleGameObj()->Peek_Model()->Get_Bounding_Box().Extent.Z * 2 : 0; if (canSquishTarget) { params.Set_Movement(target, 1.0f, 0); } - else if (!Get_Random_Pathfind_Spot(pos, (preferredRange / 2 - 2.0f), &pos) || !Can_Move_To(obj, pos) || preferredRange == 0 || isTurretRotationLimited || pathfindFailCount > 4) + // Pathfind spot check: VTOL vs flying target does not need this check, flying units are rarely within the grid (and only VTOLs can reach this code if target is flying) + else if ((!Get_Random_Pathfind_Spot(pos, (preferredRange / 2 - 2.0f), &pos) && !isTargetFlying) || !Can_Move_To(obj, pos + Vector3(0, 0, teleportZCorrection)) || preferredRange == 0 || pathfindFailCount > 4) { params.Set_Movement(targetPos, 1.0f, abs((float)preferredRange - 1.5f), moveCrouched); } @@ -2320,7 +2365,7 @@ } // COPIED ORIGINAL FUNCTION, MODIFIED FROM HERE // "Turn towards" enemy if turret cannot turn on the enemy by moving closer to target - else if (needsRotating && !isTargetFlying) + else if (needsRotating && (isVTOL || !isTargetFlying)) { targetPos = Commands->Get_Position(target); @@ -2366,7 +2411,7 @@ if (isVTOL) { params.MovePathfind = false; - params.MoveLocation.Z += flyingHeight; + params.MoveLocation.Z += bPersueTarget ? (targetType == FLYING ? 5 : 15) : flyingHeight; auto helperPos = objPos; helperPos.Z -= 15; if (isBomber && Vector3::Distance(helperPos, Commands->Get_Position(target)) <= maxRange) @@ -2852,7 +2897,7 @@ // Expecting most vehicles to be square-ish sized, epic long vehicles will be problematic here. primary_maxRange += (int)(obj_box.Extent.X / 2 + obj_box.Extent.Y / 2) / 2; } - m_primary_prefRange = primary_maxRange < 120 ? (int)(primary_maxRange / 2) : primary_maxRange - 10; + m_primary_prefRange = primary_maxRange < BOT_VERY_LONG_WEAPON_RANGE ? (int)(primary_maxRange / 2) : primary_maxRange - 10; if (primary_minRange > m_primary_prefRange) primary_minRange = m_primary_prefRange - 1; if (primary_minRange < 0) @@ -3677,12 +3722,12 @@ "Weapon_VTOL=1:int," "Priority_Building=3.0:float," "Weapon_Building=1:int," - "Max_Attack_Range=150:int," + "Max_Attack_Range=-1:int," "Min_Attack_Range=0:int," - "Preferred_Attack_Range=60:int," - "Max_Attack_Range_Secondary=150:int," + "Preferred_Attack_Range=-1:int," + "Max_Attack_Range_Secondary=-1:int," "Min_Attack_Range_Secondary=0:int," - "Preferred_Attack_Range_Secondary=60:int," + "Preferred_Attack_Range_Secondary=-1:int," "Modifier_Distance=0.25:float," "Modifier_Target_Damage=0.1:float," "Modifier_Target_Value=0.05:float," @@ -3717,6 +3762,62 @@ Commands->Send_Custom_Event(obj, killer, CUSTOM_AI_ENEMY_KILLED, 0, 0.0f); } } + +public: + StringClass Get_Range_Corrected_Parameters(GameObject* obj) + { + // Developer: copy weapon preset for range, no override (-1) + if (Get_Int_Parameter("Max_Attack_Range") == -1 || Get_Int_Parameter("Preferred_Attack_Range") == -1 || + Get_Int_Parameter("Max_Attack_Range_Secondary") == -1 || Get_Int_Parameter("Preferred_Attack_Range_Secondary") == -1) + { + int maxAttackRange = 0; + int preferredAttackRange = 0; + int maxAttackRangeSecondary = 0; + int preferredAttackRangeSecondary = 0; + Get_Equipped_Weapon_Range_Preferences(obj, maxAttackRange, preferredAttackRange, maxAttackRangeSecondary, preferredAttackRangeSecondary); + + StringClass buffer; + int count = Get_Parameter_Count(); + int i = 0; + while ((i < count)) + { + if (i > 0) + { + buffer += ","; + } + if (i == Get_Parameter_Index("Max_Attack_Range") && Get_Int_Parameter("Max_Attack_Range") == -1) + { + buffer.Format("%s,%d", buffer.Peek_Buffer(), maxAttackRange); + } + else if (i == Get_Parameter_Index("Preferred_Attack_Range") && Get_Int_Parameter("Preferred_Attack_Range") == -1) + { + buffer.Format("%s,%d", buffer.Peek_Buffer(), preferredAttackRange); + } + else if (i == Get_Parameter_Index("Max_Attack_Range_Secondary") && Get_Int_Parameter("Max_Attack_Range_Secondary") == -1) + { + buffer.Format("%s,%d", buffer.Peek_Buffer(), maxAttackRangeSecondary); + } + else if (i == Get_Parameter_Index("Preferred_Attack_Range_Secondary") && Get_Int_Parameter("Preferred_Attack_Range_Secondary") == -1) + { + buffer.Format("%s,%d", buffer.Peek_Buffer(), preferredAttackRangeSecondary); + } + else + { + const char* param = Get_Parameter(i); + buffer += param; + } + i++; + } + + return buffer; + } + else + { + char str[256]; + Get_Parameters_String(str, 256); + return str; + } + } }; REGISTER_SCRIPT(MS_AI_Preferences, "Priority_Infantry=1.0:float," @@ -3730,12 +3831,12 @@ "Weapon_VTOL=1:int," "Priority_Building=3.0:float," "Weapon_Building=1:int," - "Max_Attack_Range=150:int," + "Max_Attack_Range=-1:int," "Min_Attack_Range=0:int," - "Preferred_Attack_Range=60:int," - "Max_Attack_Range_Secondary=150:int," + "Preferred_Attack_Range=-1:int," + "Max_Attack_Range_Secondary=-1:int," "Min_Attack_Range_Secondary=0:int," - "Preferred_Attack_Range_Secondary=60:int," + "Preferred_Attack_Range_Secondary=-1:int," "Modifier_Distance=0.25:float," "Modifier_Target_Damage=0.1:float," "Modifier_Target_Value=0.05:float," @@ -3999,6 +4100,10 @@ ActionParamsStruct params; params.Set_Basic(this, 95, ACTION_AI_GET_AROUND_REVERSE); params.Set_Movement(getAroundReversePos, 1.0f, 1.0f); + + if (Get_Vehicle_Mode(obj) == VEHICLE_TYPE_FLYING) + params.MovePathfind = false; + params.MoveBackup = true; Handle_Movement_Action(obj, params); } @@ -7057,21 +7162,9 @@ { int maxAttackRange = 0; int preferredAttackRange = 0; - if (activateOnObj->As_PhysicalGameObj() && activateOnObj->As_PhysicalGameObj()->As_ArmedGameObj()) - { - auto armedObj = activateOnObj->As_PhysicalGameObj()->As_ArmedGameObj(); - if (auto weapon = armedObj->Get_Weapon()) - { - maxAttackRange = (int)(weapon->PrimaryAmmoDefinition ? weapon->PrimaryAmmoDefinition->Range() : maxAttackRange); - preferredAttackRange = (int)(weapon->PrimaryAmmoDefinition ? weapon->PrimaryAmmoDefinition->EffectiveRange(): preferredAttackRange); - // Make sure it's not zero or bigger than max - if (preferredAttackRange == 0 || preferredAttackRange > maxAttackRange) - preferredAttackRange = maxAttackRange; - // Long range units: snipers/artilleries, should not try to come as close - if (maxAttackRange >= 120) - preferredAttackRange = maxAttackRange - 10; - } - } + int maxAttackRangeSecondary = 0; + int preferredAttackRangeSecondary = 0; + Get_Equipped_Weapon_Range_Preferences(activateOnObj, maxAttackRange, preferredAttackRange, maxAttackRangeSecondary, preferredAttackRangeSecondary); // Get default parameters DynamicVectorClass parameters; @@ -7103,6 +7196,20 @@ else behaviourScriptParams.Format("%s,%s", behaviourScriptParams.Peek_Buffer(), parameter.value.Peek_Buffer()); } + else if (strcmp(parameter.name, "Max_Attack_Range_Secondary") == 0) + { + if (maxAttackRangeSecondary) + behaviourScriptParams.Format("%s,%d", behaviourScriptParams.Peek_Buffer(), maxAttackRangeSecondary); + else + behaviourScriptParams.Format("%s,%s", behaviourScriptParams.Peek_Buffer(), parameter.value.Peek_Buffer()); + } + else if (strcmp(parameter.name, "Preferred_Attack_Range_Secondary") == 0) + { + if (preferredAttackRangeSecondary) + behaviourScriptParams.Format("%s,%d", behaviourScriptParams.Peek_Buffer(), preferredAttackRangeSecondary); + else + behaviourScriptParams.Format("%s,%s", behaviourScriptParams.Peek_Buffer(), parameter.value.Peek_Buffer()); + } // Use 0 values for engineering units, they should never actively engage enemies, but run to repair instead else if ((strcmp(parameter.name, "Priority_Light_Vehicle") == 0 || strcmp(parameter.name, "Priority_Heavy_Vehicle") == 0 || strcmp(parameter.name, "Priority_VTOL") == 0) && objectiveType == dp88_AI_Objective::TYPE_ENGINEERING) { @@ -7118,9 +7225,7 @@ } else { - char str[256]; - preferencesScript->Get_Parameters_String(str, 256); - behaviourScriptParams.Format("%s", str); + behaviourScriptParams = preferencesScript->Get_Range_Corrected_Parameters(activateOnObj); } behaviourScriptParams.Format("%s,%d", behaviourScriptParams.Peek_Buffer(), objectiveType); diff -urN sourceold/scripts/scripts.vcxproj source/scripts/scripts.vcxproj --- sourceold/scripts/scripts.vcxproj 2020-09-26 09:00:03.276360000 +1000 +++ source/scripts/scripts.vcxproj 2022-02-13 10:20:09.876262200 +1000 @@ -272,7 +272,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue @@ -350,7 +349,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue @@ -475,7 +473,7 @@ - + @@ -768,6 +766,7 @@ + diff -urN sourceold/scripts/scripts.vcxproj.filters source/scripts/scripts.vcxproj.filters --- sourceold/scripts/scripts.vcxproj.filters 2020-03-28 21:10:59.049791100 +1000 +++ source/scripts/scripts.vcxproj.filters 2022-02-13 10:20:09.878324600 +1000 @@ -377,7 +377,7 @@ 01. Sources - + 01. Sources @@ -1297,6 +1297,9 @@ 02. Headers + + 02. Headers + diff -urN sourceold/scripts/unstoppable.cpp source/scripts/unstoppable.cpp --- sourceold/scripts/unstoppable.cpp 1970-01-01 10:00:00.000000000 +1000 +++ source/scripts/unstoppable.cpp 2022-02-13 10:20:09.879323500 +1000 @@ -0,0 +1,1347 @@ +/* Renegade Scripts.dll + Copyright 2022 Tiberian Technologies + + This file is part of the Renegade scripts.dll + The Renegade scripts.dll is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. See the file COPYING for more details. + In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. + Only the source code to the module(s) containing the licenced code has to be released. +*/ + +#include "General.h" +#include "engine.h" +#include "engine_common.h" +#include "engine_def.h" +#include "engine_game.h" +#include "engine_player.h" +#include "engine_tt.h" +#include "engine_script.h" +#include "engine_obj.h" +#include "WeaponClass.h" +#include "SoldierGameObj.h" +#include "VehicleGameObj.h" +#include "BuildingGameObj.h" +#include "SoldierGameObjDef.h" +#include "cPlayer.h" +#include "unstoppable.h" + +void UP_Teleport::Entered(GameObject* obj, GameObject* enterer) +{ + if (enterer->As_SoldierGameObj() || enterer->As_VehicleGameObj()) + { + Commands->Set_Position(enterer, Commands->Get_Position(Commands->Find_Object(Get_Int_Parameter("ArrowID")))); + if (Get_Parameter("TeleportSound")) + { + Create_2D_WAV_Sound_Player(enterer, Get_Parameter("TeleportSound")); + } + } +} + +ScriptRegistrant UP_Teleport_Registrant("UP_Teleport", "ArrowID=0:int,TeleportSound=SoundName.wav:string"); + +/******************************************************************************************************/ + +void UP_HUD_Message_Zone_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + if (Commands->Is_A_Star(enterer)) + { + if (Get_Parameter("Message")) + { + Set_HUD_Help_Text_Player_Text(enterer, 7811, Get_Parameter("Message"), Vector3(Get_Int_Parameter("Red") / 255.f, Get_Int_Parameter("Green") / 255.f, Get_Int_Parameter("Blue") / 255.f)); + } + + if (Get_Parameter("Sound")) + { + Create_2D_WAV_Sound_Player(enterer, Get_Parameter("Sound")); + } + } +} + +ScriptRegistrant UP_HUD_Message_Zone_Enter_Registrant("UP_HUD_Message_Zone_Enter", "Message=Your Message:string,Sound=SoundName.wav:string,Red=255:int,Green=255:int,Blue=255:int"); + +/******************************************************************************************************/ + +void UP_HUD_Message_Zone_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + if (Commands->Is_A_Star(exiter)) + { + if (Get_Parameter("Message")) + { + Set_HUD_Help_Text_Player_Text(exiter, 7811, Get_Parameter("Message"), Vector3(Get_Int_Parameter("Red") / 255.f, Get_Int_Parameter("Green") / 255.f, Get_Int_Parameter("Blue") / 255.f)); + } + + if (Get_Parameter("Sound")) + { + Create_2D_WAV_Sound_Player(exiter, Get_Parameter("Sound")); + } + } +} + +ScriptRegistrant UP_HUD_Message_Zone_Exit_Registrant("UP_HUD_Message_Zone_Exit", "Message=Your Message:string,Sound=SoundName.wav:string,Red=255:int,Green=255:int,Blue=255:int"); + +/******************************************************************************************************/ + +void UP_Stop_Vehicle_Engine::Created(GameObject* obj) +{ + Vehicle = obj; + if (Vehicle->As_VehicleGameObj()) + { + Commands->Start_Timer(Vehicle, this, Get_Float_Parameter("Duration"), 1); + Commands->Enable_Engine(Vehicle, false); + Vehicle->As_VehicleGameObj()->Set_Immovable(true); + } + else + { + Destroy_Script(); + } +} + +void UP_Stop_Vehicle_Engine::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == CUSTOM_EVENT_VEHICLE_ENTERED) + { + Commands->Enable_Engine(Vehicle, false); + Vehicle->As_VehicleGameObj()->Set_Immovable(true); + } +} + +void UP_Stop_Vehicle_Engine::Timer_Expired(GameObject* obj, int number) +{ + Commands->Enable_Engine(obj, true); + Vehicle->As_VehicleGameObj()->Set_Immovable(false); + Destroy_Script(); +} + +ScriptRegistrant UP_Stop_Vehicle_Engine_Registrant("UP_Stop_Vehicle_Engine", "Duration=0:float"); + +/******************************************************************************************************/ + +void UP_Change_Vehicle_Weapon::Created(GameObject* obj) +{ + if (obj->As_VehicleGameObj()) + { + Commands->Clear_Weapons(obj); + Grant_Weapon(obj, Get_Parameter("Preset"), true, Get_Int_Parameter("Rounds"), false); + Commands->Select_Weapon(obj, Get_Parameter("Preset")); + } + + Destroy_Script(); +} + +ScriptRegistrant UP_Change_Vehicle_Weapon_Registrant("UP_Change_Vehicle_Weapon", "Preset=Weapon:string,Rounds=1:int"); + +/******************************************************************************************************/ + +void UP_MCT_Building::Created(GameObject* obj) +{ + MCTObj = Commands->Find_Object(Get_Int_Parameter("MCTID")); + if (MCTObj) + { + if (DamageableGameObj* damageable = MCTObj->As_DamageableGameObj()) + { + if (DamageableGameObj* damageable2 = obj->As_DamageableGameObj()) + { + float maxShield = Commands->Get_Max_Shield_Strength(damageable2); + float maxHealth = Commands->Get_Max_Health(damageable2); + StringClass healthSkin = ArmorWarheadManager::Get_Armor_Name(damageable2->Get_Defense_Object()->Get_Skin()); + StringClass shieldSkin = ArmorWarheadManager::Get_Armor_Name(damageable2->Get_Defense_Object()->Get_Shield_Type()); + Set_Max_Shield_Strength(damageable, maxShield); + Set_Max_Health(damageable, maxHealth); + damageable->Get_Defense_Object()->Set_Skin(ArmorWarheadManager::Get_Armor_Type(healthSkin)); + damageable->Get_Defense_Object()->Set_Shield_Type(ArmorWarheadManager::Get_Armor_Type(shieldSkin)); + damageable->Get_Defense_Object()->Mark_Owner_Dirty(); + + Attach_Script_V(MCTObj, "UP_Master_Control_Terminal", "%d,%f", Commands->Get_ID(damageable2), Get_Float_Parameter("Multiplier")); + } + else + { + Destroy_Script(); + } + } + else + { + Destroy_Script(); + } + } + else + { + Destroy_Script(); + } +} + +void UP_MCT_Building::Damaged(GameObject* obj, GameObject* damager, float amount) +{ + Commands->Set_Health(MCTObj, Commands->Get_Health(obj)); + Commands->Set_Shield_Strength(MCTObj, Commands->Get_Shield_Strength(obj)); +} + +ScriptRegistrant UP_MCT_Building_Registrant("UP_MCT_Building", "MCTID:int,Multiplier:float"); + +/******************************************************************************************************/ + +void UP_Master_Control_Terminal::Created(GameObject* obj) +{ + MainBuilding = Commands->Find_Object(Get_Int_Parameter("Object")); + Multiplier = Get_Float_Parameter("Multiplier"); + Set_Object_Type(obj, Get_Object_Type(MainBuilding)); +} + +void UP_Master_Control_Terminal::Damaged(GameObject* obj, GameObject* damager, float amount) +{ + Commands->Set_Health(obj, Commands->Get_Max_Health(obj)); + Commands->Set_Shield_Strength(obj, Commands->Get_Max_Shield_Strength(obj)); + Commands->Apply_Damage(MainBuilding, amount * Multiplier, "None", damager); +} + +ScriptRegistrant UP_Master_Control_Terminal_Registrant("UP_Master_Control_Terminal", "Object:int,Multiplier=1.00:float"); + +/******************************************************************************************************/ + +void UP_Grant_Weapon::Created(GameObject* obj) +{ + if (DefinitionClass* Def = Find_Named_Definition(Get_Parameter("Preset"))) + { + if (Def->Get_Class_ID() == CID_Weapon) + { + Grant_Weapon(obj, Def->Get_Name(), true, 0, true); + Set_Clip_Bullets(obj, Def->Get_Name(), Get_Int_Parameter("ClipRounds")); + Set_Bullets(obj, Def->Get_Name(), Get_Int_Parameter("InventoryRounds")); + if (Get_Int_Parameter("AutoSelect")) + { + Commands->Select_Weapon(obj, Def->Get_Name()); + } + } + } + Destroy_Script(); +} + +ScriptRegistrant UP_Grant_Weapon_Registrant("UP_Grant_Weapon", "Preset=Weapon:string,ClipRounds=1:int,InventoryRounds=1:int,AutoSelect=1:int"); + +/******************************************************************************************************/ + +void UP_Grant_Weapon_Zone_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + if (DefinitionClass* Def = Find_Named_Definition(Get_Parameter("Preset"))) + { + if (Def->Get_Class_ID() == CID_Weapon) + { + Grant_Weapon(enterer, Def->Get_Name(), true, 0, true); + Set_Clip_Bullets(enterer, Def->Get_Name(), Get_Int_Parameter("ClipRounds")); + Set_Bullets(enterer, Def->Get_Name(), Get_Int_Parameter("InventoryRounds")); + if (Get_Int_Parameter("AutoSelect")) + { + Commands->Select_Weapon(enterer, Def->Get_Name()); + } + } + } +} + +ScriptRegistrant UP_Grant_Weapon_Zone_Enter_Registrant("UP_Grant_Weapon_Zone_Enter", "Preset=Weapon:string,ClipRounds=1:int,InventoryRounds=1:int,AutoSelect=1:int"); + +/******************************************************************************************************/ + +void UP_Grant_Weapon_Zone_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + if (DefinitionClass* Def = Find_Named_Definition(Get_Parameter("Preset"))) + { + if (Def->Get_Class_ID() == CID_Weapon) + { + Grant_Weapon(exiter, Def->Get_Name(), true, 0, true); + Set_Clip_Bullets(exiter, Def->Get_Name(), Get_Int_Parameter("ClipRounds")); + Set_Bullets(exiter, Def->Get_Name(), Get_Int_Parameter("InventoryRounds")); + if (Get_Int_Parameter("AutoSelect")) + { + Commands->Select_Weapon(exiter, Def->Get_Name()); + } + } + } +} + +ScriptRegistrant UP_Grant_Weapon_Zone_Exit_Registrant("UP_Grant_Weapon_Zone_Exit", "Preset=Weapon:string,ClipRounds=1:int,InventoryRounds=1:int,AutoSelect=1:int"); + +/******************************************************************************************************/ + +void UP_Spawn_When_Death::Killed(GameObject* obj, GameObject* killer) +{ + GameObject* spawnedObj = Commands->Create_Object(Get_Parameter("Preset"), Commands->Get_Position(obj)); + Commands->Set_Facing(spawnedObj, Commands->Get_Facing(obj)); +} + +ScriptRegistrant UP_Spawn_When_Death_Registrant("UP_Spawn_When_Death", "Preset=Object:string"); + +/******************************************************************************************************/ + +void UP_GameOver_When_Death::Killed(GameObject* obj, GameObject* killer) +{ + Console_Input("gameover"); +} + +ScriptRegistrant UP_GameOver_When_Death_Registrant("UP_GameOver_When_Death", ""); + +/******************************************************************************************************/ + +void UP_Change_Character::Created(GameObject* obj) +{ + if (obj->As_SoldierGameObj()) + { + if (DefinitionClass* Def = Find_Named_Definition(Get_Parameter("Preset"))) + { + if (SoldierGameObjDef* SoldierDef = (SoldierGameObjDef*)Def) + { + obj->As_SoldierGameObj()->Re_Init(*SoldierDef); + obj->As_SoldierGameObj()->Post_Re_Init(); + } + } + } + Destroy_Script(); +} + +ScriptRegistrant UP_Change_Character_Registrant("UP_Change_Character", "Preset=Character:string"); + +/******************************************************************************************************/ + +void UP_Grant_Character_Zone_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + if (enterer->As_SoldierGameObj()) + { + if (DefinitionClass* Def = Find_Named_Definition(Get_Parameter("Preset"))) + { + if (SoldierGameObjDef* SoldierDef = (SoldierGameObjDef*)Def) + { + enterer->As_SoldierGameObj()->Re_Init(*SoldierDef); + enterer->As_SoldierGameObj()->Post_Re_Init(); + } + } + } +} + +ScriptRegistrant UP_Grant_Character_Zone_Enter_Registrant("UP_Grant_Character_Zone_Enter", "Preset=Character:string"); + +/******************************************************************************************************/ + +void UP_Grant_Character_Zone_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + if (exiter->As_SoldierGameObj()) + { + if (DefinitionClass* Def = Find_Named_Definition(Get_Parameter("Preset"))) + { + if (SoldierGameObjDef* SoldierDef = (SoldierGameObjDef*)Def) + { + exiter->As_SoldierGameObj()->Re_Init(*SoldierDef); + exiter->As_SoldierGameObj()->Post_Re_Init(); + } + } + } +} + +ScriptRegistrant UP_Grant_Character_Zone_Exit_Registrant("UP_Grant_Character_Zone_Exit", "Preset=Character:string"); + +/******************************************************************************************************/ + +void UP_Spawn_And_Destroy_When_Fully_Repaired::Damaged(GameObject* obj, GameObject* damager, float amount) +{ + if (amount < 0) + { + float current = Commands->Get_Health(obj) + Commands->Get_Shield_Strength(obj); + float max = Commands->Get_Max_Health(obj) + Commands->Get_Max_Shield_Strength(obj); + if (current == max) + { + GameObject* newObject = Commands->Create_Object(Get_Parameter("Preset"), Commands->Get_Position(obj)); + Commands->Set_Facing(newObject, Commands->Get_Facing(obj)); + obj->Set_Delete_Pending(); + Destroy_Script(); + } + } +} + +ScriptRegistrant UP_Spawn_And_Destroy_When_Fully_Repaired_Registrant("UP_Spawn_And_Destroy_When_Fully_Repaired", "Preset=Object:string"); + +/******************************************************************************************************/ + +void UP_Refinery_Object::Created(GameObject* obj) +{ + Team = Get_Int_Parameter("Team"); + Amount = Get_Float_Parameter("Amount"); + Set_Object_Type(obj, Team); + Commands->Start_Timer(obj, this, Get_Float_Parameter("Interval"), 5); +} + +void UP_Refinery_Object::Timer_Expired(GameObject* obj, int number) +{ + for (SLNode* z = Get_Player_List()->Head(); z; z = z->Next()) + { + cPlayer* player = z->Data(); + if (player->Get_Is_In_Game() && player->Get_Player_Type() == Team) + { + player->Set_Money(player->Get_Money() + Amount); + } + } +} + +ScriptRegistrant UP_Refinery_Object_Registrant("UP_Refinery_Object", "Team=0:int,Interval=1.0:float,Amount=2.0:float"); + +/******************************************************************************************************/ + +void UP_Vehicle_Purchase_Terminal::Created(GameObject* obj) +{ + Preset = Get_Parameter("VehiclePreset"); + SpawnLocation = Commands->Get_Position(Commands->Find_Object(Get_Int_Parameter("SpawnerID"))); + Facing = Commands->Get_Facing(Commands->Find_Object(Get_Int_Parameter("SpawnerID"))); + Terminal = obj; + Pokable = true; + Amount = Get_Int_Parameter("Credits"); + + if (DefinitionClass* Def = Find_Named_Definition(Preset)) + { + if (Def->Get_Class_ID() != CID_Vehicle) + { + Destroy_Script(); + } + } + else + { + Destroy_Script(); + } + + Commands->Enable_HUD_Pokable_Indicator(obj, true); +} + +void UP_Vehicle_Purchase_Terminal::Poked(GameObject* obj, GameObject* poker) +{ + if (Pokable) + { + SoldierGameObj* playerObj = poker->As_SoldierGameObj(); + if (Commands->Get_Player_Type(playerObj) == Get_Int_Parameter("Team")) + { + if (Commands->Get_Money(playerObj) >= Amount) + { + GameObject* Vehicle = Commands->Create_Object(Preset, SpawnLocation); + Commands->Set_Facing(Vehicle, Facing); + Send_Message_Player(playerObj, 255, 255, 255, "Purchase request granted!"); + Create_2D_WAV_Sound_Player(playerObj, "M00GBMG_SECX0002I1GBMG_snd.wav"); + Commands->Give_Money(playerObj, Amount * -1.0f, false); + Pokable = false; + Commands->Enable_HUD_Pokable_Indicator(obj, false); + Commands->Start_Timer(obj, this, 5.0f, 1); + } + else + { + Send_Message_Player(playerObj, 255, 255, 255, "Insufficient funds!"); + + if (Get_Player_Type(poker) == 0) + { + Create_2D_WAV_Sound_Player(poker, "m00evan_dsgn0024i1evan_snd.wav"); + } + if (Get_Player_Type(poker) == 1) + { + Create_2D_WAV_Sound_Player(poker, "m00evag_dsgn0028i1evag_snd.wav"); + } + } + } + else + { + Send_Message_Player(playerObj, 255, 255, 255, StringClass::getFormattedString("Access Denied! You aren't in team %s.", Get_Team_Name(Get_Int_Parameter("Team")))); + } + } +} + +void UP_Vehicle_Purchase_Terminal::Timer_Expired(GameObject* obj, int number) +{ + if (number == 1) + { + Pokable = true; + Commands->Enable_HUD_Pokable_Indicator(obj, true); + } +} + +ScriptRegistrant UP_Vehicle_Purchase_Terminal_Registrant("UP_Vehicle_Purchase_Terminal", "Team=0:int,SpawnerID=0:int,VehiclePreset:string,Credits=400:int"); + +/******************************************************************************************************/ + +void UP_Character_Purchase_Terminal::Created(GameObject* obj) +{ + Preset = Get_Parameter("CharacterPreset"); + Terminal = obj; + Pokable = true; + Amount = Get_Int_Parameter("Credits"); + + if (DefinitionClass* Def = Find_Named_Definition(Preset)) + { + if (Def->Get_Class_ID() != CID_Soldier) + { + Destroy_Script(); + } + } + else + { + Destroy_Script(); + } + + Commands->Enable_HUD_Pokable_Indicator(obj, true); +} + +void UP_Character_Purchase_Terminal::Poked(GameObject* obj, GameObject* poker) +{ + if (Pokable) + { + SoldierGameObj* Player = poker->As_SoldierGameObj(); + if (Commands->Get_Player_Type(Player) == Get_Int_Parameter("Team")) + { + if (Commands->Get_Money(poker) >= Amount) + { + Player->Re_Init(*(SoldierGameObjDef*)Find_Named_Definition(Preset)); + Player->Post_Re_Init(); + Send_Message_Player(Player, 255, 255, 255, "Purchase request granted!"); + Create_2D_WAV_Sound_Player(Player, "M00GBMG_SECX0002I1GBMG_snd.wav"); + Commands->Give_Money(Player, Amount * -1.0f, false); + Pokable = false; + Commands->Enable_HUD_Pokable_Indicator(obj, false); + Commands->Start_Timer(obj, this, 5.0f, 1); + } + else + { + Send_Message_Player(Player, 255, 255, 255, "Insufficient funds!"); + + if (Get_Player_Type(poker) == 0) + { + Create_2D_WAV_Sound_Player(poker, "m00evan_dsgn0024i1evan_snd.wav"); + } + if (Get_Player_Type(poker) == 1) + { + Create_2D_WAV_Sound_Player(poker, "m00evag_dsgn0028i1evag_snd.wav"); + } + } + } + else + { + Send_Message_Player(Player, 255, 255, 255, StringClass::getFormattedString("Access Denied! You aren't in team %s.", Get_Team_Name(Get_Int_Parameter("Team")))); + } + } +} + +void UP_Character_Purchase_Terminal::Timer_Expired(GameObject* obj, int number) +{ + if (number == 1) + { + Pokable = true; + Commands->Enable_HUD_Pokable_Indicator(obj, true); + } +} + +ScriptRegistrant UP_Character_Purchase_Terminal_Registrant("UP_Character_Purchase_Terminal", "Team=0:int,CharacterPreset:string,Credits=400:int"); + +/******************************************************************************************************/ + +void UP_Set_Team_When_Exit::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == CUSTOM_EVENT_VEHICLE_EXITED) + { + Set_Object_Type(obj, Get_Int_Parameter("Team")); + Commands->Start_Timer(obj, this, 0.1f, 1); + } +} + +void UP_Set_Team_When_Exit::Timer_Expired(GameObject* obj, int number) +{ + Set_Object_Type(obj, Get_Int_Parameter("Team")); +} + +ScriptRegistrant UP_Set_Team_When_Exit_Registrant("UP_Set_Team_When_Exit", "Team=-1:int"); + +/******************************************************************************************************/ + +void UP_Ion_Explosion_When_Death::Killed(GameObject* obj, GameObject* killer) +{ + Vector3 Pos = Commands->Get_Position(obj); + Create_Explosion_Extended("Explosion_IonCannonBeacon", Pos, obj); + Commands->Create_Object("Beacon_Ion_Cannon_Anim_Post", Commands->Get_Position(obj)); + Destroy_Script(); +} + +ScriptRegistrant UP_Ion_Explosion_When_Death_Registrant("UP_Ion_Explosion_When_Death", ""); + +/******************************************************************************************************/ + +void UP_FlyMode_Enable::Created(GameObject* obj) +{ + if (!Get_Fly_Mode(obj)) + { + Toggle_Fly_Mode(obj); + } + + Destroy_Script(); +} + +ScriptRegistrant UP_FlyMode_Enable_Registrant("UP_FlyMode_Enable", ""); + +/******************************************************************************************************/ + +void UP_FlyMode_Disable::Created(GameObject* obj) +{ + if (Get_Fly_Mode(obj)) + { + Toggle_Fly_Mode(obj); + } + + Destroy_Script(); +} + +ScriptRegistrant UP_FlyMode_Disable_Registrant("UP_FlyMode_Disable", ""); + +/******************************************************************************************************/ + +void UP_Spectate::Created(GameObject* obj) +{ + if (Commands->Is_A_Star(obj)) + { + Console_Input(StringClass::getFormattedString("spectate %d", Get_Player_ID(obj))); + } + + Destroy_Script(); +} + +ScriptRegistrant UP_Spectate_Registrant("UP_Spectate", ""); + +/******************************************************************************************************/ + +void UP_Spectate_Zone_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + if (Commands->Is_A_Star(enterer)) + { + Console_Input(StringClass::getFormattedString("spectate %d", Get_Player_ID(enterer))); + } +} + +ScriptRegistrant UP_Spectate_Zone_Enter_Registrant("UP_Spectate_Zone_Enter", ""); + +/******************************************************************************************************/ + +void UP_Spectate_Zone_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + if (Commands->Is_A_Star(exiter)) + { + Console_Input(StringClass::getFormattedString("spectate %d", Get_Player_ID(exiter))); + } +} + +ScriptRegistrant UP_Spectate_Zone_Exit_Registrant("UP_Spectate_Zone_Exit", ""); + +/******************************************************************************************************/ + +void UP_Select_Weapon::Created(GameObject* obj) +{ + Commands->Select_Weapon(obj, Get_Parameter("WeaponPreset")); +} + +ScriptRegistrant UP_Select_Weapon_Registrant("UP_Select_Weapon", "WeaponPreset:string"); + +/******************************************************************************************************/ + +void UP_Select_Weapon_On_Zone_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + Commands->Select_Weapon(enterer, Get_Parameter("WeaponPreset")); +} + +ScriptRegistrant UP_Select_Weapon_On_Zone_Enter_Registrant("UP_Select_Weapon_On_Zone_Enter", "WeaponPreset:string"); + +/******************************************************************************************************/ + +void UP_Select_Weapon_On_Zone_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + Commands->Select_Weapon(exiter, Get_Parameter("WeaponPreset")); +} + +ScriptRegistrant UP_Select_Weapon_On_Zone_Exit_Registrant("UP_Select_Weapon_On_Zone_Exit", "WeaponPreset:string"); + +/******************************************************************************************************/ + +void UP_Chinook_Reinforcements_Paradrop::Created(GameObject* obj) +{ + presetObj1 = 0; + presetObj2 = 0; + presetObj3 = 0; + + Vector3 pos = Commands->Get_Position(obj); + float facing = Commands->Get_Facing(obj); + trajectory = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Model(trajectory, "X5D_Chinookfly"); + Commands->Set_Facing(trajectory, facing); + Commands->Set_Animation(trajectory, "X5D_Chinookfly.X5D_Chinookfly", false, NULL, 0.0f, -1.0f, false); + + if (Get_Object_Type(obj) == 0) + { + helicopter = Commands->Create_Object("Nod_Transport_Helicopter_Flyover", pos); + Commands->Set_Animation(helicopter, "v_Nod_trnspt.v_Nod_trnspt", true, NULL, 0.0f, -1.0f, false); + } + else + { + helicopter = Commands->Create_Object("GDI_Transport_Helicopter_Flyover", pos); + Commands->Set_Animation(helicopter, "v_GDI_trnspt.v_GDI_trnspt", true, NULL, 0.0f, -1.0f, false); + } + + Commands->Set_Facing(helicopter, facing); + Commands->Attach_Script(helicopter, "UP_Unkillable_Until_Custom", "1496001"); + Commands->Disable_All_Collisions(helicopter); + Commands->Attach_To_Object_Bone(helicopter, trajectory, "BN_Chinook_1"); + + chinookKilled = false; + paratrooperIndex = 0; + + Attach_Script_V(helicopter, "M03_Reinforcement_Chinook", "%d", Commands->Get_ID(obj)); + + Commands->Start_Timer(obj, this, 300 / 30.0f, 0); + Commands->Start_Timer(obj, this, 169 / 30.0f, 1); + Commands->Start_Timer(obj, this, 179 / 30.0f, 2); + Commands->Start_Timer(obj, this, 198 / 30.0f, 3); + Commands->Start_Timer(obj, this, 145 / 30.0f, 4); + Commands->Start_Timer(obj, this, 155 / 30.0f, 5); + Commands->Start_Timer(obj, this, 165 / 30.0f, 6); + Commands->Start_Timer(obj, this, 25 / 30.0f, 7); + Commands->Start_Timer(obj, this, 280 / 30.0f, 8); +} + +void UP_Chinook_Reinforcements_Paradrop::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == 23000 && param == 23000) + { + chinookKilled = true; + } + else if (type == 15730) + { + if (GameObject* Attach = Commands->Find_Object(param)) + { + presetObj1 = Attach; + } + } + else if (type == 15731) + { + if (GameObject* Attach = Commands->Find_Object(param)) + { + presetObj2 = Attach; + } + } + else if (type == 15732) + { + if (GameObject* Attach = Commands->Find_Object(param)) + { + presetObj3 = Attach; + } + } +} + +void UP_Chinook_Reinforcements_Paradrop::Timer_Expired(GameObject* obj, int number) +{ + Vector3 pos = Commands->Get_Position(obj); + const char* preset1 = Get_Parameter("FirstPreset"); + const char* preset2 = Get_Parameter("SecondPreset"); + const char* preset3 = Get_Parameter("ThirdPreset"); + float facing = Commands->Get_Facing(obj); + + if (number == 0) + { + Commands->Send_Custom_Event(0, presetObj1, 1248753, 0, 0.0f); + Commands->Send_Custom_Event(0, presetObj2, 1248753, 0, 0.0f); + Commands->Send_Custom_Event(0, presetObj3, 1248753, 0, 0.0f); + Destroy_Script(); + } + + else if (number == 8) + { + if (helicopter) + { + Commands->Destroy_Object(helicopter); + } + } + + else if (number == 7) + { + if (helicopter) + { + Commands->Enable_Engine(helicopter, true); + } + } + + else if (number == 1) + { + if (this->paratrooperIndex > 0) + { + if (presetObj1) + { + GameObject* cinObj = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Facing(cinObj, facing); + Commands->Set_Model(cinObj, "X5D_Parachute"); + Commands->Set_Animation(cinObj, "X5D_Parachute.X5D_ParaC_1", false, NULL, 0.0f, -1.0f, false); + Commands->Create_3D_Sound_At_Bone("parachute_open", cinObj, "ROOTTRANSFORM"); + Commands->Attach_Script(cinObj, "M03_No_More_Parachute", ""); + } + } + } + + else if (number == 2) + { + if (this->paratrooperIndex > 1) + { + if (presetObj2) + { + GameObject* cinObj = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Facing(cinObj, facing); + Commands->Set_Model(cinObj, "X5D_Parachute"); + Commands->Set_Animation(cinObj, "X5D_Parachute.X5D_ParaC_2", false, NULL, 0.0f, -1.0f, false); + Commands->Create_3D_Sound_At_Bone("parachute_open", cinObj, "ROOTTRANSFORM"); + Commands->Attach_Script(cinObj, "M03_No_More_Parachute", ""); + } + } + } + + else if (number == 3) + { + if (this->paratrooperIndex == 3) + { + if (presetObj3) + { + GameObject* cinObj = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Facing(cinObj, facing); + Commands->Set_Model(cinObj, "X5D_Parachute"); + Commands->Set_Animation(cinObj, "X5D_Parachute.X5D_ParaC_3", false, NULL, 0.0f, -1.0f, false); + Commands->Create_3D_Sound_At_Bone("parachute_open", cinObj, "ROOTTRANSFORM"); + Commands->Attach_Script(cinObj, "M03_No_More_Parachute", ""); + } + } + } + + else if (number == 4) + { + if (!chinookKilled) + { + if (Is_Valid_Preset(preset1) || presetObj1) + { + GameObject* trajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Model(trajectoryObj, "X5D_Box01"); + Commands->Set_Facing(trajectoryObj, facing); + Commands->Set_Animation(trajectoryObj, "X5D_Box01.X5D_Box01", false, NULL, 0.0f, -1.0f, false); + if (!presetObj1) + { + presetObj1 = Commands->Create_Object_At_Bone(trajectoryObj, preset1, "Box01"); + } + + if (presetObj1) + { + if (Check_Object(presetObj1)) + { + Commands->Set_Facing(presetObj1, facing); + Attach_Script_Once(presetObj1, "UP_Unkillable_Until_Custom", "1248753"); + Commands->Attach_Script(presetObj1, "RMV_Trigger_Killed", "1144444, 1000, 1000"); + Commands->Attach_Script(presetObj1, "M03_Killed_Sound", ""); + Commands->Attach_Script(presetObj1, "DLS_Volcano_Stumble", ""); + Commands->Set_Animation(presetObj1, "s_a_human.H_A_X5D_ParaT_1", false, NULL, 0.0f, -1.0f, false); + } + Commands->Attach_To_Object_Bone(presetObj1, trajectoryObj, "Box01"); + } + } + + paratrooperIndex++; + } + } + + else if (number == 5) + { + if (!chinookKilled) + { + if (Is_Valid_Preset(preset2) || presetObj2) + { + GameObject* trajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Model(trajectoryObj, "X5D_Box02"); + Commands->Set_Facing(trajectoryObj, facing); + Commands->Set_Animation(trajectoryObj, "X5D_Box02.X5D_Box02", false, NULL, 0.0f, -1.0f, false); + if (!presetObj2) + { + presetObj2 = Commands->Create_Object_At_Bone(trajectoryObj, preset2, "Box02"); + } + + if (presetObj2) + { + if (Check_Object(presetObj2)) + { + Commands->Set_Facing(presetObj2, facing); + Attach_Script_Once(presetObj2, "UP_Unkillable_Until_Custom", "1248753"); + Commands->Attach_Script(presetObj2, "RMV_Trigger_Killed", "1144444, 1000, 1000"); + Commands->Attach_Script(presetObj2, "M03_Killed_Sound", ""); + Commands->Attach_Script(presetObj2, "DLS_Volcano_Stumble", ""); + Commands->Set_Animation(presetObj2, "s_a_human.H_A_X5D_ParaT_2", false, NULL, 0.0f, -1.0f, false); + } + Commands->Attach_To_Object_Bone(presetObj2, trajectoryObj, "Box02"); + } + } + + paratrooperIndex++; + } + } + + else if (number == 6) + { + if (!chinookKilled) + { + if (Is_Valid_Preset(preset3) || presetObj3) + { + GameObject* trajectoryObj = Commands->Create_Object("Generic_Cinematic", pos); + Commands->Set_Model(trajectoryObj, "X5D_Box03"); + Commands->Set_Facing(trajectoryObj, facing); + Commands->Set_Animation(trajectoryObj, "X5D_Box03.X5D_Box03", false, NULL, 0.0f, -1.0f, false); + + if (!presetObj3) + { + presetObj3 = Commands->Create_Object_At_Bone(trajectoryObj, preset3, "Box03"); + } + + if (presetObj3) + { + if (Check_Object(presetObj3)) + { + Commands->Set_Facing(presetObj3, facing); + Attach_Script_Once(presetObj3, "UP_Unkillable_Until_Custom", "1248753"); + Commands->Attach_Script(presetObj3, "RMV_Trigger_Killed", "1144444, 1000, 1000"); + Commands->Attach_Script(presetObj3, "M03_Killed_Sound", ""); + Commands->Attach_Script(presetObj3, "DLS_Volcano_Stumble", ""); + Commands->Set_Animation(presetObj3, "s_a_human.H_A_X5D_ParaT_3", false, NULL, 0.0f, -1.0f, false); + } + Commands->Attach_To_Object_Bone(presetObj3, trajectoryObj, "Box03"); + } + } + + paratrooperIndex++; + } + } +} + +ScriptRegistrant UP_Chinook_Reinforcements_Paradrop_Registrant("UP_Chinook_Reinforcements_Paradrop", "FirstPreset:string,SecondPreset:string,ThirdPreset:string"); + +/******************************************************************************************************/ + +void UP_Unkillable_Until_Custom::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == Get_Int_Parameter("Message")) + { + Destroy_Script(); + } +} + +void UP_Unkillable_Until_Custom::Damaged(GameObject* obj, GameObject* damager, float amount) +{ + float maxHealth = Commands->Get_Max_Health(obj); + Commands->Set_Health(obj, maxHealth); + + float maxShield = Commands->Get_Max_Shield_Strength(obj); + Commands->Set_Shield_Strength(obj, maxShield); +} + +ScriptRegistrant UP_Unkillable_Until_Custom_Registrant("UP_Unkillable_Until_Custom", "Message:int"); + +/******************************************************************************************************/ + +void UP_AttachScript_Interval_Self::Created(GameObject* obj) +{ + Script = Get_Parameter("Script"); + Parameters = Get_Parameter("Parameters"); + Interval = Get_Float_Parameter("Interval"); + LoopCount = Get_Int_Parameter("LoopCount"); + Looped = 0; + + Parameters.Replace("|", ","); + + Commands->Start_Timer(obj, this, Interval, 234245); +} + +void UP_AttachScript_Interval_Self::Timer_Expired(GameObject* obj, int number) +{ + if (number == 234245) + { + Commands->Attach_Script(obj, Script, Parameters); + if (LoopCount != -1) + { + if (Looped >= LoopCount) + { + Destroy_Script(); + } + else + { + ++Looped; + Commands->Start_Timer(obj, this, Interval, 234245); + } + } + else + { + Commands->Start_Timer(obj, this, Interval, 234245); + } + } +} + +ScriptRegistrant UP_AttachScript_Interval_Self_Registrant("UP_AttachScript_Interval_Self", "Script:string,Parameters:string,LoopCount=-1:int,Interval=1:float"); + +/******************************************************************************************************/ + +void UP_AttachScript_Interval::Created(GameObject* obj) +{ + Target = Commands->Find_Object(Get_Int_Parameter("ObjectID")); + Script = Get_Parameter("Script"); + Parameters = Get_Parameter("Parameters"); + Interval = Get_Float_Parameter("Interval"); + LoopCount = Get_Int_Parameter("LoopCount"); + Looped = 0; + + Parameters.Replace("|", ","); + + Commands->Start_Timer(obj, this, Interval, 234244); +} + +void UP_AttachScript_Interval::Timer_Expired(GameObject* obj, int number) +{ + if (number == 234244) + { + Commands->Attach_Script(Target, Script, Parameters); + if (LoopCount != -1) + { + if (Looped >= LoopCount) + { + Destroy_Script(); + } + else + { + ++Looped; + Commands->Start_Timer(obj, this, Interval, 234244); + } + } + else + { + Commands->Start_Timer(obj, this, Interval, 234244); + } + } +} + +ScriptRegistrant UP_AttachScript_Interval_Registrant("UP_AttachScript_Interval", "ObjectID:int,Script:string,Parameters:string,LoopCount=-1:int,Interval=1:float"); + +/******************************************************************************************************/ + +void UP_Object_Follower_AI::Created(GameObject* obj) +{ + TargetChangeCustom = Get_Int_Parameter("TargetChangeCustomID"); + DestroyScriptCustom = Get_Int_Parameter("DestroyScriptCustomID"); +} + +void UP_Object_Follower_AI::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == TargetChangeCustom) + { + if(param == 0) + { + TargetObject = 0; + Commands->Action_Reset(TargetObject, FLT_MAX); + if (Has_Timer(obj, this, 12314178)) + { + Stop_Timer2(obj, this, 12314178); + } + } + else + { + if (GameObject* Target = Commands->Find_Object(param)) + { + TargetObject = Target; + Timer_Expired(obj, 12314178); + + if (!Has_Timer(obj, this, 12314178)) + { + Commands->Start_Timer(obj, this, 5.0f, 12314178); + } + } + } + } + else if (type == DestroyScriptCustom) + { + Destroy_Script(); + } +} + +void UP_Object_Follower_AI::Timer_Expired(GameObject* obj, int number) +{ + if (number == 12314178) + { + if (TargetObject) + { + ActionParamsStruct Parameters; + Parameters.Set_Basic(this, 100.0f, 20000); + Parameters.Set_Movement(TargetObject, 0.8f, 2.5f); + Commands->Action_Goto(TargetObject, Parameters); + } + } +} + +ScriptRegistrant UP_Object_Follower_AI_Registrant("UP_Object_Follower_AI", "TargetChangeCustomID=123:int,DestroyScriptCustomID=124:int"); + +/******************************************************************************************************/ + +void UP_Private_Color_Message_On_Poke::Created(GameObject* obj) +{ + Pokable = true; + Commands->Enable_HUD_Pokable_Indicator(obj, true); +} + +void UP_Private_Color_Message_On_Poke::Timer_Expired(GameObject* obj, int number) +{ + if (number == 1) + { + Pokable = true; + Commands->Enable_HUD_Pokable_Indicator(obj, true); + } +} + +void UP_Private_Color_Message_On_Poke::Poked(GameObject* obj, GameObject* poker) +{ + if (Pokable) + { + Send_Message_Player(poker, Get_Int_Parameter("Red"), Get_Int_Parameter("Green"), Get_Int_Parameter("Blue"), Get_Parameter("Message")); + Pokable = false; + Commands->Enable_HUD_Pokable_Indicator(obj, false); + Commands->Start_Timer(obj, this, 5.0f, 1); + } +} + +ScriptRegistrant UP_Private_Color_Message_On_Poke_Registrant("UP_Private_Color_Message_On_Poke", "Red=255:int,Green=255:int,Blue=255:int,Message=Message:string"); + +/******************************************************************************************************/ + +void UP_Seize_Weapon_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + const char* weaponName = Get_Parameter("Weapon"); + if (Has_Weapon(enterer, weaponName)) + { + int clipAmmo = Get_Clip_Bullets(enterer, weaponName); + int invAmmo = Get_Bullets(enterer, weaponName); + Attach_Script_V(enterer, "UP_Grant_Weapon_Custom_Then_Detach", "%s,%d,%d,0,%d", weaponName, clipAmmo, invAmmo, Get_Int_Parameter("CustomID")); + Remove_Weapon(enterer, weaponName); + } +} + +void UP_Seize_Weapon_Enter::Exited(GameObject* obj, GameObject* exiter) +{ + Commands->Send_Custom_Event(obj, exiter, Get_Int_Parameter("CustomID"), 0, .0f); +} + +ScriptRegistrant UP_Seize_Weapon_Enter_Registrant("UP_Seize_Weapon_Enter", "Weapon:string,CustomID:int"); + +/******************************************************************************************************/ + +void UP_Seize_Weapon_Exit::Entered(GameObject* obj, GameObject* enterer) +{ + Commands->Send_Custom_Event(obj, enterer, Get_Int_Parameter("CustomID"), 0, .0f); +} + +void UP_Seize_Weapon_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + const char* weaponName = Get_Parameter("Weapon"); + if (Has_Weapon(exiter, weaponName)) + { + int clipAmmo = Get_Clip_Bullets(exiter, weaponName); + int invAmmo = Get_Bullets(exiter, weaponName); + Attach_Script_V(exiter, "UP_Grant_Weapon_Custom_Then_Detach", "%s,%d,%d,0,%d", weaponName, clipAmmo, invAmmo, Get_Int_Parameter("CustomID")); + Remove_Weapon(exiter, weaponName); + } +} + +ScriptRegistrant UP_Seize_Weapon_Exit_Registrant("UP_Seize_Weapon_Exit", "Weapon:string,CustomID:int"); + +/******************************************************************************************************/ + +void UP_Seize_All_Weapons_Enter::Created(GameObject* obj) +{ + char* weaponList = newstr(Get_Parameter("WeaponsExcept")); + char* curPos = weaponList; + char* lastPos = weaponList; + + for(;;) + { + if(curPos[0] == '|') + { + curPos[0] = '\0'; + Weapons.Add(lastPos); + curPos[0] = '|'; + + curPos++; + lastPos = curPos; + } + else if (curPos[0] == '\0') + { + if (curPos > lastPos) + { + Weapons.Add(lastPos); + } + break; + } + + curPos++; + } + + delete[] weaponList; +} + +void UP_Seize_All_Weapons_Enter::Entered(GameObject* obj, GameObject* enterer) +{ + for (int i = 1; i < Get_Weapon_Count(enterer); i++) + { + if (const char* weaponName = Get_Weapon(enterer, i)) + { + if (!strcmp(weaponName, "None")) + continue; + + if (Weapons.ID(weaponName) == -1) + { + int clipAmmo = Get_Clip_Bullets(enterer, weaponName); + int invAmmo = Get_Bullets(enterer, weaponName); + Attach_Script_V(enterer, "UP_Grant_Weapon_Custom_Then_Detach", "%s,%d,%d,0,%d", weaponName, clipAmmo, invAmmo, Get_Int_Parameter("CustomID")); + Remove_Weapon(enterer, weaponName); + i--; + } + } + } +} + +void UP_Seize_All_Weapons_Enter::Exited(GameObject* obj, GameObject* exiter) +{ + Commands->Send_Custom_Event(obj, exiter, Get_Int_Parameter("CustomID"), 0, .0f); +} + +ScriptRegistrant UP_Seize_All_Weapons_Enter_Registrant("UP_Seize_All_Weapons_Enter", "WeaponsExcept:string,CustomID:int"); + +/******************************************************************************************************/ + +void UP_Seize_All_Weapons_Exit::Created(GameObject* obj) +{ + char* weaponList = newstr(Get_Parameter("WeaponsExcept")); + char* curPos = weaponList; + char* lastPos = weaponList; + + for (;;) + { + if (curPos[0] == '|') + { + curPos[0] = '\0'; + Weapons.Add(lastPos); + curPos[0] = '|'; + + curPos++; + lastPos = curPos; + continue; + } + else if (curPos[0] == '\0') + { + if (curPos > lastPos) + { + Weapons.Add(lastPos); + } + break; + } + + curPos++; + } + + delete[] weaponList; +} + +void UP_Seize_All_Weapons_Exit::Entered(GameObject* obj, GameObject* enterer) +{ + Commands->Send_Custom_Event(obj, enterer, Get_Int_Parameter("CustomID"), 0, .0f); +} + +void UP_Seize_All_Weapons_Exit::Exited(GameObject* obj, GameObject* exiter) +{ + for (int i = 1; i < Get_Weapon_Count(exiter); i++) + { + if (const char* weaponName = Get_Weapon(exiter, i)) + { + if (!strcmp(weaponName, "None")) + continue; + + if (Weapons.ID(weaponName) == -1) + { + int clipAmmo = Get_Clip_Bullets(exiter, weaponName); + int invAmmo = Get_Bullets(exiter, weaponName); + Attach_Script_V(exiter, "UP_Grant_Weapon_Custom_Then_Detach", "%s,%d,%d,0,%d", weaponName, clipAmmo, invAmmo, Get_Int_Parameter("CustomID")); + Remove_Weapon(exiter, weaponName); + i--; + } + } + } +} + +ScriptRegistrant UP_Seize_All_Weapons_Exit_Registrant("UP_Seize_All_Weapons_Exit", "WeaponsExcept:string,CustomID:int"); + +/******************************************************************************************************/ + +void UP_Grant_Weapon_Custom_Then_Detach::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == Get_Int_Parameter("CustomID")) + { + Attach_Script_V(obj, "UP_Grant_Weapon", "%s,%d,%d,%d", Get_Parameter("Preset"), Get_Int_Parameter("ClipRounds"), Get_Int_Parameter("InventoryRounds"), Get_Int_Parameter("AutoSelect")); + Destroy_Script(); + } +} + +ScriptRegistrant UP_Grant_Weapon_Custom_Then_Detach_Registrant("UP_Grant_Weapon_Custom_Then_Detach", "Preset=Weapon:string,ClipRounds=1:int,InventoryRounds=1:int,AutoSelect=1:int,CustomID=10123:int"); + +/******************************************************************************************************/ + +void UP_Disable_Weapon_For_Driver::Created(GameObject* obj) +{ + if (!obj->As_VehicleGameObj()) + Destroy_Script(); + + if (Get_Vehicle_Seat_Count(obj) < 2) + Destroy_Script(); + + HasWeapon = true; + VehicleGameObj* Vehicle = obj->As_VehicleGameObj(); + if (!Vehicle->Get_Occupant(1)) + { + Weapon = Get_Current_Weapon(Vehicle); + ClipAmmo = Get_Current_Clip_Bullets(Vehicle); + InventoryAmmo = Get_Current_Bullets(Vehicle); + Remove_Weapon(Vehicle, Weapon); + HasWeapon = false; + } +} + +void UP_Disable_Weapon_For_Driver::Custom(GameObject* obj, int type, int param, GameObject* sender) +{ + if (type == CUSTOM_EVENT_VEHICLE_ENTERED) + { + VehicleGameObj* Vehicle = obj->As_VehicleGameObj(); + if (Vehicle->Get_Occupant(1) && !HasWeapon) + { + Grant_Weapon(Vehicle, Weapon, true, 0, true); + Set_Clip_Bullets(Vehicle, Weapon, ClipAmmo); + Set_Bullets(Vehicle, Weapon, InventoryAmmo); + Commands->Select_Weapon(Vehicle, Weapon); + + Weapon = ""; + ClipAmmo = 0; + InventoryAmmo = 0; + HasWeapon = true; + } + } + else if (type == CUSTOM_EVENT_VEHICLE_EXITED) + { + VehicleGameObj* Vehicle = obj->As_VehicleGameObj(); + if (!Vehicle->Get_Occupant(1) && HasWeapon) + { + Weapon = Get_Current_Weapon(Vehicle); + ClipAmmo = Get_Current_Clip_Bullets(Vehicle); + InventoryAmmo = Get_Current_Bullets(Vehicle); + Remove_Weapon(Vehicle, Weapon); + HasWeapon = false; + } + } +} + +ScriptRegistrant UP_Disable_Weapon_For_Driver_Registrant("UP_Disable_Weapon_For_Driver", ""); + +/******************************************************************************************************/ diff -urN sourceold/scripts/unstoppable.h source/scripts/unstoppable.h --- sourceold/scripts/unstoppable.h 1970-01-01 10:00:00.000000000 +1000 +++ source/scripts/unstoppable.h 2022-02-13 10:20:09.879323500 +1000 @@ -0,0 +1,851 @@ +/* Renegade Scripts.dll + Copyright 2022 Tiberian Technologies + + This file is part of the Renegade scripts.dll + The Renegade scripts.dll is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. See the file COPYING for more details. + In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. + Only the source code to the module(s) containing the licenced code has to be released. +*/ +#pragma once +#include "scripts.h" + +/*! + * \brief Teleport + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Teleports enterer to specified object. + * + * \param ArrowID + * Object to teleport enterer. + * \param SoundName + * Name of sound file to play after teleportation. + */ +class UP_Teleport : public ScriptImpClass +{ +public: + void Entered(GameObject* obj, GameObject* enterer); +}; + +/*! + * \brief HUD Message on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Displays an HUD message when a player enters the zone. + * + * \param Message + * Message to send to enterer player. + * \param SoundName + * Name of sound file to play to player. + * \param Red + * Red tone of the message. + * \param Green + * Green tone of the message. + * \param Blue + * Blue tone of the message. + */ +class UP_HUD_Message_Zone_Enter : public ScriptImpClass +{ +public: + void Entered(GameObject* obj, GameObject* enterer) override; +}; + + +/*! + * \brief HUD Message on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Displays an HUD message when a player exits the zone. + * + * \param Message + * Message to send to exiter player. + * \param SoundName + * Name of sound file to play to player. + * \param Red + * Red tone of the message. + * \param Green + * Green tone of the message. + * \param Blue + * Blue tone of the message. + */ +class UP_HUD_Message_Zone_Exit : public ScriptImpClass +{ +public: + void Exited(GameObject* obj, GameObject* exiter) override; +}; + +/*! + * \brief Stop Vehicle Engine + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Freezes and disables vehicle engine for a duration. + * + * \param Duration + * Amount of time to keep vehicle engine disabled. + */ +class UP_Stop_Vehicle_Engine : public ScriptImpClass +{ +public: + void Created(GameObject* obj); + void Custom(GameObject* obj, int type, int param, GameObject* sender); + void Timer_Expired(GameObject* obj, int number); + +private: + ReferencerClass Vehicle; +}; + +/*! + * \brief Change Vehicle Weapon + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Changes vehicle weapon, and detaches. + * + * \param Preset + * Name of weapon preset to give. + * \param Rounds + * Amount of rounds to give. + */ +class UP_Change_Vehicle_Weapon : public ScriptImpClass +{ +public: + void Created(GameObject* obj); +}; + +/*! + * \brief MCT Controlled Building + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Configures specified object to behave like attached object's MCT. + * + * \param MCTID + * Object ID of the MCT. + * \param Multiplier + * Damage multiplier of MCT. + */ +class UP_MCT_Building : public ScriptImpClass +{ +public: + void Created(GameObject* obj); + void Damaged(GameObject* obj, GameObject* damager, float amount); + +private: + ReferencerClass MCTObj; +}; + +/*! + * \brief Master Control Terminal + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Automatically attached by UP_MCT_Building, forwards damage requests from this object to building that attached this script. + * + * \param Object + * Main building object of this MCT. + * \param Multiplier + * Damage multiplier of this MCT. + */ +class UP_Master_Control_Terminal : public ScriptImpClass +{ +private: + GameObject* MainBuilding; + float Multiplier; + +public: + void Created(GameObject* obj); + void Damaged(GameObject* obj, GameObject* damager, float amount); +}; + +/*! + * \brief Grant Weapon + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Grants a weapon to the attached object with specified ammunition, and detaches. + * + * \param Preset + * Name of weapon preset to give. + * \param ClipRounds + * Amount of clip rounds to give. + * \param InventoryRounds + * Amount of inventory rounds to give. + * \param AutoSelect + * Automatically select the weapon after giving. + */ +class UP_Grant_Weapon : public ScriptImpClass +{ + void Created(GameObject* obj); +}; + +/*! + * \brief Grant Weapon on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Grants a weapon to the enterer objects with specified ammunition. + * + * \param Preset + * Name of weapon preset to give. + * \param ClipRounds + * Amount of clip rounds to give. + * \param InventoryRounds + * Amount of inventory rounds to give. + * \param AutoSelect + * Automatically select the weapon after giving. + */ +class UP_Grant_Weapon_Zone_Enter : public ScriptImpClass +{ + void Entered(GameObject* obj, GameObject* enterer); +}; + +/*! + * \brief Grant Weapon on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Grants a weapon to the exiter objects with specified ammunition. + * + * \param Preset + * Name of weapon preset to give. + * \param ClipRounds + * Amount of clip rounds to give. + * \param InventoryRounds + * Amount of inventory rounds to give. + * \param AutoSelect + * Automatically select the weapon after giving. + */ +class UP_Grant_Weapon_Zone_Exit : public ScriptImpClass +{ + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Spawn Object on Death + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Spawns a preset when attached object dies. + * + * \param Preset + * Name of the preset to spawn. + */ +class UP_Spawn_When_Death : public ScriptImpClass +{ + void Killed(GameObject* obj, GameObject* killer); +}; + +/*! + * \brief Game Over on Death + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Ends the game when attached object dies. + */ +class UP_GameOver_When_Death : public ScriptImpClass +{ + void Killed(GameObject* obj, GameObject* killer); +}; + +/*! + * \brief Change Character + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Changes character of attached object, and detaches. + * + * \param Preset + * Name of the soldier preset to change. + */ +class UP_Change_Character : public ScriptImpClass +{ + void Created(GameObject* obj); +}; + +/*! + * \brief Change Character on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Changes character of enterer objects. + * + * \param Preset + * Name of the soldier preset to change. + */ +class UP_Grant_Character_Zone_Enter : public ScriptImpClass +{ + void Entered(GameObject* obj, GameObject* enterer); +}; + +/*! + * \brief Change Character on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Changes character of exiter objects. + * + * \param Preset + * Name of the soldier preset to change. + */ +class UP_Grant_Character_Zone_Exit : public ScriptImpClass +{ + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Spawn Object and Destroy Itself When Fully Repaired + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Spawns a specified preset, and destroys itself when attached object is fully repaired. + * + * \param Preset + * Name of the preset to spawn. + */ +class UP_Spawn_And_Destroy_When_Fully_Repaired : public ScriptImpClass +{ + void Damaged(GameObject* obj, GameObject* damager, float amount); +}; + +/*! + * \brief Refinery + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Gives specified amount of money with a specified interval to specified team. + * + * \param Team + * ID of the team to give money. + * \param Interval + * Delay between giving money. + * \param Amount + * Amount of money to give. + */ +class UP_Refinery_Object : public ScriptImpClass +{ +private: + int Team; + float Amount; + +public: + void Created(GameObject* obj); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Vehicle PT + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Creates a vehicle purchase terminal with custom spawn location for specified team. + * + * \param Team + * ID of the team to allow purchases to. + * \param SpawnerID + * Object to spawn new vehicles. + * \param VehiclePreset + * Name of the vehicle preset to spawn. + * \param Credits + * Money required to spawn the preset. + */ +class UP_Vehicle_Purchase_Terminal : public ScriptImpClass +{ +private: + bool Pokable; + Vector3 SpawnLocation; + float Facing; + ReferencerClass Terminal; + StringClass Preset; + int Amount; + +public: + void Created(GameObject* obj); + void Poked(GameObject* obj, GameObject* poker); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Infantry PT + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Creates an infantry purchase terminal for specified team. + * + * \param Team + * ID of the team to allow purchases to. + * \param CharacterPreset + * Name of the infantry preset to spawn. + * \param Credits + * Money required to buy and switch to the infantry preset. + */ +class UP_Character_Purchase_Terminal : public ScriptImpClass +{ +private: + bool Pokable; + ReferencerClass Terminal; + StringClass Preset; + int Amount; + +public: + void Created(GameObject* obj); + void Poked(GameObject* obj, GameObject* poker); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Set Team on Vehicle Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Sets the team of vehicle when someone leaves the vehicle. + * + * \param Team + * ID of team to change after leaving the vehicle. + */ +class UP_Set_Team_When_Exit : public ScriptImpClass +{ + void Custom(GameObject* obj, int type, int param, GameObject* sender); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Ion Explosion on Death + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Creates an Ion Cannon explosion at the attached object's location when it dies. + */ +class UP_Ion_Explosion_When_Death : public ScriptImpClass +{ + void Killed(GameObject* obj, GameObject* killer); +}; + +/*! + * \brief Enable Fly Mode + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Enables fly mode for attached object, and detaches. + */ +class UP_FlyMode_Enable : public ScriptImpClass +{ + void Created(GameObject* obj); +}; + +/*! + * \brief Disable Fly Mode + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Disables fly mode for attached object, and detaches. + */ +class UP_FlyMode_Disable : public ScriptImpClass +{ + void Created(GameObject* obj); +}; + +/*! + * \brief Toggle Spectate Mode + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Enables or disables spectator mode for attached player, and detaches. + */ +class UP_Spectate : public ScriptImpClass +{ + void Created(GameObject* obj); +}; + +/*! + * \brief Toggle Spectate Mode on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Enables or disables spectator mode for enterer players. + */ +class UP_Spectate_Zone_Enter : public ScriptImpClass +{ + void Entered(GameObject* obj, GameObject* enterer); +}; + +/*! + * \brief Toggle Spectate Mode on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Enables or disables spectator mode for exiter players. + */ +class UP_Spectate_Zone_Exit : public ScriptImpClass +{ + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Select Weapon + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Selects specified weapon for attached object, and detaches. + * + * \param WeaponPreset + * Name of the weapon preset to select. Nothing happens if player does not have the weapon or is an invalid preset. + */ +class UP_Select_Weapon : public ScriptImpClass +{ + void Created(GameObject* obj); +}; + +/*! + * \brief Select Weapon on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Selects specified weapon for enterer objects. + * + * \param WeaponPreset + * Name of the weapon preset to select. Nothing happens if player does not have the weapon or is an invalid preset. + */ +class UP_Select_Weapon_On_Zone_Enter : public ScriptImpClass +{ + void Entered(GameObject* obj, GameObject* enterer); +}; + +/*! + * \brief Select Weapon on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Selects specified weapon for exiter objects. + * + * \param WeaponPreset + * Name of the weapon preset to select. Nothing happens if player does not have the weapon or is an invalid preset. + */ +class UP_Select_Weapon_On_Zone_Exit : public ScriptImpClass +{ + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Paradrop + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Creates a para drop cinematic which was taken from 3rd mission scripts, and drops up to 3 presets. + * Send a custom event with type "15730" and object ID as parameter to attach a custom object to slot 1, overriding the script parameters. + * Send a custom event with type "15731" and object ID as parameter to attach a custom object to slot 2, overriding the script parameters. + * Send a custom event with type "15732" and object ID as parameter to attach a custom object to slot 3, overriding the script parameters. + * + * \param FirstPreset + * Name of the preset to spawn in first slot. + * \param SecondPreset + * Name of the preset to spawn in second slot. + * \param ThirdPreset + * Name of the preset to spawn in third slot. + */ +class UP_Chinook_Reinforcements_Paradrop : public ScriptImpClass +{ +private: + bool chinookKilled; + int paratrooperIndex; + GameObject* presetObj1; + GameObject* presetObj2; + GameObject* presetObj3; + GameObject* helicopter; + GameObject* trajectory; + + bool Check_Object(GameObject* obj) + { + if (obj) + { + if (obj->As_SmartGameObj()) + { + if (obj->As_SoldierGameObj()) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } + else + { + return false; + } + } + +public: + void Created(GameObject* obj); + void Custom(GameObject* obj, int type, int param, GameObject* sender); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Invincible Until Custom Event + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Disables damages for attached object until a custom is received. + * + * \param Message + * Type of the custom event to disable invincibility. + */ +class UP_Unkillable_Until_Custom : public ScriptImpClass +{ + void Custom(GameObject* obj, int type, int param, GameObject* sender); + void Damaged(GameObject* obj, GameObject* damager, float amount); +}; + +/*! + * \brief Attach Script to Itself with Interval + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Attaches a script to itself after every specified time. + * + * \param Script + * Name of the script to attach. + * \param Parameters + * Parameters of the script. Use '|' as the delimiter. + * \param LoopCount + * Total loop count. Set to -1 for infinite loop. + * \param Interval + * Delay between each attach. + */ +class UP_AttachScript_Interval_Self : public ScriptImpClass +{ +private: + StringClass Script; + StringClass Parameters; + float Interval; + int LoopCount; + int Looped; + +public: + void Created(GameObject* obj); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Attach Script to Target with Interval + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Attaches a script to target object after every specified time. + * + * \param ObjectID + * ID of object to attach the script. + * \param Script + * Name of the script to attach. + * \param Parameters + * Parameters of the script. Use '|' as the delimiter. + * \param LoopCount + * Total loop count. Set to -1 for infinite loop. + * \param Interval + * Delay between each attach. + */ +class UP_AttachScript_Interval : public ScriptImpClass +{ +private: + StringClass Script; + StringClass Parameters; + GameObject* Target; + float Interval; + int LoopCount; + int Looped; + +public: + void Created(GameObject* obj); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Object Follower + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Adds object following capability by customs. + * + * \param TargetChangeCustomID + * ID to listen to change target object. Set to "0" to reset following. + * \param DestroyScriptCustomID + * ID to listen to detach this script. + */ +class UP_Object_Follower_AI : public ScriptImpClass +{ +private: + int TargetChangeCustom; + int DestroyScriptCustom; + ReferencerClass TargetObject; + +public: + void Created(GameObject* obj); + void Custom(GameObject* obj, int type, int param, GameObject* sender); + void Timer_Expired(GameObject* obj, int number); +}; + +/*! + * \brief Private Color Message on Poke + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Sends a private color message to poker when poked. + * + * \param Message + * Message to send to exiter player. + * \param Red + * Red tone of the message. + * \param Green + * Green tone of the message. + * \param Blue + * Blue tone of the message. + */ +class UP_Private_Color_Message_On_Poke : public ScriptImpClass +{ +private: + bool Pokable; + +public: + void Created(GameObject* obj); + void Timer_Expired(GameObject* obj, int number); + void Poked(GameObject* obj, GameObject* poker); +}; + +/*! + * \brief Seize Weapon on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Removes the weapon from enterer object, and gives weapon back when it leaves the zone. + * + * \param Weapon + * Name of the weapon preset to seize. + * \param CustomID + * Unique custom type for this script to grant weapons back to player. + */ +class UP_Seize_Weapon_Enter : public ScriptImpClass +{ +public: + void Entered(GameObject* obj, GameObject* enterer); + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Seize Weapon on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Removes the weapon from exiter object, and gives weapon back when it enters the zone. + * + * \param Weapon + * Name of the weapon preset to seize. + * \param CustomID + * Unique custom type for this script to grant weapons back to player. + */ +class UP_Seize_Weapon_Exit : public ScriptImpClass +{ +public: + void Entered(GameObject* obj, GameObject* enterer); + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Seize All Weapons on Zone Enter + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Removes all weapons except for specified ones from enterer object, and gives everything back when it leaves the zone. + * + * \param Weapons + * Name of the weapon presets to exclude from seize. + * \param CustomID + * Unique custom type for this script to grant weapons back to player. + */ +class UP_Seize_All_Weapons_Enter : public ScriptImpClass +{ +private: + DynamicVectorClass Weapons; + +public: + void Created(GameObject* obj); + void Entered(GameObject* obj, GameObject* enterer); + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Seize All Weapons on Zone Exit + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Removes all weapons except for specified ones from exiter object, and gives everything back when it enters the zone. + * + * \param Weapons + * Name of the weapon presets to exclude from seize. + * \param CustomID + * Unique custom type for this script to grant weapons back to player. + */ +class UP_Seize_All_Weapons_Exit : public ScriptImpClass +{ +private: + DynamicVectorClass Weapons; + +public: + void Created(GameObject* obj); + void Entered(GameObject* obj, GameObject* enterer); + void Exited(GameObject* obj, GameObject* exiter); +}; + +/*! + * \brief Grant Weapon and Detach on Custom Event + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Grants specified weapon to attached object with specified ammunition on a custom event, and detaches. + * + * \param Preset + * Name of weapon preset to give. + * \param ClipRounds + * Amount of clip rounds to give. + * \param InventoryRounds + * Amount of inventory rounds to give. + * \param AutoSelect + * Automatically select the weapon after giving. + * \param CustomID + * Type of the custom event to grant weapon and detach. + */ +class UP_Grant_Weapon_Custom_Then_Detach : public ScriptImpClass +{ +public: + void Custom(GameObject* obj, int type, int param, GameObject* sender); +}; + +/*! + * \brief Disable Weapon for Driver + * \author Unstoppable + * \ingroup UnstoppableScripts + * + * Removes weapon from vehicle if driver is gunner, and gives back when a gunner enters. Designed to work with DriverIsAlwaysGunner turned off. + */ +class UP_Disable_Weapon_For_Driver : public ScriptImpClass +{ +private: + bool HasWeapon; + StringClass Weapon; + int ClipAmmo; + int InventoryAmmo; + +public: + void Created(GameObject* obj); + void Custom(GameObject* obj, int type, int param, GameObject* sender); +}; diff -urN sourceold/scripts/weaponmgr.h source/scripts/weaponmgr.h --- sourceold/scripts/weaponmgr.h 2019-06-22 07:31:28.824400000 +1000 +++ source/scripts/weaponmgr.h 2022-02-13 10:20:09.880430500 +1000 @@ -99,6 +99,7 @@ bool TrackingIgnoreVehicle; bool TrackingIgnoreSoldier; bool TrackingIgnoreVTOL; + bool UseLighting; #if (PARAM_EDITING_ON) || (DDBEDIT) || (W3DVIEWER) Vector3 ProjectileExtent; diff -urN sourceold/scripts_VC2012.sln source/scripts_VC2012.sln --- sourceold/scripts_VC2012.sln 2018-05-17 18:58:53.295200000 +1000 +++ source/scripts_VC2012.sln 2022-02-13 10:20:09.881672500 +1000 @@ -20,8 +20,6 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-plugin", "example-plugin\example-plugin.vcxproj", "{F92D70BB-3091-41A9-801C-884E239C1263}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Spectate", "Spectate\Spectate.vcxproj", "{DD84D0B5-C445-481B-80DA-367D414E41BA}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RandomStartingCredits", "randomstartingcredits\RandomStartingCredits.vcxproj", "{E2A67673-A268-4107-97DF-890422DFD757}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FirstBlood", "FirstBlood\FirstBlood.vcxproj", "{5F775E96-1754-44D3-A2D5-BBA3F69E3FC2}" @@ -116,12 +114,6 @@ {F92D70BB-3091-41A9-801C-884E239C1263}.Release SSGM|Win32.ActiveCfg = Release SSGM|Win32 {F92D70BB-3091-41A9-801C-884E239C1263}.Release SSGM|Win32.Build.0 = Release SSGM|Win32 {F92D70BB-3091-41A9-801C-884E239C1263}.Release|Win32.ActiveCfg = Release SSGM|Win32 - {DD84D0B5-C445-481B-80DA-367D414E41BA}.Debug SSGM|Win32.ActiveCfg = Debug SSGM|Win32 - {DD84D0B5-C445-481B-80DA-367D414E41BA}.Debug SSGM|Win32.Build.0 = Debug SSGM|Win32 - {DD84D0B5-C445-481B-80DA-367D414E41BA}.Debug|Win32.ActiveCfg = Debug SSGM|Win32 - {DD84D0B5-C445-481B-80DA-367D414E41BA}.Release SSGM|Win32.ActiveCfg = Release SSGM|Win32 - {DD84D0B5-C445-481B-80DA-367D414E41BA}.Release SSGM|Win32.Build.0 = Release SSGM|Win32 - {DD84D0B5-C445-481B-80DA-367D414E41BA}.Release|Win32.ActiveCfg = Release SSGM|Win32 {E2A67673-A268-4107-97DF-890422DFD757}.Debug SSGM|Win32.ActiveCfg = Debug SSGM|Win32 {E2A67673-A268-4107-97DF-890422DFD757}.Debug SSGM|Win32.Build.0 = Debug SSGM|Win32 {E2A67673-A268-4107-97DF-890422DFD757}.Debug|Win32.ActiveCfg = Debug SSGM|Win32 diff -urN sourceold/shared/shared.vcxproj source/shared/shared.vcxproj --- sourceold/shared/shared.vcxproj 2020-09-26 09:00:03.276360000 +1000 +++ source/shared/shared.vcxproj 2022-02-13 10:20:09.882633100 +1000 @@ -141,7 +141,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/swap/Swap.vcxproj source/swap/Swap.vcxproj --- sourceold/swap/Swap.vcxproj 2020-09-26 09:00:03.277358200 +1000 +++ source/swap/Swap.vcxproj 2022-02-13 10:20:09.884489500 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/tdbedit/tdbedit.vcxproj source/tdbedit/tdbedit.vcxproj --- sourceold/tdbedit/tdbedit.vcxproj 2020-09-26 09:00:03.277358200 +1000 +++ source/tdbedit/tdbedit.vcxproj 2022-02-13 10:20:09.885417900 +1000 @@ -135,7 +135,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue diff -urN sourceold/teamspeak/teamspeak.vcxproj source/teamspeak/teamspeak.vcxproj --- sourceold/teamspeak/teamspeak.vcxproj 2020-09-26 09:00:03.278355500 +1000 +++ source/teamspeak/teamspeak.vcxproj 2022-02-13 10:20:09.886312500 +1000 @@ -162,7 +162,6 @@ Use General.h $(IntDir)$(TargetName).$(Configuration).pch - AssemblyAndSourceCode Level4 true EditAndContinue