Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
44 changes: 43 additions & 1 deletion src/Ext/Script/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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; } };
Expand Down
1 change: 1 addition & 0 deletions src/Ext/Script/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool IsGlobal, class _Pr>
Expand Down