changeset 341:141124235c3c

v0.5.10.7: Changes in binding definition macros.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 10 Mar 2006 00:18:57 +0000
parents 0bde8b59b02a
children 8f82c9f61ae5
files ggrtf-barb.tf ggrtf-binds.tf ggrtf.tf
diffstat 3 files changed, 81 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/ggrtf-barb.tf	Fri Mar 10 00:06:37 2006 +0000
+++ b/ggrtf-barb.tf	Fri Mar 10 00:18:57 2006 +0000
@@ -22,7 +22,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 /prdefgbind -s"lb"	-c"/lb"
 /prdefgbind -s"burn"	-c"/lb"
-/prdefsbind -s"er"	-c"Enrage"
+/prdefsbind -s"er"	-c"Enrage"	-n
 /prdefsbind -s"fa"	-c"First Aid"
 /prdefsbind -s"bcry" 	-c"Battlecry"
 /prdefsbind -s"lure"	-c"Lure"
@@ -31,7 +31,7 @@
 /prdefsbind -s"toxi"	-c"Toxic Immunity"
 /prdefsbind -s"fwal"	-c"Fire Walking"
 /prdefsbind -s"ctol"	-c"Cold Tolerance"
-/prdefsbind -s"camp"	-c"Camping"
+/prdefsbind -s"camp"	-c"Camping"	-n
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--- a/ggrtf-binds.tf	Fri Mar 10 00:06:37 2006 +0000
+++ b/ggrtf-binds.tf	Fri Mar 10 00:18:57 2006 +0000
@@ -22,14 +22,14 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; General / miscellaneous
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-/prdefgbind -s"cere" -c"/ceremony"
+/prdefgbind -s"cere"		-c"/ceremony"
 
 /prdefcbind -s"seemagic"	-c"See Magic"
 /prdefcbind -s"seeinvis"	-c"See Invisible"
-/prdefcbind -s"ww"	-c"Water Walking"
-/prdefcbind -s"float"	-c"Floating"
-/prdefcbind -s"invis"	-c"Invisibility"
-/prdefcbind -s"ad"	-c"Aura Detection"
+/prdefcbind -s"ww"		-c"Water Walking"
+/prdefcbind -s"float"		-c"Floating"
+/prdefcbind -s"invis"		-c"Invisibility"
+/prdefcbind -s"ad"		-c"Aura Detection"
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -40,9 +40,9 @@
 /prdefcbind -s"sop"	-c"Shield of Protection"
 /prdefcbind -s"bi"	-c"Blurred Image"
 /prdefcbind -s"disp"	-c"Displacement"
-/prdefcbind -s"shelter"	-c"Shelter"	-n"Sheltering ..."
+/prdefcbind -s"shelter"	-c"Shelter"		-n	-d"Sheltering ..."
 /prdefcbind -s"dmp"	-c"Dispel Magical Protection"
-/prdefcbind -s"nf"	-c"Neutralize Field" -n"Neutralize Field ..."
+/prdefcbind -s"nf"	-c"Neutralize Field"	-n
 /prdefcbind -s"mi"	-c"Mirror Image"
 /prdefcbind -s"iw"	-c"Iron Will"
 /prdefcbind -s"rentr"	-c"Resist Entropy"
--- a/ggrtf.tf	Fri Mar 10 00:06:37 2006 +0000
+++ b/ggrtf.tf	Fri Mar 10 00:18:57 2006 +0000
@@ -1,8 +1,8 @@
 ;;
-;; GgrTF v0.5.10.6-svn - TinyFugue script for BatMUD
+;; GgrTF v0.5.10.7-svn - TinyFugue script for BatMUD
 ;; (C) Copyright 2004-2006 Matti Hämäläinen (Ggr Pupunen)
 ;;
-/set ggrtf_ver=0.5.10.6-svn
+/set ggrtf_ver=0.5.10.7-svn
 ;;
 ;; This triggerset is Free Software distributed under
 ;; GNU General Public License version 2.
@@ -103,9 +103,13 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Helper macros/functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Return ratio of 2 parameters (avoid divide by zero)
+;; Return ratio of 2 arguments (avoid divide by zero)
 /def -i prdiv = /if ({2} != 0) /return {1}/{2}%;/else /return 0%;/endif
 
