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    add(
1177        "p_finduid",
1178        &[],
1179        &[PActivePlayer, ActivePlayer],
1180        &[],
1181        &[],
1182        &[PActivePlayer2, ActivePlayer2],
1183        &[],
1184        true,
1185    );
1186    add(
1187        "p_locmerge",
1188        &[PActivePlayer],
1189        &[],
1190        &[],
1191        &[],
1192        &[],
1193        &[],
1194        false,
1195    );
1196    add("p_logout", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1197    add(
1198        "p_preventlogout",
1199        &[PActivePlayer],
1200        &[],
1201        &[],
1202        &[PActivePlayer2],
1203        &[],
1204        &[],
1205        false,
1206    );
1207    add("p_opheld", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1208    add(
1209        "p_oploc",
1210        &[PActivePlayer, ActiveLoc],
1211        &[],
1212        &[],
1213        &[],
1214        &[],
1215        &[],
1216        false,
1217    );
1218    add(
1219        "p_opnpc",
1220        &[PActivePlayer, ActiveNpc],
1221        &[],
1222        &[],
1223        &[],
1224        &[],
1225        &[],
1226        false,
1227    );
1228    add(
1229        "p_opnpct",
1230        &[PActivePlayer, ActiveNpc],
1231        &[],
1232        &[],
1233        &[],
1234        &[],
1235        &[],
1236        false,
1237    );
1238    add(
1239        "p_opobj",
1240        &[PActivePlayer, ActiveObj],
1241        &[],
1242        &[],
1243        &[],
1244        &[],
1245        &[],
1246        false,
1247    );
1248    add(
1249        "p_opplayer",
1250        &[PActivePlayer, ActivePlayer2],
1251        &[],
1252        &[],
1253        &[PActivePlayer2, ActivePlayer],
1254        &[],
1255        &[],
1256        false,
1257    );
1258    add(
1259        "p_opplayert",
1260        &[PActivePlayer, ActivePlayer2],
1261        &[],
1262        &[],
1263        &[PActivePlayer2, ActivePlayer],
1264        &[],
1265        &[],
1266        false,
1267    );
1268    {
1269        // p_pausebutton: sets last_com, corrupts everything except active + last_com
1270        let mut corrupt = delay_corrupt.clone();
1271        corrupt.retain(|p| *p != LastCom);
1272        add(
1273            "p_pausebutton",
1274            &[PActivePlayer],
1275            &[LastCom],
1276            &corrupt,
1277            &[],
1278            &[],
1279            &[],
1280            false,
1281        );
1282    }
1283    add(
1284        "p_stopaction",
1285        &[PActivePlayer],
1286        &[],
1287        &[],
1288        &[PActivePlayer2],
1289        &[],
1290        &[],
1291        false,
1292    );
1293    add(
1294        "p_clearpendingaction",
1295        &[PActivePlayer],
1296        &[],
1297        &[],
1298        &[PActivePlayer2],
1299        &[],
1300        &[],
1301        false,
1302    );
1303    add(
1304        "p_telejump",
1305        &[PActivePlayer],
1306        &[],
1307        &[],
1308        &[PActivePlayer2],
1309        &[],
1310        &[],
1311        false,
1312    );
1313    add(
1314        "p_teleport",
1315        &[PActivePlayer],
1316        &[],
1317        &[],
1318        &[PActivePlayer2],
1319        &[],
1320        &[],
1321        false,
1322    );
1323    add(
1324        "p_walk",
1325        &[PActivePlayer],
1326        &[],
1327        &[],
1328        &[PActivePlayer2],
1329        &[],
1330        &[],
1331        false,
1332    );
1333    add(
1334        "projanim_pl",
1335        &[ActivePlayer],
1336        &[],
1337        &[],
1338        &[ActivePlayer2],
1339        &[],
1340        &[],
1341        false,
1342    );
1343    add(
1344        "queue",
1345        &[ActivePlayer],
1346        &[],
1347        &[],
1348        &[ActivePlayer2],
1349        &[],
1350        &[],
1351        false,
1352    );
1353    add(
1354        "queue*",
1355        &[ActivePlayer],
1356        &[],
1357        &[],
1358        &[ActivePlayer2],
1359        &[],
1360        &[],
1361        false,
1362    );
1363    add(
1364        "say",
1365        &[ActivePlayer],
1366        &[],
1367        &[],
1368        &[ActivePlayer2],
1369        &[],
1370        &[],
1371        false,
1372    );
1373    add("setidkit", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1374    add(
1375        "walktrigger",
1376        &[ActivePlayer],
1377        &[],
1378        &[],
1379        &[ActivePlayer2],
1380        &[],
1381        &[],
1382        false,
1383    );
1384    add(
1385        "getwalktrigger",
1386        &[ActivePlayer],
1387        &[],
1388        &[],
1389        &[ActivePlayer2],
1390        &[],
1391        &[],
1392        false,
1393    );
1394    add(
1395        "settimer",
1396        &[ActivePlayer],
1397        &[],
1398        &[],
1399        &[ActivePlayer2],
1400        &[],
1401        &[],
1402        false,
1403    );
1404    add(
1405        "softtimer",
1406        &[ActivePlayer],
1407        &[],
1408        &[],
1409        &[ActivePlayer2],
1410        &[],
1411        &[],
1412        false,
1413    );
1414    add(
1415        "sound_synth",
1416        &[ActivePlayer],
1417        &[],
1418        &[],
1419        &[ActivePlayer2],
1420        &[],
1421        &[],
1422        false,
1423    );
1424    add(
1425        "spotanim_pl",
1426        &[ActivePlayer],
1427        &[],
1428        &[],
1429        &[ActivePlayer2],
1430        &[],
1431        &[],
1432        false,
1433    );
1434    add(
1435        "staffmodlevel",
1436        &[ActivePlayer],
1437        &[],
1438        &[],
1439        &[ActivePlayer2],
1440        &[],
1441        &[],
1442        false,
1443    );
1444    add(
1445        "stat",
1446        &[ActivePlayer],
1447        &[],
1448        &[],
1449        &[ActivePlayer2],
1450        &[],
1451        &[],
1452        false,
1453    );
1454    add(
1455        "stat_add",
1456        &[ActivePlayer],
1457        &[],
1458        &[],
1459        &[ActivePlayer2],
1460        &[],
1461        &[],
1462        false,
1463    );
1464    add(
1465        "stat_base",
1466        &[ActivePlayer],
1467        &[],
1468        &[],
1469        &[ActivePlayer2],
1470        &[],
1471        &[],
1472        false,
1473    );
1474    add(
1475        "stat_heal",
1476        &[ActivePlayer],
1477        &[],
1478        &[],
1479        &[ActivePlayer2],
1480        &[],
1481        &[],
1482        false,
1483    );
1484    add(
1485        "stat_sub",
1486        &[ActivePlayer],
1487        &[],
1488        &[],
1489        &[ActivePlayer2],
1490        &[],
1491        &[],
1492        false,
1493    );
1494    add(
1495        "stat_boost",
1496        &[ActivePlayer],
1497        &[],
1498        &[],
1499        &[ActivePlayer2],
1500        &[],
1501        &[],
1502        false,
1503    );
1504    add(
1505        "stat_drain",
1506        &[ActivePlayer],
1507        &[],
1508        &[],
1509        &[ActivePlayer2],
1510        &[],
1511        &[],
1512        false,
1513    );
1514    add(
1515        "stat_random",
1516        &[ActivePlayer],
1517        &[],
1518        &[],
1519        &[ActivePlayer2],
1520        &[],
1521        &[],
1522        false,
1523    );
1524    add(
1525        "uid",
1526        &[ActivePlayer],
1527        &[],
1528        &[],
1529        &[ActivePlayer2],
1530        &[],
1531        &[],
1532        false,
1533    );
1534    add(
1535        "weakqueue",
1536        &[ActivePlayer],
1537        &[],
1538        &[],
1539        &[ActivePlayer2],
1540        &[],
1541        &[],
1542        false,
1543    );
1544    add(
1545        "weakqueue*",
1546        &[ActivePlayer],
1547        &[],
1548        &[],
1549        &[ActivePlayer2],
1550        &[],
1551        &[],
1552        false,
1553    );
1554    add(
1555        "findhero",
1556        &[],
1557        &[ActivePlayer2],
1558        &[],
1559        &[],
1560        &[ActivePlayer],
1561        &[],
1562        true,
1563    );
1564    add(
1565        "both_heropoints",
1566        &[ActivePlayer, ActivePlayer2],
1567        &[],
1568        &[],
1569        &[ActivePlayer2, ActivePlayer],
1570        &[],
1571        &[],
1572        false,
1573    );
1574    add(
1575        "setgender",
1576        &[PActivePlayer],
1577        &[],
1578        &[],
1579        &[],
1580        &[],
1581        &[],
1582        false,
1583    );
1584    add(
1585        "setidkcolour",
1586        &[PActivePlayer],
1587        &[],
1588        &[],
1589        &[],
1590        &[],
1591        &[],
1592        false,
1593    );
1594    add(
1595        "p_animprotect",
1596        &[PActivePlayer],
1597        &[],
1598        &[],
1599        &[PActivePlayer2],
1600        &[],
1601        &[],
1602        false,
1603    );
1604    add(
1605        "runenergy",
1606        &[ActivePlayer],
1607        &[],
1608        &[],
1609        &[ActivePlayer2],
1610        &[],
1611        &[],
1612        false,
1613    );
1614    add(
1615        "weight",
1616        &[PActivePlayer],
1617        &[],
1618        &[],
1619        &[PActivePlayer2],
1620        &[],
1621        &[],
1622        false,
1623    );
1624    add(
1625        "p_run",
1626        &[PActivePlayer],
1627        &[],
1628        &[],
1629        &[PActivePlayer2],
1630        &[],
1631        &[],
1632        false,
1633    );
1634    add(
1635        "if_setscrollpos",
1636        &[ActivePlayer],
1637        &[],
1638        &[],
1639        &[],
1640        &[],
1641        &[],
1642        false,
1643    );
1644    add(
1645        "if_movesub",
1646        &[ActivePlayer],
1647        &[],
1648        &[],
1649        &[],
1650        &[],
1651        &[],
1652        false,
1653    );
1654    add(
1655        "set_player_op",
1656        &[ActivePlayer],
1657        &[],
1658        &[],
1659        &[],
1660        &[],
1661        &[],
1662        false,
1663    );
1664    add(
1665        "set_skill_level",
1666        &[ActivePlayer],
1667        &[],
1668        &[],
1669        &[ActivePlayer2],
1670        &[],
1671        &[],
1672        false,
1673    );
1674    add(
1675        "strongqueue",
1676        &[ActivePlayer],
1677        &[],
1678        &[],
1679        &[ActivePlayer2],
1680        &[],
1681        &[],
1682        false,
1683    );
1684    add(
1685        "strongqueue*",
1686        &[ActivePlayer],
1687        &[],
1688        &[],
1689        &[ActivePlayer2],
1690        &[],
1691        &[],
1692        false,
1693    );
1694
1695    // -----------------------------------------------------------------------
1696    // NPC ops
1697    // -----------------------------------------------------------------------
1698    add(
1699        "npc_add",
1700        &[],
1701        &[ActiveNpc],
1702        &[],
1703        &[],
1704        &[ActiveNpc2],
1705        &[],
1706        false,
1707    );
1708    add(
1709        "npc_anim",
1710        &[ActiveNpc],
1711        &[],
1712        &[],
1713        &[ActiveNpc2],
1714        &[],
1715        &[],
1716        false,
1717    );
1718    add(
1719        "npc_basestat",
1720        &[ActiveNpc],
1721        &[],
1722        &[],
1723        &[ActiveNpc2],
1724        &[],
1725        &[],
1726        false,
1727    );
1728    add(
1729        "npc_category",
1730        &[ActiveNpc],
1731        &[],
1732        &[],
1733        &[ActiveNpc2],
1734        &[],
1735        &[],
1736        false,
1737    );
1738    add(
1739        "npc_changetype",
1740        &[ActiveNpc],
1741        &[],
1742        &[],
1743        &[ActiveNpc2],
1744        &[],
1745        &[],
1746        false,
1747    );
1748    add(
1749        "npc_changetype_keepall",
1750        &[ActiveNpc],
1751        &[],
1752        &[],
1753        &[ActiveNpc2],
1754        &[],
1755        &[],
1756        false,
1757    );
1758    add(
1759        "npc_coord",
1760        &[ActiveNpc],
1761        &[],
1762        &[],
1763        &[ActiveNpc2],
1764        &[],
1765        &[],
1766        false,
1767    );
1768    add(
1769        "npc_damage",
1770        &[ActiveNpc],
1771        &[],
1772        &[],
1773        &[ActiveNpc2],
1774        &[],
1775        &[],
1776        false,
1777    );
1778    add(
1779        "npc_del",
1780        &[ActiveNpc],
1781        &[],
1782        &[],
1783        &[ActiveNpc2],
1784        &[],
1785        &[],
1786        false,
1787    );
1788    {
1789        // npc_delay: corrupts p_active_player, p_active_player2, find_*, last_*
1790        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
1791        corrupt.extend_from_slice(find_group);
1792        corrupt.extend_from_slice(&[
1793            LastCom,
1794            LastInt,
1795            LastItem,
1796            LastSlot,
1797            LastTargetslot,
1798            LastUseitem,
1799            LastUseslot,
1800        ]);
1801        add(
1802            "npc_delay",
1803            &[ActiveNpc],
1804            &[],
1805            &corrupt,
1806            &[ActiveNpc2],
1807            &[],
1808            &[],
1809            false,
1810        );
1811    }
1812    add(
1813        "npc_facesquare",
1814        &[ActiveNpc],
1815        &[],
1816        &[],
1817        &[ActiveNpc2],
1818        &[],
1819        &[],
1820        false,
1821    );
1822    add(
1823        "npc_find",
1824        &[],
1825        &[ActiveNpc],
1826        &[],
1827        &[],
1828        &[ActiveNpc2],
1829        &[],
1830        true,
1831    );
1832    add(
1833        "npc_findcat",
1834        &[],
1835        &[ActiveNpc],
1836        &[],
1837        &[],
1838        &[ActiveNpc2],
1839        &[],
1840        true,
1841    );
1842    add("npc_findallany", &[], &[FindNpc], &[], &[], &[], &[], false);
1843    add("npc_findall", &[], &[FindNpc], &[], &[], &[], &[], false);
1844    add(
1845        "npc_findallzone",
1846        &[],
1847        &[FindNpc],
1848        &[],
1849        &[],
1850        &[],
1851        &[],
1852        false,
1853    );
1854    add(
1855        "npc_findnext",
1856        &[FindNpc],
1857        &[ActiveNpc],
1858        &[],
1859        &[],
1860        &[ActiveNpc2],
1861        &[],
1862        true,
1863    );
1864    add(
1865        "npc_findexact",
1866        &[],
1867        &[ActiveNpc],
1868        &[],
1869        &[],
1870        &[ActiveNpc2],
1871        &[],
1872        true,
1873    );
1874    add(
1875        "npc_findhero",
1876        &[ActiveNpc],
1877        &[ActivePlayer],
1878        &[],
1879        &[ActiveNpc2],
1880        &[ActivePlayer2],
1881        &[],
1882        true,
1883    );
1884    add(
1885        "npc_finduid",
1886        &[],
1887        &[ActiveNpc],
1888        &[],
1889        &[],
1890        &[ActiveNpc2],
1891        &[],
1892        true,
1893    );
1894    add(
1895        "npc_getmode",
1896        &[ActiveNpc],
1897        &[],
1898        &[],
1899        &[ActiveNpc2],
1900        &[],
1901        &[],
1902        false,
1903    );
1904    add(
1905        "npc_heropoints",
1906        &[ActiveNpc, ActivePlayer],
1907        &[],
1908        &[],
1909        &[],
1910        &[],
1911        &[],
1912        false,
1913    );
1914    add(
1915        "npc_name",
1916        &[ActiveNpc],
1917        &[],
1918        &[],
1919        &[ActiveNpc2],
1920        &[],
1921        &[],
1922        false,
1923    );
1924    add(
1925        "npc_param",
1926        &[ActiveNpc],
1927        &[],
1928        &[],
1929        &[ActiveNpc2],
1930        &[],
1931        &[],
1932        false,
1933    );
1934    add(
1935        "npc_queue",
1936        &[ActiveNpc],
1937        &[],
1938        &[],
1939        &[ActiveNpc2],
1940        &[],
1941        &[],
1942        false,
1943    );
1944    add(
1945        "npc_range",
1946        &[ActiveNpc],
1947        &[],
1948        &[],
1949        &[ActiveNpc2],
1950        &[],
1951        &[],
1952        false,
1953    );
1954    add(
1955        "npc_say",
1956        &[ActiveNpc],
1957        &[],
1958        &[],
1959        &[ActiveNpc2],
1960        &[],
1961        &[],
1962        false,
1963    );
1964    add(
1965        "npc_sethunt",
1966        &[ActiveNpc],
1967        &[],
1968        &[],
1969        &[ActiveNpc2],
1970        &[],
1971        &[],
1972        false,
1973    );
1974    add(
1975        "npc_sethuntmode",
1976        &[ActiveNpc],
1977        &[],
1978        &[],
1979        &[ActiveNpc2],
1980        &[],
1981        &[],
1982        false,
1983    );
1984    add(
1985        "npc_setmode",
1986        &[ActiveNpc],
1987        &[],
1988        &[],
1989        &[ActiveNpc2],
1990        &[],
1991        &[],
1992        false,
1993    );
1994    add(
1995        "npc_walktrigger",
1996        &[ActiveNpc],
1997        &[],
1998        &[],
1999        &[ActiveNpc2],
2000        &[],
2001        &[],
2002        false,
2003    );
2004    add(
2005        "npc_settimer",
2006        &[ActiveNpc],
2007        &[],
2008        &[],
2009        &[ActiveNpc2],
2010        &[],
2011        &[],
2012        false,
2013    );
2014    add(
2015        "npc_stat",
2016        &[ActiveNpc],
2017        &[],
2018        &[],
2019        &[ActiveNpc2],
2020        &[],
2021        &[],
2022        false,
2023    );
2024    add(
2025        "npc_statadd",
2026        &[ActiveNpc],
2027        &[],
2028        &[],
2029        &[ActiveNpc2],
2030        &[],
2031        &[],
2032        false,
2033    );
2034    add(
2035        "npc_statheal",
2036        &[ActiveNpc],
2037        &[],
2038        &[],
2039        &[ActiveNpc2],
2040        &[],
2041        &[],
2042        false,
2043    );
2044    add(
2045        "npc_statsub",
2046        &[ActiveNpc],
2047        &[],
2048        &[],
2049        &[ActiveNpc2],
2050        &[],
2051        &[],
2052        false,
2053    );
2054    add(
2055        "npc_tele",
2056        &[ActiveNpc],
2057        &[],
2058        &[],
2059        &[ActiveNpc2],
2060        &[],
2061        &[],
2062        false,
2063    );
2064    add(
2065        "npc_type",
2066        &[ActiveNpc],
2067        &[],
2068        &[],
2069        &[ActiveNpc2],
2070        &[],
2071        &[],
2072        false,
2073    );
2074    add(
2075        "npc_uid",
2076        &[ActiveNpc],
2077        &[],
2078        &[],
2079        &[ActiveNpc2],
2080        &[],
2081        &[],
2082        false,
2083    );
2084    add(
2085        "projanim_npc",
2086        &[ActiveNpc],
2087        &[],
2088        &[],
2089        &[ActiveNpc2],
2090        &[],
2091        &[],
2092        false,
2093    );
2094    add(
2095        "spotanim_npc",
2096        &[ActiveNpc],
2097        &[],
2098        &[],
2099        &[ActiveNpc2],
2100        &[],
2101        &[],
2102        false,
2103    );
2104    add(
2105        "npc_walk",
2106        &[ActiveNpc],
2107        &[],
2108        &[],
2109        &[ActiveNpc2],
2110        &[],
2111        &[],
2112        false,
2113    );
2114    add(
2115        "npc_attackrange",
2116        &[ActiveNpc],
2117        &[],
2118        &[],
2119        &[ActiveNpc2],
2120        &[],
2121        &[],
2122        false,
2123    );
2124    {
2125        // npc_arrivedelay: same corruption set as npc_delay
2126        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
2127        corrupt.extend_from_slice(find_group);
2128        corrupt.extend_from_slice(&[
2129            LastCom,
2130            LastInt,
2131            LastItem,
2132            LastSlot,
2133            LastTargetslot,
2134            LastUseitem,
2135            LastUseslot,
2136        ]);
2137        add(
2138            "npc_arrivedelay",
2139            &[ActiveNpc],
2140            &[],
2141            &corrupt,
2142            &[ActiveNpc2],
2143            &[],
2144            &[],
2145            false,
2146        );
2147    }
2148    add(
2149        "npc_inrange",
2150        &[ActiveNpc],
2151        &[],
2152        &[],
2153        &[ActiveNpc2],
2154        &[],
2155        &[],
2156        false,
2157    );
2158
2159    // -----------------------------------------------------------------------
2160    // Loc ops
2161    // -----------------------------------------------------------------------
2162    add(
2163        "loc_add",
2164        &[],
2165        &[ActiveLoc],
2166        &[],
2167        &[],
2168        &[ActiveLoc2],
2169        &[],
2170        false,
2171    );
2172    add(
2173        "loc_angle",
2174        &[ActiveLoc],
2175        &[],
2176        &[],
2177        &[ActiveLoc2],
2178        &[],
2179        &[],
2180        false,
2181    );
2182    add(
2183        "loc_anim",
2184        &[ActiveLoc],
2185        &[],
2186        &[],
2187        &[ActiveLoc2],
2188        &[],
2189        &[],
2190        false,
2191    );
2192    add(
2193        "loc_category",
2194        &[ActiveLoc],
2195        &[],
2196        &[],
2197        &[ActiveLoc2],
2198        &[],
2199        &[],
2200        false,
2201    );
2202    add(
2203        "loc_change",
2204        &[ActiveLoc],
2205        &[],
2206        &[],
2207        &[ActiveLoc2],
2208        &[],
2209        &[],
2210        false,
2211    );
2212    add(
2213        "loc_coord",
2214        &[ActiveLoc],
2215        &[],
2216        &[],
2217        &[ActiveLoc2],
2218        &[],
2219        &[],
2220        false,
2221    );
2222    add(
2223        "loc_del",
2224        &[ActiveLoc],
2225        &[],
2226        &[],
2227        &[ActiveLoc2],
2228        &[],
2229        &[],
2230        false,
2231    );
2232    add(
2233        "loc_find",
2234        &[],
2235        &[ActiveLoc],
2236        &[],
2237        &[],
2238        &[ActiveLoc2],
2239        &[],
2240        true,
2241    );
2242    add(
2243        "loc_findallzone",
2244        &[],
2245        &[FindLoc],
2246        &[],
2247        &[],
2248        &[FindLoc],
2249        &[],
2250        false,
2251    );
2252    add(
2253        "loc_findnext",
2254        &[FindLoc],
2255        &[ActiveLoc],
2256        &[],
2257        &[FindLoc],
2258        &[ActiveLoc2],
2259        &[],
2260        true,
2261    );
2262    add(
2263        "loc_name",
2264        &[ActiveLoc],
2265        &[],
2266        &[],
2267        &[ActiveLoc2],
2268        &[],
2269        &[],
2270        false,
2271    );
2272    add(
2273        "loc_param",
2274        &[ActiveLoc],
2275        &[],
2276        &[],
2277        &[ActiveLoc2],
2278        &[],
2279        &[],
2280        false,
2281    );
2282    add(
2283        "loc_shape",
2284        &[ActiveLoc],
2285        &[],
2286        &[],
2287        &[ActiveLoc2],
2288        &[],
2289        &[],
2290        false,
2291    );
2292    add(
2293        "loc_type",
2294        &[ActiveLoc],
2295        &[],
2296        &[],
2297        &[ActiveLoc2],
2298        &[],
2299        &[],
2300        false,
2301    );
2302
2303    // -----------------------------------------------------------------------
2304    // Obj ops
2305    // -----------------------------------------------------------------------
2306    add(
2307        "obj_add",
2308        &[ActivePlayer],
2309        &[ActiveObj],
2310        &[],
2311        &[ActivePlayer2],
2312        &[ActiveObj2],
2313        &[],
2314        false,
2315    );
2316    add(
2317        "obj_addall",
2318        &[],
2319        &[ActiveObj],
2320        &[],
2321        &[],
2322        &[ActiveObj2],
2323        &[],
2324        false,
2325    );
2326    add(
2327        "obj_coord",
2328        &[ActiveObj],
2329        &[],
2330        &[],
2331        &[ActiveObj2],
2332        &[],
2333        &[],
2334        false,
2335    );
2336    add(
2337        "obj_count",
2338        &[ActiveObj],
2339        &[],
2340        &[],
2341        &[ActiveObj2],
2342        &[],
2343        &[],
2344        false,
2345    );
2346    add(
2347        "obj_del",
2348        &[ActiveObj],
2349        &[],
2350        &[],
2351        &[ActiveObj2],
2352        &[],
2353        &[],
2354        false,
2355    );
2356    add(
2357        "obj_name",
2358        &[ActiveObj],
2359        &[],
2360        &[],
2361        &[ActiveObj2],
2362        &[],
2363        &[],
2364        false,
2365    );
2366    add(
2367        "obj_param",
2368        &[ActiveObj],
2369        &[],
2370        &[],
2371        &[ActiveObj2],
2372        &[],
2373        &[],
2374        false,
2375    );
2376    add(
2377        "obj_takeitem",
2378        &[ActiveObj, ActivePlayer],
2379        &[],
2380        &[],
2381        &[ActiveObj2, ActivePlayer2],
2382        &[],
2383        &[],
2384        false,
2385    );
2386    add(
2387        "obj_type",
2388        &[ActiveObj],
2389        &[],
2390        &[],
2391        &[ActiveObj2],
2392        &[],
2393        &[],
2394        false,
2395    );
2396    add(
2397        "obj_find",
2398        &[],
2399        &[ActiveObj],
2400        &[],
2401        &[],
2402        &[ActiveObj2],
2403        &[],
2404        false,
2405    );
2406    add(
2407        "obj_findallzone",
2408        &[],
2409        &[FindObj],
2410        &[],
2411        &[],
2412        &[FindObj],
2413        &[],
2414        false,
2415    );
2416    add(
2417        "obj_findnext",
2418        &[FindObj],
2419        &[ActiveObj],
2420        &[],
2421        &[FindObj],
2422        &[ActiveObj2],
2423        &[],
2424        true,
2425    );
2426
2427    // -----------------------------------------------------------------------
2428    // Inventory ops
2429    // -----------------------------------------------------------------------
2430    add(
2431        "inv_add",
2432        &[ActivePlayer],
2433        &[],
2434        &[],
2435        &[ActivePlayer2],
2436        &[],
2437        &[],
2438        false,
2439    );
2440    add(
2441        "inv_changeslot",
2442        &[ActivePlayer],
2443        &[],
2444        &[],
2445        &[ActivePlayer2],
2446        &[],
2447        &[],
2448        false,
2449    );
2450    add(
2451        "inv_clear",
2452        &[ActivePlayer],
2453        &[],
2454        &[],
2455        &[ActivePlayer2],
2456        &[],
2457        &[],
2458        false,
2459    );
2460    add(
2461        "inv_del",
2462        &[ActivePlayer],
2463        &[],
2464        &[],
2465        &[ActivePlayer2],
2466        &[],
2467        &[],
2468        false,
2469    );
2470    add(
2471        "inv_delslot",
2472        &[ActivePlayer],
2473        &[],
2474        &[],
2475        &[ActivePlayer2],
2476        &[],
2477        &[],
2478        false,
2479    );
2480    add(
2481        "inv_dropitem",
2482        &[ActivePlayer],
2483        &[ActiveObj],
2484        &[],
2485        &[ActivePlayer2],
2486        &[ActiveObj2],
2487        &[],
2488        false,
2489    );
2490    add(
2491        "inv_dropitem_delayed",
2492        &[ActivePlayer],
2493        &[ActiveObj],
2494        &[],
2495        &[ActivePlayer2],
2496        &[ActiveObj2],
2497        &[],
2498        false,
2499    );
2500    add(
2501        "inv_dropslot",
2502        &[ActivePlayer],
2503        &[ActiveObj],
2504        &[],
2505        &[ActivePlayer2],
2506        &[ActiveObj2],
2507        &[],
2508        false,
2509    );
2510    add(
2511        "inv_freespace",
2512        &[ActivePlayer],
2513        &[],
2514        &[],
2515        &[ActivePlayer2],
2516        &[],
2517        &[],
2518        false,
2519    );
2520    add(
2521        "inv_getnum",
2522        &[ActivePlayer],
2523        &[],
2524        &[],
2525        &[ActivePlayer2],
2526        &[],
2527        &[],
2528        false,
2529    );
2530    add(
2531        "inv_getobj",
2532        &[ActivePlayer],
2533        &[],
2534        &[],
2535        &[ActivePlayer2],
2536        &[],
2537        &[],
2538        false,
2539    );
2540    add(
2541        "inv_itemspace",
2542        &[ActivePlayer],
2543        &[],
2544        &[],
2545        &[ActivePlayer2],
2546        &[],
2547        &[],
2548        false,
2549    );
2550    add(
2551        "inv_itemspace2",
2552        &[ActivePlayer],
2553        &[],
2554        &[],
2555        &[ActivePlayer2],
2556        &[],
2557        &[],
2558        false,
2559    );
2560    add(
2561        "inv_movefromslot",
2562        &[ActivePlayer],
2563        &[],
2564        &[],
2565        &[ActivePlayer2],
2566        &[],
2567        &[],
2568        false,
2569    );
2570    add(
2571        "inv_movetoslot",
2572        &[ActivePlayer],
2573        &[],
2574        &[],
2575        &[ActivePlayer2],
2576        &[],
2577        &[],
2578        false,
2579    );
2580    add(
2581        "both_moveinv",
2582        &[ActivePlayer, ActivePlayer2],
2583        &[],
2584        &[],
2585        &[ActivePlayer2, ActivePlayer],
2586        &[],
2587        &[],
2588        false,
2589    );
2590    add(
2591        "inv_moveitem",
2592        &[ActivePlayer],
2593        &[],
2594        &[],
2595        &[ActivePlayer2],
2596        &[],
2597        &[],
2598        false,
2599    );
2600    add(
2601        "inv_moveitem_cert",
2602        &[ActivePlayer],
2603        &[],
2604        &[],
2605        &[ActivePlayer2],
2606        &[],
2607        &[],
2608        false,
2609    );
2610    add(
2611        "inv_moveitem_uncert",
2612        &[ActivePlayer],
2613        &[],
2614        &[],
2615        &[ActivePlayer2],
2616        &[],
2617        &[],
2618        false,
2619    );
2620    add(
2621        "inv_setslot",
2622        &[ActivePlayer],
2623        &[],
2624        &[],
2625        &[ActivePlayer2],
2626        &[],
2627        &[],
2628        false,
2629    );
2630    add(
2631        "inv_total",
2632        &[ActivePlayer],
2633        &[],
2634        &[],
2635        &[ActivePlayer2],
2636        &[],
2637        &[],
2638        false,
2639    );
2640    add(
2641        "inv_totalcat",
2642        &[ActivePlayer],
2643        &[],
2644        &[],
2645        &[ActivePlayer2],
2646        &[],
2647        &[],
2648        false,
2649    );
2650    add(
2651        "inv_transmit",
2652        &[ActivePlayer],
2653        &[],
2654        &[],
2655        &[ActivePlayer2],
2656        &[],
2657        &[],
2658        false,
2659    );
2660    add(
2661        "invother_transmit",
2662        &[ActivePlayer, ActivePlayer2],
2663        &[],
2664        &[],
2665        &[ActivePlayer2, ActivePlayer],
2666        &[],
2667        &[],
2668        false,
2669    );
2670    add(
2671        "inv_stoptransmit",
2672        &[ActivePlayer],
2673        &[],
2674        &[],
2675        &[ActivePlayer2],
2676        &[],
2677        &[],
2678        false,
2679    );
2680    add(
2681        "both_dropslot",
2682        &[ActivePlayer, ActivePlayer2],
2683        &[],
2684        &[],
2685        &[ActivePlayer2, ActivePlayer],
2686        &[],
2687        &[],
2688        false,
2689    );
2690    add(
2691        "inv_dropall",
2692        &[ActivePlayer],
2693        &[],
2694        &[],
2695        &[ActivePlayer2],
2696        &[],
2697        &[],
2698        false,
2699    );
2700    add(
2701        "inv_totalparam",
2702        &[ActivePlayer],
2703        &[],
2704        &[],
2705        &[ActivePlayer2],
2706        &[],
2707        &[],
2708        false,
2709    );
2710    add(
2711        "inv_totalparam_stack",
2712        &[ActivePlayer],
2713        &[],
2714        &[],
2715        &[ActivePlayer2],
2716        &[],
2717        &[],
2718        false,
2719    );
2720
2721    // -----------------------------------------------------------------------
2722    // String ops
2723    // -----------------------------------------------------------------------
2724    add(
2725        "text_gender",
2726        &[ActivePlayer],
2727        &[],
2728        &[],
2729        &[ActivePlayer2],
2730        &[],
2731        &[],
2732        false,
2733    );
2734
2735    // -----------------------------------------------------------------------
2736    // DB ops
2737    // -----------------------------------------------------------------------
2738    add("db_findnext", &[FindDb], &[], &[], &[], &[], &[], false);
2739    add("db_find", &[], &[FindDb], &[], &[], &[], &[], false);
2740    add("db_find_refine", &[FindDb], &[], &[], &[], &[], &[], false);
2741    add("db_listall", &[], &[FindDb], &[], &[], &[], &[], false);
2742    add(
2743        "db_listall_with_count",
2744        &[],
2745        &[FindDb],
2746        &[],
2747        &[],
2748        &[],
2749        &[],
2750        false,
2751    );
2752
2753    map
2754}