summaryrefslogblamecommitdiff
path: root/world/map/conf/magic-base.sex
blob: 8f3b99788d7646c7f45e92717b261784bbe24fa6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
                         
                       
                      

                  





                     
                

          








                     
                    

                
                     
                                                                                                                                  





                              
                           

                 










                           


                          
                                
                                                                                  











                                       
                                 


                                        





                            
 

                               
 

                                 
 









                                          




                                                                                                              





























                                                                                           
 
                               
                                                                                 
















                                                     
                                                











                                                                                               
 

























































                                                                                                               

                                                       













                                             
                                       




















                                                          
 












                                  

                                            




                                   

                                                                      












                                      

                                                                                                                  



















                                                                        
 














                                               
 













                                                                           
 

                                                                      
 















                                                                   

                                                   















                                                                        

                                                   















                                     
                                                                 

                                                                                                        



                                                                                  

























                                                                                         
                                                                   














                                                                
                                                                                                                                               


































                                                                                                                                                                                                                                           
 




























                                                                                         
 


























                                                    
 









































                                                         



                                                                                      












                                             
                                                         





                                                                       
 






































                                                                                      
 









































                                                    
 
























                                                         
 


























                                             
 


























                                               
 


























                                              
 


























                                             
 


























                                              
 
































                                                     



                                                                                  






























                                                    
 





















                                                                
 





















                                                            
 





















                                                                 
 






























                                                    
 





































                                                                            
 
























                                                                                     
 








































































                                                                      


                                                             












                                           
                                                                    



















                                             
                                                                                                                  



















                                                               
 




























































                                                            
                                                                                   





































                                                                                  
 



































































































                                                                                        
 


































                                                 
 






























                                                   
 























































                                                                                      
 






























                                                       
 









































                                                                                                                        
 




















































                                                           
 













































                                                   
 







































































                                                                                 
                                      


























                                                                        
 






                                                                  
 








                                                              
 










                                                                         
 

























                                                                       
                                                                                              








                                                                     
                                                                                     
















                                                                                          




                                                               




















































                                                                       
 


























                                                   
 




























                                               
 


























                                                 
 


























                                              
 

















































                                                                   
 

























                                                                                         
 


































































































































                                                                        
 










































                                                                



                                                                                  

































                                                         
 












































                                                 
                                     



















                                                            
 






































































                                                                                           



                                                                                  

















                                         
 






                                               

                                                   





















                                            



                                                                                  
































































































































































































































































































































































                                                                                                                                                                                                                                                 
 




                                           
 





                                             
 




                                             
 





                                               
 



                                               
 






                                                 
 











                                                      



                                                                                  


















                                                     
                                                                  






























































                                                                                                  


                                          
 



                                                                                                   

                    
                      
               





                                                                 
 





















                                                                                        
 














                                                                            
 

















                                                                            
                                                                                                                                                              













                                                               
                                                                                                                                                                                














                                                              


                                                            














                                                          
                                                                



























                                                                      



                                                                                                                                                    























                                                                            


                                                        



















                                                                                        
                                                                                           

                                   
                                                            



























                                                                  
                                                                                                                                                



                                                                            


                                                        





                                                  
 











                                                     








                                                                                             

















                                                                
 


















                                                           



                                          

















                                                    
 

















                                                    
 

















                                                    
 

















                                                    
 

















                                                    
 

















                                                    



                                                                                  




                                      
 




                                      
 




                                  
 




                                 
 




                              
 




                              
 




                              
 




                                 
 




                                   
 
                                                                                  
             











                                                                                  





                                                                                  





                                                 

                                                   
"Special-purpose globals"
(SET obscure_chance 95)
(SET min_casttime 200)

"Schools of magic"
(CONST MAGIC 340)
(CONST LIFE 341)
(CONST WAR 342)
(CONST TRANSMUTE 343)
(CONST NATURE 344)
(CONST ASTRAL 345)
(CONST DARK 346)

"Elements"
(CONST ELT_NEUTRAL 0)
(CONST ELT_WATER 1)
(CONST ELT_EARTH 2)
(CONST ELT_FIRE 3)
(CONST ELT_WIND 4)
(CONST ELT_POISON 5)
(CONST ELT_SHADOW 6)
(CONST ELT_HOLY 7)
(CONST ELT_GHOST 8)
(CONST ELT_UNDEAD 9)

"Status effects"
(CONST SC_POISON 132)
(CONST SC_SHEARED 194) "This is the same as SC_HIDE, since mobs can't hide and shearing is only used for mobs.  Feel free to fix!"
(CONST SC_HIDE 194)
(CONST SC_HALT_REGENERATE 195)
(CONST SC_FLYING_BACKPACK 196)
(CONST SC_MBARRIER 197)
(CONST SC_HASTE 198)
(CONST SC_PHYS_SHIELD 199)
(CONST SO_GMINVISIBLE 4096)

"Special effects"
(CONST SFX_DEFAULT 10)
(CONST SFX_SUMMON_START 21)
(CONST SFX_SUMMON_FIRE 22)
(CONST SFX_TELEPORT 24)
(CONST SFX_RAIN 25)
(CONST SFX_HIT 25)
(CONST SFX_ARROW_HAIL 27)
(CONST SFX_BARRIER 10)
(CONST SFX_UNBARRIER 10)
(CONST SFX_HEAL 3)
(CONST SFX_LIGHTNING 18)

"Magic Spell Const"
(CONST MIN_MARRY_LEVEL 32)
(CONST MAX_RAIN_SPELL_RADIUS 15)
(CONST MAX_MAGIC_LEVEL 2) "Increase up to 5 as each new magic level is completed."
(CONST MAGIC_FLAGS "MAGIC_FLAGS")
(CONST MFLAG_MADE_CONC_POTION 16384)
(CONST MFLAG_MADE_CONC_POTION_SHIFT 14)
(CONST SCRIPT_XP "MAGIC_EXPERIENCE")
(CONST SCRIPT_XP_MASK 0xffff)
(CONST SCRIPT_XP_SHIFT 0)
(CONST SCRIPT_LASTSPELL_MASK 0xff)
(CONST SCRIPT_LASTSPELL_SHIFT 16)
(CONST SCRIPT_HEALSPELL_MASK 0xff)
(CONST SCRIPT_HEALSPELL_SHIFT 24)
(CONST DEBUG 0)
(CONST ATTACK_ICON_GENERIC 2000)
(CONST ATTACK_ICON_SHEARING 2001)
(CONST E10_FLAG_USED_FREE_WARP_SHIFT 17)

"Default sfx on caster"
(PROCEDURE default_effect ()
    (sfx caster
        (+
            (- school MAGIC)
            2)
        0))

(PROCEDURE sfx_generic (target)
    (sfx target SFX_DEFAULT 0))

(PROCEDURE sfx_lightning (target)
    (sfx target SFX_LIGHTNING 0))

(PROCEDURE set_var (name mask shift value)
    (set_script_variable caster name
        (|
            (&
                (script_int caster name)
                (neg
                    (<< mask shift)))
            (<<
                (& value mask)
                shift))))

"value is How many HP we healed"
"gain is how many life magic experience points we can potentially gain"
"heal_xp_value_divisor is 1 for instaheal, 2 for slow heal"
"base_exp_factor is the factor for how many base experience points (max) the player should be allowed to gain"
(PROCEDURE gain_heal_xp (value gain heal_xp_value_divisor base_exp_factor)
    (SET last_heal_xp
        (&
            (>>
                (script_int caster SCRIPT_XP)
                SCRIPT_HEALSPELL_SHIFT)
            SCRIPT_HEALSPELL_MASK))
    (IF (&&
            (!= target caster)
            (>
                (/ value heal_xp_value_divisor)
                (+
                    (+
                        (+ 10 last_heal_xp)
                        (random
                            (+ last_heal_xp 1)))
                    (random
                        (+ last_heal_xp 1)))))
        (BLOCK
            (SET heal_xp
                (+ last_heal_xp gain))
            (IF (> heal_xp SCRIPT_HEALSPELL_MASK)
                (SET heal_xp SCRIPT_HEALSPELL_MASK))
            (CALL set_var SCRIPT_XP SCRIPT_HEALSPELL_MASK SCRIPT_HEALSPELL_SHIFT heal_xp)))
    (IF (!= target caster)
        (gain_experience caster
            (* base_exp_factor
                (extract_healer_experience target value))
            0
            1)))

(PROCEDURE gain_xp (gain index)
    "Level 4 and 5 magic users don't gain anything from spell levels 0 resp. 0+1"
    (IF (>
            (+ level 3)
            (skill caster MAGIC))
        (BLOCK
            (SET last_index
                (&
                    (>>
                        (script_int caster SCRIPT_XP)
                        SCRIPT_LASTSPELL_SHIFT)
                    SCRIPT_LASTSPELL_MASK))
            (SET last_xp
                (&
                    (>>
                        (script_int caster SCRIPT_XP)
                        SCRIPT_XP_SHIFT)
                    SCRIPT_XP_MASK))
            (IF (!= index last_index)
                (BLOCK "Some variation observed"
                    (SET xp
                        (+ last_xp gain))
                    (IF (> xp SCRIPT_XP_MASK)
                        (SET xp SCRIPT_XP_MASK))
                    (CALL set_var SCRIPT_XP SCRIPT_XP_MASK SCRIPT_XP_SHIFT xp)
                    (CALL set_var SCRIPT_XP SCRIPT_LASTSPELL_MASK SCRIPT_LASTSPELL_SHIFT index)
                    (IF DEBUG
                        (message caster
                            (+ "Spell xp = " xp))))
                (IF DEBUG
                    (message caster
                        (+ "Re-cast same spell, xp remain at " last_xp)))))))

(PROCEDURE create_item (good_item count bad_item difficulty)
    (SET success 1)
    (SET score
        (+ experience
            (random
                (min spellpower
                    (+
                        (/ experience 3)
                        1)))))
    (IF (>= score difficulty)
        (create_item caster good_item count)
        (BLOCK
            (SET success 0)
            (SET score
                (+
                    (+ score
                        (random
                            (luk caster)))
                    (random
                        (luk caster))))
            (IF (< score
                    (/ difficulty 3))
                (BLOCK
                    (message caster "Your spell backfires!")
                    (IF (<
                            (random 110)
                            (luk caster))
                        (itemheal caster
                            (- 0
                                (*
                                    (*
                                        (+ level 1)
                                        (+ level 2))
                                    (+ 3
                                        (random 28))))
                            0)
                        (itemheal caster
                            (- 0
                                (+ level 1))
                            0)))
                (IF (< score
                        (/
                            (* difficulty 2)
                            3))
                    (BLOCK
                        (IF (==
                                (random 5)
                                0)
                            (BLOCK
                                (message caster "Your spell solidifies into the shape of a mysterious object!")
                                (create_item caster "Iten" 1))
                            (message caster "Your spell escapes!")))
                    (BLOCK
                        (message caster "Your spell takes on a mind of its own!")
                        (IF (==
                                (random 3)
                                0)
                            (create_item caster bad_item 1))))))))

