view ggrtf.tf @ 69:3cfb24dca78d rel-0_5_3

Comments, moving bits around to reorganize for cleaner look
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 27 Sep 2005 12:45:03 +0000
parents f2d0d922596b
children f7a22f1446d8
line wrap: on
line source

;;
;; GGRTF v0.5.3-cvs - TinyFugue script for BatMUD
;; (C) Copyright 2004-2005 Matti 'ccr' Hämäläinen (aka Ggr Pupunen)
;;
;; This triggerset is Free Software distributed under
;; GNU General Public License version 2.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; For installation instructions, please refer to GgrTF's homepage:
;; http://ccr.tnsp.org/ggrtf/
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Commands:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; /stats	- Show various statistics
;; /prots	- Report current prots (see also below)
;; /opts	- List available options and their current value
;;
;; Special triggers:
;; tweak	- Report prots to 'party report'-channel or tweaker (if remote-emote)
;;
;; /comppath		- Shows current path as compressed
;; /csavepath <name>	- Save compressed path as BatMUD command-alias by given name.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The actual scriptcode starts here: initialize, load prereqs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/set status_pad=_
/load map.tf

;; General settings
/set set_prexpr=embedded

;; Misc
/set battle_target=
/set battle_st=off
/set spell_st=off
/set skill_st=off
/set battle_ripfuncs=
/set battle_endfuncs=
/set battle_roundfuncs=
/set cast_info=

;; Counters
/set cnt_casts=0
/set cnt_scasts=0
/set cnt_icasts=0
/set cnt_fcasts=0
/set cnt_fucasts=0

/set cnt_hastes=0
/set cnt_ghastes=0
/set cnt_trounds=0

/set cnt_damcrits=0
/set cnt_dcrit1=0
/set cnt_dcrit2=0
/set cnt_dcrit3=0
/set cnt_dcrit4=0

/set cnt_skills=0
/set cnt_sskills=0
/set cnt_iskills=0
/set cnt_fskills=0
/set cnt_fuskills=0


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helper functions, etc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/def msq = /echo -p @{BCwhite}GGRTF@{n}: %*
;/def msr = /if ({opt_verbose}=~"on") @msr %*%;/else /msq %*%;/endif
;/def msp = /if ({opt_verbose}=~"on") @msp %*%;/else /msq %*%;/endif
;/def mse = /if ({opt_verbose}=~"on") @mse %*%;/else /msq %*%;/endif

