comparison ggrtf.tf @ 1674:fddc49a03f9e

Refactor the target shape mangling. Unfortunately this breaks backwards compatibility with previous "fmt_shape" setting. You will need to update yours with the new tokens or remove it from configuration file to use the new default.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 25 Mar 2024 19:15:08 +0200
parents 54a9a23d8df0
children 27281a74c507
comparison
equal deleted inserted replaced
1673:54a9a23d8df0 1674:fddc49a03f9e
2066 ;; Battle, enemy shape 2066 ;; Battle, enemy shape
2067 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2067 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2068 ;; Report shape 2068 ;; Report shape
2069 ;@command /shape 2069 ;@command /shape
2070 ;@desc Reports the last catched shape of a opponent (monster) in battle. 2070 ;@desc Reports the last catched shape of a opponent (monster) in battle.
2071 ;@desc This does not work too well if you were fighting more than one opponents. 2071 ;@desc This does not work too well if you are fighting more than one opponents.
2072 /def -i shape =\ 2072 /def -i shape =\
2073 /if (battle_target!~"")\ 2073 /if (battle_target!~"")\
2074 /msr %{battle_shape} (%{battle_target})%;\ 2074 /msr %{battle_shape} (%{battle_target})%;\
2075 /else \ 2075 /else \
2076 /msr %{battle_shape}%;\ 2076 /msr %{battle_shape}%;\
2077 /endif%;\ 2077 /endif%;\
2078 2078
2079 ;; Define shape formatting string 2079 ;; Define shape formatting string
2080 /prdefvar -n"fmt_shape" \ 2080 /prdefvar -n"fmt_shape" \
2081 -v"@{Cgreen}%%{4} %%{5}@{n} [@{%%{1}}%%{2}@{n}] (@{%%{1}}%%{3}%%%@{n})" \ 2081 -v"@{Cgreen}$$[pad({bs_name},-40)}@{n} [@{%%{bc_color}}%%{bs_short}@{n}] (@{%%{bs_color}}%%{bs_range}%%%@{n})@{BCred}%%{bs_extra}@{n}" \
2082 -c"Format string for shape reporting. %{1}=shape colour, %{2}=shape short name, %{3}=percentage, %{4}=target name, %{5}=shape long name" 2082 -c"Format string for shape reporting. %{bs_name}=target name, %{bs_color}=shape color, %{bs_short}=shape short name, %{bs_long}=shape long name, %{bs_range}=percentage/range, %{bs_extra}=stunned etc"
2083
2084 ;; Update/set new shape
2085 /eval /def -i gbattle_ss =\
2086 /substitute -p %{fmt_shape}%%;\
2087 /if (battle_st)\
2088 /set battle_pshape=%%{battle_shape}%%;\
2089 /set battle_shape=%%{2}%%;\
2090 /endif
2091 2083
2092 ;; (Re)initialize battle 2084 ;; (Re)initialize battle
2093 /def -i gbattle_init =\ 2085 /def -i gbattle_init =\
2094 /set battle_round=1%;\ 2086 /set battle_round=1%;\
2095 /set battle_shape=es%;\ 2087 /set battle_shape=es%;\
2124 ;; Grab target via several methods 2116 ;; Grab target via several methods
2125 /def -i -F -p9999 -mregexp -t"^You are now targetting ([A-Za-z ,.'-]+)\.$" gbattle_target3 =\ 2117 /def -i -F -p9999 -mregexp -t"^You are now targetting ([A-Za-z ,.'-]+)\.$" gbattle_target3 =\
2126 /msk @{BCyellow}Targetting@{n} -> @{BCred}%{P1}@{n}%;\ 2118 /msk @{BCyellow}Targetting@{n} -> @{BCred}%{P1}@{n}%;\
2127 /set battle_target=%{1} 2119 /set battle_target=%{1}
2128 2120
2129 ;; Get shape 2121
2130 /def -i -F -p9999 -mregexp -t"^([A-Za-z ,.'-]+) is (in (a )?)?(excellent shape|good shape|slightly hurt|noticeably hurt|not in a good shape|bad shape|very bad shape|near death)\.$" gbattle_shape1 =\ 2122 ;; Get and mangle target(s) shape
2131 /if ({P4}=~"excellent shape") /test gbattle_ss("BCgreen","es","90-100",{P1},{P4})%;\ 2123 /def -i gbattle_shape_mangle =\
2132 /elseif ({P4}=~"good shape") /test gbattle_ss("Cgreen","gs","80-90",{P1},{P4})%;\ 2124 /let bs_name=%{1}%;\
2133 /elseif ({P4}=~"slightly hurt") /test gbattle_ss("BCcyan","sh","65-80",{P1},{P4})%;\ 2125 /let bs_long=%{2}%;\
2134 /elseif ({P4}=~"noticeably hurt") /test gbattle_ss("Ccyan","nh","50-65",{P1},{P4})%;\ 2126 /let bs_perc=%{3}%;\
2135 /elseif ({P4}=~"not in a good shape") /test gbattle_ss("BCyellow","nigs","35-50",{P1},{P4})%;\ 2127 /let bs_extra=%{4}%;\
2136 /elseif ({P4}=~"bad shape") /test gbattle_ss("Cyellow","bs","20-35",{P1},{P4})%;\ 2128 /if (battle_st)\
2137 /elseif ({P4}=~"very bad shape") /test gbattle_ss("BCred","vbs","10-20",{P1},{P4})%;\ 2129 /set battle_pshape=%{battle_shape}%;\
2138 /elseif ({P4}=~"near death") /test gbattle_ss("Cred","nd","0-10",{P1},{P4})%;/endif 2130 /set battle_shape=%{bs_long}%;\
2139 2131 /endif%;\
2140 /def -i -F -p9999 -mregexp -t"^([A-Za-z ,.'-]+) is (in (a )?)?(excellent shape|good shape|slightly hurt|noticeably hurt|not in a good shape|bad shape|very bad shape|near death) \(([0-9]+).\)\.$" gbattle_shape2 =\ 2132 /if (bs_long=~"excellent shape") /let bs_color=BCgreen%; /let bs_short=es%; /let bs_range=90-100%;\
2141 /if ({P4}=~"excellent shape") /test gbattle_ss("BCgreen","es",{P5},{P1},{P4})%;\ 2133 /elseif (bs_long=~"good shape") /let bs_color=Cgreen%; /let bs_short=gs%; /let bs_range=80-90%;\
2142 /elseif ({P4}=~"good shape") /test gbattle_ss("Cgreen","gs",{P5},{P1},{P4})%;\ 2134 /elseif (bs_long=~"slightly hurt") /let bs_color=BCcyan%; /let bs_short=sh%; /let bs_range=65-80%;\
2143 /elseif ({P4}=~"slightly hurt") /test gbattle_ss("BCcyan","sh",{P5},{P1},{P4})%;\ 2135 /elseif (bs_long=~"noticeably hurt") /let bs_color=Ccyan%; /let bs_short=nh%; /let bs_range=50-65%;\
2144 /elseif ({P4}=~"noticeably hurt") /test gbattle_ss("Ccyan","nh",{P5},{P1},{P4})%;\ 2136 /elseif (bs_long=~"not in a good shape") /let bs_color=BCyellow%;/let bs_short=nigs%;/let bs_range=35-50%;\
2145 /elseif ({P4}=~"not in a good shape") /test gbattle_ss("BCyellow","nigs",{P5},{P1},{P4})%;\ 2137 /elseif (bs_long=~"bad shape") /let bs_color=Cyellow%; /let bs_short=bs%; /let bs_range=20-35%;\
2146 /elseif ({P4}=~"bad shape") /test gbattle_ss("Cyellow","bs",{P5},{P1},{P4})%;\ 2138 /elseif (bs_long=~"very bad shape") /let bs_color=BCred%; /let bs_short=vbs%; /let bs_range=10-20%;\
2147 /elseif ({P4}=~"very bad shape") /test gbattle_ss("BCred","vbs",{P5},{P1},{P4})%;\ 2139 /elseif (bs_long=~"near death") /let bs_color=Cred%; /let bs_short=nd%; /let bs_range=0-10%;/endif%;\
2148 /elseif ({P4}=~"near death") /test gbattle_ss("Cred","nd",{P5},{P1},{P4})%;/endif 2140 /if (bs_perc!~"") /let bs_range=%{bs_perc}%;/endif%;\
2149 2141 /eval /substitute -p %{fmt_shape}
2150 ;; Monster RIP does not necessarily end battle, but let's reset 2142
2151 ;; the target at least. 2143 /def -i -F -p9999 -mregexp -t"^([A-Za-z ,.'-]+) is (in (a )?)?(excellent shape|good shape|slightly hurt|noticeably hurt|not in a good shape|bad shape|very bad shape|near death)( \(([0-9]+)%\))?(.*?)?\.$" gbattle_shape_match =\
2144 /test gbattle_shape_mangle({P1},{P4},{P6},{P7})
2145
2146
2147 ;; Monster RIP does not necessarily end battle, but let's reset the target at least.
2152 /gdef -i -p9999 -aCgreen -mregexp -t"^[A-Za-z ,.'-]+ is DEAD, R.I.P.$" gbattle_rip =\ 2148 /gdef -i -p9999 -aCgreen -mregexp -t"^[A-Za-z ,.'-]+ is DEAD, R.I.P.$" gbattle_rip =\
2153 /set battle_target=%;\ 2149 /set battle_target=%;\
2154 /prexecfuncs %{event_battle_rip} 2150 /prexecfuncs %{event_battle_rip}
2155 2151
2156 ;; End of battle, probably. We trust here that the last 'scan' (if any) 2152 ;; End of battle, probably. We trust here that the last 'scan' (if any)