"Increase spellpower by school and general magic skill"
(PROCEDURE adjust_spellpower (school)
    (SET experience
        (&
            (>>
                (script_int caster SCRIPT_XP)
                SCRIPT_XP_SHIFT)
            SCRIPT_XP_MASK))
    (SET spellpower
        (+ spellpower
            (*
                (+
                    (skill caster MAGIC)
                    (skill caster school))
                10)))
    "Below, we adjust by special items"
    (IF (&&
            (not
                (failed target))
            (||
                (== school LIFE)
                (== school NATURE)))
        (IF target
            (IF (==
                    (pc target)
                    (partner caster))
                (BLOCK
                    (SET spellpower
                        (+ spellpower 200))
                    (IF (is_equipped caster "WeddingRing")
                        (SET spellpower
                            (+ spellpower 50)))
                    (IF (is_equipped
                            (pc target)
                            "WeddingRing")
                        (SET spellpower
                            (+ spellpower 50))))))))

(PROCEDURE heal (target max_heal)
    (CALL default_effect)
    (IF (!= caster target)
        (sfx target SFX_HEAL 0))
    (SET power
        (+ spellpower
            (vit caster)))
    (SET power
        (min max_heal
            (/
                (* max_heal power)
                250)))
    (itemheal target power 0))

"Goes through instaheal instead of itemheal"
(PROCEDURE quickheal (target power)
    (CALL default_effect)
    (IF (!= caster target)
        (sfx target SFX_HEAL 0))
    (instaheal target power 0))

"Can attack the target? Imports attack_range from dynamic environment"
(PROCEDURE attack_check (target)
    (IF (not
            (line_of_sight
                (location caster)
                (location target)))
        (ABORT))
    (IF (not
            (<=
                (rdistance
                    (location caster)
                    (location target))
                attack_range))
        (ABORT)))

"Cause elemental damage.  bonus_elt grants an attack bonus, malus_elt reduces the attack. `effect' is the sfx ID."
(PROCEDURE elt_damage (target damage dmgplus bonus_elt malus_elt effect)
    (SET d
        (+ damage
            (random dmgplus)))
    (IF (==
            (element target)
            malus_elt)
        (SET d
            (/ d 3)))
    (IF (==
            (element target)
            bonus_elt)
        (SET d
            (/
                (* d
                    (+ 4
                        (element_level target)))
                4)))
    (sfx target effect 0)
    (injure caster target d 0))

(PROCEDURE melee_damage (target damage dmgplus)
    (CALL attack_check target)
    (SET d
        (+ damage
            (random dmgplus)))
    (SET evade
        (+
            (level target)
            (mdef target)))
    (IF (<
            (- spellpower
                (random 100))
            evade)
        (SET d 0))
    (injure caster target d 0))

(PROCEDURE install_attack_spell (charges base_delay range attack_animation)
    (CALL default_effect)
    (SET attack_range range)
    (override_attack caster charges
        (/
            (*
                (- 200
                    (agi caster))
                base_delay)
            200)
        range
        ATTACK_ICON_GENERIC
        attack_animation
        0))

(PROCEDURE install_melee_spell (charges base_delay attack_animation)
    (CALL install_attack_spell charges base_delay 1 attack_animation))

(PROCEDURE summon_spell (mob_id count delay lifetime control_level)
    (CALL default_effect)
    (sfx location SFX_SUMMON_START 0)
    (WAIT delay)
    (sfx location SFX_SUMMON_FIRE 0)
    (spawn
        (rbox location 2)
        caster
        mob_id
        (if_then_else
            (>=
                (skill caster ASTRAL)
                control_level)
            2
            1)
        count
        lifetime)) "pets when level is high enough"

(PROCEDURE summon_dark_spell (mob_id count delay lifetime control_level)
    (CALL default_effect)
    (sfx location SFX_SUMMON_START 0)
    (WAIT delay)
    (sfx location SFX_SUMMON_FIRE 0)
    (spawn
        (rbox location 2)
        caster
        mob_id
        (if_then_else
            (>=
                (skill caster DARK)
                control_level)
            2
            1)
        count
        lifetime)) "pets when level is high enough"

(PROCEDURE abort_on_area_shield (pos)
    (IF (&&
            (==
                (is_exterior pos)
                1)
            (||
                (||
                    (==
                        (map_nr pos)
                        1)
                    (==
                        (map_nr pos)
                        9))
                (==
                    (map_nr pos)
                    20)))
        (BLOCK "1 is Tulimshar, 9 is Hurnscald and 20 is Nivalis"
            (message caster "A powerful magic drains your spell just as it is beginning to take shape!")
            (ABORT))))

"--------------------------------------------------------------------------------"
"Level 0 spells"
"--------------------------------------------------------------------------------"
(SPELL () ask-magic-exp "#abizit" ()
    (LET level 0)
    (LET school MAGIC)
    (=>
        (GUARD
            (MANA 1)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level)))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (SET level
                (skill caster MAGIC))
            (SET experience
                (&
                    (>>
                        (script_int caster SCRIPT_XP)
                        SCRIPT_XP_SHIFT)
                    SCRIPT_XP_MASK))
            (IF (&&
                    (== experience SCRIPT_XP_MASK)
                    (> level 4))
                (message caster "You are as proficient at magic as you can possibly be.")
                (BLOCK "This duplicates the table in mana-seed.txt"
                    (IF (> level 4)
                        (SET max_experience SCRIPT_XP_MASK)
                        (IF (== level 4)
                            (SET max_experience 40000)
                            (IF (== level 3)
                                (SET max_experience 8000)
                                (IF (== level 2)
                                    (SET max_experience 1200)
                                    (SET max_experience 100)))))
                    (SET ratio
                        (/
                            (-
                                (* 10 experience)
                                (random
                                    (/ max_experience 30)))
                            max_experience)) "Randomness:  jitter a bit at the transitions to give more precise information if used frequently"
                    (IF (>= ratio 45)
                        (message caster
                            (+ "Magic flows naturally from you, readily and with ease. Your understanding of what you can currently control at present is flawless, far beyond your requirements to cast magic at this level."
                                (if_then_else
                                    (>= level MAX_MAGIC_LEVEL)
                                    ""
                                    " Surely the Mana Seed will more than readily offer more magic for such a proficient user.")))
                        (IF (>= ratio 20)
                            (message caster "You have perfect control of what you understand now, but there is now a distinct sensation of something more, something indescribable. If only the Mana Seed would give more magic to you...")
                            (IF (>= ratio 10)
                                (message caster
                                    (+ "You feel in perfect control of your magic"
                                        (if_then_else
                                            (>= level MAX_MAGIC_LEVEL)
                                            "."
                                            ", and seem on the verge of something more... perhaps you should see the Mana Seed to ask for more magic?")))
                                (IF (>= ratio 9)
                                    (message caster "You feel in almost perfect control of your magic.")
                                    (IF (>= ratio 8)
                                        (message caster "You feel that you have very good control of your magic.")
                                        (IF (>= ratio 7)
                                            (message caster "You feel quite in control of your magic.")
                                            (IF (>= ratio 6)
                                                (message caster "You feel mostly in control of your magic.")
                                                (IF (>= ratio 5)
                                                    (message caster "You feel somewhat in control of your magic.")
                                                    (IF (>= ratio 4)
                                                        (message caster "You feel you still have a few difficulties in controlling your magic.")
                                                        (IF (>= ratio 3)
                                                            (message caster "Trying to control your magic is still rather troublesome.")
                                                            (IF (>= ratio 2)
                                                                (message caster "You feel that you have only the bare minimum of control over your magic.")
                                                                (IF (>= ratio 1)
                                                                    (message caster "You feel quite overwhelmed by your magic, but are beginning to see patterns.")
                                                                    (message caster "You feel completely overwhelmed by your magic."))))))))))))))))))

(SPELL () transmute-wood-to-figurine "#parum" (STRING name)
    (LET level 0)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 5)
            (CASTTIME 4000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "RawLog"))
        (|
            (=>
                (REQUIRE
                    (== name "boo"))
                (EFFECT
                    (CALL adjust_spellpower school)
                    (CALL default_effect)
                    (CALL create_item "MoubooFigurine" 1 "WarpedLog" 40)
                    (CALL gain_xp 1 0)))
            (=>
                (REQUIRE
                    (== name "lurk"))
                (EFFECT
                    (CALL adjust_spellpower school)
                    (CALL default_effect)
                    (CALL create_item "WarpedLog" 1 "WarpedLog" 40)
                    (message caster "You have no idea what a Skrytlurk looks like."))))))

(SPELL () make-sulphur "#gole" ()
    (LET level 0)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 4)
            (CASTTIME 4000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "PileOfAsh"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "SulphurPowder"
                (+
                    (+ 1
                        (/ spellpower 100))
                    (/
                        (random
                            (max 1
                                (- 800 spellpower)))
                        180))
                "PileOfAsh"
                50)
            (CALL gain_xp 1 1))))

(SPELL () lesser-heal "#lum" (STRING target)
    (LET level 0)
    (LET school LIFE)
    (=>
        (GUARD
            (MANA 6)
            (CASTTIME 500)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (if_then_else
                    (failed
                        (pc target))
                    1
                    (<
                        (rdistance
                            (location caster)
                            (location
                                (pc target)))
                        (+ 2
                            (/ spellpower 100)))))
            (GUARD
                (COMPONENTS "Lifestone")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (IF (failed
                    (pc target))
                (BLOCK
                    (IF (&&
                            (||
                                (== target "mouboo")
                                (== target "Mouboo"))
                            (<
                                (rdistance
                                    (location caster)
                                    (location
                                        (npc "Mouboo")))
                                (+ 2
                                    (/ spellpower 100))))
                        (SCRIPT "{
                            mes \"Your spell seems to have no effect on the mouboo.\";
                            close;
                        }")
                        (SET target caster)))
                (BLOCK
                    (SET target
                        (pc target))
                    (IF (is_dead target)
                        (ABORT))))
            (CALL gain_heal_xp
                (min 200
                    (-
                        (max_hp target)
                        (hp target)))
                1
                2
                2) "report half values for non-instaheal"
            (CALL heal target 200)
            (IF (>
                    (skill caster DARK)
                    1)
                (status_change caster SC_HALT_REGENERATE 0 0 0 0 2000))
            (CALL gain_xp 1 2))))

