* * @param script * @param self * @param target * @param on * @param args
(script: ScriptFile, self: Entity | null = null, target: Entity | null = null, args: ScriptArgument[] | null = [])
| 64 | * @param args |
| 65 | */ |
| 66 | static init(script: ScriptFile, self: Entity | null = null, target: Entity | null = null, args: ScriptArgument[] | null = []) { |
| 67 | const state = new ScriptState(script, args); |
| 68 | state.self = self; |
| 69 | |
| 70 | if (self instanceof Player) { |
| 71 | state._activePlayer = self; |
| 72 | state.pointerAdd(ScriptPointer.ActivePlayer); |
| 73 | } else if (self instanceof Npc) { |
| 74 | state._activeNpc = self; |
| 75 | state.pointerAdd(ScriptPointer.ActiveNpc); |
| 76 | } else if (self instanceof Loc) { |
| 77 | state._activeLoc = self; |
| 78 | state.pointerAdd(ScriptPointer.ActiveLoc); |
| 79 | } else if (self instanceof Obj) { |
| 80 | state._activeObj = self; |
| 81 | state.pointerAdd(ScriptPointer.ActiveObj); |
| 82 | } |
| 83 | |
| 84 | if (target instanceof Player) { |
| 85 | if (self instanceof Player) { |
| 86 | state._activePlayer2 = target; |
| 87 | state.pointerAdd(ScriptPointer.ActivePlayer2); |
| 88 | } else { |
| 89 | state._activePlayer = target; |
| 90 | state.pointerAdd(ScriptPointer.ActivePlayer); |
| 91 | } |
| 92 | } else if (target instanceof Npc) { |
| 93 | if (self instanceof Npc) { |
| 94 | state._activeNpc2 = target; |
| 95 | state.pointerAdd(ScriptPointer.ActiveNpc2); |
| 96 | } else { |
| 97 | state._activeNpc = target; |
| 98 | state.pointerAdd(ScriptPointer.ActiveNpc); |
| 99 | } |
| 100 | } else if (target instanceof Loc) { |
| 101 | if (self instanceof Loc) { |
| 102 | state._activeLoc2 = target; |
| 103 | state.pointerAdd(ScriptPointer.ActiveLoc2); |
| 104 | } else { |
| 105 | state._activeLoc = target; |
| 106 | state.pointerAdd(ScriptPointer.ActiveLoc); |
| 107 | } |
| 108 | } else if (target instanceof Obj) { |
| 109 | if (self instanceof Obj) { |
| 110 | state._activeObj2 = target; |
| 111 | state.pointerAdd(ScriptPointer.ActiveObj2); |
| 112 | } else { |
| 113 | state._activeObj = target; |
| 114 | state.pointerAdd(ScriptPointer.ActiveObj); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return state; |
| 119 | } |
| 120 | |
| 121 | static execute(state: ScriptState) { |
| 122 | if (!state || !state.script || !state.script.info) { |
no test coverage detected