Skip to main content

runec/
pointer.rs

1use std::collections::HashMap;
2use std::fmt;
3
4/// The pointer types tracked by the script pointer checker.
5///
6/// Each variant maps to a bit position in [`PointerSet`] and has a display
7/// name matching the reference TypeScript implementation.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9#[repr(u8)]
10pub enum PointerType {
11    ActivePlayer = 0,
12    ActivePlayer2 = 1,
13    PActivePlayer = 2,
14    PActivePlayer2 = 3,
15    ActiveNpc = 4,
16    ActiveNpc2 = 5,
17    ActiveLoc = 6,
18    ActiveLoc2 = 7,
19    ActiveObj = 8,
20    ActiveObj2 = 9,
21    FindPlayer = 10,
22    FindNpc = 11,
23    FindLoc = 12,
24    FindObj = 13,
25    FindDb = 14,
26    LastCom = 15,
27    LastInt = 16,
28    LastItem = 17,
29    LastSlot = 18,
30    LastTargetslot = 19,
31    LastUseitem = 20,
32    LastUseslot = 21,
33    ActiveComponent = 22,
34    ActiveComponent2 = 23,
35}
36
37impl PointerType {
38    pub const COUNT: usize = 24;
39
40    pub const ALL: [PointerType; Self::COUNT] = [
41        PointerType::ActivePlayer,
42        PointerType::ActivePlayer2,
43        PointerType::PActivePlayer,
44        PointerType::PActivePlayer2,
45        PointerType::ActiveNpc,
46        PointerType::ActiveNpc2,
47        PointerType::ActiveLoc,
48        PointerType::ActiveLoc2,
49        PointerType::ActiveObj,
50        PointerType::ActiveObj2,
51        PointerType::FindPlayer,
52        PointerType::FindNpc,
53        PointerType::FindLoc,
54        PointerType::FindObj,
55        PointerType::FindDb,
56        PointerType::LastCom,
57        PointerType::LastInt,
58        PointerType::LastItem,
59        PointerType::LastSlot,
60        PointerType::LastTargetslot,
61        PointerType::LastUseitem,
62        PointerType::LastUseslot,
63        PointerType::ActiveComponent,
64        PointerType::ActiveComponent2,
65    ];
66
67    /// The representation string used in diagnostics, matching the TS reference.
68    pub fn representation(self) -> &'static str {
69        match self {
70            PointerType::ActivePlayer => "active_player",
71            PointerType::ActivePlayer2 => ".active_player",
72            PointerType::PActivePlayer => "p_active_player",
73            PointerType::PActivePlayer2 => ".p_active_player",
74            PointerType::ActiveNpc => "active_npc",
75            PointerType::ActiveNpc2 => ".active_npc",
76            PointerType::ActiveLoc => "active_loc",
77            PointerType::ActiveLoc2 => ".active_loc",
78            PointerType::ActiveObj => "active_obj",
79            PointerType::ActiveObj2 => ".active_obj",
80            PointerType::FindPlayer => "find_player",
81            PointerType::FindNpc => "find_npc",
82            PointerType::FindLoc => "find_loc",
83            PointerType::FindObj => "find_obj",
84            PointerType::FindDb => "find_db",
85            PointerType::LastCom => "last_com",
86            PointerType::LastInt => "last_int",
87            PointerType::LastItem => "last_item",
88            PointerType::LastSlot => "last_slot",
89            PointerType::LastTargetslot => "last_targetslot",
90            PointerType::LastUseitem => "last_useitem",
91            PointerType::LastUseslot => "last_useslot",
92            PointerType::ActiveComponent => "active_component",
93            PointerType::ActiveComponent2 => ".active_component",
94        }
95    }
96
97    pub fn index(self) -> usize {
98        self as usize
99    }
100
101    /// Look up a pointer type by its lowercase name (e.g. "active_player",
102    /// ".active_player", "p_active_player").
103    pub fn from_name(name: &str) -> Option<PointerType> {
104        let lower = name.to_lowercase();
105        Self::ALL
106            .iter()
107            .find(|&&ptr| ptr.representation() == lower)
108            .copied()
109    }
110}
111
112impl fmt::Display for PointerType {
113    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
114        f.write_str(self.representation())
115    }
116}
117
118// ---------------------------------------------------------------------------
119// PointerSet: bitmask for efficient pointer set operations
120// ---------------------------------------------------------------------------
121
122#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
123pub struct PointerSet(u32);
124
125impl PointerSet {
126    pub fn new() -> Self {
127        PointerSet(0)
128    }
129
130    /// A set containing every pointer type.
131    pub fn all() -> Self {
132        PointerSet((1u32 << PointerType::COUNT) - 1)
133    }
134
135    pub fn insert(&mut self, ptr: PointerType) {
136        self.0 |= 1u32 << ptr.index();
137    }
138
139    pub fn remove(&mut self, ptr: PointerType) {
140        self.0 &= !(1u32 << ptr.index());
141    }
142
143    pub fn contains(self, ptr: PointerType) -> bool {
144        (self.0 & (1u32 << ptr.index())) != 0
145    }
146
147    pub fn union(self, other: PointerSet) -> PointerSet {
148        PointerSet(self.0 | other.0)
149    }
150
151    pub fn is_empty(self) -> bool {
152        self.0 == 0
153    }
154
155    pub fn iter(self) -> PointerSetIter {
156        PointerSetIter { bits: self.0 }
157    }
158}
159
160pub struct PointerSetIter {
161    bits: u32,
162}
163
164impl Iterator for PointerSetIter {
165    type Item = PointerType;
166
167    fn next(&mut self) -> Option<Self::Item> {
168        if self.bits == 0 {
169            return None;
170        }
171        let idx = self.bits.trailing_zeros() as usize;
172        self.bits &= self.bits - 1; // clear lowest bit
173        if idx < PointerType::COUNT {
174            Some(PointerType::ALL[idx])
175        } else {
176            None
177        }
178    }
179}
180
181impl FromIterator<PointerType> for PointerSet {
182    fn from_iter<T: IntoIterator<Item = PointerType>>(iter: T) -> Self {
183        let mut set = PointerSet::new();
184        for ptr in iter {
185            set.insert(ptr);
186        }
187        set
188    }
189}
190
191// ---------------------------------------------------------------------------
192// PointerHolder — describes a command's pointer requirements
193// ---------------------------------------------------------------------------
194
195#[derive(Clone, Debug, Default)]
196pub struct PointerHolder {
197    pub required: PointerSet,
198    pub set: PointerSet,
199    pub conditional_set: bool,
200    pub corrupted: PointerSet,
201}
202
203// ---------------------------------------------------------------------------
204// trigger_pointers — which pointers a trigger type initializes
205// ---------------------------------------------------------------------------
206
207/// Returns the set of pointers that are initialized when a script with the
208/// given trigger type begins execution. Matches `ServerTriggerType.ts`.
209pub fn trigger_pointers(trigger: &str) -> PointerSet {
210    use PointerType::*;
211
212    let ptrs: &[PointerType] = match trigger {
213        // proc and label get ALL pointers (they inherit from caller)
214        "proc" | "label" => return PointerSet::all(),
215
216        // debugproc gets only active_player (console command context)
217        "debugproc" => &[ActivePlayer],
218
219        // Player-NPC approach/operate triggers
220        "apnpc1" | "apnpc2" | "apnpc3" | "apnpc4" | "apnpc5" => {
221            &[ActivePlayer, PActivePlayer, ActiveNpc]
222        }
223        "apnpcu" => &[
224            ActivePlayer,
225            PActivePlayer,
226            LastUseitem,
227            LastUseslot,
228            ActiveNpc,
229        ],
230        "apnpct" => &[ActivePlayer, PActivePlayer, ActiveNpc],
231        "opnpc1" | "opnpc2" | "opnpc3" | "opnpc4" | "opnpc5" => {
232            &[ActivePlayer, PActivePlayer, ActiveNpc]
233        }
234        "opnpcu" => &[
235            ActivePlayer,
236            PActivePlayer,
237            LastUseitem,
238            LastUseslot,
239            ActiveNpc,
240        ],
241        "opnpct" => &[ActivePlayer, PActivePlayer, ActiveNpc],
242
243        // AI NPC triggers (NPC vs NPC)
244        "ai_apnpc1" | "ai_apnpc2" | "ai_apnpc3" | "ai_apnpc4" | "ai_apnpc5" => {
245            &[ActiveNpc, ActiveNpc2]
246        }
247        "ai_opnpc1" | "ai_opnpc2" | "ai_opnpc3" | "ai_opnpc4" | "ai_opnpc5" => {
248            &[ActiveNpc, ActiveNpc2]
249        }
250
251        // Player-Obj approach/operate triggers
252        "apobj1" | "apobj2" | "apobj3" | "apobj4" | "apobj5" => {
253            &[ActivePlayer, PActivePlayer, ActiveObj]
254        }
255        "apobju" => &[
256            ActivePlayer,
257            PActivePlayer,
258            LastUseitem,
259            LastUseslot,
260            ActiveObj,
261        ],
262        "apobjt" => &[ActivePlayer, PActivePlayer, ActiveObj],
263        "opobj1" | "opobj2" | "opobj3" | "opobj4" | "opobj5" => {
264            &[ActivePlayer, PActivePlayer, ActiveObj]
265        }
266        "opobju" => &[
267            ActivePlayer,
268            PActivePlayer,
269            LastUseitem,
270            LastUseslot,
271            ActiveObj,
272        ],
273        "opobjt" => &[ActivePlayer, PActivePlayer, ActiveObj],
274
275        // AI Obj triggers (NPC vs obj)
276        "ai_apobj1" | "ai_apobj2" | "ai_apobj3" | "ai_apobj4" | "ai_apobj5" => {
277            &[ActiveNpc, ActiveObj]
278        }
279        "ai_opobj1" | "ai_opobj2" | "ai_opobj3" | "ai_opobj4" | "ai_opobj5" => {
280            &[ActiveNpc, ActiveObj]
281        }
282
283        // Player-Loc approach/operate triggers
284        "aploc1" | "aploc2" | "aploc3" | "aploc4" | "aploc5" => {
285            &[ActivePlayer, PActivePlayer, ActiveLoc]
286        }
287        "aplocu" => &[
288            ActivePlayer,
289            PActivePlayer,
290            LastUseitem,
291            LastUseslot,
292            ActiveLoc,
293        ],
294        "aploct" => &[ActivePlayer, PActivePlayer, ActiveLoc],
295        "oploc1" | "oploc2" | "oploc3" | "oploc4" | "oploc5" => {
296            &[ActivePlayer, PActivePlayer, ActiveLoc]
297        }
298        "oplocu" => &[
299            ActivePlayer,
300            PActivePlayer,
301            LastUseitem,
302            LastUseslot,
303            ActiveLoc,
304        ],
305        "oploct" => &[ActivePlayer, PActivePlayer, ActiveLoc],
306
307        // AI Loc triggers (NPC vs loc)
308        "ai_aploc1" | "ai_aploc2" | "ai_aploc3" | "ai_aploc4" | "ai_aploc5" => {
309            &[ActiveNpc, ActiveLoc]
310        }
311        "ai_oploc1" | "ai_oploc2" | "ai_oploc3" | "ai_oploc4" | "ai_oploc5" => {
312            &[ActiveNpc, ActiveLoc]
313        }
314
315        // Player-Player approach/operate triggers
316        "applayer1" | "applayer2" | "applayer3" | "applayer4" | "applayer5" => {
317            &[ActivePlayer, PActivePlayer, ActivePlayer2]
318        }
319        "applayeru" => &[
320            ActivePlayer,
321            PActivePlayer,
322            LastUseitem,
323            LastUseslot,
324            ActivePlayer2,
325        ],
326        "applayert" => &[ActivePlayer, PActivePlayer, ActivePlayer2],
327        "opplayer1" | "opplayer2" | "opplayer3" | "opplayer4" | "opplayer5" => {
328            &[ActivePlayer, PActivePlayer, ActivePlayer2]
329        }
330        "opplayeru" => &[
331            ActivePlayer,
332            PActivePlayer,
333            LastUseitem,
334            LastUseslot,
335            ActivePlayer2,
336        ],
337        "opplayert" => &[ActivePlayer, PActivePlayer, ActivePlayer2],
338
339        // AI Player triggers (NPC vs player)
340        "ai_applayer1" | "ai_applayer2" | "ai_applayer3" | "ai_applayer4" | "ai_applayer5" => {
341            &[ActiveNpc, ActivePlayer]
342        }
343        "ai_opplayer1" | "ai_opplayer2" | "ai_opplayer3" | "ai_opplayer4" | "ai_opplayer5" => {
344            &[ActiveNpc, ActivePlayer]
345        }
346
347        // Queue trigger
348        "queue" => &[ActivePlayer, PActivePlayer],
349
350        // AI queue triggers
351        "ai_queue1" | "ai_queue2" | "ai_queue3" | "ai_queue4" | "ai_queue5" | "ai_queue6"
352        | "ai_queue7" | "ai_queue8" | "ai_queue9" | "ai_queue10" | "ai_queue11" | "ai_queue12"
353        | "ai_queue13" | "ai_queue14" | "ai_queue15" | "ai_queue16" | "ai_queue17"
354        | "ai_queue18" | "ai_queue19" | "ai_queue20" => &[ActiveNpc, LastInt],
355
356        // Soft timer (player context only)
357        "softtimer" => &[ActivePlayer],
358
359        // Timer (player + protected)
360        "timer" => &[ActivePlayer, PActivePlayer],
361
362        // AI timer (NPC context)
363        "ai_timer" => &[ActiveNpc],
364
365        // Held item triggers
366        "opheld1" | "opheld2" | "opheld3" | "opheld4" | "opheld5" => {
367            &[ActivePlayer, PActivePlayer, LastItem, LastSlot]
368        }
369        "opheldu" => &[
370            ActivePlayer,
371            PActivePlayer,
372            LastItem,
373            LastSlot,
374            LastUseitem,
375            LastUseslot,
376        ],
377        "opheldt" => &[ActivePlayer, PActivePlayer, LastItem, LastSlot],
378
379        // Interface button trigger
380        "if_button" => &[ActivePlayer, LastCom],
381
382        // Interface close trigger
383        "if_close" => &[ActivePlayer],
384
385        // Inventory button triggers
386        "inv_button1" | "inv_button2" | "inv_button3" | "inv_button4" | "inv_button5" => {
387            &[ActivePlayer, LastItem, LastSlot]
388        }
389        // Also accept if_button1..5 aliases
390        "if_button1" | "if_button2" | "if_button3" | "if_button4" | "if_button5" => {
391            &[ActivePlayer, LastItem, LastSlot]
392        }
393        "inv_buttond" | "if_buttond" => &[ActivePlayer, LastSlot, LastTargetslot],
394        // Rev-647: inventory item ops 6-10. Only the if_button spelling extends
395        // to 6-10 (inv_button is the 225 family, capped at 5). Content uses these
396        // + the `p_opheld(op, inv, slot)` command.
397        "if_button6" | "if_button7" | "if_button8" | "if_button9" | "if_button10" => {
398            &[ActivePlayer, LastItem, LastSlot]
399        }
400
401        // Walk trigger
402        "walktrigger" => &[ActivePlayer, PActivePlayer],
403
404        // Global triggers
405        "login" | "logout" | "tutorial" | "switch_window_mode" => &[ActivePlayer, PActivePlayer],
406        "advancestat" | "changestat" => &[ActivePlayer, PActivePlayer],
407        "mapzone" | "mapzoneexit" | "zone" | "zoneexit" => &[ActivePlayer, PActivePlayer],
408        "area" | "areaexit" => &[ActivePlayer, PActivePlayer],
409
410        // AI lifecycle triggers
411        "ai_spawn" | "ai_despawn" => &[ActiveNpc],
412
413        // AI walktrigger
414        "ai_walktrigger" => &[ActiveNpc],
415
416        // Controller queue (its int in last_int) and timer
417        "ai_conqueue" => &[LastInt],
418        "ai_contimer" => &[],
419
420        // Unknown trigger — no pointers initialized
421        _ => return PointerSet::new(),
422    };
423
424    ptrs.iter().copied().collect()
425}
426
427// ---------------------------------------------------------------------------
428// command_pointers — pointer requirements for every engine command
429// ---------------------------------------------------------------------------
430
431/// Builds the full mapping from command name to its pointer requirements.
432///
433/// Both primary and secondary (`.` prefixed) variants are generated as
434/// separate entries. The keys use lowercase command names matching the
435/// SymbolRegistry command map.
436///
437/// Transcribed from `ScriptOpcodePointers.ts`.
438pub fn command_pointers() -> HashMap<String, PointerHolder> {
439    use PointerType::*;
440
441    let mut map = HashMap::new();
442
443    // Helper closures to reduce boilerplate
444    let mut add = |name: &str,
445                   require: &[PointerType],
446                   set: &[PointerType],
447                   corrupt: &[PointerType],
448                   require2: &[PointerType],
449                   set2: &[PointerType],
450                   corrupt2: &[PointerType],
451                   conditional: bool| {
452        // Primary entry
453        let holder = PointerHolder {
454            required: require.iter().copied().collect(),
455            set: set.iter().copied().collect(),
456            corrupted: corrupt.iter().copied().collect(),
457            conditional_set: conditional,
458        };
459        map.insert(name.to_lowercase(), holder);
460
461        // Secondary entry (dot-prefixed) if any require2/set2/corrupt2 are specified
462        if !require2.is_empty() || !set2.is_empty() || !corrupt2.is_empty() {
463            let holder2 = PointerHolder {
464                required: require2.iter().copied().collect(),
465                set: set2.iter().copied().collect(),
466                corrupted: corrupt2.iter().copied().collect(),
467                conditional_set: conditional,
468            };
469            map.insert(format!(".{}", name.to_lowercase()), holder2);
470        }
471    };
472
473    // The POINTER_GROUP_FIND shorthand
474    let find_group: &[PointerType] = &[FindPlayer, FindNpc, FindLoc, FindObj, FindDb];
475    // Corruption set for p_delay / p_arrivedelay style commands:
476    // everything except active is assumed corrupted
477    let delay_corrupt: Vec<PointerType> = {
478        let mut v: Vec<PointerType> = find_group.to_vec();
479        v.extend_from_slice(&[
480            LastCom,
481            LastInt,
482            LastItem,
483            LastSlot,
484            LastTargetslot,
485            LastUseitem,
486            LastUseslot,
487        ]);
488        v
489    };
490
491    // -----------------------------------------------------------------------
492    // Player ops
493    // -----------------------------------------------------------------------
494    add(
495        "allowdesign",
496        &[ActivePlayer],
497        &[],
498        &[],
499        &[],
500        &[],
501        &[],
502        false,
503    );
504    add(
505        "anim",
506        &[ActivePlayer],
507        &[],
508        &[],
509        &[ActivePlayer2],
510        &[],
511        &[],
512        false,
513    );
514    add("readyanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
515    add("runanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
516    add("turnanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
517    add(
518        "walkanim_b",
519        &[ActivePlayer],
520        &[],
521        &[],
522        &[],
523        &[],
524        &[],
525        false,
526    );
527    add("walkanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
528    add(
529        "walkanim_l",
530        &[ActivePlayer],
531        &[],
532        &[],
533        &[],
534        &[],
535        &[],
536        false,
537    );
538    add(
539        "walkanim_r",
540        &[ActivePlayer],
541        &[],
542        &[],
543        &[],
544        &[],
545        &[],
546        false,
547    );
548    add(
549        "buildappearance",
550        &[ActivePlayer],
551        &[],
552        &[],
553        &[],
554        &[],
555        &[],
556        false,
557    );
558    add(
559        "busy",
560        &[ActivePlayer],
561        &[],
562        &[],
563        &[ActivePlayer2],
564        &[],
565        &[],
566        false,
567    );
568    add(
569        "busy2",
570        &[ActivePlayer],
571        &[],
572        &[],
573        &[ActivePlayer2],
574        &[],
575        &[],
576        false,
577    );
578    add(
579        "cam_lookat",
580        &[ActivePlayer],
581        &[],
582        &[],
583        &[ActivePlayer2],
584        &[],
585        &[],
586        false,
587    );
588    add(
589        "cam_moveto",
590        &[ActivePlayer],
591        &[],
592        &[],
593        &[ActivePlayer2],
594        &[],
595        &[],
596        false,
597    );
598    add(
599        "cam_reset",
600        &[ActivePlayer],
601        &[],
602        &[],
603        &[ActivePlayer2],
604        &[],
605        &[],
606        false,
607    );
608    add(
609        "cam_shake",
610        &[ActivePlayer],
611        &[],
612        &[],
613        &[ActivePlayer2],
614        &[],
615        &[],
616        false,
617    );
618    add(
619        "clearqueue",
620        &[ActivePlayer],
621        &[],
622        &[],
623        &[],
624        &[],
625        &[],
626        false,
627    );
628    add(
629        "clearsofttimer",
630        &[ActivePlayer],
631        &[],
632        &[],
633        &[ActivePlayer2],
634        &[],
635        &[],
636        false,
637    );
638    add(
639        "cleartimer",
640        &[ActivePlayer],
641        &[],
642        &[],
643        &[ActivePlayer2],
644        &[],
645        &[],
646        false,
647    );
648    add(
649        "gettimer",
650        &[ActivePlayer],
651        &[],
652        &[],
653        &[ActivePlayer2],
654        &[],
655        &[],
656        false,
657    );
658    add(
659        "coord",
660        &[ActivePlayer],
661        &[],
662        &[],
663        &[ActivePlayer2],
664        &[],
665        &[],
666        false,
667    );
668    add(
669        "damage",
670        &[ActivePlayer],
671        &[],
672        &[],
673        &[ActivePlayer2],
674        &[],
675        &[],
676        false,
677    );
678    add(
679        "displayname",
680        &[ActivePlayer],
681        &[],
682        &[],
683        &[ActivePlayer2],
684        &[],
685        &[],
686        false,
687    );
688    add(
689        "facesquare",
690        &[ActivePlayer],
691        &[],
692        &[],
693        &[ActivePlayer2],
694        &[],
695        &[],
696        false,
697    );
698    add(
699        "finduid",
700        &[],
701        &[ActivePlayer],
702        &[PActivePlayer],
703        &[],
704        &[ActivePlayer2],
705        &[PActivePlayer2],
706        true,
707    );
708    add(
709        "gender",
710        &[ActivePlayer],
711        &[],
712        &[],
713        &[ActivePlayer2],
714        &[],
715        &[],
716        false,
717    );
718    add(
719        "getqueue",
720        &[ActivePlayer],
721        &[],
722        &[],
723        &[ActivePlayer2],
724        &[],
725        &[],
726        false,
727    );
728    add(
729        "stat_advance",
730        &[ActivePlayer],
731        &[],
732        &[],
733        &[],
734        &[],
735        &[],
736        false,
737    );
738    add(
739        "headicons_get",
740        &[ActivePlayer],
741        &[],
742        &[],
743        &[],
744        &[],
745        &[],
746        false,
747    );
748    add(
749        "headicons_set",
750        &[ActivePlayer],
751        &[],
752        &[],
753        &[],
754        &[],
755        &[],
756        false,
757    );
758    add(
759        "healenergy",
760        &[ActivePlayer],
761        &[],
762        &[],
763        &[],
764        &[],
765        &[],
766        false,
767    );
768    add(
769        "hint_coord",
770        &[ActivePlayer],
771        &[],
772        &[],
773        &[],
774        &[],
775        &[],
776        false,
777    );
778    add(
779        "hint_npc",
780        &[ActivePlayer, ActiveNpc],
781        &[],
782        &[],
783        &[],
784        &[],
785        &[],
786        false,
787    );
788    add(
789        "hint_pl",
790        &[ActivePlayer, ActivePlayer2],
791        &[],
792        &[],
793        &[],
794        &[],
795        &[],
796        false,
797    );
798    add("hint_stop", &[ActivePlayer], &[], &[], &[], &[], &[], false);
799    add("huntall", &[], &[FindPlayer], &[], &[], &[], &[], false);
800    add(
801        "huntnext",
802        &[FindPlayer],
803        &[ActivePlayer],
804        &[],
805        &[FindPlayer],
806        &[ActivePlayer2],
807        &[],
808        true,
809    );
810    add(
811        "npc_hunt",
812        &[],
813        &[ActiveNpc],
814        &[],
815        &[],
816        &[ActiveNpc2],
817        &[],
818        false,
819    );
820    add("npc_huntall", &[], &[FindNpc], &[], &[], &[], &[], false);
821    add(
822        "npc_hasop",
823        &[ActiveNpc],
824        &[],
825        &[],
826        &[ActiveNpc2],
827        &[],
828        &[],
829        false,
830    );
831    add(
832        "if_close",
833        &[ActivePlayer],
834        &[],
835        &[],
836        &[ActivePlayer2],
837        &[],
838        &[],
839        false,
840    );
841    add("tut_close", &[ActivePlayer], &[], &[], &[], &[], &[], false);
842    add(
843        "if_openchat",
844        &[ActivePlayer],
845        &[],
846        &[],
847        &[],
848        &[],
849        &[],
850        false,
851    );
852    add("tut_open", &[ActivePlayer], &[], &[], &[], &[], &[], false);
853    // 2004scape (rev 225) names this command `if_openmain`. Rev 647 renamed it
854    // to `if_opentop` (since `if_openmain` is reserved for opening a modal in
855    // the main viewport). Both names get the same pointer rules so the compiler
856    // accepts content from either revision.
857    add(
858        "if_openmain",
859        &[ActivePlayer],
860        &[],
861        &[],
862        &[ActivePlayer2],
863        &[],
864        &[],
865        false,
866    );
867    add(
868        "if_opentop",
869        &[ActivePlayer],
870        &[],
871        &[],
872        &[ActivePlayer2],
873        &[],
874        &[],
875        false,
876    );
877    add(
878        "if_openmain_side",
879        &[ActivePlayer],
880        &[],
881        &[],
882        &[ActivePlayer2],
883        &[],
884        &[],
885        false,
886    );
887    add(
888        "if_openoverlay",
889        &[ActivePlayer],
890        &[],
891        &[],
892        &[ActivePlayer2],
893        &[],
894        &[],
895        false,
896    );
897    add(
898        "if_openside",
899        &[ActivePlayer],
900        &[],
901        &[],
902        &[],
903        &[],
904        &[],
905        false,
906    );
907    add(
908        "if_setanim",
909        &[ActivePlayer],
910        &[],
911        &[],
912        &[],
913        &[],
914        &[],
915        false,
916    );
917    add(
918        "if_setcolour",
919        &[ActivePlayer],
920        &[],
921        &[],
922        &[],
923        &[],
924        &[],
925        false,
926    );
927    add(
928        "if_sethide",
929        &[ActivePlayer],
930        &[],
931        &[],
932        &[ActivePlayer2],
933        &[],
934        &[],
935        false,
936    );
937    add(
938        "if_setmodel",
939        &[ActivePlayer],
940        &[],
941        &[],
942        &[],
943        &[],
944        &[],
945        false,
946    );
947    add(
948        "if_setnpchead",
949        &[ActivePlayer],
950        &[],
951        &[],
952        &[],
953        &[],
954        &[],
955        false,
956    );
957    add(
958        "if_setobject",
959        &[ActivePlayer],
960        &[],
961        &[],
962        &[],
963        &[],
964        &[],
965        false,
966    );
967    add(
968        "if_setplayerhead",
969        &[ActivePlayer],
970        &[],
971        &[],
972        &[],
973        &[],
974        &[],
975        false,
976    );
977    add(
978        "if_setposition",
979        &[ActivePlayer],
980        &[],
981        &[],
982        &[],
983        &[],
984        &[],
985        false,
986    );
987    add(
988        "if_addresumebutton",
989        &[ActivePlayer],
990        &[],
991        &[],
992        &[],
993        &[],
994        &[],
995        false,
996    );
997    add("if_settab", &[ActivePlayer], &[], &[], &[], &[], &[], false);
998    add(
999        "if_settabactive",
1000        &[ActivePlayer],
1001        &[],
1002        &[],
1003        &[ActivePlayer2],
1004        &[],
1005        &[],
1006        false,
1007    );
1008    add("tut_flash", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1009    add(
1010        "if_settext",
1011        &[ActivePlayer],
1012        &[],
1013        &[],
1014        &[ActivePlayer2],
1015        &[],
1016        &[],
1017        false,
1018    );
1019    add(
1020        "last_login_info",
1021        &[ActivePlayer],
1022        &[],
1023        &[],
1024        &[],
1025        &[],
1026        &[],
1027        false,
1028    );
1029    add("last_com", &[LastCom], &[], &[], &[], &[], &[], false);
1030    add("last_int", &[LastInt], &[], &[], &[], &[], &[], false);
1031    add("last_item", &[LastItem], &[], &[], &[], &[], &[], false);
1032    add("last_slot", &[LastSlot], &[], &[], &[], &[], &[], false);
1033    add(
1034        "last_targetslot",
1035        &[LastTargetslot],
1036        &[],
1037        &[],
1038        &[],
1039        &[],
1040        &[],
1041        false,
1042    );
1043    add(
1044        "last_useitem",
1045        &[LastUseitem],
1046        &[],
1047        &[],
1048        &[],
1049        &[],
1050        &[],
1051        false,
1052    );
1053    add(
1054        "last_useslot",
1055        &[LastUseslot],
1056        &[],
1057        &[],
1058        &[],
1059        &[],
1060        &[],
1061        false,
1062    );
1063    add(
1064        "longqueue",
1065        &[ActivePlayer],
1066        &[],
1067        &[],
1068        &[ActivePlayer2],
1069        &[],
1070        &[],
1071        false,
1072    );
1073    add(
1074        "longqueue*",
1075        &[ActivePlayer],
1076        &[],
1077        &[],
1078        &[ActivePlayer2],
1079        &[],
1080        &[],
1081        false,
1082    );
1083    add("lowmem", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1084    add(
1085        "mes",
1086        &[ActivePlayer],
1087        &[],
1088        &[],
1089        &[ActivePlayer2],
1090        &[],
1091        &[],
1092        false,
1093    );
1094    add(
1095        "midi_jingle",
1096        &[ActivePlayer],
1097        &[],
1098        &[],
1099        &[],
1100        &[],
1101        &[],
1102        false,
1103    );
1104    add("midi_song", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1105    add(
1106        "minimap_toggle",
1107        &[ActivePlayer],
1108        &[],
1109        &[],
1110        &[ActivePlayer2],
1111        &[],
1112        &[],
1113        false,
1114    );
1115    add(
1116        "name",
1117        &[ActivePlayer],
1118        &[],
1119        &[],
1120        &[ActivePlayer2],
1121        &[],
1122        &[],
1123        false,
1124    );
1125    add(
1126        "p_aprange",
1127        &[PActivePlayer],
1128        &[],
1129        &[],
1130        &[],
1131        &[],
1132        &[],
1133        false,
1134    );
1135    add(
1136        "p_arrivedelay",
1137        &[PActivePlayer],
1138        &[],
1139        &delay_corrupt,
1140        &[],
1141        &[],
1142        &[],
1143        false,
1144    );
1145    {
1146        // p_countdialog: sets last_int, corrupts everything except active + last_int
1147        let mut corrupt = delay_corrupt.clone();
1148        corrupt.retain(|p| *p != LastInt);
1149        add(
1150            "p_countdialog",
1151            &[PActivePlayer],
1152            &[LastInt],
1153            &corrupt,
1154            &[],
1155            &[],
1156            &[],
1157            false,
1158        );
1159    }
1160    add(
1161        "p_delay",
1162        &[PActivePlayer],
1163        &[],
1164        &delay_corrupt,
1165        &[],
1166        &[],
1167        &[],
1168        false,
1169    );
1170    add(
1171        "p_exactmove",
1172        &[PActivePlayer],
1173        &[],
1174        &[],
1175        &[],
1176        &[],
1177        &[],
1178        false,
1179    );
1180    for name in [
1181        "p_namedialog",
1182        "p_stringdialog",
1183        "p_setdisplayname",
1184        "p_get_suggestion",
1185        "p_next_suggestions",
1186        "p_prev_suggestions",
1187        "p_request_more_suggestions",
1188        "p_rest",
1189        "p_temprun",
1190    ] {
1191        add(name, &[PActivePlayer], &[], &[], &[], &[], &[], false);
1192    }
1193    add(
1194        "p_finduid",
1195        &[],
1196        &[PActivePlayer, ActivePlayer],
1197        &[],
1198        &[],
1199        &[PActivePlayer2, ActivePlayer2],
1200        &[],
1201        true,
1202    );
1203    add(
1204        "p_locmerge",
1205        &[PActivePlayer],
1206        &[],
1207        &[],
1208        &[],
1209        &[],
1210        &[],
1211        false,
1212    );
1213    add("p_logout", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1214    add(
1215        "p_preventlogout",
1216        &[PActivePlayer],
1217        &[],
1218        &[],
1219        &[PActivePlayer2],
1220        &[],
1221        &[],
1222        false,
1223    );
1224    add("p_opheld", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1225    add(
1226        "p_oploc",
1227        &[PActivePlayer, ActiveLoc],
1228        &[],
1229        &[],
1230        &[],
1231        &[],
1232        &[],
1233        false,
1234    );
1235    add(
1236        "p_opnpc",
1237        &[PActivePlayer, ActiveNpc],
1238        &[],
1239        &[],
1240        &[],
1241        &[],
1242        &[],
1243        false,
1244    );
1245    add(
1246        "p_opnpct",
1247        &[PActivePlayer, ActiveNpc],
1248        &[],
1249        &[],
1250        &[],
1251        &[],
1252        &[],
1253        false,
1254    );
1255    add(
1256        "p_opobj",
1257        &[PActivePlayer, ActiveObj],
1258        &[],
1259        &[],
1260        &[],
1261        &[],
1262        &[],
1263        false,
1264    );
1265    add(
1266        "p_opplayer",
1267        &[PActivePlayer, ActivePlayer2],
1268        &[],
1269        &[],
1270        &[PActivePlayer2, ActivePlayer],
1271        &[],
1272        &[],
1273        false,
1274    );
1275    add(
1276        "p_opplayert",
1277        &[PActivePlayer, ActivePlayer2],
1278        &[],
1279        &[],
1280        &[PActivePlayer2, ActivePlayer],
1281        &[],
1282        &[],
1283        false,
1284    );
1285    {
1286        // p_pausebutton: sets last_com, corrupts everything except active + last_com
1287        let mut corrupt = delay_corrupt.clone();
1288        corrupt.retain(|p| *p != LastCom);
1289        add(
1290            "p_pausebutton",
1291            &[PActivePlayer],
1292            &[LastCom],
1293            &corrupt,
1294            &[],
1295            &[],
1296            &[],
1297            false,
1298        );
1299    }
1300    add(
1301        "p_stopaction",
1302        &[PActivePlayer],
1303        &[],
1304        &[],
1305        &[PActivePlayer2],
1306        &[],
1307        &[],
1308        false,
1309    );
1310    add(
1311        "p_clearpendingaction",
1312        &[PActivePlayer],
1313        &[],
1314        &[],
1315        &[PActivePlayer2],
1316        &[],
1317        &[],
1318        false,
1319    );
1320    add(
1321        "p_telejump",
1322        &[PActivePlayer],
1323        &[],
1324        &[],
1325        &[PActivePlayer2],
1326        &[],
1327        &[],
1328        false,
1329    );
1330    add(
1331        "p_teleport",
1332        &[PActivePlayer],
1333        &[],
1334        &[],
1335        &[PActivePlayer2],
1336        &[],
1337        &[],
1338        false,
1339    );
1340    add(
1341        "p_walk",
1342        &[PActivePlayer],
1343        &[],
1344        &[],
1345        &[PActivePlayer2],
1346        &[],
1347        &[],
1348        false,
1349    );
1350    add(
1351        "projanim_pl",
1352        &[ActivePlayer],
1353        &[],
1354        &[],
1355        &[ActivePlayer2],
1356        &[],
1357        &[],
1358        false,
1359    );
1360    add(
1361        "queue",
1362        &[ActivePlayer],
1363        &[],
1364        &[],
1365        &[ActivePlayer2],
1366        &[],
1367        &[],
1368        false,
1369    );
1370    add(
1371        "queue*",
1372        &[ActivePlayer],
1373        &[],
1374        &[],
1375        &[ActivePlayer2],
1376        &[],
1377        &[],
1378        false,
1379    );
1380    add(
1381        "say",
1382        &[ActivePlayer],
1383        &[],
1384        &[],
1385        &[ActivePlayer2],
1386        &[],
1387        &[],
1388        false,
1389    );
1390    add("setidkit", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1391    add(
1392        "walktrigger",
1393        &[ActivePlayer],
1394        &[],
1395        &[],
1396        &[ActivePlayer2],
1397        &[],
1398        &[],
1399        false,
1400    );
1401    add(
1402        "getwalktrigger",
1403        &[ActivePlayer],
1404        &[],
1405        &[],
1406        &[ActivePlayer2],
1407        &[],
1408        &[],
1409        false,
1410    );
1411    add(
1412        "settimer",
1413        &[ActivePlayer],
1414        &[],
1415        &[],
1416        &[ActivePlayer2],
1417        &[],
1418        &[],
1419        false,
1420    );
1421    add(
1422        "softtimer",
1423        &[ActivePlayer],
1424        &[],
1425        &[],
1426        &[ActivePlayer2],
1427        &[],
1428        &[],
1429        false,
1430    );
1431    add(
1432        "sound_synth",
1433        &[ActivePlayer],
1434        &[],
1435        &[],
1436        &[ActivePlayer2],
1437        &[],
1438        &[],
1439        false,
1440    );
1441    add(
1442        "spotanim_pl",
1443        &[ActivePlayer],
1444        &[],
1445        &[],
1446        &[ActivePlayer2],
1447        &[],
1448        &[],
1449        false,
1450    );
1451    add(
1452        "staffmodlevel",
1453        &[ActivePlayer],
1454        &[],
1455        &[],
1456        &[ActivePlayer2],
1457        &[],
1458        &[],
1459        false,
1460    );
1461    add(
1462        "stat",
1463        &[ActivePlayer],
1464        &[],
1465        &[],
1466        &[ActivePlayer2],
1467        &[],
1468        &[],
1469        false,
1470    );
1471    add(
1472        "stat_add",
1473        &[ActivePlayer],
1474        &[],
1475        &[],
1476        &[ActivePlayer2],
1477        &[],
1478        &[],
1479        false,
1480    );
1481    add(
1482        "stat_base",
1483        &[ActivePlayer],
1484        &[],
1485        &[],
1486        &[ActivePlayer2],
1487        &[],
1488        &[],
1489        false,
1490    );
1491    add(
1492        "stat_heal",
1493        &[ActivePlayer],
1494        &[],
1495        &[],
1496        &[ActivePlayer2],
1497        &[],
1498        &[],
1499        false,
1500    );
1501    add(
1502        "stat_sub",
1503        &[ActivePlayer],
1504        &[],
1505        &[],
1506        &[ActivePlayer2],
1507        &[],
1508        &[],
1509        false,
1510    );
1511    add(
1512        "stat_boost",
1513        &[ActivePlayer],
1514        &[],
1515        &[],
1516        &[ActivePlayer2],
1517        &[],
1518        &[],
1519        false,
1520    );
1521    add(
1522        "stat_drain",
1523        &[ActivePlayer],
1524        &[],
1525        &[],
1526        &[ActivePlayer2],
1527        &[],
1528        &[],
1529        false,
1530    );
1531    add(
1532        "stat_random",
1533        &[ActivePlayer],
1534        &[],
1535        &[],
1536        &[ActivePlayer2],
1537        &[],
1538        &[],
1539        false,
1540    );
1541    add(
1542        "uid",
1543        &[ActivePlayer],
1544        &[],
1545        &[],
1546        &[ActivePlayer2],
1547        &[],
1548        &[],
1549        false,
1550    );
1551    add(
1552        "weakqueue",
1553        &[ActivePlayer],
1554        &[],
1555        &[],
1556        &[ActivePlayer2],
1557        &[],
1558        &[],
1559        false,
1560    );
1561    add(
1562        "weakqueue*",
1563        &[ActivePlayer],
1564        &[],
1565        &[],
1566        &[ActivePlayer2],
1567        &[],
1568        &[],
1569        false,
1570    );
1571    add(
1572        "findhero",
1573        &[],
1574        &[ActivePlayer2],
1575        &[],
1576        &[],
1577        &[ActivePlayer],
1578        &[],
1579        true,
1580    );
1581    add(
1582        "both_heropoints",
1583        &[ActivePlayer, ActivePlayer2],
1584        &[],
1585        &[],
1586        &[ActivePlayer2, ActivePlayer],
1587        &[],
1588        &[],
1589        false,
1590    );
1591    add(
1592        "setgender",
1593        &[PActivePlayer],
1594        &[],
1595        &[],
1596        &[],
1597        &[],
1598        &[],
1599        false,
1600    );
1601    add(
1602        "setidkcolour",
1603        &[PActivePlayer],
1604        &[],
1605        &[],
1606        &[],
1607        &[],
1608        &[],
1609        false,
1610    );
1611    add(
1612        "p_animprotect",
1613        &[PActivePlayer],
1614        &[],
1615        &[],
1616        &[PActivePlayer2],
1617        &[],
1618        &[],
1619        false,
1620    );
1621    add(
1622        "runenergy",
1623        &[ActivePlayer],
1624        &[],
1625        &[],
1626        &[ActivePlayer2],
1627        &[],
1628        &[],
1629        false,
1630    );
1631    add(
1632        "weight",
1633        &[PActivePlayer],
1634        &[],
1635        &[],
1636        &[PActivePlayer2],
1637        &[],
1638        &[],
1639        false,
1640    );
1641    add(
1642        "p_run",
1643        &[PActivePlayer],
1644        &[],
1645        &[],
1646        &[PActivePlayer2],
1647        &[],
1648        &[],
1649        false,
1650    );
1651    add(
1652        "if_setscrollpos",
1653        &[ActivePlayer],
1654        &[],
1655        &[],
1656        &[],
1657        &[],
1658        &[],
1659        false,
1660    );
1661    add(
1662        "if_movesub",
1663        &[ActivePlayer],
1664        &[],
1665        &[],
1666        &[],
1667        &[],
1668        &[],
1669        false,
1670    );
1671    add(
1672        "set_player_op",
1673        &[ActivePlayer],
1674        &[],
1675        &[],
1676        &[],
1677        &[],
1678        &[],
1679        false,
1680    );
1681    add(
1682        "set_skill_level",
1683        &[ActivePlayer],
1684        &[],
1685        &[],
1686        &[ActivePlayer2],
1687        &[],
1688        &[],
1689        false,
1690    );
1691    add(
1692        "strongqueue",
1693        &[ActivePlayer],
1694        &[],
1695        &[],
1696        &[ActivePlayer2],
1697        &[],
1698        &[],
1699        false,
1700    );
1701    add(
1702        "strongqueue*",
1703        &[ActivePlayer],
1704        &[],
1705        &[],
1706        &[ActivePlayer2],
1707        &[],
1708        &[],
1709        false,
1710    );
1711
1712    // -----------------------------------------------------------------------
1713    // NPC ops
1714    // -----------------------------------------------------------------------
1715    add(
1716        "npc_add",
1717        &[],
1718        &[ActiveNpc],
1719        &[],
1720        &[],
1721        &[ActiveNpc2],
1722        &[],
1723        false,
1724    );
1725    add(
1726        "npc_anim",
1727        &[ActiveNpc],
1728        &[],
1729        &[],
1730        &[ActiveNpc2],
1731        &[],
1732        &[],
1733        false,
1734    );
1735    add(
1736        "npc_basestat",
1737        &[ActiveNpc],
1738        &[],
1739        &[],
1740        &[ActiveNpc2],
1741        &[],
1742        &[],
1743        false,
1744    );
1745    add(
1746        "npc_category",
1747        &[ActiveNpc],
1748        &[],
1749        &[],
1750        &[ActiveNpc2],
1751        &[],
1752        &[],
1753        false,
1754    );
1755    add(
1756        "npc_changetype",
1757        &[ActiveNpc],
1758        &[],
1759        &[],
1760        &[ActiveNpc2],
1761        &[],
1762        &[],
1763        false,
1764    );
1765    add(
1766        "npc_changetype_keepall",
1767        &[ActiveNpc],
1768        &[],
1769        &[],
1770        &[ActiveNpc2],
1771        &[],
1772        &[],
1773        false,
1774    );
1775    add(
1776        "npc_coord",
1777        &[ActiveNpc],
1778        &[],
1779        &[],
1780        &[ActiveNpc2],
1781        &[],
1782        &[],
1783        false,
1784    );
1785    add(
1786        "npc_damage",
1787        &[ActiveNpc],
1788        &[],
1789        &[],
1790        &[ActiveNpc2],
1791        &[],
1792        &[],
1793        false,
1794    );
1795    add(
1796        "npc_del",
1797        &[ActiveNpc],
1798        &[],
1799        &[],
1800        &[ActiveNpc2],
1801        &[],
1802        &[],
1803        false,
1804    );
1805    {
1806        // npc_delay: corrupts p_active_player, p_active_player2, find_*, last_*
1807        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
1808        corrupt.extend_from_slice(find_group);
1809        corrupt.extend_from_slice(&[
1810            LastCom,
1811            LastInt,
1812            LastItem,
1813            LastSlot,
1814            LastTargetslot,
1815            LastUseitem,
1816            LastUseslot,
1817        ]);
1818        add(
1819            "npc_delay",
1820            &[ActiveNpc],
1821            &[],
1822            &corrupt,
1823            &[ActiveNpc2],
1824            &[],
1825            &[],
1826            false,
1827        );
1828    }
1829    add(
1830        "npc_facesquare",
1831        &[ActiveNpc],
1832        &[],
1833        &[],
1834        &[ActiveNpc2],
1835        &[],
1836        &[],
1837        false,
1838    );
1839    add(
1840        "npc_find",
1841        &[],
1842        &[ActiveNpc],
1843        &[],
1844        &[],
1845        &[ActiveNpc2],
1846        &[],
1847        true,
1848    );
1849    add(
1850        "npc_findcat",
1851        &[],
1852        &[ActiveNpc],
1853        &[],
1854        &[],
1855        &[ActiveNpc2],
1856        &[],
1857        true,
1858    );
1859    add("npc_findallany", &[], &[FindNpc], &[], &[], &[], &[], false);
1860    add("npc_findall", &[], &[FindNpc], &[], &[], &[], &[], false);
1861    add(
1862        "npc_findallzone",
1863        &[],
1864        &[FindNpc],
1865        &[],
1866        &[],
1867        &[],
1868        &[],
1869        false,
1870    );
1871    add(
1872        "npc_findnext",
1873        &[FindNpc],
1874        &[ActiveNpc],
1875        &[],
1876        &[],
1877        &[ActiveNpc2],
1878        &[],
1879        true,
1880    );
1881    add(
1882        "npc_findexact",
1883        &[],
1884        &[ActiveNpc],
1885        &[],
1886        &[],
1887        &[ActiveNpc2],
1888        &[],
1889        true,
1890    );
1891    add(
1892        "npc_findhero",
1893        &[ActiveNpc],
1894        &[ActivePlayer],
1895        &[],
1896        &[ActiveNpc2],
1897        &[ActivePlayer2],
1898        &[],
1899        true,
1900    );
1901    add(
1902        "npc_finduid",
1903        &[],
1904        &[ActiveNpc],
1905        &[],
1906        &[],
1907        &[ActiveNpc2],
1908        &[],
1909        true,
1910    );
1911    add(
1912        "npc_getmode",
1913        &[ActiveNpc],
1914        &[],
1915        &[],
1916        &[ActiveNpc2],
1917        &[],
1918        &[],
1919        false,
1920    );
1921    add(
1922        "npc_heropoints",
1923        &[ActiveNpc, ActivePlayer],
1924        &[],
1925        &[],
1926        &[],
1927        &[],
1928        &[],
1929        false,
1930    );
1931    add(
1932        "npc_name",
1933        &[ActiveNpc],
1934        &[],
1935        &[],
1936        &[ActiveNpc2],
1937        &[],
1938        &[],
1939        false,
1940    );
1941    add(
1942        "npc_param",
1943        &[ActiveNpc],
1944        &[],
1945        &[],
1946        &[ActiveNpc2],
1947        &[],
1948        &[],
1949        false,
1950    );
1951    add(
1952        "npc_queue",
1953        &[ActiveNpc],
1954        &[],
1955        &[],
1956        &[ActiveNpc2],
1957        &[],
1958        &[],
1959        false,
1960    );
1961    add(
1962        "npc_range",
1963        &[ActiveNpc],
1964        &[],
1965        &[],
1966        &[ActiveNpc2],
1967        &[],
1968        &[],
1969        false,
1970    );
1971    add(
1972        "npc_say",
1973        &[ActiveNpc],
1974        &[],
1975        &[],
1976        &[ActiveNpc2],
1977        &[],
1978        &[],
1979        false,
1980    );
1981    add(
1982        "npc_sethunt",
1983        &[ActiveNpc],
1984        &[],
1985        &[],
1986        &[ActiveNpc2],
1987        &[],
1988        &[],
1989        false,
1990    );
1991    add(
1992        "npc_sethuntmode",
1993        &[ActiveNpc],
1994        &[],
1995        &[],
1996        &[ActiveNpc2],
1997        &[],
1998        &[],
1999        false,
2000    );
2001    add(
2002        "npc_setmode",
2003        &[ActiveNpc],
2004        &[],
2005        &[],
2006        &[ActiveNpc2],
2007        &[],
2008        &[],
2009        false,
2010    );
2011    add(
2012        "npc_walktrigger",
2013        &[ActiveNpc],
2014        &[],
2015        &[],
2016        &[ActiveNpc2],
2017        &[],
2018        &[],
2019        false,
2020    );
2021    add(
2022        "npc_settimer",
2023        &[ActiveNpc],
2024        &[],
2025        &[],
2026        &[ActiveNpc2],
2027        &[],
2028        &[],
2029        false,
2030    );
2031    add(
2032        "npc_stat",
2033        &[ActiveNpc],
2034        &[],
2035        &[],
2036        &[ActiveNpc2],
2037        &[],
2038        &[],
2039        false,
2040    );
2041    add(
2042        "npc_statadd",
2043        &[ActiveNpc],
2044        &[],
2045        &[],
2046        &[ActiveNpc2],
2047        &[],
2048        &[],
2049        false,
2050    );
2051    add(
2052        "npc_statheal",
2053        &[ActiveNpc],
2054        &[],
2055        &[],
2056        &[ActiveNpc2],
2057        &[],
2058        &[],
2059        false,
2060    );
2061    add(
2062        "npc_statsub",
2063        &[ActiveNpc],
2064        &[],
2065        &[],
2066        &[ActiveNpc2],
2067        &[],
2068        &[],
2069        false,
2070    );
2071    add(
2072        "npc_tele",
2073        &[ActiveNpc],
2074        &[],
2075        &[],
2076        &[ActiveNpc2],
2077        &[],
2078        &[],
2079        false,
2080    );
2081    add(
2082        "npc_type",
2083        &[ActiveNpc],
2084        &[],
2085        &[],
2086        &[ActiveNpc2],
2087        &[],
2088        &[],
2089        false,
2090    );
2091    add(
2092        "npc_uid",
2093        &[ActiveNpc],
2094        &[],
2095        &[],
2096        &[ActiveNpc2],
2097        &[],
2098        &[],
2099        false,
2100    );
2101    add(
2102        "projanim_npc",
2103        &[ActiveNpc],
2104        &[],
2105        &[],
2106        &[ActiveNpc2],
2107        &[],
2108        &[],
2109        false,
2110    );
2111    add(
2112        "spotanim_npc",
2113        &[ActiveNpc],
2114        &[],
2115        &[],
2116        &[ActiveNpc2],
2117        &[],
2118        &[],
2119        false,
2120    );
2121    add(
2122        "npc_walk",
2123        &[ActiveNpc],
2124        &[],
2125        &[],
2126        &[ActiveNpc2],
2127        &[],
2128        &[],
2129        false,
2130    );
2131    add(
2132        "npc_attackrange",
2133        &[ActiveNpc],
2134        &[],
2135        &[],
2136        &[ActiveNpc2],
2137        &[],
2138        &[],
2139        false,
2140    );
2141    {
2142        // npc_arrivedelay: same corruption set as npc_delay
2143        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
2144        corrupt.extend_from_slice(find_group);
2145        corrupt.extend_from_slice(&[
2146            LastCom,
2147            LastInt,
2148            LastItem,
2149            LastSlot,
2150            LastTargetslot,
2151            LastUseitem,
2152            LastUseslot,
2153        ]);
2154        add(
2155            "npc_arrivedelay",
2156            &[ActiveNpc],
2157            &[],
2158            &corrupt,
2159            &[ActiveNpc2],
2160            &[],
2161            &[],
2162            false,
2163        );
2164    }
2165    add(
2166        "npc_inrange",
2167        &[ActiveNpc],
2168        &[],
2169        &[],
2170        &[ActiveNpc2],
2171        &[],
2172        &[],
2173        false,
2174    );
2175
2176    // -----------------------------------------------------------------------
2177    // Loc ops
2178    // -----------------------------------------------------------------------
2179    add(
2180        "loc_add",
2181        &[],
2182        &[ActiveLoc],
2183        &[],
2184        &[],
2185        &[ActiveLoc2],
2186        &[],
2187        false,
2188    );
2189    add(
2190        "loc_angle",
2191        &[ActiveLoc],
2192        &[],
2193        &[],
2194        &[ActiveLoc2],
2195        &[],
2196        &[],
2197        false,
2198    );
2199    add(
2200        "loc_anim",
2201        &[ActiveLoc],
2202        &[],
2203        &[],
2204        &[ActiveLoc2],
2205        &[],
2206        &[],
2207        false,
2208    );
2209    add(
2210        "loc_category",
2211        &[ActiveLoc],
2212        &[],
2213        &[],
2214        &[ActiveLoc2],
2215        &[],
2216        &[],
2217        false,
2218    );
2219    add(
2220        "loc_change",
2221        &[ActiveLoc],
2222        &[],
2223        &[],
2224        &[ActiveLoc2],
2225        &[],
2226        &[],
2227        false,
2228    );
2229    add(
2230        "loc_coord",
2231        &[ActiveLoc],
2232        &[],
2233        &[],
2234        &[ActiveLoc2],
2235        &[],
2236        &[],
2237        false,
2238    );
2239    add(
2240        "loc_del",
2241        &[ActiveLoc],
2242        &[],
2243        &[],
2244        &[ActiveLoc2],
2245        &[],
2246        &[],
2247        false,
2248    );
2249    add(
2250        "loc_find",
2251        &[],
2252        &[ActiveLoc],
2253        &[],
2254        &[],
2255        &[ActiveLoc2],
2256        &[],
2257        true,
2258    );
2259    add(
2260        "loc_findallzone",
2261        &[],
2262        &[FindLoc],
2263        &[],
2264        &[],
2265        &[FindLoc],
2266        &[],
2267        false,
2268    );
2269    add(
2270        "loc_findnext",
2271        &[FindLoc],
2272        &[ActiveLoc],
2273        &[],
2274        &[FindLoc],
2275        &[ActiveLoc2],
2276        &[],
2277        true,
2278    );
2279    add(
2280        "loc_name",
2281        &[ActiveLoc],
2282        &[],
2283        &[],
2284        &[ActiveLoc2],
2285        &[],
2286        &[],
2287        false,
2288    );
2289    add(
2290        "loc_param",
2291        &[ActiveLoc],
2292        &[],
2293        &[],
2294        &[ActiveLoc2],
2295        &[],
2296        &[],
2297        false,
2298    );
2299    add(
2300        "loc_shape",
2301        &[ActiveLoc],
2302        &[],
2303        &[],
2304        &[ActiveLoc2],
2305        &[],
2306        &[],
2307        false,
2308    );
2309    add(
2310        "loc_type",
2311        &[ActiveLoc],
2312        &[],
2313        &[],
2314        &[ActiveLoc2],
2315        &[],
2316        &[],
2317        false,
2318    );
2319
2320    // -----------------------------------------------------------------------
2321    // Obj ops
2322    // -----------------------------------------------------------------------
2323    add(
2324        "obj_add",
2325        &[ActivePlayer],
2326        &[ActiveObj],
2327        &[],
2328        &[ActivePlayer2],
2329        &[ActiveObj2],
2330        &[],
2331        false,
2332    );
2333    add(
2334        "obj_addall",
2335        &[],
2336        &[ActiveObj],
2337        &[],
2338        &[],
2339        &[ActiveObj2],
2340        &[],
2341        false,
2342    );
2343    add(
2344        "obj_coord",
2345        &[ActiveObj],
2346        &[],
2347        &[],
2348        &[ActiveObj2],
2349        &[],
2350        &[],
2351        false,
2352    );
2353    add(
2354        "obj_count",
2355        &[ActiveObj],
2356        &[],
2357        &[],
2358        &[ActiveObj2],
2359        &[],
2360        &[],
2361        false,
2362    );
2363    add(
2364        "obj_del",
2365        &[ActiveObj],
2366        &[],
2367        &[],
2368        &[ActiveObj2],
2369        &[],
2370        &[],
2371        false,
2372    );
2373    add(
2374        "obj_name",
2375        &[ActiveObj],
2376        &[],
2377        &[],
2378        &[ActiveObj2],
2379        &[],
2380        &[],
2381        false,
2382    );
2383    add(
2384        "obj_param",
2385        &[ActiveObj],
2386        &[],
2387        &[],
2388        &[ActiveObj2],
2389        &[],
2390        &[],
2391        false,
2392    );
2393    add(
2394        "obj_getvar",
2395        &[ActiveObj],
2396        &[],
2397        &[],
2398        &[ActiveObj2],
2399        &[],
2400        &[],
2401        false,
2402    );
2403    add(
2404        "obj_setvar",
2405        &[ActiveObj],
2406        &[],
2407        &[],
2408        &[ActiveObj2],
2409        &[],
2410        &[],
2411        false,
2412    );
2413    add(
2414        "obj_takeitem",
2415        &[ActiveObj, ActivePlayer],
2416        &[],
2417        &[],
2418        &[ActiveObj2, ActivePlayer2],
2419        &[],
2420        &[],
2421        false,
2422    );
2423    add(
2424        "obj_type",
2425        &[ActiveObj],
2426        &[],
2427        &[],
2428        &[ActiveObj2],
2429        &[],
2430        &[],
2431        false,
2432    );
2433    add(
2434        "obj_find",
2435        &[],
2436        &[ActiveObj],
2437        &[],
2438        &[],
2439        &[ActiveObj2],
2440        &[],
2441        false,
2442    );
2443    add(
2444        "obj_findallzone",
2445        &[],
2446        &[FindObj],
2447        &[],
2448        &[],
2449        &[FindObj],
2450        &[],
2451        false,
2452    );
2453    add(
2454        "obj_findnext",
2455        &[FindObj],
2456        &[ActiveObj],
2457        &[],
2458        &[FindObj],
2459        &[ActiveObj2],
2460        &[],
2461        true,
2462    );
2463
2464    // -----------------------------------------------------------------------
2465    // Inventory ops
2466    // -----------------------------------------------------------------------
2467    add(
2468        "inv_add",
2469        &[ActivePlayer],
2470        &[],
2471        &[],
2472        &[ActivePlayer2],
2473        &[],
2474        &[],
2475        false,
2476    );
2477    add(
2478        "inv_changeslot",
2479        &[ActivePlayer],
2480        &[],
2481        &[],
2482        &[ActivePlayer2],
2483        &[],
2484        &[],
2485        false,
2486    );
2487    add(
2488        "inv_clear",
2489        &[ActivePlayer],
2490        &[],
2491        &[],
2492        &[ActivePlayer2],
2493        &[],
2494        &[],
2495        false,
2496    );
2497    add(
2498        "inv_del",
2499        &[ActivePlayer],
2500        &[],
2501        &[],
2502        &[ActivePlayer2],
2503        &[],
2504        &[],
2505        false,
2506    );
2507    add(
2508        "inv_delslot",
2509        &[ActivePlayer],
2510        &[],
2511        &[],
2512        &[ActivePlayer2],
2513        &[],
2514        &[],
2515        false,
2516    );
2517    add(
2518        "inv_dropitem",
2519        &[ActivePlayer],
2520        &[ActiveObj],
2521        &[],
2522        &[ActivePlayer2],
2523        &[ActiveObj2],
2524        &[],
2525        false,
2526    );
2527    add(
2528        "inv_dropitem_delayed",
2529        &[ActivePlayer],
2530        &[ActiveObj],
2531        &[],
2532        &[ActivePlayer2],
2533        &[ActiveObj2],
2534        &[],
2535        false,
2536    );
2537    add(
2538        "inv_dropslot",
2539        &[ActivePlayer],
2540        &[ActiveObj],
2541        &[],
2542        &[ActivePlayer2],
2543        &[ActiveObj2],
2544        &[],
2545        false,
2546    );
2547    add(
2548        "inv_freespace",
2549        &[ActivePlayer],
2550        &[],
2551        &[],
2552        &[ActivePlayer2],
2553        &[],
2554        &[],
2555        false,
2556    );
2557    add(
2558        "inv_getnum",
2559        &[ActivePlayer],
2560        &[],
2561        &[],
2562        &[ActivePlayer2],
2563        &[],
2564        &[],
2565        false,
2566    );
2567    add(
2568        "inv_getobj",
2569        &[ActivePlayer],
2570        &[],
2571        &[],
2572        &[ActivePlayer2],
2573        &[],
2574        &[],
2575        false,
2576    );
2577    add(
2578        "inv_getvar",
2579        &[ActivePlayer],
2580        &[],
2581        &[],
2582        &[ActivePlayer2],
2583        &[],
2584        &[],
2585        false,
2586    );
2587    add(
2588        "inv_itemspace",
2589        &[ActivePlayer],
2590        &[],
2591        &[],
2592        &[ActivePlayer2],
2593        &[],
2594        &[],
2595        false,
2596    );
2597    add(
2598        "inv_itemspace2",
2599        &[ActivePlayer],
2600        &[],
2601        &[],
2602        &[ActivePlayer2],
2603        &[],
2604        &[],
2605        false,
2606    );
2607    add(
2608        "inv_movefromslot",
2609        &[ActivePlayer],
2610        &[],
2611        &[],
2612        &[ActivePlayer2],
2613        &[],
2614        &[],
2615        false,
2616    );
2617    add(
2618        "inv_movetoslot",
2619        &[ActivePlayer],
2620        &[],
2621        &[],
2622        &[ActivePlayer2],
2623        &[],
2624        &[],
2625        false,
2626    );
2627    add(
2628        "both_moveinv",
2629        &[ActivePlayer, ActivePlayer2],
2630        &[],
2631        &[],
2632        &[ActivePlayer2, ActivePlayer],
2633        &[],
2634        &[],
2635        false,
2636    );
2637    add(
2638        "inv_moveitem",
2639        &[ActivePlayer],
2640        &[],
2641        &[],
2642        &[ActivePlayer2],
2643        &[],
2644        &[],
2645        false,
2646    );
2647    add(
2648        "inv_moveitem_cert",
2649        &[ActivePlayer],
2650        &[],
2651        &[],
2652        &[ActivePlayer2],
2653        &[],
2654        &[],
2655        false,
2656    );
2657    add(
2658        "inv_moveitem_uncert",
2659        &[ActivePlayer],
2660        &[],
2661        &[],
2662        &[ActivePlayer2],
2663        &[],
2664        &[],
2665        false,
2666    );
2667    add(
2668        "inv_setslot",
2669        &[ActivePlayer],
2670        &[],
2671        &[],
2672        &[ActivePlayer2],
2673        &[],
2674        &[],
2675        false,
2676    );
2677    add(
2678        "inv_setvar",
2679        &[ActivePlayer],
2680        &[],
2681        &[],
2682        &[ActivePlayer2],
2683        &[],
2684        &[],
2685        false,
2686    );
2687    add(
2688        "inv_total",
2689        &[ActivePlayer],
2690        &[],
2691        &[],
2692        &[ActivePlayer2],
2693        &[],
2694        &[],
2695        false,
2696    );
2697    add(
2698        "inv_totalcat",
2699        &[ActivePlayer],
2700        &[],
2701        &[],
2702        &[ActivePlayer2],
2703        &[],
2704        &[],
2705        false,
2706    );
2707    add(
2708        "inv_transmit",
2709        &[ActivePlayer],
2710        &[],
2711        &[],
2712        &[ActivePlayer2],
2713        &[],
2714        &[],
2715        false,
2716    );
2717    add(
2718        "invother_transmit",
2719        &[ActivePlayer, ActivePlayer2],
2720        &[],
2721        &[],
2722        &[ActivePlayer2, ActivePlayer],
2723        &[],
2724        &[],
2725        false,
2726    );
2727    add(
2728        "inv_stoptransmit",
2729        &[ActivePlayer],
2730        &[],
2731        &[],
2732        &[ActivePlayer2],
2733        &[],
2734        &[],
2735        false,
2736    );
2737    add(
2738        "both_dropslot",
2739        &[ActivePlayer, ActivePlayer2],
2740        &[],
2741        &[],
2742        &[ActivePlayer2, ActivePlayer],
2743        &[],
2744        &[],
2745        false,
2746    );
2747    add(
2748        "inv_dropall",
2749        &[ActivePlayer],
2750        &[],
2751        &[],
2752        &[ActivePlayer2],
2753        &[],
2754        &[],
2755        false,
2756    );
2757    add(
2758        "inv_totalparam",
2759        &[ActivePlayer],
2760        &[],
2761        &[],
2762        &[ActivePlayer2],
2763        &[],
2764        &[],
2765        false,
2766    );
2767    add(
2768        "inv_totalparam_stack",
2769        &[ActivePlayer],
2770        &[],
2771        &[],
2772        &[ActivePlayer2],
2773        &[],
2774        &[],
2775        false,
2776    );
2777
2778    // -----------------------------------------------------------------------
2779    // String ops
2780    // -----------------------------------------------------------------------
2781    add(
2782        "text_gender",
2783        &[ActivePlayer],
2784        &[],
2785        &[],
2786        &[ActivePlayer2],
2787        &[],
2788        &[],
2789        false,
2790    );
2791
2792    // -----------------------------------------------------------------------
2793    // DB ops
2794    // -----------------------------------------------------------------------
2795    add("db_findnext", &[FindDb], &[], &[], &[], &[], &[], false);
2796    add("db_find", &[], &[FindDb], &[], &[], &[], &[], false);
2797    add("db_find_refine", &[FindDb], &[], &[], &[], &[], &[], false);
2798    add("db_listall", &[], &[FindDb], &[], &[], &[], &[], false);
2799    add(
2800        "db_listall_with_count",
2801        &[],
2802        &[FindDb],
2803        &[],
2804        &[],
2805        &[],
2806        &[],
2807        false,
2808    );
2809
2810    map
2811}