(SPELL () flare-dart "#flar" ()
    (LET level 0)
    (LET school WAR)
    (=>
        (GUARD
            (MANA 10)
            (CASTTIME 500)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            2))
                    (COMPONENTS "SulphurPowder"))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (SET damage
                (* 5
                    (sqrt spellpower)))
            (SET damage_bonus
                (+ 5
                    (/
                        (level caster)
                        3)))
            (CALL install_attack_spell
                (+ 3
                    (/ spellpower 50))
                1200
                4
                31)
            (CALL gain_xp 1 3)
            (ATTRIGGER
                (CALL attack_check target)
                (CALL elt_damage target damage damage_bonus ELT_WATER ELT_FIRE 15)))))

(SPELL () magic-blade "#chiza" ()
    (LET level 0)
    (LET school WAR)
    (=>
        (GUARD
            (MANA 9)
            (CASTTIME 500)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level)))
        (|
            (=>
                (COMPONENTS "SharpKnife")
                (EFFECT
                    (CALL adjust_spellpower WAR)
                    (CALL default_effect)
                    (CALL install_melee_spell
                        (+ 10
                            (/ spellpower 15))
                        1200
                        30)
                    (CALL gain_xp 1 4)
                    (ATTRIGGER
                        (CALL melee_damage target 60
                            (+ 5
                                (str caster))))))
            (=>
                (COMPONENTS "Knife")
                (EFFECT
                    (CALL adjust_spellpower WAR)
                    (CALL default_effect)
                    (CALL install_melee_spell
                        (+ 10
                            (/ spellpower 15))
                        1200
                        30)
                    (CALL gain_xp 1 5)
                    (ATTRIGGER
                        (CALL melee_damage target 40
                            (+ 5
                                (str caster)))))))))

(SPELL () aggravate "#itenplz" ()
    (LET level 0)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 3)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level)))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (FOREACH MOB target
                (rbox
                    (location caster)
                    (+ 2
                        (/ spellpower 50)))
                (IF (line_of_sight
                        (location caster)
                        (location target))
                    (BLOCK
                        (CALL sfx_generic target)
                        (aggravate target 0 caster)))))))

(SPELL () grow-mauve "#modrilax" ()
    (LET level 0)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 4)
            (CASTTIME 2000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "MauveHerb" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 1 6)
            (spawn
                (rbox location 2)
                caster
                1029
                1
                (+
                    (/
                        (skill caster school)
                        2)
                    1)
                10000))))

(SPELL () grow-alizarin "#modriphoo" ()
    (LET level 0)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 4)
            (CASTTIME 2000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "AlizarinHerb" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 1 7)
            (spawn
                (rbox location 2)
                caster
                1032
                1
                (+
                    (/
                        (skill caster school)
                        2)
                    1)
                10000))))

(SPELL () grow-gamboge "#modriyikam" ()
    (LET level 0)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 4)
            (CASTTIME 2000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "GambogeHerb" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 1 8)
            (spawn
                (rbox location 2)
                caster
                1031
                1
                (+
                    (/
                        (skill caster school)
                        2)
                    1)
                10000))))

(SPELL () grow-cobalt "#modrisump" ()
    (LET level 0)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 4)
            (CASTTIME 2000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "CobaltHerb" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 1 9)
            (spawn
                (rbox location 2)
                caster
                1030
                1
                (+
                    (/
                        (skill caster school)
                        2)
                    1)
                10000))))

(SPELL (LOCAL) summon-maggots "#kalmurk" ()
    (LET level 0)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 21)
            (CASTTIME 20000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (COMPONENTS "MaggotSlime" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL gain_xp 1 10)
            (CALL summon_spell 1002
                (+ 1
                    (/
                        (+
                            (sqrt spellpower)
                            (/ spellpower 15))
                        5))
                (- 5000
                    (* spellpower 5))
                (+ 10000
                    (* spellpower 50))
                1))))

(SPELL () detect-magic "#miteyo" ()
    (LET level 0)
    (LET school MAGIC)
    (=>
        (GUARD
            (MANA 3)
            (CASTTIME 6000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level)))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (SET range
                (+ 1
                    (/ spellpower 50)))
            (FOREACH NPC n
                (rbox
                    (location caster)
                    range)
                (IF (||
                        (contains_string
                            (name_of n)
                            "#MAGIC")
                        (contains_string
                            (name_of n)
                            "#_M"))
                    (sfx n SFX_DEFAULT 0)))
            (FOREACH SPELL s (rbox
                    (location caster)
                    range) (IF (!= s self_invocation)
                    (sfx s SFX_DEFAULT 0))))))

"--------------------------------------------------------------------------------"
"Level 1 spells"
"--------------------------------------------------------------------------------"
(SPELL () make-arrows "#kularzufrill" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 8)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "RawLog"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "Arrow"
                (+
                    (+ 1
                        (/ spellpower 40))
                    (/
                        (random
                            (max 1
                                (- 800 spellpower)))
                        80))
                "WarpedLog"
                500)
            (CALL gain_xp 1 11))))

(SPELL () make-shirt "#patmuploo" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 25)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS
                (5 "CottonCloth")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "CottonShirt" 1 "CottonCloth" 425)
            (CALL gain_xp 2 12))))

(SPELL () make-tanktop "#patloree" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 25)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS
                (4 "CottonCloth")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "TankTop" 1 "CottonCloth" 350)
            (CALL gain_xp 2 13))))

(SPELL () make-short-tanktop "#patviloree" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 25)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS
                (3 "CottonCloth")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "ShortTankTop" 1 "CottonCloth" 250)
            (CALL gain_xp 2 14))))

(SPELL () make-iron-powder "#zukminbirf" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 8)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "IronOre"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "IronPowder"
                (+
                    (+ 1
                        (/ spellpower 140))
                    (/
                        (random
                            (max 1
                                (- 900 spellpower)))
                        220))
                "IronOre"
                700)
            (CALL gain_xp 3 15))))

(SPELL () make-concentration-potion "#loshira" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 8)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "BottleOfWater"
                (2 "CobaltHerb")
                (2 "PinkPetal")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item
                (if_then_else
                    (<
                        (random
                            (+ 2000 experience))
                        experience)
                    "ConcentrationPotion"
                    "DarkConcentrationPotion")
                1
                (if_then_else
                    (random 2)
                    "DilutedConcentrationPot"
                    "DarkConcentrationPotion")
                2000)
            (IF success
                (CALL set_var MAGIC_FLAGS 1 MFLAG_MADE_CONC_POTION_SHIFT 1))
            (CALL gain_xp 4 16))))

(SPELL () merge-concentration-potions "#skrimp" ()
    (LET level 1)
    (LET school TRANSMUTE)
    (=>
        (GUARD
            (MANA 8)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "DarkConcentrationPotion" "DilutedConcentrationPot"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL create_item "ConcentrationPotion" 1 "DilutedConcentrationPot" 1000)
            (message caster
                (+ "success = " success))
            (IF success
                (CALL set_var MAGIC_FLAGS 1 MFLAG_MADE_CONC_POTION_SHIFT 1))
            (CALL gain_xp 4 17))))

(SPELL () lay-on-hands "#inma" (STRING target)
    (LET level 1)
    (LET school LIFE)
    (=>
        (GUARD
            (MANA 10)
            (CASTTIME 500)
            (REQUIRE
                (>
                    (hp caster)
                    (/
                        (max_hp caster)
                        20)))
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (if_then_else
                    (failed
                        (pc target))
                    1
                    (&&
                        (&&
                            (&&
                                (!=
                                    (pc target)
                                    caster)
                                (<
                                    (rdistance
                                        (location caster)
                                        (location
                                            (pc target)))
                                    (+ 2
                                        (/
                                            (+
                                                (* 12
                                                    (sqrt spellpower))
                                                spellpower)
                                            100))))
                            (not
                                (running_status_update
                                    (pc target)
                                    SC_HALT_REGENERATE)))
                        (not
                            (is_equipped
                                (pc target)
                                "MagicGMTopHat"))))))
        (EFFECT
            (CALL adjust_spellpower school)
            (IF (not target)
                (ABORT))
            (IF (failed
                    (pc target))
                (BLOCK
                    (IF (&&
                            (||
                                (== target "mouboo")
                                (== target "Mouboo"))
                            (<
                                (rdistance
                                    (location caster)
                                    (location
                                        (npc "Mouboo")))
                                (+ 2
                                    (/ spellpower 100))))
                        (BLOCK
                            (SET needed 1000)
                            (SCRIPT "{
                                set @spell, 1;
                                callfunc \"QuestMoubooHeal\";
                            }"))
                        (ABORT)))
                (BLOCK
                    (SET target
                        (pc target))
                    (SET needed
                        (-
                            (max_hp target)
                            (hp target)))))
            (SET pay_fraction
                (max 80
                    (- 200
                        (+
                            (vit caster)
                            (/ spellpower 10))))) "Pay at least 40%"
            (SET payment
                (/
                    (* needed pay_fraction)
                    200))
            (SET available
                (-
                    (hp caster)
                    (/
                        (max_hp caster)
                        20)))
            (IF (< payment available)
                (SET power needed)
                (BLOCK
                    (SET payment available)
                    (SET power
                        (/
                            (* available 200)
                            pay_fraction))))
            (CALL gain_heal_xp power 1 1 3)
            (CALL quickheal target power)
            (SET t 5000) "with dark magic skill you pay 1/20 of max hp but the regenerate cooldown is cut in half"
            (SET school DARK)
            (SET h
                (*
                    (/
                        (max_hp caster)
                        20)
                    -1))
            (IF (>
                    (skill caster school)
                    level)
                (itemheal caster h 0))
            (IF (>
                    (skill caster school)
                    level)
                (SET t 10000))
            (status_change caster SC_HALT_REGENERATE 0 0 0 0 t)
            (CALL gain_xp
                (min 4
                    (/ payment 100))
                18))))