+;; Return ratio of 2 arguments rounded to two decimals
+/def -i prstdiv = /return prround(prdiv({1},{2}),2)
+
+
 ;; Return a substring of given string with specified maxlen, padded to maxlen
 /def -i prsubpad = /return pad(substr({1},0,{2}),{2})
 
@@ -206,6 +210,9 @@
 	/eval /set _prlist= $$[%{1}] %;\
 	/if (regmatch(strcat("(^",{2},"| ",{2}," | ",{2},"$)"),_prlist) <= 0)\
 		/eval /set %{1}=%%{%{1}} %{2}%;\
+		/return 1%;\
+	/else \
+		/return 0%;\
 	/endif
 
 
@@ -223,6 +230,7 @@
 	/done%;\
 	/eval /set %{_tdname}=%{_tdlist}
 
+
 /def -i prlist_delete =\
 	/eval /prlist_delete_do %{1} %{2} $$[%{1}]
 
@@ -454,45 +462,77 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Hooks and bindings
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+/set lst_bindings=
+
 ;; Define a generic command/macro bind
+; -s"<name>"	String to bind
+; -c"<command>"	Command/macro to be executed
+; -m		Use regular expression matching
 /def -i prdefgbind =\
-	/if (!getopts("s:c:r", "")) /gerror Invalid bind creation command!%;/break%;/endif%;\
-	/if (opt_r) /let qmatch=-mregexp%;/else /let qmatch=%;/endif%;\
-	/eval /def -i %{qmatch} -h"SEND {%{bind_prefix}%{opt_s}}" bind_%{opt_s} = %{opt_c}
+	/if (!getopts("s:c:m", "")) /gerror Invalid bind creation command!%;/break%;/endif%;\
+	/if (!prlist_insert("lst_bindings", opt_s)) /gwarning Binding for '%{opt_s}' already defined!%;/endif%;\
+	/if (opt_m) /let _qmatch=-mregexp%;/else /let _qmatch=%;/endif%;\
+	/eval /def -i %{_qmatch} -h"SEND {%{bind_prefix}%{opt_s}}" bind_%{opt_s} = %{opt_c}
 
 
-;; Define a skill bind with party reporting
+;; Define a skill bind with optional party reporting
+; -s"<name>"		String to bind
+; -c"<skill name>"	Name of the skill to be executed
+; -n			Skill does not use a target
+; -d"<message>"		Use non-default message for reporting
+; -q			Quiet (no reporting)
 /def -i prdefsbind =\
-	/if (!getopts("s:c:n:", "")) /gerror Invalid bind creation command!%;/break%;/endif%;\
-	/let qs=$[tolower(opt_c)]%;\
+	/if (!getopts("s:c:d:nq", "")) /gerror Invalid bind creation command!%;/break%;/endif%;\
+	/if (!prlist_insert("lst_bindings", opt_s)) /gwarning Binding for '%{opt_s}' already defined!%;/endif%;\
+	/let _qs=$[tolower(opt_c)]%;\
+	/if (opt_d!~"") /let _qm=%{opt_d}%;/else /let _qm=%{opt_c}%;/endif%;\
 	/if (opt_n)\
-		/let qw=%{opt_n}%;\
+		/let _qw=%{_qm} ...%;\
 	/else \
-		/let qw=%{opt_c} -> %%%2%;\
-		/let qs='%{qs}' %%%2%;\
+		/let _qw=%{_qm} -> %%%2%;\
+		/let _qs='%{_qs}' %%%2%;\
 	/endif%;\
-	/eval /def -i -h"SEND {%{bind_prefix}%{opt_s}}*" bind_%{opt_s} =\
-		/msr %{qw}%%%;use %{qs}
+	/if (opt_q)\
+		/eval /def -i -h"SEND {%{bind_prefix}%{opt_s}}*" bind_%{opt_s} =\
+			@use %{_qs}%;\
+	/else \
+		/eval /def -i -h"SEND {%{bind_prefix}%{opt_s}}*" bind_%{opt_s} =\
+			/msr %{_qw}%%%;@use %{_qs}%;\
+	/endif
 
 
-;; Define a spellcasting (at a target) bind with party reporting
+;; Define a spellcasting (at a target) bind with optional party reporting
+; Usage same as with /prdefsbind
 /def -i prdefcbind =\