/def msr = /if ({opt_verbose}=~"on") @@party report %*%;/else /msq %*%;/endif
/def msp = /if ({opt_verbose}=~"on") @@party say %*%;/else /msq %*%;/endif
/def mse = /if ({opt_verbose}=~"on") @@party say emote %*%;/else /msq %*%;/endif


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Execute macros given as parameters
/def -i prexecfuncs =\
/while ({#})\
	/eval /%{1}%;\
	/shift%;\
/done

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Report current statistics
/def -i stats =\
/let qs1=%{cnt_casts} casts, %{cnt_scasts} succ, %{cnt_fcasts} fail, %{cnt_icasts} intr, %{cnt_fucasts} fumbled.%;\
/let qs2=%{cnt_hastes} hastes, %{cnt_ghastes} ghastes, %{cnt_trounds} total rounds.%;\
/let qs3=%{cnt_damcrits} total, %{cnt_dcrit1} lvl#1, %{cnt_dcrit2} lvl#2, %{cnt_dcrit3} lvl#3, %{cnt_dcrit4} lvl#4%;\
/let qs4=%{cnt_skills} skills, %{cnt_sskills} succ, %{cnt_fskills} fail, %{cnt_iskills} intr, %{cnt_fuskills} fumbled.%;\
/msq ,------------------.%;\
/msq | @{BCgreen}ggrTF@{n} @{Cyellow}Statistics@{n} |%;\
/msq +------------------+-------------------------------------------------.%;\
/msq | Spells........: $[pad(qs1,-50)] |%;\
/msq | Cast time.....: $[pad(qs2,-50)] |%;\
/msq | Damcrits......: $[pad(qs3,-50)] |%;\
/msq | Skills........: $[pad(qs4,-50)] |%;\
/msq `--------------------------------------------------------------------'


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Return string describing time elapsed from given timestamp parameter
/def -i prgetstime =\
/if ({1} > 0)\
	/let jtime=$[time() - {1}]%;\
	/let jtimeh=$[jtime / 3600]%;\
	/let jtimeq=$[mod(jtime,3600)]%;\
	/if ({jtimeh} > 0)\
		/let jstr=[%{jtimeh}h%;\
		/else \
		/let jstr=[%;\
		/endif%;\
	/let jstr=%{jstr}$[jtimeq / 60]m$[mod(jtimeq,60)]s]%;\
	/return jstr%;\
	/else \
	/return%;\
	/endif

/def -i prgetstime_2 =\
/if ({1} > 0)\
	/let jtime=$[time() - {1}]%;\
	/let jtimeh=$[jtime / 3600]%;\
	/let jtimeq=$[mod(jtime,3600)]%;\
	/if ({jtimeh} > 0)\
		/let jstr=[%{jtimeh}:%;\
		/else \
		/let jstr=[%;\
		/endif%;\
	/let jstr=%{jstr}$[jtimeq / 60]:$[mod(jtimeq,60)]]%;\
	/return jstr%;\
	/else \
	/return%;\
	/endif


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Return a color definition based on [n, nmax] (useful for hp/sp/ep lites)
/def -i prgetnlite =
	


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; List available options
/def -i opts_dolist =\
/while ({#})\
	/eval /set qtval=$$[opt_%{1}]%;\
	/eval /set qtval_d=$$[opt_%{1}_d]%;\
	/if ({qtval}=~"on") /set qtval_s=@{BCgreen} ON@{n}%;/else /set qtval_s=@{Cred}OFF@{n}%;/endif%;\
	/msq | /@{BCyellow}$[pad({1},-10)]@{n} : $[pad(qtval_d,-40)] - [%{qtval_s}]      |%;\
	/shift%;\
/done

/def -i settings_dolist =\
/while ({#})\
	/eval /set qtval=$$[set_%{1}]%;\
	/eval /set qtval_d=$$[set_%{1}_d]%;\
	/eval /set qtval_s=$$[set_%{1}_s]%;\
	/msq | /@{BCyellow}$[pad({1},-10)]@{n} : $[pad(qtval_d,-40)] - [@{Cgreen}$[pad(qtval,8)]@{n}] |%;\
	/shift%;\
/done


/def -i opts =\
/msq ,----------------.%;\
/msq | @{BCgreen}ggrTF@{n} @{Cyellow}Settings@{n} |%;\
/msq +----------------+----------------------------------------------------.%;\
/opts_dolist %{lst_options}%;\
/settings_dolist %{lst_settings}%;\
/settings_dolist %{lst_hooks}%;\
/msq `---------------------------------------------------------------------'


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Option toggles
/set lst_options=
/def -i deftoggle =\
	/if (!getopts("n:d:", "")) /msq ERROR! Invalid toggle creation command!%;/break%;/endif%;\
	/set lst_options=%{opt_n} %{lst_options}%;\
	/set opt_%{opt_n}_d=%{opt_d}%;\
	/eval /def -i %{opt_n} =\
		/if ({opt_%{opt_n}}=~"on")\
			/set opt_%{opt_n}=off%%%;\
			/let qstr=@{Cred}OFF@{n}%%%;\
		/else \
			/set opt_%{opt_n}=on%%%;\
			/let qstr=@{BCgreen}ON@{n}%%%;\
		/endif%%%;\
		/msq @{Cyellow}%{opt_d}@{n} [%%%{qstr}]

;; Settings
/set lst_settings=
/def -i chksetting =\
	/set qrvals=0%;\
	/let qtvals=%{1}%;\
	/shift%;\
	/while ({#})\
		/if ({1}=~{qtvals}) /set qrvals=1%;/break%;/endif%;\
		/shift%;\
	/done


/def -i defsetting =\
	/if (!getopts("n:d:s:", "")) /msq ERROR! Invalid setting creation command!%;/break%;/endif%;\
	/set lst_settings=%{opt_n} %{lst_settings}%;\
	/set set_%{opt_n}_d=%{opt_d}%;\
	/set set_%{opt_n}_s=%{opt_s}%;\
	/eval /def %{opt_n} =\
		/if ({#})\
			/chksetting %%%{1} %%%{set_%{opt_n}_s}%%%;\
			/if ({qrvals}>0)\
				/set set_%{opt_n}=%%%{1}%%%;\
				/msq @{Cyellow}%{opt_n}@{n} : Set to [@{BCgreen}%%%{set_%{opt_n}}@{n}]%%%;\
			/else \
				/msq @{Cyellow}%{opt_n}@{n} : @{BCred}Invalid setting@{n} [@{BCgreen}%%%{1}@{n}]!%%%;\
			/endif%%%;\
		/else \
			/msq @{BCred}/%{opt_n}@{n} - @{Cyellow}%{opt_d}@{n} [@{BCgreen}%%%{set_%{opt_n}_s}@{n}]%%%;\
		/endif

;; Function hook setting
/set lst_hooks=
/def -i defhook =\
	/if (!getopts("n:d:s:h:", "")) /msq ERROR! Invalid function hook setting creation command!%;/break%;/endif%;\
	/set lst_hooks=%{opt_n} %{lst_hooks}%;\
	/set set_%{opt_n}_d=%{opt_d}%;\
	/set set_%{opt_n}_s=%{opt_s}%;\
	/eval /def %{opt_n} =\
		/if ({#})\
			/chksetting %%%{1} %%%{set_%{opt_n}_s}%%%;\
			/if ({qrvals}>0)\
				/set set_%{opt_n}=%%%{1}%%%;\
				/msq @{Cyellow}%{opt_n}@{n} : Set to [@{BCgreen}%%%{set_%{opt_n}}@{n}]%%%;\
				/eval /def -i %{opt_h}=/%{opt_h}_%%%{1} %%%%%*%%%;\
			/else \
				/msq @{Cyellow}%{opt_n}@{n} : @{BCred}Invalid setting@{n} [@{BCgreen}%%%{1}@{n}]!%%%;\
			/endif%%%;\
		/else \
			/msq @{BCred}/%{opt_n}@{n} - @{Cyellow}%{opt_d}@{n} [@{BCgreen}%%%{set_%{opt_n}_s}@{n}]%%%;\
		/endif


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Define some generic option toggles and settings
/set opt_verbose=on
/deftoggle -n"verbose"	-d"Verbose (off = echo to client only)"
/deftoggle -n"rshape"	-d"Report enemy shape when it changes"
/deftoggle -n"rrounds"	-d"Report spell/skill rounds"
/deftoggle -n"rstat"	-d"Report your hp/sp/ep every round"
/deftoggle -n"pss"	-d"Auto party short status"
/deftoggle -n"info"	-d"Cast/skill information in prompt"



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Redefinable macros for user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/def dig_grave = @dig grave
/def eat_corpse = @get corpse;@eat corpse
/def get_corpse = @get corpse


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Define RIP functions
/set battle_ripfuncs=ripfunc
/def -i defripfunc =\
	/eval /set set_ripaction_s=%{1} %{set_ripaction_s}%;\
	/eval /def -i ripfunc_%{1} = %{-1}

/defripfunc off
/defripfunc dig /dig_grave
/defripfunc eat /eat_corpse
/defripfunc get /get_corpse

/defhook -n"ripaction" -d"Set the action performed at RIP" -h"ripfunc" -s"off dig eat get"
/ripaction off


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Movement
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Catch movement commands to update the status bar
/def -i -mglob -h'send {n|s|e|w|ne|sw|nw|se|u|d}' prmove_send =\
	/set prmove_last=%*%;\
	/status_update%;\
	/send %*

;; Normal movement
/def -i prmove_walk = /set prmove_last=%{1}%;/status_update%;@%{1}

;; Autopeering
/def -i prmove_peer = /set prmove_last=%{1}%;/status_update%;@%{1}%;\
	/if ({1}=~"n" | {1}=~"s") /let pd1=w%;/let pd2=e%;/endif%;\
	/if ({1}=~"w" | {1}=~"e") /let pd1=n%;/let pd2=s%;/endif%;\
	@@grep '(%{set_prexpr})' peer %{pd1}%;\
	@@grep '(%{set_prexpr})' peer %{pd2}

;; Ship movement
/deftoggle -n"cruise" -d"Cruise speed on ship (off = sail)"
/def -i prmove_ship = /set prmove_last=%{1}%;/status_update%;\
/if ({opt_cruise}=~"on") @cruise %{1}%;/else @sail %{1}%;/endif


;; Main handling macro for binding movemement keys, etc.
/defhook -n"move" -d"Keyboard movement hooks" -h"prmove" -s"walk ship peer"
/move walk

;; 'view' on every ship move
/def -i -F -mregexp -t"^The ship (sails|cruises) " ship_move = @view


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Status bar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; These macros handle the statusbar functionality. Unfortunately
; some things (like channeller energy aura), etc. are hardcoded here,
; due to some complexities in modularizing them. This might get changed
; in future, though...

;; Add value item (hp/sp/ep/etc) to status string
/def -i status_add_val =\
	/eval /set qtval1v=$$[status_%{1}]%;\
	/eval /set qtval2v=$$[status_%{1}max]%;\
	/let qtval1=status_%{1}%;\
	/let qtval2=status_%{1}max%;\
	/let qtcolor=Cwhite%;\
	/if ({qtval1v} >= (qtval2v * 6 / 7)) /let qtcolor=BCgreen%;/endif%;\
	/if ({qtval1v} < (qtval2v * 6 / 7)) /let qtcolor=Cgreen%;/endif%;\
	/if ({qtval1v} < (qtval2v * 5 / 7)) /let qtcolor=BCyellow%;/endif%;\
	/if ({qtval1v} < (qtval2v * 4 / 7)) /let qtcolor=Cyellow%;/endif%;\
	/if ({qtval1v} < (qtval2v * 3 / 7)) /let qtcolor=Cred%;/endif%;\
	/if ({qtval1v} < (qtval2v * 2 / 7)) /let qtcolor=BCred%;/endif%;\
	/set status_pstr=%{status_pstr} :1 "[%{2}:" %{qtval1}:4:%{qtcolor} "/" %{qtval2}:4:BCgreen "]"

;; Add aura item
/def -i status_add_aura =\
/if ({prot_eaura} > 0)\
	/if ({prot_eaura} == 1) /let qtcolor=BCyellow%;/endif%;\
	/if ({prot_eaura} == 2) /let qtcolor=BCred%;/endif%;\
	/if ({prot_eaura} == 3) /let qtcolor=BCblue%;/endif%;\
	/if ({prot_eaura_weak}=~"on")\
		/let qttimes=$[prgetstime(prot_eaura_weak_t)]%;\
		/let qtweak=/" "WEAK":4:Cred "%{qttimes}" "%;\
		/else \
		/let qtweak=%;\
		/endif%;\
	/let qttimes=$[prgetstime(prot_eaura_t)]%;\
	/set status_pstr=%{status_pstr} :1 "[" "Aura%{prot_eaura}":5:%{qtcolor} "%{qttimes}%{qtweak}]"%;\
	/endif


;; Update statusbar
/def -i status_update=\
	/set status_pstr=%;\
	/status_add_val hp HP%;\
	/status_add_val sp SP%;\
	/status_add_val ep EP%;\
	/status_add_aura%;\
	/prots_get%;\
	/set status_pstr=%{status_pstr} :1 "[" "%{prmove_last}":1:BCgreen "]" :1 "%{protstr2}":40:BCgreen%;\
	/set status_fields=$[{status_pstr}]


;; Grab SHORT SCORE (sc)
;"H:325/325 [] S:985/985 [+26] E:235/235 $:2814 [] exp:5156 []"
/def -i -F -p9999 -mregexp -t"^H:([+-]*[0-9]+)/([0-9]+) \[[+-]*[0-9]*\] S:([+-]*[0-9]+)/([0-9]+) \[[+-]*[0-9]*\] E:([+-]*[0-9]+)/([0-9]+) \$:([0-9]+) \[[+-]*[0-9]*\] exp:([0-9]+) \[[+-]*[0-9]*\]$" gstatus_sc1=\
	/set status_hp=%{P1}%;/set status_hpmax=%{P2}%;\
	/set status_sp=%{P3}%;/set status_spmax=%{P4}%;\
	/set status_ep=%{P5}%;/set status_epmax=%{P6}%;\
	/status_update

;; For HCbat
/def -i -F -p9999 -mregexp -t"^H:([+-]*[0-9]+)/([0-9]+) \[[+-]*[0-9]*\] S:([+-]*[0-9]+)/([0-9]+) \[[+-]*[0-9]*\] E:([+-]*[0-9]+)/([0-9]+) \$:([0-9]+) exp:([0-9]+)$" gstatus_sc2=\
	/set status_hp=%{P1}%;/set status_hpmax=%{P2}%;\
	/set status_sp=%{P3}%;/set status_spmax=%{P4}%;\
	/set status_ep=%{P5}%;/set status_epmax=%{P6}%;\
	/status_update


;; Grab PROMPT
;"H:336/336 S:1049/1049 E:243/243 >"
/def -i -mregexp -h"PROMPT ^H:([+-]*[0-9]+)/([0-9]+) S:([+-]*[0-9]+)/([0-9]+) E:([+-]*[0-9]+)/([0-9]+) >$" gstatus_prompt=\
	/set status_hp=%{P1}%;/set status_hpmax=%{P2}%;\
	/set status_sp=%{P3}%;/set status_spmax=%{P4}%;\
	/set status_ep=%{P5}%;/set status_epmax=%{P6}%;\
	/if ({opt_info}=~"on" & {cast_info}!~"") \
		/if ({cast_info_t}!~"") \
			/test prompt("%{cast_info}[%{cast_info_n} -> %{cast_info_t}] >")%;\
			/else \
			/test prompt("%{cast_info}[%{cast_info_n}] >")%;\
			/endif%;\
		/else \
		/test prompt("GGRTF >")%;\
		/endif


/status_update


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Path compression utilities
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/def -i docomptoken =\
/if ({1} > 1)\
	/let madd=%{1} %{2}%;\
	/else \
	/let madd=%{2}%;\
	/endif%;\
/if ({qs}=~"")\
	/set qs=%{madd}%;\
	/else \
	/set qs=%{qs};%{madd}%;\
	/endif

/def -i docomppath =\
/set qs=%;/let qp=%;/let qi=1%;/let qc=1%;\
/while (qi <= {#})\
	/eval /set qv=%%{%qi}%;\
	/if ({qv}=~{qp} & {qc} < 20)\
		/let qc=$[qc + 1]%;\
		/else \
		/docomptoken %{qc} %{qp}%;\
		/let qc=1%;\
		/endif%;\
	/let qi=$[qi + 1]%;\
	/let qp=%{qv}%;\
	/done%;\
/docomptoken %{qc} %{qp}

/def comppath = /docomppath %{path}%;/echo CPath: %{qs}
/def csavepath = /docomppath %{path}%;@command %1 %{qs}


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Prot triggers and reporting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Clear/setup all variables related to prot
; -i"<name>"
; -n"<shortname>"
; -l"<desc/longname>"
; -A"<prerequisite trigger #1>"
; -B"<prerequisite trigger #2>"
; -C"<prerequisite trigger #3>"
; -r Use regexp instead of simple matching
; -s Stackable prot
; -h Renewable prot (does not stack, but can be renewed)
; -k Takes parameters (implies usage of regexp patterns aka '-r')

/set lst_prots=
/def -i prcreate =\
	/if (!getopts("i:n:l:A:B:C:u:d:srkh", "")) /msq ERROR! Invalid prot creation command!%;/break%;/endif%;\
	/set lst_prots=%{opt_i} %{lst_prots}%;\
	/set prot_%{opt_i}=0%;\
	/set prot_%{opt_i}_t=-1%;\
	/set prot_%{opt_i}_n=%{opt_n}%;\
	/set prot_%{opt_i}_l=%{opt_l}%;\
	/set prot_%{opt_i}_p=0%;\
	/if (opt_s) /set prot_%{opt_i}_stack=1%;/else /set prot_%{opt_i}_stack=0%;/endif%;\
	/if (opt_h) /set prot_%{opt_i}_renew=1%;/else /set prot_%{opt_i}_renew=0%;/endif%;\
	/if ({opt_u}=~"" | {opt_d}=~"") /break%;/endif%;\
	/if (opt_k | opt_r) /let qmatch=regexp%;/else /let qmatch=simple%;/endif%;\
	/let pstr=0%;\
	/if ({opt_A}!~"") /let pstr=1%;/def -i -p9999 -F -aCyellow -mregexp -t'%{opt_A}' rec_%{opt_i}_A=/set prot_%{opt_i}_p=1%;/endif%;\
	/if ({opt_B}!~"") /let pstr=2%;/def -i -p9999 -F -aCyellow -mregexp -t'%{opt_B}' rec_%{opt_i}_B=/if ({prot_%{opt_i}_p}=1) /set prot_%{opt_i}_p=2%%;/endif%;/endif%;\
	/if ({opt_C}!~"") /let pstr=3%;/def -i -p9999 -F -aCyellow -mregexp -t'%{opt_C}' rec_%{opt_i}_C=/if ({prot_%{opt_i}_p}=2) /set prot_%{opt_i}_p=3%%;/endif%;/endif%;\
	/if ({pstr}>0)\
		/if (opt_k)\
		/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/if ({prot_%{opt_i}_p}==%{pstr}) /set prot_%{opt_i}_p=0%%;/pron %{opt_i} [%%{P1}]%%;/endif%;\
		/else \
		/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/if ({prot_%{opt_i}_p}==%{pstr}) /set prot_%{opt_i}_p=0%%;/pron %{opt_i}%%;/endif%;\
		/endif%;\
	/else \
		/if (opt_k)\
		/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/set prot_%{opt_i}_p=0%%;/pron %{opt_i} [%%{P1}]%;\
		/else \
		/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/set prot_%{opt_i}_p=0%%;/pron %{opt_i}%;\
		/endif%;\
	/endif%;\
	/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_d}' rec_%{opt_i}_off=/set prot_%{opt_i}_p=0%%;/proff %{opt_i}


;; Turn prot ON
/def -i pron =\
	/eval /set qtval_l=$$[prot_%{1}_l]%;\
	/eval /set qtval_s=$$[prot_%{1}_stack]%;\
	/eval /set qtval_h=$$[prot_%{1}_renew]%;\
	/eval /set qtval_c=$$[prot_%{1}]%;\
	/if ({qtval_c} == 0 | ({qtval_h} == 1 & {qtval_s} == 0))\
		/if ({qtval_c} > 0)\
			/eval /set qtval_t=$$[prot_%{1}_t]%;\
			/let qtstrs=Renewed! $[prgetstime(qtval_t)]%;\
			/else \
			/let qtstrs=ON!%;\
			/endif%;\
		/set prot_%{1}=1%;\
		/else \
		/if ({qtval_s})\
			/set prot_%{1}=$[qtval_c + 1]%;\
			/let qtstrs=ON [#$[qtval_c + 1]]%;\
			/else \
			/msq ERROR! Prot '%{1}' (%{qtval_l}) increased even though not flagged stackable!%;\
			/break%;\
			/endif%;\
		/endif%;\
	/set prot_%{1}_t=$[time()]%;\
	/if ({-1}!~"")\
		/msr %{qtval_l} %{-1} %{qtstrs}%;\
		/else \
		/msr %{qtval_l} %{qtstrs}%;\
		/endif


;; Turn prot OFF
/def -i proff =\
	/eval /set qtval_c=$$[prot_%{1} - 1]%;\
	/set prot_%{1}=%{qtval_c}%;\
	/eval /set qtval_l=$$[prot_%{1}_l]%;\
	/eval /set qtval_s=$$[prot_%{1}_stack]%;\
	/eval /set qtval_t=$$[prot_%{1}_t]%;\
	/eval /set qtval_h=$$[prot_%{1}_renew]%;\
	/if ({qtval_c} < 0) \
		/msq ERROR! '%{1}' (%{qtval_l}) count %{qtval_c} at /proff!%;\
		/set prot_%{1}=0%;\
		/break%;\
		/endif%;\
	/if ({qtval_s} & {qtval_c} >= 1 & {qtval_h} == 0) \
		/msr %{qtval_l} Weakened! [#%{qtval_c}] $[prgetstime(qtval_t)]%;\
		/else \
		/set prot_%{1}=0%;\
		/msr %{qtval_l} OFF! $[prgetstime(qtval_t)]%;\
		/endif


;; Turn of prots that expire on death
/def -i -p9999 -F -aCgreen -msimple -t"You die." prots_rip =\
	/msq @{BCyellow}Various prots expire as you die!@{n}%;\
	/set prot_flexsh=0%;\
	/set prot_invis=0%;\
	/set prot_eskin=0%;\
	/set prot_pfe=0%;\
	/status_update


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Create normal regular prots without complexities
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/prcreate -i"eaura"	-n"EAura"	-l"Energy Aura"	-s -h
/prcreate -i"pff"	-n"PFF"		-l"Personal Force Field" -r -u"^You surround yourself by a bubble of force.$" -d"^Your field disperses with a soft \*pop\* and is gone.$"

/prcreate -i"infra"	-n"Infra" 	-l"Infravision" -s -A"\'demoni on pomoni\'$" -u"You have infravision." -d"Everything no longer seems so red."
/prcreate -i"ww"	-n"WW" 		-l"Water Walking" -A" \'Jeeeeeeeeeeeesuuuuuuuus\'$"	-u"You feel light." -d"You feel heavier."
/prcreate -i"float"	-n"Float"	-l"Floating" 	-u"You feel light, and rise into the air." -d"You slowly descend until your feet are on the ground."
/prcreate -i"invis"	-n"Invis"	-l"Invisibility" -r -A" \'..... .... ... ..  .    .!\'$" -u"^You (suddenly can\'t see yourself|twist the ring and suddenly you become invisible).$" -d"^You turn visible.$"
/prcreate -i"godpr"	-n"GodPr"	-l"Godly Presence"
/prcreate -i"seeinvis"	-n"SeeInv"	-l"See Invisible" -u"You feel you can see more than ever." -d"Your vision is less sensitive now."
/prcreate -i"seemagic"	-n"SeeMag"	-l"See Magic" -u"You can now see magical things." -d"You are no longer sensitive to magical things."
/prcreate -i"hw"	-n"HW"		-l"Heavy Weight" -A" \'tonnikalaa\'$" -u"You suddenly feel magically heavier." -d"You feel lighter, but it doesn\'t seem to affect your weight!"

/prcreate -i"haste"	-n"Haste"	-l"Haste"

/prcreate -i"erage"	-n"ERage"	-l"Enrage" -r -u"^(You are maddened with rage!|You feel your barbarian rage stir up.|Holy CRAP! OH what a RUSH!|You feel TOTALLY ENRAGED and ready to KICK ASS!|YOU FEEL AS IF YOU WERE GROO HIMSELF!|You are ENRAGED! Your body ACHES for action!|You feel the adrenaline BURST into your veins!|Your blood is boiling of rage!|You tremble uncontrollably and feel completely ENRAGED!)$" -d"^You no longer feel enraged.$"
/prcreate -i"ptsh"	-n"Ptrsh"	-l"Pain Treshold" -u"You begin to concentrate on pain threshold." -d"Your concentration breaks and you feel less protected from physical damage."

;/prcreate -i"pbsf"	-"PbSf"		-l"Protection by Sacrifice" -A" kneels before you and whispers \'With my life I\'ll protect yours\'.$" -r -u"^(She|He|It) stands up with a solemn look on her face.$"

;; ---- Epriest ----
/prcreate -i"pfg"	-n"PfG"		-l"Protection from Good" -u"A vile black aura surrounds you." -d"You no longer have a vile black aura around you."
/prcreate -i"paranoia"	-n"Para"	-l"Paranoia" -A" \'noxim delusa\'" -u"You have a bad feeling about this." -d"Everything seems so much more pleasant."

;; ---- Tarmalen ----
/prcreate -i"unpain"	-n"Unpain"	-l"Unpain" -h -r -u"^You feel your will getting stronger.$" -d"^(You feel your will returning normal.|Your Unpain spell dissipates|You feel your will getting normal.|You suffer an acute health change)"
/prcreate -i"unstun"	-n"Unstun"	-l"Unstun" -h
/prcreate -i"bot"	-n"BoT"		-l"Blessing of Tarmalen" -u"You feel strong - like you could carry whole flat world on your back!" -d"You feel weaker."
/prcreate -i"lifelnk"	-n"LifeLnk"	-l"Life Link" -r -k -u"^You feel somehow linked to ([A-Z][a-z]+)!$" -d"^You hear a loud snap like sound!$"

;; ---- Nun ----
/prcreate -i"pfe"	-n"PfE"		-l"Protection from Evil" -A" \'sanctus Exzordus\'" -B"you are surrounded by" -r -u"protective holy aura." -d"^(You suddenly feel more vulnerable to evil|Your glow fades away and you suddenly feel more vulnerable to evil).$"
/prcreate -i"soulsh"	-n"SoulSh"	-l"Soul Shield" -r -u"^[A-Z][A-Za-z]+ places her hand over you and blesses your soul in the name of Las.$" -d"^Your soul feels suddenly more vulnerable.$"
/prcreate -i"sof"	-n"SoF"		-l"Shield of Faith" -u"You are surrounded by divine glow!" -d"Your glow disappears."
/prcreate -i"hprot"	-n"HProt"	-l"Heavenly Protection" -A"\'sanctus . o O\'" -r -u"as you are suddenly surrounded" -d"^Holy particles slow down, rapidly fading away.$"


;; ---- Psionicist ----
/prcreate -i"levi"	-n"Levi"	-l"Levitation" -u"You slowly rise from the ground and start levitating." -d"You decide that you have levitated enough and slowly descend to the ground."
/prcreate -i"manash"	-n"ManaSh"	-l"Mana Shield"
/prcreate -i"psychs"	-n"PsychS"	-l"Psychic Sanctuary"
/prcreate -i"forcesh"	-n"ForcSh"	-l"Force Shield"

;; ---- Druid ----
/prcreate -i"flexsh"	-n"FlexSh"	-l"Flex Shield" -u"You sense a flex shield covering your body like a second skin." -d"Your flex shield wobbles, PINGs and vanishes."
/prcreate -i"epower"	-n"EPower"	-l"Earth Power" -u"You feel your strength changing. You flex you muscles experimentally." -d"The runic sigla \'% !^\' fade away.. leaving you feeling strange."
/prcreate -i"eskin"	-n"ESkin"	-l"Earth Skin" -s -u"You feel your skin harden." -d"Your skin feels softer."
/prcreate -i"eblood"	-n"EBlood"	-l"Earth Blood" -A" traces icy blue runes on the ground with his Staff of Druids" -B"druidstaff is surrounded by a sudden cloudburst" -u"An icy chill runs through your veins." -d"The runic sigla \'\!\( \*\)\' fade away.. leaving you feeling strange."
/prcreate -i"vmant"	-n"Vmant"	-l"Vine Mantle" -s -u"Vines entangle your body." -d"The vines crumbles to dust."
/prcreate -i"regen"	-n"Rgn"		-l"Regeneration" -u"You feel your metabolism speed up." -d"You no longer have a active regeneration spell on you."

;; ---- Bard ----
/prcreate -i"warez"	-n"WarEns"	-l"War Ensemble" -A"\'War is TOTAL massacre, sport the war, war SUPPOORT!!!\'" -u"You feel full of battle rage! Victory is CERTAIN!" -d"The effect of war ensemble wears off."
/prcreate -i"emelody"	-n"EMelody"	-l"Embracing Melody" -r -u"^[A-Z][A-Za-z]+ wraps you into an embracing melody\.$" -d"^The embracing melody subsides, leaving you longing for more\.$"
/prcreate -i"afavour"	-n"AFav"	-l"Arches Favour" -u"You feel optimistic about your near future!" -d"You no longer have Arches Favour on you. You feel sad."

;; ---- Conjurer ----
/prcreate -i"sop"	-n"SoP"		-l"Shield of Protection" -A" \'nsiiznau\'$" -u"You feel a slight tingle." -d"You feel more vulnerable now."
/prcreate -i"bimage"	-n"BImg"	-l"Blurred Image" -A" \'ziiiuuuuns wiz\'$" -u"You feel a powerful aura." -d"You feel less invisible."
/prcreate -i"disp"	-n"Disp"	-l"Displacement" -A" \'diiiiuuunz aaanziz\'$" -u"You feel a powerful aura." -d"You feel much less invisible."
;/prcreate -i"fabs"	-n"Fabs"	-l"Force Absorption" -u"You sense a powerful protective aura around you." -d"A skin brown flash momentarily surrounds you and then vanishes."
/prcreate -i"aoa"	-n"AoA"		-l"Armour of Aether" -A" \'fooharribah inaminos cantor\'$" -u"You see a crystal clear shield fade into existance around you." -d"Your crystal clear shield fades out."
/prcreate -i"frosts"	-n"FrostS"	-l"Frost Shield" -u"You see a frosty blue-white shield fade into existance around you." -d"Your frosty blue-white shield fades out."


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Unstun (NS)
/set stun_st=off

/def -i -F -aCgreen -mregexp -t"^[A-Z][A-Za-z]+\'s chanting appears to do absolutely nothing.$" rec_unstun_on =\
	/pron unstun%;/set prot_unstun_w=0

;/def -i -F -aCgreen -msimple -t"You feel no longer protected from being stunned." rec_unstun_off = /proff unstun

/def -i -F -aCgreen -msimple -t"You are STUNNED." stun_start =\
	/set stun_st=on%;/proff unstun

/def -i -F -aCgreen -E({stun_st}=~"on") -msimple -t"You are no longer stunned." stun_end =\
	/set stun_st=off%;/msr No longer stunned

/def -i -F -aCgreen -msimple -t"It doesn't hurt as much as it normally does!" stun_nohurt =\
	/proff unstun

/def -i -F -aCgreen -msimple -t"It doesn't hurt at all!" stun_notall =\
	/set prot_unstun_w=$[prot_unstun_w + 1]%;\
	/msr Unstun weakened [#%{prot_unstun_w}]


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Form the "current prots" strings
/def -i prots_doget =\
/while ({#})\
	/eval /set qtval=$$[prot_%{1}]%;\
	/eval /set qtval_t=$$[prot_%{1}_t]%;\
	/eval /set qtval_n=$$[prot_%{1}_n]%;\
	/if ({qtval} > 0)\
		/set protcount=$[protcount + 1]%;\
		/let qtstr=%{qtval_n}$[prgetstime(qtval_t)]%;\
		/if ({protstr}!~"")\
			/set protstr=%{protstr}|%{qtstr}%;\
			/set protstr2=%{protstr2}|%{qtval_n}%;\
			/else \
			/set protstr=%{qtstr}%;\
			/set protstr2=%{qtval_n}%;\
			/endif%;\
		/endif%;\
	/shift%;\
/done

/def -i prots_get =\
	/set protstr=%;\
	/set protstr2=%;\
	/set protcount=0%;\
	/eval /prots_doget %{lst_prots}%;\
	/if ({protcount} > 0)\
		/return protstr%;\
		/else \
		/return "No prots."%;\
	/endif


;; Report prots
/def prots = /msq $[prots_get()]
/def -i -p9999 -mregexp -t"^[A-Z][a-z]+ tweaks your nose (mischievously|mischeviously).$" prot_tweak1 = /msr $[prots_get()]
/def -i -p9999 -mregexp -t"^@([A-Z][a-z]+) tweaks your nose (mischievously|mischeviously).$" prot_tweak2 = @@emoteto %{P1} $[prots_get()]
/def -i -p9999 -mregexp -t"^You tweak your own nose (mischievously|mischeviously).$" prot_tweak3 = /msr $[prots_get()]


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Skill and skill-status reporting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Start of skill
/def -i -p9999 -ag -msimple -t"You start concentrating on the skill." skill_start =\
	/set skill_t=$[time()]%;\
	/set cnt_skills=$[cnt_skills + 1]%;\
	/set skill_st=on%;\
	/set skill_st2=off%;\
	/if ({opt_info}=~"on") @@cast info%;/endif%;\
	/msq @{Cgreen}Skill@{n} @{BCgreen}START@{n} (@{Cyellow}%{cnt_skills}@{n})


;; Skill done
/def -i -p9999 -ag -msimple -t"You are prepared to do the skill." skill_end =\
	/set cnt_sskills=$[cnt_sskills + 1]%;\
	/set skill_st=off%;\
	/set skill_st2=on%;\
	/set cast_info=%;\
	/msq @{Cgreen}Skill@{n} @{BCgreen}DONE@{n} @{Cyellow}$[prgetstime(skill_t)]@{n}


;; Cast info
/def -i -p9999 -mregexp -t"^You are using \'([a-z ]+)\'.$" skill_info1 =\
	/set cast_info=SK%;/set cast_info_n=%{P1}%;/set cast_info_t=%;\
	/if ({opt_rskills}=~"on") @@emote is using '%{P1}'%;/endif

/def -i -p9999 -mregexp -t"^You are using \'([a-z ]+)\' at \'([A-Za-z ,.'-]+)\'.$" skill_info2 =\
	/set cast_info=SK%;/set cast_info_n=%{P1}%;/set cast_info_t=%{P2}%;\
	/if ({opt_rskills}=~"on") @@emote is using '%{P1}' -> '%{P2}'%;/endif

;; Skill fumbled
/def -i skill_fumble =\
/if ({skill_st2}=~"on")\
	/set cnt_sskills=$[cnt_sskills - 1]%;\
	/set cnt_fuskills=$[cnt_fuskills + 1]%;\
	/set skill_st2=off%;\
	/endif

;; Skill failed
/def -i skill_fail =\
/if ({skill_st2}=~"on")\
	/set cnt_sskills=$[cnt_sskills - 1]%;\
	/set cnt_fskills=$[cnt_fskills + 1]%;\
	/set skill_st2=off%;\
	/endif

;; Skill interrupted
/def -i skill_interrupt =\
/if ({skill_st}=~"on")\
	/set cnt_iskills=$[cnt_iskills + 1]%;\
	/set skill_st=off%;\
	/set cast_info=%;\
	/msq @{Cgreen}Skill@{n} @{Cred}interrupted@{n}%;\
	/else \
	/msq @{BCred}FAKE@{n} SKILL @{Cred}INTERRUPTED@{n}%;\
	/endif

/def -i -p9999 -ag -msimple -t"Your movement prevents you from doing the skill." skill_interrupt1 =\
	/skill_interrupt

/def -i -p9999 -ag -msimple -t"You break your skill attempt." skill_interrupt2 =\
	/skill_interrupt

/def -i -p9999 -ag -msimple -t"You decide to change the skill to a new one." skill_interrupt3 =\
	/skill_interrupt

/def -i -p9999 -ag -msimple -t"You decide to change the skill to new one." skill_interrupt4 =\
	/skill_interrupt


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Battle, enemy shape
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Report shape
/def shape =\
/if ({battle_target}!~"")\
	/msr %{battle_shape} (%{battle_target})%;\
	/else \
	/msr %{battle_shape}%;\
	/endif%;\

;; Update/set new shape
/def -i battle_ss =\
/if ({3}=~"He"|{3}=~"She"|{3}=~"It")\
	/echo -p @{Cgreen}%{-2}@{n} (@{Cred}%{2}%%@{n})%;\
	/else \
	/if ({battle_st}=~"on")\
		/echo -p @{Cgreen}%{-2}@{n} (@{Cred}%{2}%%@{n})%;\
		/set battle_pshape=%{battle_shape}%;\
		/set battle_shape=%{1}%;\
		/if ({opt_rshape}=~"on" & {battle_shape}!~{battle_pshape})\
			/shape%;\
			/endif%;\
		/endif%;\
	/endif

;; Update/set new target
/def -i battle_settarget =\
	/set battle_oldtarget=%{battle_target}%;\
	/set battle_target=%*



;; New round
/def -i -msimple -t"*****************************************************" battle_round =\
	/status_update%;@scan%;\
	/if ({opt_pss}=~"on")	@pss%;/endif%;\
	/if ({opt_rstat}=~"on")	@party report%;/endif%;\
	/if ({battle_st}!~"on")\
		/set battle_shape=es%;\
		/set battle_pshape=es%;\
		/set battle_st=on%;\
		/endif%;\
	/prexecfuncs %{battle_roundfuncs}

;; Grab target via several methods
/def -i -p9999 -ag -mregexp -t"^You are now targetting ([A-Za-z ,.'-]+)\.$" battle_settarget3 =\
	/msq @{BCyellow}Targetting@{n} -> @{BCred}%{P1}@{n}%;\
	/battle_settarget %{P1}

/eval /def -mregexp -t"^%{set_plrname} hits (.*) [1-9] times" battle_settarget2 =\
	/battle_settarget %%{P1}

;; Get shape
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is in excellent shape)\.$"	battle_shape0 = /battle_ss es 90-100 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is in a good shape)\.$"		battle_shape3 = /battle_ss gs 80-90 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is slightly hurt)\.$"		battle_shape1 = /battle_ss sh 65-80 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is noticeably hurt)\.$"		battle_shape2 = /battle_ss nh 50-65 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is not in a good shape)\.$"	battle_shape4 = /battle_ss nigs 35-50 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is in bad shape)\.$"		battle_shape5 = /battle_ss bs 20-35 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is in very bad shape)\.$"	battle_shape6 = /battle_ss vbs 10-20 %{P1}
/def -i -p9999 -ag -mregexp -t"^([A-Za-z ,.'-]+ is near death)\.$"		battle_shape7 = /battle_ss nd 0-10 %{P1}

;; End of battle
/def -F -i -p9999 -aCgreen -mregexp -t"^[A-Za-z ,.'-]+ is DEAD, R.I.P.$" battle_rip =\
	/set battle_st=off%;\
	/set battle_target=%;\
	@scan%;\
	/prexecfuncs %{battle_ripfuncs}

/def -F -i -p9999 -aCyellow -msimple -t"You are not in combat right now." battle_end =\
	/set battle_st=off%;\
	/set battle_target=%;\
	/prexecfuncs %{battle_endfuncs}