(SPELL () lightning-strike "#ingrav" ()
    (LET level 1)
    (LET school WAR)
    (=>
        (GUARD
            (MANA 20)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "IronPowder"))))
        (EFFECT
            (CALL adjust_spellpower school)
            (SET damage spellpower)
            (SET damage_bonus
                (+ 1
                    (/ spellpower 2)))
            (CALL install_attack_spell
                (+ 1
                    (/ spellpower 90))
                3000
                8
                31)
            (CALL gain_xp 2 19)
            (ATTRIGGER
                (CALL attack_check target)
                (SET in_rain 0)
                (SET area
                    (location caster))
                (FOREACH SPELL s (rbox
                        (location caster)
                        (+ MAX_RAIN_SPELL_RADIUS 1)) (IF (==
                            (name_of s)
                            "rain")
                        (BLOCK
                            (IF (is_in
                                    (location caster)
                                    (. s area))
                                (BLOCK
                                    (SET in_rain
                                        (| in_rain 1))
                                    (SET area
                                        (+ area
                                            (. s area)))))
                            (IF (is_in
                                    (location target)
                                    (. s area))
                                (SET in_rain
                                    (| in_rain 2))))))
                (IF (& in_rain 1)
                    (BLOCK "caster standing in the rain?  This is going to be fun."
                        (SET used 0)
                        (FOREACH TARGET t area
                            (IF (>
                                    (+
                                        (random 200)
                                        (luk caster))
                                    175)
                                (BLOCK
                                    (SET used
                                        (+ used 1))
                                    (CALL elt_damage t
                                        (/ damage 6)
                                        (+ 1
                                            (/ damage_bonus 3))
                                        ELT_EARTH
                                        ELT_WIND
                                        (+ 17
                                            (random 3))))))
                        (IF (||
                                (not used)
                                (<
                                    (+
                                        (random 200)
                                        (luk caster))
                                    150))
                            (BLOCK
                                (sfx caster
                                    (+ 17
                                        (random 3))
                                    0)
                                (itemheal caster
                                    (-
                                        (- 0 damage)
                                        (random damage_bonus))
                                    0))))
                    (CALL elt_damage target damage damage_bonus ELT_EARTH ELT_WIND
                        (+ 17
                            (random 3))))))))

(SPELL (LOCAL) arrow-hail "#frillyar" ()
    (LET level 1)
    (LET school WAR)
    (=>
        (GUARD
            (MANA 25)
            (CASTTIME 5000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (is_exterior
                    (location caster)))
            (GUARD
                (OR
                    (COMPONENTS
                        (20 "Arrow"))
                    (COMPONENTS
                        (20 "IronArrow"))))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "SulphurPowder"))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL abort_on_area_shield
                (location caster))
            (SET range 7)
            (SET area
                (rbox
                    (awayfrom
                        (location caster)
                        (dir caster)
                        (+ 1 range))
                    range))
            (FOREACH SPELL s (rbox
                    (awayfrom
                        (location caster)
                        (dir caster)
                        (+ 1 range))
                    (* range 2)) (IF (&&
                        (!= s self_invocation)
                        (==
                            (name_of s)
                            "arrow-hail"))
                    (BLOCK
                        (message caster "A nearby arrow hail spell absorbs your magic!")
                        (ABORT))))
            (SET damage 125)
            (SET damage_bonus
                (/ spellpower 5))
            (CALL gain_xp 2 20)
            (FOR i 0
                (/ spellpower 8)
                (BLOCK
                    (FOR j 0 2
                        (BLOCK
                            (SET location
                                (random_location area))
                            (sfx location SFX_ARROW_HAIL 0)
                            (SET done 0)
                            (FOREACH TARGET target
                                (rbox location 0)
                                (BLOCK
                                    (injure caster target
                                        (+
                                            (+ damage
                                                (random damage_bonus))
                                            (random damage_bonus))
                                        0)
                                    (SET done 1)
                                    (BREAK)))
                            (IF (&&
                                    (==
                                        (location caster)
                                        location)
                                    (not done))
                                (BLOCK
                                    (itemheal caster
                                        (- 0
                                            (+
                                                (+ damage
                                                    (random damage_bonus))
                                                (random damage_bonus)))
                                        0)
                                    (sfx caster SFX_HIT 0)))))
                    (WAIT
                        (+
                            (+ 250
                                (random 50))
                            (random 50))))))))

(SPELL () magic-knuckles "#upmarmu" ()
    (LET level 1)
    (LET school WAR)
    (=>
        (GUARD
            (MANA 20)
            (CASTTIME 500)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "Beer"))))
        (EFFECT
            (CALL adjust_spellpower WAR)
            (SET str
                (str caster))
            (CALL install_melee_spell
                (+ 10
                    (/ spellpower 10))
                1300
                34)
            (ATTRIGGER
                (CALL melee_damage target 30
                    (+ 5
                        (* str 2)))))))

(SPELL (LOCAL) summon-snakes "#halhiss" ()
    (LET level 1)
    (LET school DARK)
    (=>
        (GUARD
            (MANA 40)
            (CASTTIME 15000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (>
                    (script_int caster "OrumQuest")
                    40))
            (COMPONENTS "DarkCrystal" "SnakeEgg"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 3 31)
            (CALL summon_dark_spell 1010
                (+ 1
                    (/ spellpower 300))
                (- 4000
                    (* spellpower 9))
                (* spellpower 80)
                2))))

(SPELL () toxic-dart "#phlex" ()
    (LET level 1)
    (LET school DARK)
    (=>
        (GUARD
            (MANA 15)
            (CASTTIME 500)
            (REQUIRE
                (>
                    (script_int caster "OrumQuest")
                    37))
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            2))
                    (COMPONENTS
                        (2 "Root")))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (SET damage
                (* 5
                    (sqrt spellpower)))
            (SET damage_bonus
                (+ 5
                    (/
                        (level caster)
                        3)))
            (CALL install_attack_spell
                (+ 3
                    (/ spellpower 75))
                1200
                4
                31)
            (CALL gain_xp 3 35)
            (ATTRIGGER
                (CALL attack_check target)
                (CALL elt_damage target damage damage_bonus ELT_NEUTRAL ELT_POISON 15)
                (IF (&&
                        (is_pc target)
                        (!= caster target))
                    (status_change target SC_POISON
                        (+ 5
                            (max 15
                                (/ spellpower 15)))
                        0
                        0
                        0
                        (+ 5000
                            (* spellpower 1200))))))))

(SPELL (LOCAL) summon-wickedmushroom "#helorp" ()
    (LET level 1)
    (LET school DARK)
    (=>
        (GUARD
            (MANA 35)
            (CASTTIME 15000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (script_int caster "OrumQuest")
                    36))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "SmallMushroom" "DarkCrystal"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 3 36)
            (CALL summon_dark_spell 1106
                (+ 1
                    (/ spellpower 250))
                (- 4000
                    (* spellpower 9))
                (* spellpower 80)
                2))))

(SPELL () flying-backpack "#plugh" (PC target)
    (LET level 1)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 12)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "SilkCocoon")))
            (REQUIRE
                (<
                    (rdistance
                        (location target)
                        (location caster))
                    (+ 2
                        (/ spellpower 30)))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (IF (!= caster target)
                (sfx caster 2 0))
            (status_change target SC_FLYING_BACKPACK 0 0 0 0
                (+ 5000
                    (* spellpower 500)))
            (message target "Your backpack is lifted by a mystical force; you no longer feel it pressing on your back.")
            (CALL gain_xp 1 21)
            (ATEND
                (message target "Your backpack is no longer levitating.")
                (sfx target 2 0)))))

(SPELL () protect "#betsanc" (PC target)
    (LET level 1)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 14)
            (CASTTIME 1500)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (not
                    (is_equipped
                        (pc target)
                        "MagicGMTopHat")))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "HardSpike")))
            (REQUIRE
                (<
                    (rdistance
                        (location target)
                        (location caster))
                    (+ 2
                        (/ spellpower 30)))))
        (EFFECT
            (CALL adjust_spellpower school)
            (sfx target 11 0)
            (IF (!= caster target)
                (CALL default_effect))
            (status_change target SC_PHYS_SHIELD
                (+ 5
                    (max 15
                        (/ spellpower 20)))
                0
                0
                0
                (+ 5000
                    (* spellpower 1000)))
            (message target "You feel more protected.")
            (CALL gain_xp 2 22)
            (ATEND
                (message target "You feel less protected.")
                (sfx target 111 0)))))

(SPELL () happy-curse "#joyplim" (PC target)
    (LET level 1)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 13)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "GingerBreadMan")))
            (REQUIRE
                (<
                    (rdistance
                        (location target)
                        (location caster))
                    (+ 1
                        (/ spellpower 100)))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (IF (>
                    (skill caster DARK)
                    1)
                (FOR i 0
                    (/ spellpower 10)
                    (BLOCK
                        (emote target 5)
                        (WAIT 500)))
                (FOR i 0
                    (/ spellpower 10)
                    (BLOCK
                        (emote target 3)
                        (WAIT 500))))
            (CALL gain_xp 1 23))))

(SPELL (LOCAL) rain "#kaflosh" ()
    (LET level 1)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 17)
            (CASTTIME 3000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (is_exterior
                    (location caster)))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "BottleOfWater"))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL abort_on_area_shield
                (location caster))
            (FOREACH SPELL s (rbox
                    (location caster)
                    (+ MAX_RAIN_SPELL_RADIUS 1)) (IF (&&
                        (!= s self_invocation)
                        (==
                            (name_of s)
                            "rain"))
                    (BLOCK
                        (message caster "A nearby raincloud absorbs your magic.")
                        (ABORT))))
            (CALL gain_xp 1 24)
            (SET range
                (min MAX_RAIN_SPELL_RADIUS
                    (+ 3
                        (/
                            (min spellpower 200)
                            30))))
            (SET area
                (rbox
                    (location caster)
                    range))
            (IF (||
                    (is_in
                        (location
                            (npc "#DruidTree0#_M"))
                        area)
                    (is_in
                        (location
                            (npc "#DruidTree1#_M"))
                        area))
                (SCRIPT "{
                    set @flag, 1;
                    callfunc \"QuestTreeTrigger\";
                }"))
            (IF (is_in
                    (location caster)
                    (@+
                        (@ "011-1.gat" 94 38)
                        9
                        7))
                (SCRIPT "{
                    callfunc \"HalloweenQuestWaterPumpkins\";
                }")) "Halloween quest"
            (FOR i 0
                (/ spellpower 3)
                (BLOCK
                    (FOR j 0
                        (/
                            (min
                                (/ spellpower 2)
                                200)
                            100)
                        (BLOCK
                            (SET location
                                (random_location area))
                            (sfx location SFX_RAIN 0)
                            (FOREACH TARGET target
                                (rbox location 1)
                                (IF (==
                                        (element target)
                                        ELT_FIRE)
                                    (injure caster target
                                        (+ 2
                                            (random
                                                (+ 5
                                                    (/ spellpower 15))))
                                        0)))))
                    (WAIT
                        (+ 400
                            (random 100))))))))

(PROCEDURE shear-drop (target target2 item prob)
    (IF (||
            (== target name)
            (== target2 name))
        (BLOCK
            (IF (< score prob)
                (drop_item_for place item 1 60000 caster 5000)))))

(PROCEDURE shear-drop2 (target target2 item prob item2 prob2)
    (IF (||
            (== target name)
            (== target2 name))
        (BLOCK
            (IF (< score prob)
                (drop_item_for place item 1 60000 caster 5000)
                (CALL shear-drop target target2 item2
                    (+ prob2 prob))))))

