Files
gunshiz 0d374b03ed
CI / verify (push) Successful in 43s
CI / build-and-deploy (push) Successful in 1m17s
feat : add fix delay helper and target
2026-09-13 15:34:42 +07:00

41 lines
1.3 KiB
TypeScript

export const ROTATION_DELAY_HELPER = `fn rand_delay(mean, stddev) {
let del = randnorm() * stddev + mean;
if del > (mean + mean) {
del = mean + mean;
}
delay(del);
}
let prev_char_id = -1;
let prev_action_id = -1;
let _execute_action = execute_action;
fn execute_action(char_id number, action_id number, p map) {
if prev_char_id != char_id && action_id != .action.swap {
execute_action(char_id, .action.swap, []);
}
if action_id == .action.swap {
rand_delay(12, 3);
} else if prev_action_id == .action.attack && action_id != .action.attack && action_id != .action.charge {
rand_delay(6, 3);
} else if prev_action_id != .action.attack {
rand_delay(6, 3);
}
prev_char_id = char_id;
prev_action_id = action_id;
return _execute_action(char_id, action_id, p);
}`;
export const ROTATION_ENVIRONMENT = `target lvl=100 resist=0.1 radius=2 pos=0,2.4 hp=999999999 freeze_resist=1;
energy every interval=480,720 amount=1;`;
// These names belong to the fixed generated helper, including when reimported.
export function isRotationDefaultStatement(statement: string): boolean {
return /^fn\s+(?:rand_delay|execute_action)\s*\(/.test(statement)
|| /^let\s+(?:prev_char_id|prev_action_id|_execute_action)\s*=/.test(statement)
|| /^(?:target|energy)\b/i.test(statement);
}