-	/if (!getopts("s:c:n:", "")) /gerror Invalid bind creation command!%;/break%;/endif%;\
-	/let qs=$[tolower(opt_c)]%;\
+	/if (!getopts("s:c:d:nq", "")) /gerror Invalid bind creation command!%;/break%;/endif%;\
+	/if (!prlist_insert("lst_bindings", opt_s)) /gwarning Binding for '%{opt_s}' already defined!%;/endif%;\
+	/let _qs=$[tolower(opt_c)]%;\
+	/if (opt_d!~"") /let _qm=%{opt_d}%;/else /let _qm=%{opt_c}%;/endif%;\
 	/if (opt_n)\
-		/let qw=%{opt_n}%;\
+		/let _qw=%{_qm} ...%;\
+	/else \
+		/let _qw=%{_qm} -> %%%2%;\
+		/let _qs='%{_qs}' %%%2%;\
+	/endif%;\
+	/if (opt_q)\
+		/eval /def -i -h"SEND {%{bind_prefix}%{opt_s}}*" bind_%{opt_s} =\
+			@cast %{_qs}%;\
 	/else \
-		/let qw=%{opt_c} -> %%%2%;\
-		/let qs='%{qs}' %%%2%;\
-	/endif%;\
-	/eval /def -i -h"SEND {%{bind_prefix}%{opt_s}}*" bind_%{opt_s} =\
-		/msr %{qw}%%%;cast %{qs}
+		/eval /def -i -h"SEND {%{bind_prefix}%{opt_s}}*" bind_%{opt_s} =\
+			/msr %{_qw}%%%;@cast %{_qs}%;\
+	/endif
+
+
+/def -i binds =\
+/msw ,------------------.%;\
+/msw | @{BCgreen}GgrTF@{n} @{Cyellow}Bindings@{n} |%;\
+/msw +------------------+-------------------------------------------------.%;\
+/msw `--------------------------------------------------------------------'
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Report current statistics
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-/def -i prstdiv=/return prround(prdiv({1},{2}),2)
-
 /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.%;\
@@ -941,7 +981,7 @@
 		/if (opt_p & opt_P) /gerror Minor and major typeprot options given.%;/break%;/endif%;\
 		/if (opt_d=~"" | opt_A=~"") /gerror Conjurer typeprot definition requires proper -A and -d options!%;/break%;/endif%;\
 		/set lst_cprots=%{opt_i} %{lst_cprots}%;\
-		/let qmatch=simple%;\
+		/let _qmatch=simple%;\
 		/let qact1=%%;%;\
 		/let qact2= (sticky)%%;/set prot_%{opt_i}_st=1%%;%;\
 		/if (opt_P) \
@@ -961,26 +1001,26 @@
 		/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%;\
+		/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})/pron %{opt_i} [%%{P1}]%%;/endif%%;/set prot_%{opt_i}_p=0%;\
+				/def -i -p9999 -F -aCgreen -m%{_qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/if (prot_%{opt_i}_p==%{pstr})/pron %{opt_i} [%%{P1}]%%;/endif%%;/set prot_%{opt_i}_p=0%;\
 			/else \
-				/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/if (prot_%{opt_i}_p==%{pstr})/pron %{opt_i}%%;/endif%%;/set prot_%{opt_i}_p=0%;\
+				/def -i -p9999 -F -aCgreen -m%{_qmatch} -t'%{opt_u}' rec_%{opt_i}_on=/if (prot_%{opt_i}_p==%{pstr})/pron %{opt_i}%%;/endif%%;/set prot_%{opt_i}_p=0%;\
 			/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}]%;\
+				/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}%;\
+				/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%;\
 	/endif%;\
-	/def -i -p9999 -F -aCgreen -m%{qmatch} -t'%{opt_d}' rec_%{opt_i}_off=/proff %{opt_i}
+	/def -i -p9999 -F -aCgreen -m%{_qmatch} -t'%{opt_d}' rec_%{opt_i}_off=/proff %{opt_i}
 
 
 ;; Turn prot ON