(PROCEDURE shear-drop3 (target target2 item prob item2 prob2 item3 prob3)
    (IF (||
            (== target name)
            (== target2 name))
        (BLOCK
            (IF (< score prob)
                (drop_item_for place item 1 60000 caster 5000)
                (CALL shear-drop2 target target2 item2
                    (+ prob2 prob)
                    item3
                    (+ prob3 prob))))))

(SPELL () shear "#chipchip" ()
    (LET level 1)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 23)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level)))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (override_attack caster 1 2000 1 ATTACK_ICON_SHEARING 30 0)
            (ATTRIGGER
                (IF (not
                        (is_pc target))
                    (BLOCK
                        (SET score
                            (random
                                (- 1000
                                    (random spellpower)))) "lower score -> more valuable item"
                        (SET name
                            (name_of target))
                        (SET place
                            (random_location
                                (rbox
                                    (location target)
                                    1)))
                        (IF (running_status_update target SC_SHEARED)
                            (ABORT))
                        (status_change target SC_SHEARED 0 0 0 0 600000) "10 minutes"
                        (CALL shear-drop "Fluffy" "Fluffy" "WhiteFur" 300)
                        (CALL shear-drop "EasterFluffy" "Easter Fluffy" "WhiteFur" 300)
                        (CALL shear-drop "SpikyMushroom" "Spiky Mushroom" "HardSpike" 250)
                        (CALL shear-drop "Mouboo" "Mouboo" "CottonCloth" 175)
                        (CALL shear-drop "Cobalt" "CobaltPlant" "CobaltHerb" 700)
                        (CALL shear-drop "Alizarin" "AlizarinPlant" "AlizarinHerb" 700)
                        (CALL shear-drop "Gamboge" "GambogePlant" "GambogeHerb" 700)
                        (CALL shear-drop "Mauve" "MauvePlant" "MauveHerb" 700)
                        (CALL shear-drop "SilkWorm" "Silkworm" "SilkCocoon" 300)
                        (CALL shear-drop "Pinkie" "Pinkie" "PinkAntenna" 180)
                        (IF (&&
                                (||
                                    (||
                                        (== name "Fluffy")
                                        (== name "Mouboo"))
                                    (== name "Pinkie"))
                                (random 2))
                            (SCRIPT "{
                                set @value, 1;
                                callfunc \"QuestSagathaHappy\";
                            }"))))))))

(SPELL () barrier "#asorm" (PC target)
    (LET level 1)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 16)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (not
                    (is_equipped
                        (pc target)
                        "MagicGMTopHat")))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "SmallMushroom")))
            (REQUIRE
                (<
                    (rdistance
                        (location target)
                        (location caster))
                    (+ 2
                        (/ spellpower 30)))))
        (EFFECT
            (CALL adjust_spellpower school)
            (sfx target SFX_BARRIER 0)
            (IF (!= caster target)
                (CALL default_effect))
            (status_change target SC_MBARRIER
                (+ 20
                    (max 30
                        (/ spellpower 8)))
                0
                0
                0
                (+ 2000
                    (* spellpower 200)))
            (message target "You are surrounded by a magical barrier.")
            (CALL gain_xp 3 25)
            (ATEND
                (message target "Your magical barrier dissipates.")
                (sfx target SFX_UNBARRIER 0)))))

(SPELL (LOCAL) summon-spiky-mushrooms "#kalrenk" ()
    (LET level 1)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 33)
            (CASTTIME 20000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "HardSpike" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 1 26)
            (CALL summon_spell 1019
                (+ 1
                    (/ spellpower 120))
                (- 5000
                    (* spellpower 9))
                (* spellpower 400)
                2))))

(SPELL (LOCAL) summon-fluffies "#kalakarenk" ()
    (LET level 1)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 39)
            (CASTTIME 20000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "WhiteFur" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 1 27)
            (CALL summon_spell 1020
                (+
                    (+ 1
                        (/ spellpower 170))
                    (/ spellpower 430))
                (- 5000
                    (* spellpower 8))
                (* spellpower 350)
                2))))

(SPELL (LOCAL) summon-mouboo "#kalboo" ()
    (LET level 1)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 35)
            (CASTTIME 20000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "MoubooFigurine" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 2 37)
            (CALL summon_spell 1028
                (+ 1
                    (/ spellpower 270))
                (- 4000
                    (* spellpower 9))
                (* spellpower 100)
                2))))

(SPELL (LOCAL) summon-pinkie "#kalgina" ()
    (LET level 1)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 35)
            (CASTTIME 20000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "PinkAntenna" "Root"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (CALL gain_xp 2 38)
            (CALL summon_spell 1018
                (+ 1
                    (/ spellpower 120))
                (- 5000
                    (* spellpower 9))
                (* spellpower 150)
                2))))

(SPELL () detect-players "#inwilt" ()
    (LET level 1)
    (LET school MAGIC)
    (=>
        (GUARD
            (MANA 7)
            (CASTTIME 300)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level)))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (SET message "")
            (FOREACH PC target
                (rbox
                    (location caster)
                    (/ spellpower 2))
                (IF (&&
                        (&&
                            (!= target caster)
                            (not
                                (running_status_update
                                    (pc target)
                                    SC_HIDE)))
                        (not
                            (status_option target SO_GMINVISIBLE)))
                    (BLOCK
                        (IF (!= message "")
                            (SET message
                                (+ message ", ")))
                        (SET message
                            (+ message
                                (name_of target)))
                        (IF (> spellpower 99)
                            (SET message
                                (+
                                    (+
                                        (+ message "(")
                                        (level target))
                                    ")"))))))
            (IF (== message "")
                (message caster "You sense no-one else nearby.")
                (message caster
                    (+ "You sense the following: " message))))))

(SPELL () enchant-lifestone "#manpahil" ()
    (LET level 1)
    (LET school MAGIC)
    (=>
        (GUARD
            (MANA 15)
            (CASTTIME 4000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (GUARD
                (OR
                    (OR
                        (COMPONENTS "BugLeg")
                        (COMPONENTS "MaggotSlime"))
                    (COMPONENTS "MauveHerb" "AlizarinHerb" "CobaltHerb" "GambogeHerb"))))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (create_item caster "Lifestone" 1)
            (CALL gain_xp 1 28))))

(SPELL () sense-spouse "#inzuwilt" ()
    (LET level 1)
    (LET school MAGIC)
    (=>
        (GUARD
            (MANA 7)
            (CASTTIME 400)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (is_married caster))
            (REQUIRE
                (is_equipped caster "WeddingRing")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (IF (||
                    (failed
                        (partner caster))
                    (not
                        (is_equipped
                            (partner caster)
                            "WeddingRing")))
                (BLOCK
                    (message caster "You cannot sense your partner.")
                    (ABORT)))
            (SET partner
                (partner caster))
            (SET name
                (name_of partner))
            (IF (||
                    (is_dead partner)
                    (!=
                        (map_nr
                            (location partner))
                        (map_nr
                            (location caster))))
                (BLOCK
                    (message caster
                        (+
                            (+ "You cannot sense " name)
                            " nearby."))
                    (ABORT)))
            (IF (&&
                    (>
                        (map_level
                            (location partner))
                        2)
                    (<
                        (map_level
                            (location caster))
                        (map_level
                            (location partner))))
                (BLOCK
                    (message caster
                        (+
                            (+ "You sense " name)
                            " somewhere below."))
                    (ABORT)))
            (IF (&&
                    (>
                        (map_level
                            (location caster))
                        2)
                    (<
                        (map_level
                            (location partner))
                        (map_level
                            (location caster))))
                (BLOCK
                    (message caster
                        (+
                            (+ "You sense " name)
                            " somewhere above."))
                    (ABORT)))
            (IF (!=
                    (map_level
                        (location caster))
                    (map_level
                        (location partner)))
                (message caster
                    (+
                        (+ "You sense " name)
                        " somewhere in the vincinity."))
                (BLOCK
                    (SET distance
                        (rdistance
                            (location caster)
                            (location partner)))
                    (SET dir
                        (dir_towards
                            (location caster)
                            (location partner)
                            1))
                    (IF (< distance 3)
                        (message caster
                            (+
                                (+ "You sense " name)
                                " right next to you."))
                        (IF (< distance 30)
                            (message caster
                                (+
                                    (+
                                        (+
                                            (+ "You sense " name)
                                            " close by, towards the ")
                                        dir)
                                    "."))
                            (IF (< distance 200)
                                (message caster
                                    (+
                                        (+
                                            (+
                                                (+ "You sense " name)
                                                " nearby, towards the ")
                                            dir)
                                        "."))
                                (message caster
                                    (+
                                        (+
                                            (+
                                                (+ "You sense " name)
                                                " in the ")
                                            dir)
                                        "."))))))))))

(SPELL () hide "#anwiltyp" (PC target)
    (LET level 1)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 11)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (GUARD
                (OR
                    (REQUIRE
                        (>
                            (skill caster school)
                            3))
                    (COMPONENTS "CottonCloth")))
            (REQUIRE
                (<
                    (rdistance
                        (location target)
                        (location caster))
                    (+ 2
                        (/ spellpower 30)))))
        (EFFECT
            (CALL adjust_spellpower school)
            (sfx target SFX_DEFAULT 0)
            (IF (!= caster target)
                (CALL default_effect))
            (status_change target SC_HIDE 0 0 0 0
                (+ 5000
                    (* spellpower 2500)))
            (CALL gain_xp 2 29)
            (message target "You are hidden!")
            (IF (!= caster target)
                (message caster "You hid someone!"))
            (ATEND
                (message target "You are no longer hidden.")))))

"--------------------------------------------------------------------------------"
"Level 2 spells"
"--------------------------------------------------------------------------------"
(SPELL () cure-poison "#anju" (PC target)
    (LET level 2)
    (LET school LIFE)
    (=>
        (GUARD
            (MANA 15)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (<
                    (rdistance
                        (location caster)
                        (location
                            (pc target)))
                    (+ 1
                        (/ spellpower 60))))
            (COMPONENTS "GambogeHerb"))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (IF (running_status_update target SC_POISON)
                (BLOCK
                    (CALL gain_heal_xp 40 1 2 2)
                    (stop_status_change target SC_POISON)
                    (CALL gain_xp 2 30)
                    (IF (!= caster target)
                        (sfx target SFX_HEAL 0)))))))

