@q @program asys-effects 1 99999 d i ( asys-effects v1.2 Jessy@FurryMUCK 6/00 This program handles skill-related commands and events. INSTALLATION: asys-effects uses the standard Argo installation method. Port the program and set it Wizard. Type '+install asys-effects' USAGE: +use [at|on|versus|vs] [] asys-effects may be freely ported. Please comment any changes. ) (2345678901234567890123456789012345678901234567890123456789012345678901) $def thisVersion "1.2" $define Tell me @ owner swap notify $enddef $define VerifyEvent caller #0 "@a/calls/eventloop" getprop dbcmp not if ">> This routine must be called from asys-eventmgr." me @ swap notify 0 exit then $enddef $include $lib/argo lvar ourArg (* inital arg string, unmodified *) lvar ourAttackVal (* int: amound user made roll by *) lvar ourBoolean (* int: misc flow control var *) lvar ourCom (* string: 'official' name of command *) lvar ourCounter (* misc. counter var *) lvar ourDataObj (* dbref: object holding system-wide data *) lvar ourMaterial (* dbref: material object to be used *) lvar ourString (* string: skill prop *) lvar ourSkill (* string: skill name, formatted *) lvar ourTarget (* dbref: object we're targeting *) lvar scratch (* workspace var *) : DoInstall ( -- ) (* install program into Argo system *) caller program? not if (* confirm installation method *) ">> Programs must be installed via the " "+install" GetCommandName strcat " command." strcat Tell exit then prog "@a/version" getpropstr if ">> Reinstalling..." Tell else ">> Installing..." Tell then (* record 'official' name of prog; remove old links *) prog "@a/name" "asys-effects" setprop RecOldActions (* create and register command; set default props *) #0 "+use" newexit dup scratch ! prog setlink prog "@a/version" thisVersion setprop scratch @ "@a/version" thisVersion setprop #0 "@a/comm_list/+use" scratch @ setprop #0 "@a/prog_list/" prog name strcat prog setprop scratch @ "@a/name" "+use" setprop ">> Installed." Tell ; : DoUninstall (* uninstall program from Argo *) prog "@a/name" getpropstr if #0 "@a/prog_list/" prog "@a/name" getpropstr strcat getprop not if ">> " prog name strcat " is not currently installed." strcat Tell pid kill then else ">> " prog name strcat " is not currently installed." strcat Tell pid kill then ">> Please confirm: You wish to uninstall " prog name strcat "?" strcat Tell ReadYesNo not if ">> Aborted." Tell pid kill Then background "@a/comm_list/+use" RemoveCommand #0 "@a/prog_list/" prog "@a/name" getpropstr strcat remove_prop RecOldActions ">> Uninstalled. Please edit the online manual as appropriate." Tell ; : DoHelp ( -- ) (* display help screen *) " " Tell prog name " (#" strcat prog intostr strcat ")" strcat Tell " " Tell ; : DoCritSucc ( -- ) (* notify room: null skill succeeded criticaly *) ourTarget @ me @ dbcmp if ">> $me successfully uses the $skill skill. [CRITICAL]" me @ name "$me" subst TellRoom ourSkill @ CapAll subst TellRoom else ">> $me successfully uses $skill on $you. [CRITICAL]" me @ name "$me" subst ourTarget @ "$you" subst ourSkill @ CapAll subst TellRoom then ; : DoCritFail ( -- ) (* notify room: null skill failed criticaly *) ourTarget @ me @ dbcmp if ">> $me's attempt to use $skill fails. [CRITICAL]" me @ name "$me" subst TellRoom ourSkill @ CapAll subst TellRoom else ">> $me's attempt to use $skill on $you fails. [CRITICAL]" me @ name "$me" subst ourTarget @ "$you" subst ourSkill @ CapAll subst TellRoom then ; : DoUseNull ( -- ) (* run a skill with no coded effects *) me @ "@a/eloop/skill" getpropstr dup if "@a/skills/" swap strcat scratch ! scratch @ "/tools/" strcat Tools? not if ">> You don't have the tools necessary for that skill." Tell exit then scratch @ "/materials/" strcat Materials? if scratch @ "/materials/" strcat UseMaterials else ">> You don't have the materials necessary for that skill." Tell exit then me @ scratch @ GetModAbility if 3 else 4 then 6 0 Dice dup 4 <= if DoCritSucc NukeStack exit then dup 17 >= if DoCritFail NukeStack exit then ourDataObj @ scratch @ getpropstr dup if dup "," instr 1 - strcut pop dup "phy" smatch if pop me @ GetPhysSkill atoi else dup "phy" smatch if pop me @ GetCraftSkill atoi else me @ "@a/stats/" rot strcat GetModAbility then then me @ "@a/eloop/genmod" getpropstr atoi + me @ scratch @ GetModAbility + <= if me @ "@a/eloop/target" getprop me @ dbcmp not if ">> $me successfully uses $skill on $you." me @ name "$me" subst me @ "@a/eloop/target" getprop name "$you" subst me @ "@a/eloop/skill" getpropstr CapAll "$skill" subst TellRoom else ">> $me successfully uses the $skill skill." me @ name "$me" subst me @ "@a/eloop/skill" getpropstr CapAll "$skill" subst TellRoom then else me @ "@a/eloop/target" getprop me @ dbcmp not if ">> $me's attempt to use $skill on $you fails." me @ name "$me" subst me @ "@a/eloop/target" getprop name "$you" subst me @ "@a/eloop/skill" getpropstr CapAll "$skill" subst TellRoom else ">> $me's attempt to use $skill fails." me @ name "$me" subst me @ "@a/eloop/skill" getpropstr CapAll "$skill" subst TellRoom then then else pop pop then else pop then TellWait ; : DoParseArgs ( -- ) (* parse command args; store in lvars *) ourArg @ "$~$" " at " subst ourArg ! (* mark target delimeter *) ourArg @ "$~$" " on " subst ourArg ! ourArg @ "$~$" " vs " subst ourArg ! ourArg @ "$~$" " versus " subst ourArg ! ourArg @ "" "." subst ourArg ! (* clean string *) ourArg @ "" "'" subst ourArg ! ourArg @ "" "," subst ourArg ! ourArg @ "$~$" rinstr if (* tokenize if needed *) ourArg @ "$~$" explode 2 = not if ">> Syntax: $com [at|on|vs ]" command @ "$com" subst Tell NukeStack pid kill then strip ourString ! strip ourTarget ! else ourArg @ ourString ! then ourTarget @ not if "me" ourTarget ! then (* verify skill *) ourDataObj @ "@a/skills/" ourString @ strcat getprop not if ">> Skill '$skill' not found." ourString @ Capitalize "$skill" subst Tell 0 exit then ourDataObj @ "@a/skills/$skill/nodef" ourString @ "$skill" subst getpropstr me @ "@a/skills/" ourString @ strcat GetModAbility not and if ">> You don't know how to do that." Tell 0 exit then ourDataObj @ "@a/skills/" nextprop begin dup while dup "" "@a/skills/" subst ourString @ smatch not while ourDataObj @ swap nextprop repeat dup if "" "@a/skills/" subst ourSkill ! else ">> Skill '$skill' not found." ourString @ Capitalize "$skill" subst Tell pop 0 exit then "@a/skills/" ourString @ strcat ourString ! ourTarget @ if ourTarget @ match ourTarget ! then ourTarget @ ok? not if ">> That's not a valid target." Tell NukeStack 0 exit then ourTarget @ player? if ourTarget @ location me @ location dbcmp not if ">> $name is not here." ourTarget @ name "$name" subst Tell NukeStack 0 exit then then ourTarget @ player? if ourTarget @ CheckIdle if ">> $name is idle. Cannot target." ourTarget @ name "$name" subst Tell NukeStack 0 exit then then ourTarget @ exit? if loc @ "@a/ic" envpropstr pop not if ">> You can only target exits in IC areas." Tell NukeStack 0 exit then then 1 ; : DoUse ( -- ) (* go parse cmd args; initiate event loop *) DoParseArgs not if exit then ourString @ "/tools/" strcat Tools? not if ">> You don't have the tools necessary for that skill." Tell exit then ourString @ "/materials/" strcat Materials? not if ">> You don't have the materials necessary for that skill." Tell exit then me @ "@a/eloop/act" #0 "@a/calls/use" ourSkill @ strcat getprop not if "usenull" else "use" ourSkill @ tolower strcat then setprop me @ "@a/eloop/skill" ourSkill @ setprop me @ "@a/eloop/acting" "preparing an action" setprop me @ "@a/eloop/target" ourTarget @ setprop ">> Preparing action..." Tell EventLoop ; : main "me" match me ! (* initialize *) GetDataObj ourDataObj ! strip ourArg ! trig "@a/name" getpropstr ourCom ! Update ourArg @ if ourArg @ "#" stringpfx if "#help" ourArg @ stringpfx if DoHelp else "#enable" ourArg @ stringpfx if DoEnable else "#disable" ourArg @ stringpfx if DoDisable else "#version" ourArg @ stringpfx if DoVersion else "#install" ourArg @ stringpfx if DoInstall else "#uninstall" ourArg @ stringpfx if DoUninstall else ">> #Argument not understood." Tell then then then then then then exit then then Approved? me @ ArgoPermCheck Disabled? DoUse ; . c q @set asys-effects=W