@q @program asys-magic 1 99999 d i ( asys-magic v1.2 Jessy@FurryMUCK 6/00 This program handles spell-related commands and events. INSTALLATION: asys-magic uses the standard Argo installation method. Port the program and set it Wizard. Type '+install asys-magic' USAGE: +cast [at|on|versus|vs] [] asys-magic 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: spell prop *) lvar ourSpell (* string: spell 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-magic" setprop RecOldActions (* create and register command; set default props *) #0 "+cast" newexit dup scratch ! prog setlink prog "@a/version" thisVersion setprop scratch @ "@a/version" thisVersion setprop #0 "@a/comm_list/+cast" scratch @ setprop #0 "@a/prog_list/" prog name strcat prog setprop scratch @ "@a/name" "+cast" 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/+cast" 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 spell succeeded criticaly *) ourTarget @ me @ dbcmp if ">> $me successfully casts the $spell spell. [CRITICAL]" me @ name "$me" subst TellRoom ourSpell @ CapAll subst TellRoom else ">> $me successfully casts $spell on $you. [CRITICAL]" me @ name "$me" subst ourTarget @ "$you" subst ourSpell @ CapAll subst TellRoom then ; : DoCritFail ( -- ) (* notify room: null spell failed criticaly *) ourTarget @ me @ dbcmp if ">> $me's attempt to cast $spell fails. [CRITICAL]" me @ name "$me" subst TellRoom ourSpell @ CapAll subst TellRoom else ">> $me's attempt to cast $spell on $you fails. [CRITICAL]" me @ name "$me" subst ourTarget @ "$you" subst ourSpell @ CapAll subst TellRoom then ; : DoCastNull ( -- ) (* run a spell with no coded effects *) me @ "@a/eloop/spell" getpropstr dup if "@a/spells/" swap strcat scratch ! scratch @ "/tools/" strcat Tools? not if ">> You don't have the components necessary for that spell." Tell exit then scratch @ "/materials/" strcat Materials? if scratch @ "/materials/" strcat UseMaterials else ">> You don't have the materials necessary for that spell." 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 ourTarget @ if ourTarget @ GetMagResAdv + 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 casts $spell on $you." me @ name "$me" subst me @ "@a/eloop/target" getprop name "$you" subst me @ "@a/eloop/spell" getpropstr CapAll "$spell" subst TellRoom else ">> $me successfully casts the $spell spell." me @ name "$me" subst me @ "@a/eloop/spell" getpropstr CapAll "$spell" subst TellRoom then else me @ "@a/eloop/target" getprop me @ dbcmp not if ">> $me's attempt to cast $spell on $you fails." me @ name "$me" subst me @ "@a/eloop/target" getprop name "$you" subst me @ "@a/eloop/spell" getpropstr CapAll "$spell" subst TellRoom else ">> $me's attempt to cast $spell fails." me @ name "$me" subst me @ "@a/eloop/spell" getpropstr CapAll "$spell" subst TellRoom then then else pop pop then else pop then TellWait ; : DoParseArgs ( -- ) (* parse command args; store in lvars *) me @ "@a/eloop/spell" remove_prop 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 @ "$~$" 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 ourString @ not if ">> Syntax: $com at|on|vs " command @ "$com" subst Tell 0 exit then (* verify spell *) ourDataObj @ "@a/spells/" ourString @ strcat getprop not if ">> Spell '$spell' not found." ourString @ Capitalize "$spell" subst Tell 0 exit then me @ "@a/spells/" ourString @ strcat GetModAbility not if ">> You don't know how to do that." Tell 0 exit then ourDataObj @ "@a/spells/" nextprop begin dup while dup "" "@a/spells/" subst ourString @ smatch not while ourDataObj @ swap nextprop repeat dup if "" "@a/spells/" subst ourSpell ! else ">> Spell '$spell' not found." ourString @ Capitalize "$spell" subst Tell pop 0 exit then "@a/spells/" ourString @ strcat ourString ! me @ "@a/stats/con" GetModAbility me @ "@a/stats/str" GetModAbility + me @ GetEnduranceAdv + dup -1 * swap me @ "@a/stats/fat" getpropstr atoi - ourDataObj @ ourString @ "/fat" strcat getpropstr atoi - > if ">> You don't have the energy to cast $spell right now." ourSpell @ "$spell" subst Tell 0 exit then ourTarget @ "'s " instr if ourTarget @ "" "'s" subst dup " " instr strcut strip me @ "@a/eloop/subtarget" rot setprop strip ourTarget ! then ourTarget @ FindOther ourTarget ! ourTarget @ player? if ourTarget @ VerifyTarget not if ">> $name is not a valid target." ourTarget @ name "$name" subst Tell NukeStack 0 exit then else ourTarget @ exit? not ourTarget @ "@a/version" getpropstr not and if ">> $name is not a valid target." ourTarget @ name "$name" subst Tell NukeStack 0 exit then then 1 ; : DoCast ( -- ) (* go parse cmd args; initiate event loop *) DoParseArgs not if NukeStack exit then ourString @ "/tools/" strcat Tools? not if ">> You don't have the components necessary for that spell." Tell NukeStack exit then ourString @ "/materials/" strcat Materials? not if ">> You don't have the materials necessary for that spell." Tell NukeStack exit then me @ "@a/eloop/act" #0 "@a/calls/cast" ourSpell @ strcat getprop not if "castnull" else "cast" ourSpell @ tolower strcat then setprop me @ "@a/eloop/spell" ourSpell @ 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 me @ "@a/eloop/subtarget" remove_prop 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 Magic? Approved? me @ ArgoPermCheck Disabled? DoCast ; . c q @set asys-magic=W