(SPELL () fire-ball "#flarfol" ()
    (LET level 2)
    (LET school WAR)
    (=>
        (GUARD
            (MANA 30)
            (CASTTIME 1000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (COMPONENTS "PileOfAsh"))
        (EFFECT
            (CALL adjust_spellpower school)
            (SET damage
                (min
                    (+ 50
                        (*
                            (skill caster school)
                            40))
                    (+ 30
                        (/
                            (* spellpower 3)
                            2))))
            (SET damage_bonus
                (+
                    (level caster)
                    (* spellpower 2)))
            (SET radius
                (+ 2
                    (/ spellpower 50)))
            (CALL install_attack_spell
                (+ 1
                    (/ spellpower 60))
                5000
                10
                31)
            (ATTRIGGER
                (CALL attack_check target)
                (SET loc
                    (location target))
                (DISABLED (WAIT 500))
                (sfx loc 16 0)
                (FOREACH TARGET target
                    (rbox loc radius)
                    (IF (line_of_sight loc
                            (location target))
                        (BLOCK
                            (SET divisor
                                (+ 3
                                    (rdistance loc
                                        (location target))))
                            (CALL elt_damage target
                                (/
                                    (* damage 3)
                                    divisor)
                                (/
                                    (* damage_bonus 3)
                                    divisor)
                                ELT_WATER
                                ELT_FIRE
                                15))))))))

(SPELL () summon-partner "#kalzumin" ()
    (LET level 2)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 30)
            (CASTTIME 2000)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level))
            (REQUIRE
                (is_married caster))
            (REQUIRE
                (is_equipped caster "WeddingRing")))
        (EFFECT
            (CALL adjust_spellpower school)
            (CALL default_effect)
            (IF (failed
                    (partner caster))
                (message caster "You call out for your partner, but there is no response.")
                (BLOCK
                    (message caster
                        (+
                            (+ "You call out for "
                                (name_of
                                    (partner caster)))
                            "."))
                    (message
                        (partner caster)
                        (+
                            (name_of caster)
                            " is calling for your aid!"))
                    (sfx
                        (partner caster)
                        2
                        0)
                    (WAIT
                        (max 5000
                            (- 30000
                                (* spellpower 60))))
                    (IF (failed
                            (partner caster))
                        (message caster "Your partner has abandoned you.")
                        (IF (is_dead
                                (partner caster))
                            (message caster
                                (+
                                    (+ "Something seems to have happened to "
                                        (name_of
                                            (partner caster)))
                                    "."))
                            (BLOCK
                                (sfx
                                    (location
                                        (partner caster))
                                    SFX_TELEPORT
                                    0)
                                (SET dest
                                    (awayfrom
                                        (location caster)
                                        (random_dir 1)
                                        1))
                                (warp
                                    (partner caster)
                                    dest)
                                (sfx dest SFX_TELEPORT 0)))))))))

"--------------------------------------------------------------------------------"
"Level 4 spells"
"--------------------------------------------------------------------------------"
(SPELL () shroud "#anwilvimar" ()
    (LET level 4)
    (LET school NATURE)
    (=>
        (GUARD
            (MANA 40)
            (CASTTIME 400)
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level)))
        (EFFECT
            (CALL default_effect)
            (shroud caster 0x04))))

(SPELL () teleport "#vorp" (STRING destination)
    (LET level 4)
    (LET school ASTRAL)
    (=>
        (GUARD
            (MANA 80)
            (CASTTIME 400)
            (DISABLED (COMPONENT "EtherEssence"))
            (DISABLED (CATALYST "TeleportCrystal"))
            (REQUIRE
                (>
                    (skill caster MAGIC)
                    level))
            (REQUIRE
                (>
                    (skill caster school)
                    level)))
        (EFFECT
            (CALL default_effect)
            (WAIT
                (+ 1000
                    (/ 200000
                        (+ spellpower 10))))
            (sfx
                (location caster)
                SFX_TELEPORT
                200)
            (warp caster
                (random_location
                    (anchor destination)))
            (sfx caster SFX_TELEPORT 200))))

"--------------------------------------------------------------------------------"
"Debug keywords"
"--------------------------------------------------------------------------------"
(SPELL () debug "debug" ()
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (message caster
                (+
                    (+
                        (+
                            (+
                                (+
                                    (+
                                        (+
                                            (+
                                                (+
                                                    (+
                                                        (+
                                                            (+
                                                                (+
                                                                    (+
                                                                        (+
                                                                            (+
                                                                                (+
                                                                                    (+
                                                                                        (+
                                                                                            (+
                                                                                                (+
                                                                                                    (+
                                                                                                        (+
                                                                                                            (+
                                                                                                                (+
                                                                                                                    (+
                                                                                                                        (+
                                                                                                                            (+
                                                                                                                                (+
                                                                                                                                    (+
                                                                                                                                        (+
                                                                                                                                            (+
                                                                                                                                                (+
                                                                                                                                                    (+
                                                                                                                                                        (+
                                                                                                                                                            (+
                                                                                                                                                                (+
                                                                                                                                                                    (+
                                                                                                                                                                        (+
                                                                                                                                                                            (+
                                                                                                                                                                                (+
                                                                                                                                                                                    (+
                                                                                                                                                                                        (+
                                                                                                                                                                                            (+
                                                                                                                                                                                                (+
                                                                                                                                                                                                    (+
                                                                                                                                                                                                        (+ "FLAGS: " "drank=")
                                                                                                                                                                                                        (>
                                                                                                                                                                                                            (&
                                                                                                                                                                                                                (script_int caster "MAGIC_FLAGS")
                                                                                                                                                                                                                1)
                                                                                                                                                                                                            0))
                                                                                                                                                                                                    ", ")
                                                                                                                                                                                                "Kmseed=")
                                                                                                                                                                                            (>
                                                                                                                                                                                                (&
                                                                                                                                                                                                    (script_int caster "MAGIC_FLAGS")
                                                                                                                                                                                                    2)
                                                                                                                                                                                                0))
                                                                                                                                                                                        ", ")
                                                                                                                                                                                    "touched-mseed=")
                                                                                                                                                                                (>
                                                                                                                                                                                    (&
                                                                                                                                                                                        (script_int caster "MAGIC_FLAGS")
                                                                                                                                                                                        4)
                                                                                                                                                                                    0))
                                                                                                                                                                            ", ")
                                                                                                                                                                        "mseed-max=")
                                                                                                                                                                    (>
                                                                                                                                                                        (&
                                                                                                                                                                            (script_int caster "MAGIC_FLAGS")
                                                                                                                                                                            8)
                                                                                                                                                                        0))
                                                                                                                                                                ", ")
                                                                                                                                                            "Kauldsbel=")
                                                                                                                                                        (>
                                                                                                                                                            (&
                                                                                                                                                                (script_int caster "MAGIC_FLAGS")
                                                                                                                                                                16)
                                                                                                                                                            0))
                                                                                                                                                    ", ")
                                                                                                                                                "Kwyara=")
                                                                                                                                            (>
                                                                                                                                                (&
                                                                                                                                                    (script_int caster "MAGIC_FLAGS")
                                                                                                                                                    32)
                                                                                                                                                0))
                                                                                                                                        ", ")
                                                                                                                                    "Ksagatha=")
                                                                                                                                (>
                                                                                                                                    (&
                                                                                                                                        (script_int caster "MAGIC_FLAGS")
                                                                                                                                        64)
                                                                                                                                    0))
                                                                                                                            ", ")
                                                                                                                        "Kmpotion=")
                                                                                                                    (>
                                                                                                                        (&
                                                                                                                            (script_int caster "MAGIC_FLAGS")
                                                                                                                            128)
                                                                                                                        0))
                                                                                                                ", ")
                                                                                                            "mseed-rumour=")
                                                                                                        (>
                                                                                                            (&
                                                                                                                (script_int caster "MAGIC_FLAGS")
                                                                                                                256)
                                                                                                            0))
                                                                                                    ", ")
                                                                                                "Kcuttree=")
                                                                                            (>
                                                                                                (&
                                                                                                    (script_int caster "MAGIC_FLAGS")
                                                                                                    512)
                                                                                                0))
                                                                                        ", ")
                                                                                    "cut=")
                                                                                (>
                                                                                    (&
                                                                                        (script_int caster "MAGIC_FLAGS")
                                                                                        1024)
                                                                                    0))
                                                                            ", ")
                                                                        "Kdruidtree=")
                                                                    (>
                                                                        (&
                                                                            (script_int caster "MAGIC_FLAGS")
                                                                            2048)
                                                                        0))
                                                                ", ")
                                                            "Kimp=")
                                                        (>
                                                            (&
                                                                (script_int caster "MAGIC_FLAGS")
                                                                4096)
                                                            0))
                                                    ", ")
                                                "Koldwiz=")
                                            (>
                                                (&
                                                    (script_int caster "MAGIC_FLAGS")
                                                    8192)
                                                0))
                                        ", ")
                                    "made-conc=")
                                (>
                                    (&
                                        (script_int caster "MAGIC_FLAGS")
                                        16384)
                                    0))
                            ", ")
                        "elanore-omar=")
                    (>
                        (&
                            (script_int caster "MAGIC_FLAGS")
                            32768)
                        0)))
            (message caster
                (+
                    (+
                        (+
                            (+
                                (+ "EXP: "
                                    (&
                                        (script_int caster "MAGIC_EXPERIENCE")
                                        0xffff))
                                ", lastspell=")
                            (&
                                (>>
                                    (script_int caster "MAGIC_EXPERIENCE")
                                    16)
                                0xff))
                        ", healexp=")
                    (&
                        (>>
                            (script_int caster "MAGIC_EXPERIENCE")
                            24)
                        0xff)))
            (message caster
                (+
                    (+
                        (+
                            (+
                                (+
                                    (+
                                        (+
                                            (+
                                                (+
                                                    (+
                                                        (+
                                                            (+
                                                                (+
                                                                    (+
                                                                        (+
                                                                            (+
                                                                                (+
                                                                                    (+
                                                                                        (+
                                                                                            (+
                                                                                                (+
                                                                                                    (+
                                                                                                        (+
                                                                                                            (+
                                                                                                                (+
                                                                                                                    (+
                                                                                                                        (+
                                                                                                                            (+ "STATUS: " "auldsbel:")
                                                                                                                            (&
                                                                                                                                (script_int caster "QUEST_MAGIC")
                                                                                                                                0x1f))
                                                                                                                        ",")
                                                                                                                    (&
                                                                                                                        (>>
                                                                                                                            (script_int caster "QUEST_MAGIC")
                                                                                                                            5)
                                                                                                                        0x7))
                                                                                                                ", ")
                                                                                                            "dt/mb:")
                                                                                                        (&
                                                                                                            (>>
                                                                                                                (script_int caster "QUEST_MAGIC")
                                                                                                                8)
                                                                                                            0xf))
                                                                                                    ", ")
                                                                                                "s-unhappy:")
                                                                                            (&
                                                                                                (>>
                                                                                                    (script_int caster "QUEST_MAGIC")
                                                                                                    12)
                                                                                                0xf))
                                                                                        ", ")
                                                                                    "sagatha:")
                                                                                (&
                                                                                    (>>
                                                                                        (script_int caster "QUEST_MAGIC")
                                                                                        16)
                                                                                    0xff))
                                                                            ", ")
                                                                        "swords:")
                                                                    (&
                                                                        (>>
                                                                            (script_int caster "QUEST_MAGIC")
                                                                            24)
                                                                        0xff))
                                                                ", ")
                                                            "imp:")
                                                        (&
                                                            (>>
                                                                (script_int caster "QUEST_MAGIC2")
                                                                0)
                                                            0xf))
                                                    ", ")
                                                "elanore:")
                                            (&
                                                (>>
                                                    (script_int caster "QUEST_MAGIC2")
                                                    4)
                                                0xf))
                                        ", ")
                                    "elanore-sub:")
                                (&
                                    (>>
                                        (script_int caster "QUEST_MAGIC2")
                                        12)
                                    0xf))
                            ", ")
                        "wyara:")
                    (&
                        (>>
                            (script_int caster "QUEST_MAGIC2")
                            8)
                        0xf))))))
