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        // Unknown trigger — no pointers initialized
417        _ => return PointerSet::new(),
418    };
419
420    ptrs.iter().copied().collect()
421}
422
423// ---------------------------------------------------------------------------
424// command_pointers — pointer requirements for every engine command
425// ---------------------------------------------------------------------------
426
427/// Builds the full mapping from command name to its pointer requirements.
428///
429/// Both primary and secondary (`.` prefixed) variants are generated as
430/// separate entries. The keys use lowercase command names matching the
431/// SymbolRegistry command map.
432///
433/// Transcribed from `ScriptOpcodePointers.ts`.
434pub fn command_pointers() -> HashMap<String, PointerHolder> {
435    use PointerType::*;
436
437    let mut map = HashMap::new();
438
439    // Helper closures to reduce boilerplate
440    let mut add = |name: &str,
441                   require: &[PointerType],
442                   set: &[PointerType],
443                   corrupt: &[PointerType],
444                   require2: &[PointerType],
445                   set2: &[PointerType],
446                   corrupt2: &[PointerType],
447                   conditional: bool| {
448        // Primary entry
449        let holder = PointerHolder {
450            required: require.iter().copied().collect(),
451            set: set.iter().copied().collect(),
452            corrupted: corrupt.iter().copied().collect(),
453            conditional_set: conditional,
454        };
455        map.insert(name.to_lowercase(), holder);
456
457        // Secondary entry (dot-prefixed) if any require2/set2/corrupt2 are specified
458        if !require2.is_empty() || !set2.is_empty() || !corrupt2.is_empty() {
459            let holder2 = PointerHolder {
460                required: require2.iter().copied().collect(),
461                set: set2.iter().copied().collect(),
462                corrupted: corrupt2.iter().copied().collect(),
463                conditional_set: conditional,
464            };
465            map.insert(format!(".{}", name.to_lowercase()), holder2);
466        }
467    };
468
469    // The POINTER_GROUP_FIND shorthand
470    let find_group: &[PointerType] = &[FindPlayer, FindNpc, FindLoc, FindObj, FindDb];
471    // Corruption set for p_delay / p_arrivedelay style commands:
472    // everything except active is assumed corrupted
473    let delay_corrupt: Vec<PointerType> = {
474        let mut v: Vec<PointerType> = find_group.to_vec();
475        v.extend_from_slice(&[
476            LastCom,
477            LastInt,
478            LastItem,
479            LastSlot,
480            LastTargetslot,
481            LastUseitem,
482            LastUseslot,
483        ]);
484        v
485    };
486
487    // -----------------------------------------------------------------------
488    // Player ops
489    // -----------------------------------------------------------------------
490    add(
491        "allowdesign",
492        &[ActivePlayer],
493        &[],
494        &[],
495        &[],
496        &[],
497        &[],
498        false,
499    );
500    add(
501        "anim",
502        &[ActivePlayer],
503        &[],
504        &[],
505        &[ActivePlayer2],
506        &[],
507        &[],
508        false,
509    );
510    add("readyanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
511    add("runanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
512    add("turnanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
513    add(
514        "walkanim_b",
515        &[ActivePlayer],
516        &[],
517        &[],
518        &[],
519        &[],
520        &[],
521        false,
522    );
523    add("walkanim", &[ActivePlayer], &[], &[], &[], &[], &[], false);
524    add(
525        "walkanim_l",
526        &[ActivePlayer],
527        &[],
528        &[],
529        &[],
530        &[],
531        &[],
532        false,
533    );
534    add(
535        "walkanim_r",
536        &[ActivePlayer],
537        &[],
538        &[],
539        &[],
540        &[],
541        &[],
542        false,
543    );
544    add(
545        "buildappearance",
546        &[ActivePlayer],
547        &[],
548        &[],
549        &[],
550        &[],
551        &[],
552        false,
553    );
554    add(
555        "busy",
556        &[ActivePlayer],
557        &[],
558        &[],
559        &[ActivePlayer2],
560        &[],
561        &[],
562        false,
563    );
564    add(
565        "busy2",
566        &[ActivePlayer],
567        &[],
568        &[],
569        &[ActivePlayer2],
570        &[],
571        &[],
572        false,
573    );
574    add(
575        "cam_lookat",
576        &[ActivePlayer],
577        &[],
578        &[],
579        &[ActivePlayer2],
580        &[],
581        &[],
582        false,
583    );
584    add(
585        "cam_moveto",
586        &[ActivePlayer],
587        &[],
588        &[],
589        &[ActivePlayer2],
590        &[],
591        &[],
592        false,
593    );
594    add(
595        "cam_reset",
596        &[ActivePlayer],
597        &[],
598        &[],
599        &[ActivePlayer2],
600        &[],
601        &[],
602        false,
603    );
604    add(
605        "cam_shake",
606        &[ActivePlayer],
607        &[],
608        &[],
609        &[ActivePlayer2],
610        &[],
611        &[],
612        false,
613    );
614    add(
615        "clearqueue",
616        &[ActivePlayer],
617        &[],
618        &[],
619        &[],
620        &[],
621        &[],
622        false,
623    );
624    add(
625        "clearsofttimer",
626        &[ActivePlayer],
627        &[],
628        &[],
629        &[ActivePlayer2],
630        &[],
631        &[],
632        false,
633    );
634    add(
635        "cleartimer",
636        &[ActivePlayer],
637        &[],
638        &[],
639        &[ActivePlayer2],
640        &[],
641        &[],
642        false,
643    );
644    add(
645        "gettimer",
646        &[ActivePlayer],
647        &[],
648        &[],
649        &[ActivePlayer2],
650        &[],
651        &[],
652        false,
653    );
654    add(
655        "coord",
656        &[ActivePlayer],
657        &[],
658        &[],
659        &[ActivePlayer2],
660        &[],
661        &[],
662        false,
663    );
664    add(
665        "damage",
666        &[ActivePlayer],
667        &[],
668        &[],
669        &[ActivePlayer2],
670        &[],
671        &[],
672        false,
673    );
674    add(
675        "displayname",
676        &[ActivePlayer],
677        &[],
678        &[],
679        &[ActivePlayer2],
680        &[],
681        &[],
682        false,
683    );
684    add(
685        "facesquare",
686        &[ActivePlayer],
687        &[],
688        &[],
689        &[ActivePlayer2],
690        &[],
691        &[],
692        false,
693    );
694    add(
695        "finduid",
696        &[],
697        &[ActivePlayer],
698        &[PActivePlayer],
699        &[],
700        &[ActivePlayer2],
701        &[PActivePlayer2],
702        true,
703    );
704    add(
705        "gender",
706        &[ActivePlayer],
707        &[],
708        &[],
709        &[ActivePlayer2],
710        &[],
711        &[],
712        false,
713    );
714    add(
715        "getqueue",
716        &[ActivePlayer],
717        &[],
718        &[],
719        &[ActivePlayer2],
720        &[],
721        &[],
722        false,
723    );
724    add(
725        "stat_advance",
726        &[ActivePlayer],
727        &[],
728        &[],
729        &[],
730        &[],
731        &[],
732        false,
733    );
734    add(
735        "headicons_get",
736        &[ActivePlayer],
737        &[],
738        &[],
739        &[],
740        &[],
741        &[],
742        false,
743    );
744    add(
745        "headicons_set",
746        &[ActivePlayer],
747        &[],
748        &[],
749        &[],
750        &[],
751        &[],
752        false,
753    );
754    add(
755        "healenergy",
756        &[ActivePlayer],
757        &[],
758        &[],
759        &[],
760        &[],
761        &[],
762        false,
763    );
764    add(
765        "hint_coord",
766        &[ActivePlayer],
767        &[],
768        &[],
769        &[],
770        &[],
771        &[],
772        false,
773    );
774    add(
775        "hint_npc",
776        &[ActivePlayer, ActiveNpc],
777        &[],
778        &[],
779        &[],
780        &[],
781        &[],
782        false,
783    );
784    add(
785        "hint_pl",
786        &[ActivePlayer, ActivePlayer2],
787        &[],
788        &[],
789        &[],
790        &[],
791        &[],
792        false,
793    );
794    add("hint_stop", &[ActivePlayer], &[], &[], &[], &[], &[], false);
795    add("huntall", &[], &[FindPlayer], &[], &[], &[], &[], false);
796    add(
797        "huntnext",
798        &[FindPlayer],
799        &[ActivePlayer],
800        &[],
801        &[FindPlayer],
802        &[ActivePlayer2],
803        &[],
804        true,
805    );
806    add(
807        "npc_hunt",
808        &[],
809        &[ActiveNpc],
810        &[],
811        &[],
812        &[ActiveNpc2],
813        &[],
814        false,
815    );
816    add("npc_huntall", &[], &[FindNpc], &[], &[], &[], &[], false);
817    add(
818        "npc_hasop",
819        &[ActiveNpc],
820        &[],
821        &[],
822        &[ActiveNpc2],
823        &[],
824        &[],
825        false,
826    );
827    add(
828        "if_close",
829        &[ActivePlayer],
830        &[],
831        &[],
832        &[ActivePlayer2],
833        &[],
834        &[],
835        false,
836    );
837    add("tut_close", &[ActivePlayer], &[], &[], &[], &[], &[], false);
838    add(
839        "if_openchat",
840        &[ActivePlayer],
841        &[],
842        &[],
843        &[],
844        &[],
845        &[],
846        false,
847    );
848    add("tut_open", &[ActivePlayer], &[], &[], &[], &[], &[], false);
849    // 2004scape (rev 225) names this command `if_openmain`. Rev 647 renamed it
850    // to `if_opentop` (since `if_openmain` is reserved for opening a modal in
851    // the main viewport). Both names get the same pointer rules so the compiler
852    // accepts content from either revision.
853    add(
854        "if_openmain",
855        &[ActivePlayer],
856        &[],
857        &[],
858        &[ActivePlayer2],
859        &[],
860        &[],
861        false,
862    );
863    add(
864        "if_opentop",
865        &[ActivePlayer],
866        &[],
867        &[],
868        &[ActivePlayer2],
869        &[],
870        &[],
871        false,
872    );
873    add(
874        "if_openmain_side",
875        &[ActivePlayer],
876        &[],
877        &[],
878        &[ActivePlayer2],
879        &[],
880        &[],
881        false,
882    );
883    add(
884        "if_openoverlay",
885        &[ActivePlayer],
886        &[],
887        &[],
888        &[ActivePlayer2],
889        &[],
890        &[],
891        false,
892    );
893    add(
894        "if_openside",
895        &[ActivePlayer],
896        &[],
897        &[],
898        &[],
899        &[],
900        &[],
901        false,
902    );
903    add(
904        "if_setanim",
905        &[ActivePlayer],
906        &[],
907        &[],
908        &[],
909        &[],
910        &[],
911        false,
912    );
913    add(
914        "if_setcolour",
915        &[ActivePlayer],
916        &[],
917        &[],
918        &[],
919        &[],
920        &[],
921        false,
922    );
923    add(
924        "if_sethide",
925        &[ActivePlayer],
926        &[],
927        &[],
928        &[ActivePlayer2],
929        &[],
930        &[],
931        false,
932    );
933    add(
934        "if_setmodel",
935        &[ActivePlayer],
936        &[],
937        &[],
938        &[],
939        &[],
940        &[],
941        false,
942    );
943    add(
944        "if_setnpchead",
945        &[ActivePlayer],
946        &[],
947        &[],
948        &[],
949        &[],
950        &[],
951        false,
952    );
953    add(
954        "if_setobject",
955        &[ActivePlayer],
956        &[],
957        &[],
958        &[],
959        &[],
960        &[],
961        false,
962    );
963    add(
964        "if_setplayerhead",
965        &[ActivePlayer],
966        &[],
967        &[],
968        &[],
969        &[],
970        &[],
971        false,
972    );
973    add(
974        "if_setposition",
975        &[ActivePlayer],
976        &[],
977        &[],
978        &[],
979        &[],
980        &[],
981        false,
982    );
983    add(
984        "if_addresumebutton",
985        &[ActivePlayer],
986        &[],
987        &[],
988        &[],
989        &[],
990        &[],
991        false,
992    );
993    add("if_settab", &[ActivePlayer], &[], &[], &[], &[], &[], false);
994    add(
995        "if_settabactive",
996        &[ActivePlayer],
997        &[],
998        &[],
999        &[ActivePlayer2],
1000        &[],
1001        &[],
1002        false,
1003    );
1004    add("tut_flash", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1005    add(
1006        "if_settext",
1007        &[ActivePlayer],
1008        &[],
1009        &[],
1010        &[ActivePlayer2],
1011        &[],
1012        &[],
1013        false,
1014    );
1015    add(
1016        "last_login_info",
1017        &[ActivePlayer],
1018        &[],
1019        &[],
1020        &[],
1021        &[],
1022        &[],
1023        false,
1024    );
1025    add("last_com", &[LastCom], &[], &[], &[], &[], &[], false);
1026    add("last_int", &[LastInt], &[], &[], &[], &[], &[], false);
1027    add("last_item", &[LastItem], &[], &[], &[], &[], &[], false);
1028    add("last_slot", &[LastSlot], &[], &[], &[], &[], &[], false);
1029    add(
1030        "last_targetslot",
1031        &[LastTargetslot],
1032        &[],
1033        &[],
1034        &[],
1035        &[],
1036        &[],
1037        false,
1038    );
1039    add(
1040        "last_useitem",
1041        &[LastUseitem],
1042        &[],
1043        &[],
1044        &[],
1045        &[],
1046        &[],
1047        false,
1048    );
1049    add(
1050        "last_useslot",
1051        &[LastUseslot],
1052        &[],
1053        &[],
1054        &[],
1055        &[],
1056        &[],
1057        false,
1058    );
1059    add(
1060        "longqueue",
1061        &[ActivePlayer],
1062        &[],
1063        &[],
1064        &[ActivePlayer2],
1065        &[],
1066        &[],
1067        false,
1068    );
1069    add(
1070        "longqueue*",
1071        &[ActivePlayer],
1072        &[],
1073        &[],
1074        &[ActivePlayer2],
1075        &[],
1076        &[],
1077        false,
1078    );
1079    add("lowmem", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1080    add(
1081        "mes",
1082        &[ActivePlayer],
1083        &[],
1084        &[],
1085        &[ActivePlayer2],
1086        &[],
1087        &[],
1088        false,
1089    );
1090    add(
1091        "midi_jingle",
1092        &[ActivePlayer],
1093        &[],
1094        &[],
1095        &[],
1096        &[],
1097        &[],
1098        false,
1099    );
1100    add("midi_song", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1101    add(
1102        "minimap_toggle",
1103        &[ActivePlayer],
1104        &[],
1105        &[],
1106        &[ActivePlayer2],
1107        &[],
1108        &[],
1109        false,
1110    );
1111    add(
1112        "name",
1113        &[ActivePlayer],
1114        &[],
1115        &[],
1116        &[ActivePlayer2],
1117        &[],
1118        &[],
1119        false,
1120    );
1121    add(
1122        "p_aprange",
1123        &[PActivePlayer],
1124        &[],
1125        &[],
1126        &[],
1127        &[],
1128        &[],
1129        false,
1130    );
1131    add(
1132        "p_arrivedelay",
1133        &[PActivePlayer],
1134        &[],
1135        &delay_corrupt,
1136        &[],
1137        &[],
1138        &[],
1139        false,
1140    );
1141    {
1142        // p_countdialog: sets last_int, corrupts everything except active + last_int
1143        let mut corrupt = delay_corrupt.clone();
1144        corrupt.retain(|p| *p != LastInt);
1145        add(
1146            "p_countdialog",
1147            &[PActivePlayer],
1148            &[LastInt],
1149            &corrupt,
1150            &[],
1151            &[],
1152            &[],
1153            false,
1154        );
1155    }
1156    add(
1157        "p_delay",
1158        &[PActivePlayer],
1159        &[],
1160        &delay_corrupt,
1161        &[],
1162        &[],
1163        &[],
1164        false,
1165    );
1166    add(
1167        "p_exactmove",
1168        &[PActivePlayer],
1169        &[],
1170        &[],
1171        &[],
1172        &[],
1173        &[],
1174        false,
1175    );
1176    for name in [
1177        "p_namedialog",
1178        "p_stringdialog",
1179        "p_setdisplayname",
1180        "p_get_suggestion",
1181        "p_next_suggestions",
1182        "p_prev_suggestions",
1183        "p_request_more_suggestions",
1184        "p_rest",
1185        "p_temprun",
1186    ] {
1187        add(name, &[PActivePlayer], &[], &[], &[], &[], &[], false);
1188    }
1189    add(
1190        "p_finduid",
1191        &[],
1192        &[PActivePlayer, ActivePlayer],
1193        &[],
1194        &[],
1195        &[PActivePlayer2, ActivePlayer2],
1196        &[],
1197        true,
1198    );
1199    add(
1200        "p_locmerge",
1201        &[PActivePlayer],
1202        &[],
1203        &[],
1204        &[],
1205        &[],
1206        &[],
1207        false,
1208    );
1209    add("p_logout", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1210    add(
1211        "p_preventlogout",
1212        &[PActivePlayer],
1213        &[],
1214        &[],
1215        &[PActivePlayer2],
1216        &[],
1217        &[],
1218        false,
1219    );
1220    add("p_opheld", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1221    add(
1222        "p_oploc",
1223        &[PActivePlayer, ActiveLoc],
1224        &[],
1225        &[],
1226        &[],
1227        &[],
1228        &[],
1229        false,
1230    );
1231    add(
1232        "p_opnpc",
1233        &[PActivePlayer, ActiveNpc],
1234        &[],
1235        &[],
1236        &[],
1237        &[],
1238        &[],
1239        false,
1240    );
1241    add(
1242        "p_opnpct",
1243        &[PActivePlayer, ActiveNpc],
1244        &[],
1245        &[],
1246        &[],
1247        &[],
1248        &[],
1249        false,
1250    );
1251    add(
1252        "p_opobj",
1253        &[PActivePlayer, ActiveObj],
1254        &[],
1255        &[],
1256        &[],
1257        &[],
1258        &[],
1259        false,
1260    );
1261    add(
1262        "p_opplayer",
1263        &[PActivePlayer, ActivePlayer2],
1264        &[],
1265        &[],
1266        &[PActivePlayer2, ActivePlayer],
1267        &[],
1268        &[],
1269        false,
1270    );
1271    add(
1272        "p_opplayert",
1273        &[PActivePlayer, ActivePlayer2],
1274        &[],
1275        &[],
1276        &[PActivePlayer2, ActivePlayer],
1277        &[],
1278        &[],
1279        false,
1280    );
1281    {
1282        // p_pausebutton: sets last_com, corrupts everything except active + last_com
1283        let mut corrupt = delay_corrupt.clone();
1284        corrupt.retain(|p| *p != LastCom);
1285        add(
1286            "p_pausebutton",
1287            &[PActivePlayer],
1288            &[LastCom],
1289            &corrupt,
1290            &[],
1291            &[],
1292            &[],
1293            false,
1294        );
1295    }
1296    add(
1297        "p_stopaction",
1298        &[PActivePlayer],
1299        &[],
1300        &[],
1301        &[PActivePlayer2],
1302        &[],
1303        &[],
1304        false,
1305    );
1306    add(
1307        "p_clearpendingaction",
1308        &[PActivePlayer],
1309        &[],
1310        &[],
1311        &[PActivePlayer2],
1312        &[],
1313        &[],
1314        false,
1315    );
1316    add(
1317        "p_telejump",
1318        &[PActivePlayer],
1319        &[],
1320        &[],
1321        &[PActivePlayer2],
1322        &[],
1323        &[],
1324        false,
1325    );
1326    add(
1327        "p_teleport",
1328        &[PActivePlayer],
1329        &[],
1330        &[],
1331        &[PActivePlayer2],
1332        &[],
1333        &[],
1334        false,
1335    );
1336    add(
1337        "p_walk",
1338        &[PActivePlayer],
1339        &[],
1340        &[],
1341        &[PActivePlayer2],
1342        &[],
1343        &[],
1344        false,
1345    );
1346    add(
1347        "projanim_pl",
1348        &[ActivePlayer],
1349        &[],
1350        &[],
1351        &[ActivePlayer2],
1352        &[],
1353        &[],
1354        false,
1355    );
1356    add(
1357        "queue",
1358        &[ActivePlayer],
1359        &[],
1360        &[],
1361        &[ActivePlayer2],
1362        &[],
1363        &[],
1364        false,
1365    );
1366    add(
1367        "queue*",
1368        &[ActivePlayer],
1369        &[],
1370        &[],
1371        &[ActivePlayer2],
1372        &[],
1373        &[],
1374        false,
1375    );
1376    add(
1377        "say",
1378        &[ActivePlayer],
1379        &[],
1380        &[],
1381        &[ActivePlayer2],
1382        &[],
1383        &[],
1384        false,
1385    );
1386    add("setidkit", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1387    add(
1388        "walktrigger",
1389        &[ActivePlayer],
1390        &[],
1391        &[],
1392        &[ActivePlayer2],
1393        &[],
1394        &[],
1395        false,
1396    );
1397    add(
1398        "getwalktrigger",
1399        &[ActivePlayer],
1400        &[],
1401        &[],
1402        &[ActivePlayer2],
1403        &[],
1404        &[],
1405        false,
1406    );
1407    add(
1408        "settimer",
1409        &[ActivePlayer],
1410        &[],
1411        &[],
1412        &[ActivePlayer2],
1413        &[],
1414        &[],
1415        false,
1416    );
1417    add(
1418        "softtimer",
1419        &[ActivePlayer],
1420        &[],
1421        &[],
1422        &[ActivePlayer2],
1423        &[],
1424        &[],
1425        false,
1426    );
1427    add(
1428        "sound_synth",
1429        &[ActivePlayer],
1430        &[],
1431        &[],
1432        &[ActivePlayer2],
1433        &[],
1434        &[],
1435        false,
1436    );
1437    add(
1438        "spotanim_pl",
1439        &[ActivePlayer],
1440        &[],
1441        &[],
1442        &[ActivePlayer2],
1443        &[],
1444        &[],
1445        false,
1446    );
1447    add(
1448        "staffmodlevel",
1449        &[ActivePlayer],
1450        &[],
1451        &[],
1452        &[ActivePlayer2],
1453        &[],
1454        &[],
1455        false,
1456    );
1457    add(
1458        "stat",
1459        &[ActivePlayer],
1460        &[],
1461        &[],
1462        &[ActivePlayer2],
1463        &[],
1464        &[],
1465        false,
1466    );
1467    add(
1468        "stat_add",
1469        &[ActivePlayer],
1470        &[],
1471        &[],
1472        &[ActivePlayer2],
1473        &[],
1474        &[],
1475        false,
1476    );
1477    add(
1478        "stat_base",
1479        &[ActivePlayer],
1480        &[],
1481        &[],
1482        &[ActivePlayer2],
1483        &[],
1484        &[],
1485        false,
1486    );
1487    add(
1488        "stat_heal",
1489        &[ActivePlayer],
1490        &[],
1491        &[],
1492        &[ActivePlayer2],
1493        &[],
1494        &[],
1495        false,
1496    );
1497    add(
1498        "stat_sub",
1499        &[ActivePlayer],
1500        &[],
1501        &[],
1502        &[ActivePlayer2],
1503        &[],
1504        &[],
1505        false,
1506    );
1507    add(
1508        "stat_boost",
1509        &[ActivePlayer],
1510        &[],
1511        &[],
1512        &[ActivePlayer2],
1513        &[],
1514        &[],
1515        false,
1516    );
1517    add(
1518        "stat_drain",
1519        &[ActivePlayer],
1520        &[],
1521        &[],
1522        &[ActivePlayer2],
1523        &[],
1524        &[],
1525        false,
1526    );
1527    add(
1528        "stat_random",
1529        &[ActivePlayer],
1530        &[],
1531        &[],
1532        &[ActivePlayer2],
1533        &[],
1534        &[],
1535        false,
1536    );
1537    add(
1538        "uid",
1539        &[ActivePlayer],
1540        &[],
1541        &[],
1542        &[ActivePlayer2],
1543        &[],
1544        &[],
1545        false,
1546    );
1547    add(
1548        "weakqueue",
1549        &[ActivePlayer],
1550        &[],
1551        &[],
1552        &[ActivePlayer2],
1553        &[],
1554        &[],
1555        false,
1556    );
1557    add(
1558        "weakqueue*",
1559        &[ActivePlayer],
1560        &[],
1561        &[],
1562        &[ActivePlayer2],
1563        &[],
1564        &[],
1565        false,
1566    );
1567    add(
1568        "findhero",
1569        &[],
1570        &[ActivePlayer2],
1571        &[],
1572        &[],
1573        &[ActivePlayer],
1574        &[],
1575        true,
1576    );
1577    add(
1578        "both_heropoints",
1579        &[ActivePlayer, ActivePlayer2],
1580        &[],
1581        &[],
1582        &[ActivePlayer2, ActivePlayer],
1583        &[],
1584        &[],
1585        false,
1586    );
1587    add(
1588        "setgender",
1589        &[PActivePlayer],
1590        &[],
1591        &[],
1592        &[],
1593        &[],
1594        &[],
1595        false,
1596    );
1597    add(
1598        "setidkcolour",
1599        &[PActivePlayer],
1600        &[],
1601        &[],
1602        &[],
1603        &[],
1604        &[],
1605        false,
1606    );
1607    add(
1608        "p_animprotect",
1609        &[PActivePlayer],
1610        &[],
1611        &[],
1612        &[PActivePlayer2],
1613        &[],
1614        &[],
1615        false,
1616    );
1617    add(
1618        "runenergy",
1619        &[ActivePlayer],
1620        &[],
1621        &[],
1622        &[ActivePlayer2],
1623        &[],
1624        &[],
1625        false,
1626    );
1627    add(
1628        "weight",
1629        &[PActivePlayer],
1630        &[],
1631        &[],
1632        &[PActivePlayer2],
1633        &[],
1634        &[],
1635        false,
1636    );
1637    add(
1638        "p_run",
1639        &[PActivePlayer],
1640        &[],
1641        &[],
1642        &[PActivePlayer2],
1643        &[],
1644        &[],
1645        false,
1646    );
1647    add(
1648        "if_setscrollpos",
1649        &[ActivePlayer],
1650        &[],
1651        &[],
1652        &[],
1653        &[],
1654        &[],
1655        false,
1656    );
1657    add(
1658        "if_movesub",
1659        &[ActivePlayer],
1660        &[],
1661        &[],
1662        &[],
1663        &[],
1664        &[],
1665        false,
1666    );
1667    add(
1668        "set_player_op",
1669        &[ActivePlayer],
1670        &[],
1671        &[],
1672        &[],
1673        &[],
1674        &[],
1675        false,
1676    );
1677    add(
1678        "set_skill_level",
1679        &[ActivePlayer],
1680        &[],
1681        &[],
1682        &[ActivePlayer2],
1683        &[],
1684        &[],
1685        false,
1686    );
1687    add(
1688        "strongqueue",
1689        &[ActivePlayer],
1690        &[],
1691        &[],
1692        &[ActivePlayer2],
1693        &[],
1694        &[],
1695        false,
1696    );
1697    add(
1698        "strongqueue*",
1699        &[ActivePlayer],
1700        &[],
1701        &[],
1702        &[ActivePlayer2],
1703        &[],
1704        &[],
1705        false,
1706    );
1707
1708    // -----------------------------------------------------------------------
1709    // NPC ops
1710    // -----------------------------------------------------------------------
1711    add(
1712        "npc_add",
1713        &[],
1714        &[ActiveNpc],
1715        &[],
1716        &[],
1717        &[ActiveNpc2],
1718        &[],
1719        false,
1720    );
1721    add(
1722        "npc_anim",
1723        &[ActiveNpc],
1724        &[],
1725        &[],
1726        &[ActiveNpc2],
1727        &[],
1728        &[],
1729        false,
1730    );
1731    add(
1732        "npc_basestat",
1733        &[ActiveNpc],
1734        &[],
1735        &[],
1736        &[ActiveNpc2],
1737        &[],
1738        &[],
1739        false,
1740    );
1741    add(
1742        "npc_category",
1743        &[ActiveNpc],
1744        &[],
1745        &[],
1746        &[ActiveNpc2],
1747        &[],
1748        &[],
1749        false,
1750    );
1751    add(
1752        "npc_changetype",
1753        &[ActiveNpc],
1754        &[],
1755        &[],
1756        &[ActiveNpc2],
1757        &[],
1758        &[],
1759        false,
1760    );
1761    add(
1762        "npc_changetype_keepall",
1763        &[ActiveNpc],
1764        &[],
1765        &[],
1766        &[ActiveNpc2],
1767        &[],
1768        &[],
1769        false,
1770    );
1771    add(
1772        "npc_coord",
1773        &[ActiveNpc],
1774        &[],
1775        &[],
1776        &[ActiveNpc2],
1777        &[],
1778        &[],
1779        false,
1780    );
1781    add(
1782        "npc_damage",
1783        &[ActiveNpc],
1784        &[],
1785        &[],
1786        &[ActiveNpc2],
1787        &[],
1788        &[],
1789        false,
1790    );
1791    add(
1792        "npc_del",
1793        &[ActiveNpc],
1794        &[],
1795        &[],
1796        &[ActiveNpc2],
1797        &[],
1798        &[],
1799        false,
1800    );
1801    {
1802        // npc_delay: corrupts p_active_player, p_active_player2, find_*, last_*
1803        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
1804        corrupt.extend_from_slice(find_group);
1805        corrupt.extend_from_slice(&[
1806            LastCom,
1807            LastInt,
1808            LastItem,
1809            LastSlot,
1810            LastTargetslot,
1811            LastUseitem,
1812            LastUseslot,
1813        ]);
1814        add(
1815            "npc_delay",
1816            &[ActiveNpc],
1817            &[],
1818            &corrupt,
1819            &[ActiveNpc2],
1820            &[],
1821            &[],
1822            false,
1823        );
1824    }
1825    add(
1826        "npc_facesquare",
1827        &[ActiveNpc],
1828        &[],
1829        &[],
1830        &[ActiveNpc2],
1831        &[],
1832        &[],
1833        false,
1834    );
1835    add(
1836        "npc_find",
1837        &[],
1838        &[ActiveNpc],
1839        &[],
1840        &[],
1841        &[ActiveNpc2],
1842        &[],
1843        true,
1844    );
1845    add(
1846        "npc_findcat",
1847        &[],
1848        &[ActiveNpc],
1849        &[],
1850        &[],
1851        &[ActiveNpc2],
1852        &[],
1853        true,
1854    );
1855    add("npc_findallany", &[], &[FindNpc], &[], &[], &[], &[], false);
1856    add("npc_findall", &[], &[FindNpc], &[], &[], &[], &[], false);
1857    add(
1858        "npc_findallzone",
1859        &[],
1860        &[FindNpc],
1861        &[],
1862        &[],
1863        &[],
1864        &[],
1865        false,
1866    );
1867    add(
1868        "npc_findnext",
1869        &[FindNpc],
1870        &[ActiveNpc],
1871        &[],
1872        &[],
1873        &[ActiveNpc2],
1874        &[],
1875        true,
1876    );
1877    add(
1878        "npc_findexact",
1879        &[],
1880        &[ActiveNpc],
1881        &[],
1882        &[],
1883        &[ActiveNpc2],
1884        &[],
1885        true,
1886    );
1887    add(
1888        "npc_findhero",
1889        &[ActiveNpc],
1890        &[ActivePlayer],
1891        &[],
1892        &[ActiveNpc2],
1893        &[ActivePlayer2],
1894        &[],
1895        true,
1896    );
1897    add(
1898        "npc_finduid",
1899        &[],
1900        &[ActiveNpc],
1901        &[],
1902        &[],
1903        &[ActiveNpc2],
1904        &[],
1905        true,
1906    );
1907    add(
1908        "npc_getmode",
1909        &[ActiveNpc],
1910        &[],
1911        &[],
1912        &[ActiveNpc2],
1913        &[],
1914        &[],
1915        false,
1916    );
1917    add(
1918        "npc_heropoints",
1919        &[ActiveNpc, ActivePlayer],
1920        &[],
1921        &[],
1922        &[],
1923        &[],
1924        &[],
1925        false,
1926    );
1927    add(
1928        "npc_name",
1929        &[ActiveNpc],
1930        &[],
1931        &[],
1932        &[ActiveNpc2],
1933        &[],
1934        &[],
1935        false,
1936    );
1937    add(
1938        "npc_param",
1939        &[ActiveNpc],
1940        &[],
1941        &[],
1942        &[ActiveNpc2],
1943        &[],
1944        &[],
1945        false,
1946    );
1947    add(
1948        "npc_queue",
1949        &[ActiveNpc],
1950        &[],
1951        &[],
1952        &[ActiveNpc2],
1953        &[],
1954        &[],
1955        false,
1956    );
1957    add(
1958        "npc_range",
1959        &[ActiveNpc],
1960        &[],
1961        &[],
1962        &[ActiveNpc2],
1963        &[],
1964        &[],
1965        false,
1966    );
1967    add(
1968        "npc_say",
1969        &[ActiveNpc],
1970        &[],
1971        &[],
1972        &[ActiveNpc2],
1973        &[],
1974        &[],
1975        false,
1976    );
1977    add(
1978        "npc_sethunt",
1979        &[ActiveNpc],
1980        &[],
1981        &[],
1982        &[ActiveNpc2],
1983        &[],
1984        &[],
1985        false,
1986    );
1987    add(
1988        "npc_sethuntmode",
1989        &[ActiveNpc],
1990        &[],
1991        &[],
1992        &[ActiveNpc2],
1993        &[],
1994        &[],
1995        false,
1996    );
1997    add(
1998        "npc_setmode",
1999        &[ActiveNpc],
2000        &[],
2001        &[],
2002        &[ActiveNpc2],
2003        &[],
2004        &[],
2005        false,
2006    );
2007    add(
2008        "npc_walktrigger",
2009        &[ActiveNpc],
2010        &[],
2011        &[],
2012        &[ActiveNpc2],
2013        &[],
2014        &[],
2015        false,
2016    );
2017    add(
2018        "npc_settimer",
2019        &[ActiveNpc],
2020        &[],
2021        &[],
2022        &[ActiveNpc2],
2023        &[],
2024        &[],
2025        false,
2026    );
2027    add(
2028        "npc_stat",
2029        &[ActiveNpc],
2030        &[],
2031        &[],
2032        &[ActiveNpc2],
2033        &[],
2034        &[],
2035        false,
2036    );
2037    add(
2038        "npc_statadd",
2039        &[ActiveNpc],
2040        &[],
2041        &[],
2042        &[ActiveNpc2],
2043        &[],
2044        &[],
2045        false,
2046    );
2047    add(
2048        "npc_statheal",
2049        &[ActiveNpc],
2050        &[],
2051        &[],
2052        &[ActiveNpc2],
2053        &[],
2054        &[],
2055        false,
2056    );
2057    add(
2058        "npc_statsub",
2059        &[ActiveNpc],
2060        &[],
2061        &[],
2062        &[ActiveNpc2],
2063        &[],
2064        &[],
2065        false,
2066    );
2067    add(
2068        "npc_tele",
2069        &[ActiveNpc],
2070        &[],
2071        &[],
2072        &[ActiveNpc2],
2073        &[],
2074        &[],
2075        false,
2076    );
2077    add(
2078        "npc_type",
2079        &[ActiveNpc],
2080        &[],
2081        &[],
2082        &[ActiveNpc2],
2083        &[],
2084        &[],
2085        false,
2086    );
2087    add(
2088        "npc_uid",
2089        &[ActiveNpc],
2090        &[],
2091        &[],
2092        &[ActiveNpc2],
2093        &[],
2094        &[],
2095        false,
2096    );
2097    add(
2098        "projanim_npc",
2099        &[ActiveNpc],
2100        &[],
2101        &[],
2102        &[ActiveNpc2],
2103        &[],
2104        &[],
2105        false,
2106    );
2107    add(
2108        "spotanim_npc",
2109        &[ActiveNpc],
2110        &[],
2111        &[],
2112        &[ActiveNpc2],
2113        &[],
2114        &[],
2115        false,
2116    );
2117    add(
2118        "npc_walk",
2119        &[ActiveNpc],
2120        &[],
2121        &[],
2122        &[ActiveNpc2],
2123        &[],
2124        &[],
2125        false,
2126    );
2127    add(
2128        "npc_attackrange",
2129        &[ActiveNpc],
2130        &[],
2131        &[],
2132        &[ActiveNpc2],
2133        &[],
2134        &[],
2135        false,
2136    );
2137    {
2138        // npc_arrivedelay: same corruption set as npc_delay
2139        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
2140        corrupt.extend_from_slice(find_group);
2141        corrupt.extend_from_slice(&[
2142            LastCom,
2143            LastInt,
2144            LastItem,
2145            LastSlot,
2146            LastTargetslot,
2147            LastUseitem,
2148            LastUseslot,
2149        ]);
2150        add(
2151            "npc_arrivedelay",
2152            &[ActiveNpc],
2153            &[],
2154            &corrupt,
2155            &[ActiveNpc2],
2156            &[],
2157            &[],
2158            false,
2159        );
2160    }
2161    add(
2162        "npc_inrange",
2163        &[ActiveNpc],
2164        &[],
2165        &[],
2166        &[ActiveNpc2],
2167        &[],
2168        &[],
2169        false,
2170    );
2171
2172    // -----------------------------------------------------------------------
2173    // Loc ops
2174    // -----------------------------------------------------------------------
2175    add(
2176        "loc_add",
2177        &[],
2178        &[ActiveLoc],
2179        &[],
2180        &[],
2181        &[ActiveLoc2],
2182        &[],
2183        false,
2184    );
2185    add(
2186        "loc_angle",
2187        &[ActiveLoc],
2188        &[],
2189        &[],
2190        &[ActiveLoc2],
2191        &[],
2192        &[],
2193        false,
2194    );
2195    add(
2196        "loc_anim",
2197        &[ActiveLoc],
2198        &[],
2199        &[],
2200        &[ActiveLoc2],
2201        &[],
2202        &[],
2203        false,
2204    );
2205    add(
2206        "loc_category",
2207        &[ActiveLoc],
2208        &[],
2209        &[],
2210        &[ActiveLoc2],
2211        &[],
2212        &[],
2213        false,
2214    );
2215    add(
2216        "loc_change",
2217        &[ActiveLoc],
2218        &[],
2219        &[],
2220        &[ActiveLoc2],
2221        &[],
2222        &[],
2223        false,
2224    );
2225    add(
2226        "loc_coord",
2227        &[ActiveLoc],
2228        &[],
2229        &[],
2230        &[ActiveLoc2],
2231        &[],
2232        &[],
2233        false,
2234    );
2235    add(
2236        "loc_del",
2237        &[ActiveLoc],
2238        &[],
2239        &[],
2240        &[ActiveLoc2],
2241        &[],
2242        &[],
2243        false,
2244    );
2245    add(
2246        "loc_find",
2247        &[],
2248        &[ActiveLoc],
2249        &[],
2250        &[],
2251        &[ActiveLoc2],
2252        &[],
2253        true,
2254    );
2255    add(
2256        "loc_findallzone",
2257        &[],
2258        &[FindLoc],
2259        &[],
2260        &[],
2261        &[FindLoc],
2262        &[],
2263        false,
2264    );
2265    add(
2266        "loc_findnext",
2267        &[FindLoc],
2268        &[ActiveLoc],
2269        &[],
2270        &[FindLoc],
2271        &[ActiveLoc2],
2272        &[],
2273        true,
2274    );
2275    add(
2276        "loc_name",
2277        &[ActiveLoc],
2278        &[],
2279        &[],
2280        &[ActiveLoc2],
2281        &[],
2282        &[],
2283        false,
2284    );
2285    add(
2286        "loc_param",
2287        &[ActiveLoc],
2288        &[],
2289        &[],
2290        &[ActiveLoc2],
2291        &[],
2292        &[],
2293        false,
2294    );
2295    add(
2296        "loc_shape",
2297        &[ActiveLoc],
2298        &[],
2299        &[],
2300        &[ActiveLoc2],
2301        &[],
2302        &[],
2303        false,
2304    );
2305    add(
2306        "loc_type",
2307        &[ActiveLoc],
2308        &[],
2309        &[],
2310        &[ActiveLoc2],
2311        &[],
2312        &[],
2313        false,
2314    );
2315
2316    // -----------------------------------------------------------------------
2317    // Obj ops
2318    // -----------------------------------------------------------------------
2319    add(
2320        "obj_add",
2321        &[ActivePlayer],
2322        &[ActiveObj],
2323        &[],
2324        &[ActivePlayer2],
2325        &[ActiveObj2],
2326        &[],
2327        false,
2328    );
2329    add(
2330        "obj_addall",
2331        &[],
2332        &[ActiveObj],
2333        &[],
2334        &[],
2335        &[ActiveObj2],
2336        &[],
2337        false,
2338    );
2339    add(
2340        "obj_coord",
2341        &[ActiveObj],
2342        &[],
2343        &[],
2344        &[ActiveObj2],
2345        &[],
2346        &[],
2347        false,
2348    );
2349    add(
2350        "obj_count",
2351        &[ActiveObj],
2352        &[],
2353        &[],
2354        &[ActiveObj2],
2355        &[],
2356        &[],
2357        false,
2358    );
2359    add(
2360        "obj_del",
2361        &[ActiveObj],
2362        &[],
2363        &[],
2364        &[ActiveObj2],
2365        &[],
2366        &[],
2367        false,
2368    );
2369    add(
2370        "obj_name",
2371        &[ActiveObj],
2372        &[],
2373        &[],
2374        &[ActiveObj2],
2375        &[],
2376        &[],
2377        false,
2378    );
2379    add(
2380        "obj_param",
2381        &[ActiveObj],
2382        &[],
2383        &[],
2384        &[ActiveObj2],
2385        &[],
2386        &[],
2387        false,
2388    );
2389    add(
2390        "obj_getvar",
2391        &[ActiveObj],
2392        &[],
2393        &[],
2394        &[ActiveObj2],
2395        &[],
2396        &[],
2397        false,
2398    );
2399    add(
2400        "obj_setvar",
2401        &[ActiveObj],
2402        &[],
2403        &[],
2404        &[ActiveObj2],
2405        &[],
2406        &[],
2407        false,
2408    );
2409    add(
2410        "obj_takeitem",
2411        &[ActiveObj, ActivePlayer],
2412        &[],
2413        &[],
2414        &[ActiveObj2, ActivePlayer2],
2415        &[],
2416        &[],
2417        false,
2418    );
2419    add(
2420        "obj_type",
2421        &[ActiveObj],
2422        &[],
2423        &[],
2424        &[ActiveObj2],
2425        &[],
2426        &[],
2427        false,
2428    );
2429    add(
2430        "obj_find",
2431        &[],
2432        &[ActiveObj],
2433        &[],
2434        &[],
2435        &[ActiveObj2],
2436        &[],
2437        false,
2438    );
2439    add(
2440        "obj_findallzone",
2441        &[],
2442        &[FindObj],
2443        &[],
2444        &[],
2445        &[FindObj],
2446        &[],
2447        false,
2448    );
2449    add(
2450        "obj_findnext",
2451        &[FindObj],
2452        &[ActiveObj],
2453        &[],
2454        &[FindObj],
2455        &[ActiveObj2],
2456        &[],
2457        true,
2458    );
2459
2460    // -----------------------------------------------------------------------
2461    // Inventory ops
2462    // -----------------------------------------------------------------------
2463    add(
2464        "inv_add",
2465        &[ActivePlayer],
2466        &[],
2467        &[],
2468        &[ActivePlayer2],
2469        &[],
2470        &[],
2471        false,
2472    );
2473    add(
2474        "inv_changeslot",
2475        &[ActivePlayer],
2476        &[],
2477        &[],
2478        &[ActivePlayer2],
2479        &[],
2480        &[],
2481        false,
2482    );
2483    add(
2484        "inv_clear",
2485        &[ActivePlayer],
2486        &[],
2487        &[],
2488        &[ActivePlayer2],
2489        &[],
2490        &[],
2491        false,
2492    );
2493    add(
2494        "inv_del",
2495        &[ActivePlayer],
2496        &[],
2497        &[],
2498        &[ActivePlayer2],
2499        &[],
2500        &[],
2501        false,
2502    );
2503    add(
2504        "inv_delslot",
2505        &[ActivePlayer],
2506        &[],
2507        &[],
2508        &[ActivePlayer2],
2509        &[],
2510        &[],
2511        false,
2512    );
2513    add(
2514        "inv_dropitem",
2515        &[ActivePlayer],
2516        &[ActiveObj],
2517        &[],
2518        &[ActivePlayer2],
2519        &[ActiveObj2],
2520        &[],
2521        false,
2522    );
2523    add(
2524        "inv_dropitem_delayed",
2525        &[ActivePlayer],
2526        &[ActiveObj],
2527        &[],
2528        &[ActivePlayer2],
2529        &[ActiveObj2],
2530        &[],
2531        false,
2532    );
2533    add(
2534        "inv_dropslot",
2535        &[ActivePlayer],
2536        &[ActiveObj],
2537        &[],
2538        &[ActivePlayer2],
2539        &[ActiveObj2],
2540        &[],
2541        false,
2542    );
2543    add(
2544        "inv_freespace",
2545        &[ActivePlayer],
2546        &[],
2547        &[],
2548        &[ActivePlayer2],
2549        &[],
2550        &[],
2551        false,
2552    );
2553    add(
2554        "inv_getnum",
2555        &[ActivePlayer],
2556        &[],
2557        &[],
2558        &[ActivePlayer2],
2559        &[],
2560        &[],
2561        false,
2562    );
2563    add(
2564        "inv_getobj",
2565        &[ActivePlayer],
2566        &[],
2567        &[],
2568        &[ActivePlayer2],
2569        &[],
2570        &[],
2571        false,
2572    );
2573    add(
2574        "inv_getvar",
2575        &[ActivePlayer],
2576        &[],
2577        &[],
2578        &[ActivePlayer2],
2579        &[],
2580        &[],
2581        false,
2582    );
2583    add(
2584        "inv_itemspace",
2585        &[ActivePlayer],
2586        &[],
2587        &[],
2588        &[ActivePlayer2],
2589        &[],
2590        &[],
2591        false,
2592    );
2593    add(
2594        "inv_itemspace2",
2595        &[ActivePlayer],
2596        &[],
2597        &[],
2598        &[ActivePlayer2],
2599        &[],
2600        &[],
2601        false,
2602    );
2603    add(
2604        "inv_movefromslot",
2605        &[ActivePlayer],
2606        &[],
2607        &[],
2608        &[ActivePlayer2],
2609        &[],
2610        &[],
2611        false,
2612    );
2613    add(
2614        "inv_movetoslot",
2615        &[ActivePlayer],
2616        &[],
2617        &[],
2618        &[ActivePlayer2],
2619        &[],
2620        &[],
2621        false,
2622    );
2623    add(
2624        "both_moveinv",
2625        &[ActivePlayer, ActivePlayer2],
2626        &[],
2627        &[],
2628        &[ActivePlayer2, ActivePlayer],
2629        &[],
2630        &[],
2631        false,
2632    );
2633    add(
2634        "inv_moveitem",
2635        &[ActivePlayer],
2636        &[],
2637        &[],
2638        &[ActivePlayer2],
2639        &[],
2640        &[],
2641        false,
2642    );
2643    add(
2644        "inv_moveitem_cert",
2645        &[ActivePlayer],
2646        &[],
2647        &[],
2648        &[ActivePlayer2],
2649        &[],
2650        &[],
2651        false,
2652    );
2653    add(
2654        "inv_moveitem_uncert",
2655        &[ActivePlayer],
2656        &[],
2657        &[],
2658        &[ActivePlayer2],
2659        &[],
2660        &[],
2661        false,
2662    );
2663    add(
2664        "inv_setslot",
2665        &[ActivePlayer],
2666        &[],
2667        &[],
2668        &[ActivePlayer2],
2669        &[],
2670        &[],
2671        false,
2672    );
2673    add(
2674        "inv_setvar",
2675        &[ActivePlayer],
2676        &[],
2677        &[],
2678        &[ActivePlayer2],
2679        &[],
2680        &[],
2681        false,
2682    );
2683    add(
2684        "inv_total",
2685        &[ActivePlayer],
2686        &[],
2687        &[],
2688        &[ActivePlayer2],
2689        &[],
2690        &[],
2691        false,
2692    );
2693    add(
2694        "inv_totalcat",
2695        &[ActivePlayer],
2696        &[],
2697        &[],
2698        &[ActivePlayer2],
2699        &[],
2700        &[],
2701        false,
2702    );
2703    add(
2704        "inv_transmit",
2705        &[ActivePlayer],
2706        &[],
2707        &[],
2708        &[ActivePlayer2],
2709        &[],
2710        &[],
2711        false,
2712    );
2713    add(
2714        "invother_transmit",
2715        &[ActivePlayer, ActivePlayer2],
2716        &[],
2717        &[],
2718        &[ActivePlayer2, ActivePlayer],
2719        &[],
2720        &[],
2721        false,
2722    );
2723    add(
2724        "inv_stoptransmit",
2725        &[ActivePlayer],
2726        &[],
2727        &[],
2728        &[ActivePlayer2],
2729        &[],
2730        &[],
2731        false,
2732    );
2733    add(
2734        "both_dropslot",
2735        &[ActivePlayer, ActivePlayer2],
2736        &[],
2737        &[],
2738        &[ActivePlayer2, ActivePlayer],
2739        &[],
2740        &[],
2741        false,
2742    );
2743    add(
2744        "inv_dropall",
2745        &[ActivePlayer],
2746        &[],
2747        &[],
2748        &[ActivePlayer2],
2749        &[],
2750        &[],
2751        false,
2752    );
2753    add(
2754        "inv_totalparam",
2755        &[ActivePlayer],
2756        &[],
2757        &[],
2758        &[ActivePlayer2],
2759        &[],
2760        &[],
2761        false,
2762    );
2763    add(
2764        "inv_totalparam_stack",
2765        &[ActivePlayer],
2766        &[],
2767        &[],
2768        &[ActivePlayer2],
2769        &[],
2770        &[],
2771        false,
2772    );
2773
2774    // -----------------------------------------------------------------------
2775    // String ops
2776    // -----------------------------------------------------------------------
2777    add(
2778        "text_gender",
2779        &[ActivePlayer],
2780        &[],
2781        &[],
2782        &[ActivePlayer2],
2783        &[],
2784        &[],
2785        false,
2786    );
2787
2788    // -----------------------------------------------------------------------
2789    // DB ops
2790    // -----------------------------------------------------------------------
2791    add("db_findnext", &[FindDb], &[], &[], &[], &[], &[], false);
2792    add("db_find", &[], &[FindDb], &[], &[], &[], &[], false);
2793    add("db_find_refine", &[FindDb], &[], &[], &[], &[], &[], false);
2794    add("db_listall", &[], &[FindDb], &[], &[], &[], &[], false);
2795    add(
2796        "db_listall_with_count",
2797        &[],
2798        &[FindDb],
2799        &[],
2800        &[],
2801        &[],
2802        &[],
2803        false,
2804    );
2805
2806    map
2807}