OSDN Git Service

6e311bd59b180867b08a4bb1c4b14b4ae91fbc9b
[nazghul-jp/nazghul-jp.git] / worlds / haxima-1.002 / mimic.scm
1 ;; mimic.scm -- define a mechanism which looks like a chest, but when opened it
2 ;; spawns a hostile mimic npc
3
4 ;; Spawn a mimic npc where the mimic mechanism is and remove the mechanism.
5 (define (mimic-open kobj kchar)
6   (kern-obj-put-at (mk-npc 'mimic (calc-level))
7                    (kern-obj-get-location kobj))
8   (kern-obj-remove kobj)
9   )
10
11 ;; The trap detection handlers are nops
12 (define (mimic-get-traps kobj) nil)
13 (define (mimic-rm-traps kobj) nil)
14
15 ;; Emulate the container-ifc, including the trap detection signal handlers,
16 ;; otherwise An Sanct will give the mimic away.
17 (define mimic-ifc
18   (ifc '()
19        (method 'open mimic-open)
20        (method 'get-traps mimic-get-traps)
21        (method 'rm-traps mimic-rm-traps)
22        ))
23
24 (mk-obj-type 't_mimic "chest" s_chest layer-mechanism mimic-ifc)
25
26 (define (mk-mimic)
27   (kern-mk-obj t_mimic 1))