(PROCEDURE debug_xmod (name mask shift gain)
    (SET value
        (+
            (&
                (>>
                    (script_int caster name)
                    shift)
                mask)
            gain))
    (IF (< value 0)
        (SET value 0))
    (IF (> value mask)
        (SET value mask))
    (CALL set_var name mask shift value))
(PROCEDURE debug_mod (name delta)
    (IF (== name "mexp")
        (CALL debug_xmod "MAGIC_EXPERIENCE" 0xffff 0 delta)
        (IF (== name "lastspell")
            (CALL debug_xmod "MAGIC_EXPERIENCE" 0xff 16 delta)
            (IF (== name "healexp")
                (CALL debug_xmod "MAGIC_EXPERIENCE" 0xff 24 delta)
                (IF (== name "drank")
                    (CALL debug_xmod "MAGIC_FLAGS" 0x1 0 delta)
                    (IF (== name "Kmseed")
                        (CALL debug_xmod "MAGIC_FLAGS" 0x1 1 delta)
                        (IF (== name "touched-mseed")
                            (CALL debug_xmod "MAGIC_FLAGS" 0x1 2 delta)
                            (IF (== name "mseed-max")
                                (CALL debug_xmod "MAGIC_FLAGS" 0x1 3 delta)
                                (IF (== name "Kauldsbel")
                                    (CALL debug_xmod "MAGIC_FLAGS" 0x1 4 delta)
                                    (IF (== name "Kwyara")
                                        (CALL debug_xmod "MAGIC_FLAGS" 0x1 5 delta)
                                        (IF (== name "Ksagatha")
                                            (CALL debug_xmod "MAGIC_FLAGS" 0x1 6 delta)
                                            (IF (== name "Kmpotion")
                                                (CALL debug_xmod "MAGIC_FLAGS" 0x1 7 delta)
                                                (IF (== name "mseed-rumour")
                                                    (CALL debug_xmod "MAGIC_FLAGS" 0x1 8 delta)
                                                    (IF (== name "Kcuttree")
                                                        (CALL debug_xmod "MAGIC_FLAGS" 0x1 9 delta)
                                                        (IF (== name "cut")
                                                            (CALL debug_xmod "MAGIC_FLAGS" 0x1 10 delta)
                                                            (IF (== name "Kdruidtree")
                                                                (CALL debug_xmod "MAGIC_FLAGS" 0x1 11 delta)
                                                                (IF (== name "Kimp")
                                                                    (CALL debug_xmod "MAGIC_FLAGS" 0x1 12 delta)
                                                                    (IF (== name "oldwiz")
                                                                        (CALL debug_xmod "MAGIC_FLAGS" 0x1 13 delta)
                                                                        (IF (== name "made-conc")
                                                                            (CALL debug_xmod "MAGIC_FLAGS" 0x1 14 delta)
                                                                            (IF (== name "elanore-omar")
                                                                                (CALL debug_xmod "MAGIC_FLAGS" 0x1 15 delta)
                                                                                (IF (== name "auldsbel")
                                                                                    (CALL debug_xmod "QUEST_MAGIC" 0x1f 0 delta)
                                                                                    (IF (== name "Qauldsbel")
                                                                                        (CALL debug_xmod "QUEST_MAGIC" 0x7 5 delta)
                                                                                        (IF (== name "dt")
                                                                                            (CALL debug_xmod "QUEST_MAGIC" 0x3 10 delta)
                                                                                            (IF (== name "mb")
                                                                                                (CALL debug_xmod "QUEST_MAGIC" 0x3 8 delta)
                                                                                                (IF (== name "s-unhappy")
                                                                                                    (CALL debug_xmod "QUEST_MAGIC" 0xff 12 delta)
                                                                                                    (IF (== name "sagatha")
                                                                                                        (CALL debug_xmod "QUEST_MAGIC" 0xff 16 delta)
                                                                                                        (IF (== name "swords")
                                                                                                            (CALL debug_xmod "QUEST_MAGIC" 0xff 24 delta)
                                                                                                            (IF (== name "imp")
                                                                                                                (CALL debug_xmod "QUEST_MAGIC2" 0xf 0 delta)
                                                                                                                (IF (== name "elanore")
                                                                                                                    (CALL debug_xmod "QUEST_MAGIC2" 0xf 4 delta)
                                                                                                                    (IF (== name "wyara")
                                                                                                                        (CALL debug_xmod "QUEST_MAGIC2" 0xf 8 delta)
                                                                                                                        (IF (== name "elanore-sub")
                                                                                                                            (CALL debug_xmod "QUEST_MAGIC2" 0xf 12 delta)
                                                                                                                            (message caster "Unknown"))))))))))))))))))))))))))))))))

(SPELL () debug-up1 "debug+1" (STRING name)
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (CALL debug_mod name 1))))

(SPELL () debug-down1 "debug-1" (STRING name)
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (CALL debug_mod name
                (- 0 1)))))

(SPELL () debug-up16 "debug+16" (STRING name)
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (CALL debug_mod name 16))))

(SPELL () debug-down16 "debug-16" (STRING name)
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (CALL debug_mod name
                (- 0 16)))))

(SPELL () debug-up256 "debug+256" (STRING name)
    (=>
        (REQUIRE DEBUG)
        (EFFECT

            (CALL debug_mod name 256))))
(SPELL () debug-down256 "debug-256" (STRING name)
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (CALL debug_mod name
                (- 0 256)))))

(SPELL () debug-reset "debug-reset" ()
    (=>
        (REQUIRE DEBUG)
        (EFFECT
            (set_script_variable caster "QUEST_MAGIC"
                0)
            (set_script_variable caster "QUEST_MAGIC2"
                0)
            (set_script_variable caster "MAGIC_FLAGS"
                0)
            (set_script_variable caster "MAGIC_EXP"
                0))))

"--------------------------------------------------------------------------------"
"Special-purpose quasispells"
"--------------------------------------------------------------------------------"
(SPELL (NONMAGIC SILENT) marriage "marry" (PC target)
    (=>
        (GUARD
            (REQUIRE
                (||
                    (is_in
                        (location caster)
                        (@+
                            (@ "014-1.gat" 28 39)
                            8
                            6))
                    (is_in
                        (location caster)
                        (@+
                            (@ "021-2.gat" 20 25)
                            4
                            4)))))
        (EFFECT
            (IF (== target caster)
                (ABORT)) "no valid target or tried to marry self?"
            (IF (<
                    (level caster)
                    MIN_MARRY_LEVEL)
                (BLOCK
                    (message caster
                        (+
                            (+ "You must be level " MIN_MARRY_LEVEL)
                            " or higher to marry!"))
                    (ABORT)))
            (IF (<
                    (level target)
                    MIN_MARRY_LEVEL)
                (BLOCK
                    (message caster
                        (+
                            (+ "Your partner must be level " MIN_MARRY_LEVEL)
                            " or higher to marry!"))
                    (ABORT)))
            (IF (==
                    (partner caster)
                    target)
                (BLOCK
                    (message caster
                        (+
                            (+ "You and "
                                (name_of target))
                            " are already married."))
                    (ABORT)))
            (IF (is_married caster)
                (BLOCK
                    (message caster "You are already married!")
                    (ABORT)))
            (IF (is_married target)
                (BLOCK
                    (message caster
                        (+
                            (name_of target)
                            " is already married."))
                    (ABORT)))
            (IF (!=
                    (distance
                        (location caster)
                        (location target))
                    1)
                (BLOCK
                    (message caster "You need to stand next to each other.")
                    (ABORT)))
            (IF (||
                    (==
                        (count_item caster "WeddingRing")
                        0)
                    (==
                        (count_item target "WeddingRing")
                        0))
                (BLOCK
                    (message caster "You must both be wearing your wedding rings!")
                    (ABORT)))
            (SET script_target target)
            (SCRIPT "{
                announce @caster_name$ + \" is asking \" + strcharinfo(0) + \" for marriage.\", 2;
                mes @caster_name$ + \" wishes to marry you.\";
                mes \"Do you accept?\";
                next;
                menu
                    \"Yes, I do!\", L_yes,
                    \"No.\", L_Close;

            L_yes:
                if (marriage(@caster_name$))
                    announce @caster_name$ + \" and \" + strcharinfo(0) + \" are now married!\", 0;
                goto L_Close;

            L_Close:
                close;
            }")
            (IF (not
                    (is_married caster))
                (message caster
                    (+
                        (name_of target)
                        " turned down your marriage offer."))))))

(SPELL (LOCAL) mouboo-groan "#g" ()
    (=>
        (GUARD
            (MANA 1)
            (REQUIRE
                (==
                    (name_of caster)
                    "MOUBOOTAUR")))
        (EFFECT
            (FOREACH PC p
                (rbox
                    (location caster)
                    200)
                (SET distance
                    (rdistance
                        (location caster)
                        (location p))))
            (IF (< distance 15)
                (message p "The moubootaur's groaning rings in your ears!")
                (IF (< distance 70)
                    (message p "You hear a loud groaning noise, not far away...")
                    (message p "You hear an odd groaning noise in the distance..."))))))

(SPELL (LOCAL) mouboo-smell "#s" ()
    (=>
        (GUARD
            (MANA 1)
            (REQUIRE
                (==
                    (name_of caster)
                    "MOUBOOTAUR")))
        (EFFECT
            (WAIT 30000)
            (FOREACH PC p
                (rbox
                    (location caster)
                    30)
                (message p "You notice a strange smell all around you.")))))

