MCPcopy Create free account
hub / github.com/MaxBittker/rs-sdk / init

Method init

server/engine/src/engine/script/ScriptRunner.ts:66–119  ·  view source on GitHub ↗

* * @param script * @param self * @param target * @param on * @param args

(script: ScriptFile, self: Entity | null = null, target: Entity | null = null, args: ScriptArgument[] | null = [])

Source from the content-addressed store, hash-verified

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) {

Callers 14

updateMovementMethod · 0.45
processTimersMethod · 0.45
processQueueMethod · 0.45
tryInteractMethod · 0.45
consumeHuntTargetMethod · 0.45
onLoginMethod · 0.45
processEngineQueueMethod · 0.45
closeTutorialMethod · 0.45
closeModalMethod · 0.45
processQueueMethod · 0.45
processWeakQueueMethod · 0.45
processTimersMethod · 0.45

Calls 1

pointerAddMethod · 0.95

Tested by

no test coverage detected