armoha / euddraft

System for pluginizing eudplib codes.
Other
29 stars 4 forks source link

Change representation of `TrgComparison`, `TrgModifier`, `TrgSwitchState`, `TrgSwitchAction`, `TrgPropState`, `TrgOrder` #120

Open armoha opened 9 months ago

armoha commented 9 months ago

Change

// TrgComparison
$AtLeast = 0  // (no change)
$AtMost = 0x10000
$Exactly = 0xA0000

// TrgSwitchState
$Set = ambiguous // (no change: Switch uses 2 and SetSwitch uses 4)
$Cleared = 0x30000

// TrgCount
$All = 0  // (no change)

// TrgPropState
$Enable = 0x4000000
$Disable = 0x5000000
$Toggle = 0x6000000

// TrgSwitchAction
$Set = ambiguous // (no change: Switch uses 2 and SetSwitch uses 4)
$Clear = 0x5000000
$Toggle = 0x6000000
$Random = 0xB000000

// TrgModifier
$SetTo = 0x7000000
$Add = 0x8000000
$Subtract = 0x9000000

// TrgOrder
$Move = 0  // (no change)
$Patrol = 0x1000000
$Attack = 0x2000000

Motivation

Currently, those parameters use different representation inside and outside of trigger:

SetDeaths(P1, Add, 1, "Terran Marine");
// Currently $Add = 8 while trigger requires 8 << 24 (converted in build time)

function foo(modifier: TrgModifier) {
    SetDeaths(P1, modifier, 1, "Terran Marine");
}
// Currently these calculate << 24 during game
foo(Add);
foo(8);
var m = $Add;
foo(m);
var n = 8;
foo(n);

To remove in-game conversion and assign directly into trigger, we need to unify and match value representation.

Affected condition parameters

u8 << 16: Numeric comparison, switch state u8 << 24: Condition byte

Affected action parameters

u8 << 16: Action byte u8 << 24: Number of units (0 means All Units), action state, unit order, number modifier

armoha commented 9 months ago

cc @dr-zzt