(SPELL (NONMAGIC SILENT) world-shift "#alonzialonzo" ()
    (=>
        (GUARD
            (REQUIRE
                (&&
                    (==
                        (&
                            (>>
                                (script_int caster "Easter_2010_QuestState")
                                16)
                            1)
                        1)
                    (==
                        (&
                            (>>
                                (script_int caster "Easter_2010_QuestState")
                                7)
                            3)
                        2))) "Travel only works when you have both helped the doctor at least thrice and have defeated the invader - top level requirement." )
        (|
            (=>
                (GUARD
                    (REQUIRE
                        (&&
                            (&&
                                (count_item caster "DarkPetal")
                                (!=
                                    (map_nr
                                        (location caster))
                                    52))
                            (!=
                                (map_nr
                                    (location caster))
                                5698))) "Allow unlimited travel with the petal, 52 Do not allow if player is in Illia island, 5698 Do not allow if player is in botcheck area" )
                (|
                    (=>
                        (GUARD
                            (REQUIRE
                                (<
                                    (rdistance
                                        (location caster)
                                        (@ "028-1.gat" 69 70))
                                    5)))
                        (EFFECT
                            (sfx
                                (location caster)
                                SFX_TELEPORT
                                200)
                            (WAIT 8000)
                            (SCRIPT "{
                                savepoint \"009-1\", 52, 39;
                            }")
                            (warp caster
                                (@ "009-1.gat" 55 37))
                            (sfx
                                (location caster)
                                SFX_TELEPORT
                                200)))
                    (=>
                        (GUARD
                            (REQUIRE
                                (!=
                                    (map_nr
                                        (location caster))
                                    28)))
                        (EFFECT
                            (SET inithp
                                (hp caster)) "Store this value."
                            (sfx
                                (location caster)
                                SFX_TELEPORT
                                200)
                            (IF (||
                                    (||
                                        (||
                                            (==
                                                (map_nr
                                                    (location caster))
                                                9)
                                            (==
                                                (map_nr
                                                    (location caster))
                                                1))
                                        (==
                                            (map_nr
                                                (location caster))
                                            21))
                                    (==
                                        (map_nr
                                            (location caster))
                                        20))
                                (WAIT 8000)
                                (WAIT 20000))
                            (IF (<
                                    (hp caster)
                                    inithp)
                                (ABORT)) "Cancel teleport if the player took damage during channel time (hacky, but for most purposes should work.)"
                            (SCRIPT "{
                                savepoint \"028-1\", 69, 71;
                            }")
                            (warp caster
                                (@ "028-1.gat" 69 70))
                            (sfx
                                (location caster)
                                SFX_TELEPORT
                                200)))))
            (|
                (=>
                    (REQUIRE
                        (<
                            (rdistance
                                (location caster)
                                (@ "028-1.gat" 69 70))
                            5))
                    (EFFECT
                        (set_script_variable caster "Easter_2010_QuestState"
                            (|
                                (script_int caster "Easter_2010_QuestState")
                                (<< 1 17)))
                        (sfx
                            (location caster)
                            SFX_TELEPORT
                            200)
                        (WAIT 8000)
                        (SCRIPT "{
                            savepoint \"009-1\", 52, 39;
                        }")
                        (warp caster
                            (@ "009-1.gat" 55 37))
                        (sfx
                            (location caster)
                            SFX_TELEPORT
                            200)))
                (=>
                    (GUARD
                        (REQUIRE
                            (&&
                                (!=
                                    (map_nr
                                        (location caster))
                                    28)
                                (==
                                    (&
                                        (>>
                                            (script_int caster "Easter_2010_QuestState")
                                            17)
                                        1)
                                    0))) "Allow for one free warp home without the petal" )
                    (EFFECT
                        (SET inithp
                            (hp caster)) "Store this value."
                        (sfx
                            (location caster)
                            SFX_TELEPORT
                            200)
                        (IF (||
                                (||
                                    (||
                                        (==
                                            (map_nr
                                                (location caster))
                                            9)
                                        (==
                                            (map_nr
                                                (location caster))
                                            1))
                                    (==
                                        (map_nr
                                            (location caster))
                                        21))
                                (==
                                    (map_nr
                                        (location caster))
                                    20))
                            (WAIT 8000)
                            (WAIT 20000))
                        (IF (<
                                (hp caster)
                                inithp)
                            (ABORT)) "Cancel teleport if the player took damage during channel time (hacky, but for most purposes should work.)"
                        (set_script_variable caster "Easter_2010_QuestState"
                            (|
                                (script_int caster "Easter_2010_QuestState")
                                (<< 1 17)))
                        (SCRIPT "{
                            savepoint \"028-1\", 69, 70;
                        }")
                        (warp caster
                            (@ "028-1.gat" 69 70))
                        (sfx
                            (location caster)
                            SFX_TELEPORT
                            200)))))))

(SPELL (NONMAGIC SILENT) easter-get-debug "#e" (PC p)
    (=>
        (GUARD
            (REQUIRE
                (||
                    (==
                        (name_of caster)
                        "Freeyorp")
                    (==
                        (name_of caster)
                        "Xakelbael the Dark"))))
        (EFFECT
            (SCRIPT "{
                message strcharinfo(0), \"Global state egg1: \"+ $Easter_2010_Egg_Loc_State1;
                message strcharinfo(0), \"Global state egg2: \"+ $Easter_2010_Egg_Loc_State2;
                message strcharinfo(0), \"Global state egg3: \"+ $Easter_2010_Egg_Loc_State3;
                message strcharinfo(0), \"Global state egg4: \"+ $Easter_2010_Egg_Loc_State4;
                message strcharinfo(0), \"Global state egg5: \"+ $Easter_2010_Egg_Loc_State5;
                message strcharinfo(0), \"Global npc state1: \"+ $Easter_2010_Npc_State1;
                message strcharinfo(0), \"Global npc state2: \"+ $Easter_2010_Npc_State2;
            }")
            (message caster
                (+ "Local state egg1: "
                    (script_int p "Easter_2010_EggState1")))
            (message caster
                (+ "Local state egg2: "
                    (script_int p "Easter_2010_EggState2")))
            (message caster
                (+ "Local state egg3: "
                    (script_int p "Easter_2010_EggState3")))
            (message caster
                (+ "Local state egg4: "
                    (script_int p "Easter_2010_EggState4")))
            (message caster
                (+ "Local state egg5: "
                    (script_int p "Easter_2010_EggState5")))
            (message caster
                (+ "Local state quest: "
                    (script_int p "Easter_2010_QuestState"))))))

(PROCEDURE hug_tree (target)
    (IF (||
            (||
                (||
                    (||
                        (||
                            (||
                                (||
                                    (||
                                        (== target "")
                                        (== target "tree"))
                                    (== target "tree*"))
                                (== target "Tree"))
                            (== target "Tree*"))
                        (== target "druid"))
                    (== target "druid*"))
                (== target "Druid"))
            (== target "Druid*"))
        (SCRIPT "{
            set @flag, 2;
            callfunc \"QuestTreeTrigger\";
        }")))

(SPELL (NONMAGIC) hug0 "hug" (STRING target)
    (=>
        (REQUIRE
            (||
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree0#_M")))
                    1)
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree1#_M")))
                    1)))
        (EFFECT
            (CALL hug_tree target))))

(SPELL (NONMAGIC) hug1 "*hug*" (STRING target)
    (=>
        (REQUIRE
            (||
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree0#_M")))
                    1)
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree1#_M")))
                    1)))
        (EFFECT
            (CALL hug_tree target))))

(SPELL (NONMAGIC) hug2 "*hug" (STRING target)
    (=>
        (REQUIRE
            (||
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree0#_M")))
                    1)
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree1#_M")))
                    1)))
        (EFFECT
            (CALL hug_tree target))))

(SPELL (NONMAGIC) hug3 "hugs" (STRING target)
    (=>
        (REQUIRE
            (||
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree0#_M")))
                    1)
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree1#_M")))
                    1)))
        (EFFECT
            (CALL hug_tree target))))

(SPELL (NONMAGIC) hug4 "*hugs*" (STRING target)
    (=>
        (REQUIRE
            (||
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree0#_M")))
                    1)
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree1#_M")))
                    1)))
        (EFFECT
            (CALL hug_tree target))))

(SPELL (NONMAGIC) hug5 "*hugs" (STRING target)
    (=>
        (REQUIRE
            (||
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree0#_M")))
                    1)
                (<=
                    (rdistance
                        (location caster)
                        (location
                            (npc "#DruidTree1#_M")))
                    1)))
        (EFFECT
            (CALL hug_tree target))))

"--------------------------------------------------------------------------------"
"Teleport anchors"
"--------------------------------------------------------------------------------"
(TELEPORT-ANCHOR tulimshar "tulimshar"
    (@+
        (@ "001-1.gat" 43 66)
        3
        3))

(TELEPORT-ANCHOR hurnscald "hurnscald"
    (@+
        (@ "009-1.gat" 55 37)
        3
        3))

(TELEPORT-ANCHOR nivalis "nivalis"
    (@+
        (@ "020-1.gat" 75 63)
        19
        12))

(TELEPORT-ANCHOR wizardhut "##00"
    (@+
        (@ "013-1.gat" 41 92)
        3
        3))

(TELEPORT-ANCHOR pachua "##01"
    (@+
        (@ "006-1.gat" 22 101)
        3
        3))

(TELEPORT-ANCHOR desert "##02"
    (@+
        (@ "005-1.gat" 160 64)
        5
        5))

(TELEPORT-ANCHOR forest "##03"
    (@+
        (@ "015-1.gat" 35 35)
        40
        40))

(TELEPORT-ANCHOR snakecave "##04"
    (@+
        (@ "011-4.gat" 50 75)
        3
        3))

(TELEPORT-ANCHOR dimondscove "##05"
    (@+
        (@ "010-2.gat" 23 79)
        3
        3))

"--------------------------------------------------------------------------------"
"Illia spell"
"--------------------------------------------------------------------------------"
(SPELL (NONMAGIC) illia0 "#catalazuli" ()
    (=>
        (REQUIRE
            (==
                (rdistance
                    (location caster)
                    (location
                        (npc "#Power Circle")))
                0))
        (EFFECT
            (SCRIPT "{
                callfunc \"StartChannelling\";}
            "))))

"--------------------------------------------------------------------------------"
"Kill the GM event spell"
"--------------------------------------------------------------------------------"
(SPELL (NONMAGIC) killgm0 "#pullrabbit" ()
    (=>
        (REQUIRE
            (is_equipped caster "MagicGMTopHat"))
        (EFFECT
            (SCRIPT "{
                callfunc \"ActivateMagicGMTophat\";
            }"))))