-
Notifications
You must be signed in to change notification settings - Fork 5
Create Custom Timed Action
Jason Stallings edited this page Dec 6, 2022
·
7 revisions
import { ISBaseTimedAction, ISLogSystem, IsoGridSquare, IsoPlayer, ISTimedActionQueue } from "@asledgehammer/pipewrench";
/**
* Test Action
* @param character The character that execute the action
* @param square Custom parameter for this timed action
* @returns Return the action
*/
export function TestAction(character: IsoPlayer, square: IsoGridSquare) {
const action = new ISBaseTimedAction(character);
action.Type = "TestAction";
action.maxTime = 120;
action.stopOnAim = true;
action.stopOnRun = true;
action.stopOnWalk = true;
// isValid
action.isValid = () => {
return square != null;
}
// start
action.start = () => {
}
// update
action.update = () => {
}
// stop
action.stop = () => {
print(`${action.Type} stopped`)
ISTimedActionQueue.getTimedActionQueue(character).resetQueue()
}
// perform
action.perform = () => {
print(`${action.Type} performed`)
ISTimedActionQueue.getTimedActionQueue(character).onCompleted(action)
ISLogSystem.logAction(action)
}
return action
}
import { getSpecificPlayer, InventoryItem, ISContextMenu, IsoGridSquare, IsoPlayer, ISTakePillAction, ISTimedActionQueue } from "@asledgehammer/pipewrench";
import { onFillWorldObjectContextMenu } from "@asledgehammer/pipewrench-events";
import { TestAction } from "./TimedActions/TestAction";
function doTestAction(player: IsoPlayer, square: IsoGridSquare) {
ISTimedActionQueue.add(TestAction(player, square));
}
onFillWorldObjectContextMenu.addListener((playerNum: number, context: ISContextMenu, worldObjects: any, test: boolean) => {
if (test) return;
const player = getSpecificPlayer(playerNum);
if (player.getVehicle()) return;
context.addOption("Do test action", player, doTestAction, player.getSquare());
});