@q @program asys-spells 1 99999 d i ( asys-spells v1.2 Jessy @ FurryMUCK 6/97, 2/99 Asys-spells runs Argo +spells command, which is used to modify a character's skill levels for spells. INSTALLATION: asys-spells uses the default Argo installation method. Port and install lib-argo. Set asys-spells W. Type '+install asys-spells' to install this program and its action. USAGE: +spells................ Follow prompts to learn new spells or modify existing ones See lib-argo and the Argo manual for further information. Asys-spells may be freely ported. Please comment any changes. ) (2345678901234567890123456789012345678901234567890123456789012345678901) $def thisVersion "1.2" $define Tell me @ owner swap notify $enddef $include $lib/argo lvar scratch (* workspace var *) lvar ourCounter (* misc. counter var *) lvar ourDataObj (* dbref: object holding system-wide data *) lvar ourArg (* inital arg string, unmodified *) lvar ourOption (* string: command #option *) lvar ourString (* string: job prop *) lvar ourCom (* string: 'official' name of command *) : 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 prog "@a/name" "asys-realm" setprop RecOldActions #0 "+spells" newexit dup scratch ! (* create command *) prog setlink prog "@a/version" thisVersion setprop (* set version *) scratch @ "@a/version" thisVersion setprop (* register command *) #0 "@a/comm_list/+spells" scratch @ setprop #0 "@a/prog_list/" prog name strcat prog setprop #0 "@a/cat_list/spells" "Spell" setprop scratch @ "@a/name" "+spells" setprop (* set desc to show help *) scratch @ "{muf:#" prog intostr strcat "," strcat "#help}" strcat setdesc ">> Installed." Tell ; : DoUninstall (* uninstall program from Argo *) ">> Please confirm: You wish to uninstall " prog name strcat "?" strcat Tell ReadLine not if ">> Aborted." Tell pid kill Then background "@a/comm_list/+spells" RemoveCommand #0 "@a/prog_list/" prog "@a/name" getpropstr strcat remove_prop RecOldActions ">> Uninstalled." Tell ">> Please edit the online manual as appropriate." Tell ; : DoHelp ( -- ) (* display help screen *) " " Tell prog name " (#" strcat prog intostr strcat ")" strcat Tell " " Tell "The $com command is used to modify your skill levels for spells, by " "spending character points to learn new Spills or improve existing " "ones. To use it, type $com and follow prompts. As with any " "prompt-driven Argo command, you can speak and pose while at a " "prompt, but cannot enter other MUCK commands." strcat strcat strcat strcat command @ "$com" subst Tell " " Tell "You can also use the $info command to get information about a " "specific spell. See `$info #help'." strcat "+info" GetCommandName "$info" subst Tell " " Tell ; : FindNamedSpell ( s -- s i ) (* find spell specified by name; return name and T|F *) ourDataObj @ "@a/spells/" nextprop begin dup while dup "" "@a/spells/" subst 3 pick smatch if swap pop "" "@a/spells/" subst 1 exit then ourDataObj @ swap nextprop repeat pop CapAll 0 ; : SetSpell ( s -- ) (* adjust user's level for spell s *) (* check: user has points to spend *) me @ "@a/avail/main" getpropstr atoi 0 > not me @ "@a/status" getpropstr "na" smatch not and if ">> Sorry, you don't have any points to spend on spells." Tell ">> Done." Tell pop pid kill then (* check: user has perqs? *) dup me @ "spells" 3 pick CheckPerqs not if ">> Sorry, you don't have the prerequisites for that spell." Tell pop exit then (* check: user has objects needed to learn? *) "@a/spells/$spell/tolearn/" over "$spell" subst Tools? not if ">> Sorry, you don't have the objects necessary to learn that spell." Tell pop exit then (* check: user has required Intelligence? *) me @ "@a/stats/int" getpropstr atoi ourDataObj @ "@a/spells/" 4 pick strcat getpropstr "," explode pop pop swap pop atoi dup rot > if ">> Sorry, your Intelligence must be " swap intostr strcat " to learn " strcat swap strcat "." strcat Tell exit else pop then (* check: user has status necessary for group influence? *) dup "* Influence" smatch if ourDataObj @ "@a/groups/" 3 pick dup strlen 10 - strcut pop strcat "/SR" strcat over over getpropstr if getpropstr atoi me @ "@a/dis-ad/status" getpropstr atoi > if ">> Sorry, your Status must be higher to have Influence in the " swap dup strlen 10 - strcut pop strcat " group." strcat Tell then else pop pop then then (* find out how many levels user wants *) begin (* begin level-asking loop *) ">> How many levels of the " over strcat " spell do you want to add?" strcat Tell ">> [Enter a number between " me @ "@a/status" getpropstr dup "na" smatch swap "exempt" smatch or if me @ "@a/spells/" 4 pick strcat getpropstr atoi dup if 0 swap - me @ "@a/spells/" 5 pick strcat "/floor" strcat getpropstr atoi + intostr else pop "1" then else "1" then strcat " and " strcat me @ "@a/avail/main" getpropstr strcat ", or .q to quit]" strcat Tell ReadLine strip QCheck (* check: valid entry? *) dup number? not if ">> Sorry, that's not a number." Tell pop continue then (* check: negative level? *) me @ "@a/spells/" 4 pick strcat getpropstr atoi over atoi + 0 < if ">> Sorry, you cannot have a negative skill level." Tell pop continue then (* check: approved player trying to lower? *) me @ "@a/status" getpropstr dup "na" smatch swap "exempt" smatch or not if dup atoi 1 < if ">> Sorry, you must specify at least one additional level." Tell pop continue then then (* check: would current mod go below floor? *) dup atoi 0 < if me @ "@a/spells/" 4 pick strcat "/floor" strcat getpropstr dup if me @ "@a/spells/" 5 pick strcat getpropstr atoi 3 pick atoi + swap atoi < if pop pop ">> Sorry, that would violate a prerequisite or " "template dependency." strcat Tell exit then else pop then then atoi dup me @ "@a/avail/main" getpropstr atoi > if ">> Sorry, you don't have enough points for that." Tell pop exit then (* check: user has enough money? *) ourDataObj @ "@a/spells/" 4 pick strcat getpropstr "," explode pop pop pop atoi over * dup if me @ swap CheckFunds not if ">> Sorry, you don't have enough money to learn that spell." Tell pop exit then else pop then break (* passed all tests! *) repeat (* end level-asking loop *) (* set floor if spell has preqs & this is 1st time learning, or if user is reducing ability level *) me @ "@a/spells/" 4 pick strcat getpropstr not if ourDataObj @ "@a/spells/" 4 pick strcat "/preqs#/" strcat over over nextprop dup if begin (* begin preq-floor-setting loop *) dup while ourDataObj @ over getpropstr "," explode 3 = not if ">> ERROR." Tell ">> There is an error with this spells's prerequisites." Tell ">> Please contact a staff member." Tell ">> Spell not set." Tell exit then "@a/" swap strcat "/" strcat swap Capitalize strcat "/floor" strcat me @ swap over over getpropstr atoi 4 rotate atoi + intostr setprop ourDataObj @ swap nextprop repeat (* end preq-floor-setting loop *) pop pop pop else pop pop pop then then ourDataObj @ "@a/spells/" 4 pick strcat getpropstr "," explode pop pop pop atoi over * dup if me @ swap Charge not if ">> Error with monetary cost: Please contact a staff member." Tell exit then else pop then me @ "@a/avail/main" over over getpropstr atoi 4 pick - intostr setprop me @ "@a/spells/" 4 pick strcat over over getpropstr atoi 4 rotate + intostr setprop (* remove floors that no longer apply *) me @ "@a/spells/" 3 pick strcat getpropstr atoi 0 <= if ourDataObj @ "@a/spells/" 3 pick strcat "/preqs#/" strcat nextprop dup if begin (* begin floor-removing loop *) dup while ourDataObj @ over getpropstr "," explode pop me @ "@a/" rot strcat "/" strcat rot strcat "/floor" strcat over over 5 rotate atoi 0 swap - ApplyArgoMod over over getpropstr atoi 0 <= if (* strip floors <= 0 *) remove_prop else pop pop then ourDataObj @ swap nextprop repeat (* end floor-removing loop *) pop else pop then then ">> Your ability level for " over strcat " is now " strcat me @ "@a/spells/" 4 pick strcat getpropstr strcat "." strcat Tell (* strip spells <= 0 *) me @ "@a/spells/" rot strcat over over getpropstr atoi 0 <= if remove_prop else pop pop then ; : DoSpells ( -- ) (* enter interactive session; adjust spells *) (* check: location ok? *) CheckCGRoom not if ">> Sorry, this command must be used in a designated setup room." Tell exit then (* check: spells defined? *) ourDataObj @ "@a/spells/" nextprop not if ">> Sorry, no spells have been entered for this realm." Tell exit then (* get name of spell *) begin (* begin spell-reading loop *) ">> You have $num available character $noun." me @ "@a/avail/main" getpropstr dup scratch ! "$num" subst scratch @ "1" smatch if "point" else "points" then "$noun" subst Tell ">> What spell do you wish to learn?" Tell ">> [Enter a spell, or .l to list choices, or .q to quit]" Tell ReadLine strip QCheck dup ".l" smatch if "@a/spells/" 3-coln-prop continue then dup number? if "@a/spells/" swap FindNumProp dup not if ">> Sorry, there is no spell with that number." Tell pop continue then else FindNamedSpell not if ">> Sorry, there is no spell named " swap strcat "." strcat Tell continue then then SetSpell repeat (* end spell-reading loop *) ; : main "me" match me ! (* initialize *) GetDataObj ourDataObj ! strip ourArg ! trig "@a/name" getpropstr ourCom ! ourArg @ if ourArg @ "#" stringpfx if ourArg @ " " instr if ourArg @ dup " " instr strcut strip ourArg ! strip ourOption ! else ourArg @ strip ourOption ! then "#help" ourOption @ stringpfx if DoHelp else "#enable" ourOption @ stringpfx if DoEnable else "#disable" ourOption @ stringpfx if DoDisable else "#version" ourOption @ stringpfx if DoVersion else "#install" ourOption @ stringpfx if DoInstall else "#uninstall" ourOption @ stringpfx if DoUninstall else ">> #Argument not understood." Tell then then then then then then exit then then Magic? not if ">> The Magic system is currently disabled." Tell exit then me @ ArgoPermCheck Disabled? DeadCheck DoSpells ; . c q @set asys-spells=W