diff --git a/README.md b/README.md index c9a6948ffa..526edcc8d2 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Credits - **secsome (SEC-SOME)** - debug info dump hotkey, refactoring & porting of Ares helper code, introducing more Ares-derived stuff, disguise removal warhead, Mind Control removal warhead, Mind Control enhancement, shields, AnimList.PickRandom, MoveToCell fix, unlimited waypoints, Build At trigger action buildup anim fix, Undeploy building into a unit plays `EVA_NewRallyPointEstablished` fix, custom ore gathering anim, TemporaryClass related crash, Retry dialog on mission failure, Default disguise for individual InfantryTypes, PowerPlant Enhancer, SaveGame Trigger Action, QuickSave command, Numeric variables, Custom gravity for projectiles, Retint map actions bugfix - **Otamaa (Fahroni, BoredEXE)** - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass, DebrisMaximums fixes, Anim-to-Unit, NotHuman anim sequences improvements, Customizable OpenTopped Properties, hooks for ScriptType Actions 92 & 93, ore stage threshold for `HideIfNoOre`, occupied building `MuzzleFlashX` bugfix - **E1 Elite** - TileSet 255 and above bridge repair fix -- **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71 to 112, MC deployer fixes, help with docs, Automatic Passenger Deletion +- **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71 to 113, MC deployer fixes, help with docs, Automatic Passenger Deletion - **AutoGavy** - interceptor logic, warhead critical damage system - **ChrisLv_CN** - interceptor logic, LaserTrails, laser fixes, general assistance (work relicensed under [following permission](images/ChrisLv-relicense.png)) - **Xkein** - general assistance, YRpp edits diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index cdfeffc797..c086ce6539 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1018,6 +1018,17 @@ In `aimd.ini`: [SOMESCRIPTTYPE] ; ScriptType x=112,n ``` + +### `113` Randomly Skip Next Action + +- When executed this action picks a random value between 1 and 100. If the value is equal or below the second parameter then the next action will be skipped. If the second parameter is 0 means that the next action will never be skipped and 100 means thay always will be skipped. + +In `aimd.ini`: +```ini +[SOMESCRIPTTYPE] ; ScriptType +x=113,n ; where 0 > n <= 100 +``` + ### `500 - 523` Edit Variable - Operate a variable's value - The variable's value type is int16 instead of int32 in trigger actions for some reason, which means it ranges from -2^15 to 2^15-1. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 03dcbf5395..0671e5f1c3 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -247,6 +247,7 @@ New: - Script Action 110 that Modify how ends the new move actions (by FS-21) - Script Action 111 that un-register Team success, is just the opposite effect of Action 49 (by FS-21) - Script Action 112 to regroup temporarily around the Team Leader (by FS-21) +- Script Action 113 to Randomly Skip Next Action (by FS-21) - ObjectInfo now shows current Target and AI Trigger data (by FS-21) - Shield absorption and passthrough customization (by Morton) - Limbo Delivery of buildings (by Morton) diff --git a/src/Ext/Script/Body.cpp b/src/Ext/Script/Body.cpp index 057cbdc305..32c5e8b7e8 100644 --- a/src/Ext/Script/Body.cpp +++ b/src/Ext/Script/Body.cpp @@ -193,6 +193,9 @@ void ScriptExt::ProcessAction(TeamClass* pTeam) case 112: ScriptExt::Mission_Gather_NearTheLeader(pTeam, -1); break; + case 113: + ScriptExt::SkipNextAction(pTeam, -1); + break; default: // Do nothing because or it is a wrong Action number or it is an Ares/YR action... if (action > 70 && !(action >= PhobosScripts::LocalVariableAdd && action <= PhobosScripts::GlobalVariableAndByGlobal)) @@ -2535,7 +2538,7 @@ void ScriptExt::SetCloseEnoughDistance(TeamClass *pTeam, double distance = -1) void ScriptExt::UnregisterGreatSuccess(TeamClass* pTeam) { pTeam->AchievedGreatSuccess = false; - pTeam->StepCompleted = true; // This action finished - FS-21 + pTeam->StepCompleted = true; } void ScriptExt::SetMoveMissionEndMode(TeamClass* pTeam, int mode = 0) @@ -2676,6 +2679,45 @@ bool ScriptExt::MoveMissionEndStatus(TeamClass* pTeam, TechnoClass* pFocus, Foot return bForceNextAction; } + +void ScriptExt::SkipNextAction(TeamClass* pTeam, int successPercentage = 0) +{ + // This team has no units! END + if (!pTeam) + { + // This action finished + pTeam->StepCompleted = true; + Debug::Log("DEBUG: [%s] [%s] (line: %d) Jump to next line: %d = %d,%d -> (No team members alive)\n", + pTeam->Type->ID, pTeam->CurrentScript->Type->ID, pTeam->CurrentScript->idxCurrentLine, + pTeam->CurrentScript->idxCurrentLine + 1, pTeam->CurrentScript->Type->ScriptActions[pTeam->CurrentScript->idxCurrentLine + 1].Action, + pTeam->CurrentScript->Type->ScriptActions[pTeam->CurrentScript->idxCurrentLine + 1].Argument); + + return; + } + + if (successPercentage < 0 || successPercentage > 100) + successPercentage = pTeam->CurrentScript->Type->ScriptActions[pTeam->CurrentScript->idxCurrentLine].Argument; + + if (successPercentage < 0) + successPercentage = 0; + + if (successPercentage > 100) + successPercentage = 100; + + int percentage = ScenarioClass::Instance->Random.RandomRanged(1, 100); + + if (percentage <= successPercentage) + { + Debug::Log("DEBUG: ScripType: [%s] [%s] (line: %d) Next script line skipped successfuly. Next line will be: %d = %d,%d\n", + pTeam->Type->ID, pTeam->CurrentScript->Type->ID, pTeam->CurrentScript->idxCurrentLine, pTeam->CurrentScript->idxCurrentLine + 2, + pTeam->CurrentScript->Type->ScriptActions[pTeam->CurrentScript->idxCurrentLine + 2].Action, pTeam->CurrentScript->Type->ScriptActions[pTeam->CurrentScript->idxCurrentLine + 2].Argument); + pTeam->CurrentScript->idxCurrentLine++; + } + + // This action finished + pTeam->StepCompleted = true; +} + void ScriptExt::VariablesHandler(TeamClass* pTeam, PhobosScripts eAction, int nArg) { struct operation_set { int operator()(const int& a, const int& b) { return b; } }; diff --git a/src/Ext/Script/Body.h b/src/Ext/Script/Body.h index 695fe9dc40..1d66464240 100644 --- a/src/Ext/Script/Body.h +++ b/src/Ext/Script/Body.h @@ -147,6 +147,7 @@ class ScriptExt static void Mission_Move_List1Random(TeamClass *pTeam, int calcThreatMode, bool pickAllies, int attackAITargetType, int idxAITargetTypeItem); static void SetCloseEnoughDistance(TeamClass *pTeam, double distance); static void SetMoveMissionEndMode(TeamClass* pTeam, int mode); + static void SkipNextAction(TeamClass* pTeam, int successPercentage); static void VariablesHandler(TeamClass* pTeam, PhobosScripts eAction, int nArg); template