@program $lib/rp 1 1000 d i ( LibRPS.muf.so -- Alynna Trypnotk, and Nuku Valente ) ( It lives again ) $def RPSYSTEM "$rpsystem" match $def RPDEFS "$rpdefs" match $def RPBASE "/@rp/" $def AVATAR #21 $include $muf/rp/boxutils $include $rpdefs $include $lib/alynna : rpstat ( s -- ? ) ( returns an RPsys stat ) RPSYSTEM swap getprop ; PUBLIC rpstat : virtstat ( d s -- ? ) ( virtual stat support function - is recursive with getstat ) dup RPDEFS swap "/_defs/" swap strcat prop? if ( any virtual stats by that name? ) RPDEFS swap call ( call the RPsystem ) else ( else ) pop pop 0 ( return jack ) then ; PUBLIC virtstat : envstat ( d s -- d ? ) ( finds a stat up the environment, returns the first object it finds it on ) "ds" checkargs RPBASE swap strcat envprop ( return the object ) ; PUBLIC envstat : envstatobj ( d s -- d ) ( finds a stat up the environment, returns the first object it finds it on ) envstat pop ; PUBLIC envstatobj : envstatval ( d s -- ? ) ( finds a stat up the environment, returns the first stat it finds ) envstat swap pop ; PUBLIC envstatval lvar target lvar prop lvar debugging : getstat ( d s -- ? ) prog "debug" flag? if 1 debugging ! .debug-off else 0 debugging ! then ( this getstat function is set up to support virtual stats ) "ds" checkargs ( first of all, if the prop exists, its assumed to be ) ( overriden, even if it is a virtual stat) over over RPBASE swap strcat prop? if ( does the prop exist ) RPBASE swap strcat getprop ( return the value ) else ( else ) prop ! target ! target @ prop @ "Special/" swap strcat RPBASE swap strcat getprop dup not if pop target @ prop @ virtstat ( try to get a virtual stat ) then then debugging @ if .debug-off then ; PUBLIC getstat : findstat ( d s -- d ? ) ( searches the player, then the environment, then the RPsystem itself, for a valid stat ) ( returns the first one it finds and the object it was found on ) over over getstat dup wassup? not if ( check the object and do a virtstat check ) pop over over envstat swap pop dup wassup? not if ( check the environment ) pop swap pop rpstat dup wassup? not if ( check the RP system ) pop #-1 "" ( didnt find a blasted thing ) else ( found something [rpsystem], return with the stack OK ) ( get rid of the original d s ) RPSYSTEM swap ( return with RPSYSTEM ? ) then else 4 rotate 2 popn ( get rid of the original d s, rest of result ok ) then else swap pop ( get rid of original s, keep the d, return new ? ) then ; PUBLIC findstat : findstatobj ( d s -- d ) ( searches the player, then the room, then the RPsystem itself, for a valid stat ) ( returns the first object it finds it on ) findstat pop ; PUBLIC findstatobj : findstatval ( d s -- ? ) ( searches the player, then the environment, then the RPsystem itself, for a valid stat ) ( returns the first one it finds and the object it was found on ) findstat swap pop ; PUBLIC findstatval lvar target lvar user : setstat ( d s -- ) swap RPBASE swap strcat swap setprop ; PUBLIC setstat : getstatint ( d s -- i ) "ds" checkargs target ! user ! "Virtual/" target @ strcat rpstat dup not if pop else target ! then user @ target @ getstat dup float? if int then dup string? if atoi then dup dbref? if int then dup lock? if "DIED: LOCK stored in rpsystem propdir" abort then ; PUBLIC getstatint : getstatfloat ( d s -- f ) "ds" checkargs target ! user ! "Virtual/" target @ strcat rpstat dup not if pop else target ! then user @ target @ getstat dup int? if float then dup string? if "0" swap strcat strtof then dup dbref? if int then dup lock? if "DIED: LOCK stored in rpsystem propdir" abort then ; PUBLIC getstatfloat : getstatstr ( d s -- s ) "ds" checkargs target ! user ! "Virtual/" target @ strcat rpstat dup not if pop else target ! then user @ target @ getstat dup int? if intostr then dup float? if ftostr then dup dbref? if int intostr "#" swap strcat then dup lock? if prettylock then ; PUBLIC getstatstr lvar scX lvar target : skillcost ( d s -- i ) ( check cost to raise a skill ) scx ! target ! target @ scx @ getstatint 1 + 25 > if 0.0 exit then 160.0 target @ "Jobs/Mundane" getstatint 8 * - target @ "Caps/" scx @ strcat getstatint dup 8 > if pop 8 then 20 * - dup 100 < if 100 + 2 / then target @ scx @ getstatint dup not if pop 5.0 * else sqrt * then 100.0 / rpsystem "cost/" scx @ strcat getpropstr dup "." instring 1 = if "0" swap strcat then strtof dup not if pop rpsystem "cost/" scx @ strcat getpropstr atoi then 1.0 + * 0.3 target @ scx @ getstatint 25.0 / 0.2 * + * .debug-off ; PUBLIC skillcost : subskillcost ( d s -- i ) ( check cost to raise a skill ) scx ! target ! target @ scx @ getstatint 1 + 25 > if 0.0 exit then 160.0 me @ "Jobs/Mundane" getstatint 8 * - target @ "Caps/" scx @ dup "/" instring 1 - strcut pop strcat getstatint dup 8 > if pop 8 then 20 * - target @ "Caps/" scx @ strcat getstatint dup 8 > if pop 8 then 20 * - dup 30 < if pop 30 then target @ scx @ getstatint dup not if pop 5.0 * else sqrt * then 100 / rpsystem "cost/" scx @ strcat getpropstr dup "." instring 1 = if "0" swap strcat then strtof dup not if pop rpsystem "cost/" scx @ strcat getpropstr atoi then 1.0 + * 0.3 target @ scx @ getstatint 25.0 / 0.2 * + * ; PUBLIC subskillcost : wise ( s s -- ? ) ( get rp prop according to current job ) swap "/jobs/" swap strcat "/" strcat swap strcat rpstat ; PUBLIC wise lvar nvS lvar nvX lvar nvI lvar nvI1 lvar nvI2 lvar nvI3 lvar nvI4 lvar nvI5 lvar nvI6 lvar nvI7 lvar nvI8 lvar nvI9 lvar nvI10 : nextval ( s i -- i ) ( Parse the pre-exploded string on the stack, returning the next highest value from i contained in s. ) ( If there is none, 0 is returned. ) nvX ! nvS ! nvS @ "`" explode nvI ! ( Grab em ) 0 0 0 0 0 0 0 0 0 0 nvI1 ! nvI2 ! nvI3 ! nvI4 ! nvI5 ! nvI6 ! nvI7 ! nvI8 ! nvI9 ! nvI10 ! begin atoi dup 1 = if 1 nvI1 ! then dup 2 = if 1 nvI2 ! then dup 3 = if 1 nvI3 ! then dup 4 = if 1 nvI4 ! then dup 5 = if 1 nvI5 ! then dup 6 = if 1 nvI6 ! then dup 7 = if 1 nvI7 ! then dup 8 = if 1 nvI8 ! then dup 9 = if 1 nvI9 ! then dup 10 = if 1 nvI10 ! then pop nvI @ 1 - nvI ! nvI @ 0 = until 1 nvI ! begin nvI @ dup 1 = if 1 nvI1 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 2 = if 1 nvI2 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 3 = if 1 nvI3 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 4 = if 1 nvI4 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 5 = if 1 nvI5 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 6 = if 1 nvI6 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 7 = if 1 nvI7 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 8 = if 1 nvI8 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 9 = if 1 nvI9 @ = if nvI @ nvX @ > if pop nvI @ exit then then then dup 10 = if 1 nvI10 @ = if nvI @ nvX @ > if pop nvI @ exit then then then pop nvI @ 1 + nvI ! nvI @ 11 = until 0 ; PUBLIC nextval lvar yipD lvar yipS lvar yipJ lvar yipI lvar yipN lvar prof lvar base : treetraveler ( -- ) yipD @ "Jobs/" prof @ strcat getstatint 20 * - base @ "Rogue" smatch if prof @ "Fighter" instring prof @ "Mage" instring or if 100 + exit else prof @ "Monster" instring prof @ "Mundane" instring or if 150 + exit else 200 + exit then then then base @ "Fighter" smatch if prof @ "Rogue" instring prof @ "Acolyte" instring or if 100 + exit else prof @ "Monster" instring prof @ "Mundane" instring or if 150 + exit else 200 + exit then then then base @ "Mage" smatch if prof @ "Acolyte" instring prof @ "Rogue" instring or if 100 + exit else prof @ "Monster" instring prof @ "Mundane" instring or if 150 + exit else 200 + exit then then then base @ "Acolyte" smatch if prof @ "Fighter" instring prof @ "Mage" instring or if 100 + exit else prof @ "Monster" instring prof @ "Mundane" instring or if 150 + exit else 200 + exit then then then base @ "Monster" smatch if prof @ "Fighter" instring prof @ "Mage" instring prof @ "Rogue" instring prof @ "Acolyte" instring or or or if 150 + exit else 200 + exit then then base @ "Mundane" smatch if prof @ "Fighter" instring prof @ "Mage" instring prof @ "Rogue" instring prof @ "Acolyte" instring or or or if 150 + exit else 200 + exit then then ; lvar tier : talentcost ( d s s -- i ) var costmod yipS ! yipJ ! yipD ! ( d s - save these values, magery is dangerous ) yipD @ "special/" yipS @ strcat getstatint yipI ! ( get current special, save it ) yipI @ 1 + yipN ! ( Find out what the next possible value is, store it ) yipN @ 0 = if 0 exit then ( leave with 0 if there isnt any ) YipD @ "Special/" YipS @ strcat getstatint 1 + 25 > if 0.0 exit then 110.0 yipS @ "Talents/" swap strcat "/Profession" strcat rpsystem swap getpropstr prof ! yipD @ "Class" getstatstr dup if base ! else pop yipD @ "Professionlist" getstatstr dup " " instring dup not if pop dup strlen then strcut pop base ! base @ "" "," subst base ! then yipD @ "Caps/" yipS @ strcat getstatint 8 * - prof @ not if 50.0 + else prof @ base @ instring not if treetraveler then then yipD @ "Jobs/" base @ strcat getstatint prof @ base @ instring if tier ! else 2 / tier ! then costmod ! ( is the special a component? ) rpsystem str "Talents/" yipS @ "/shock" cat getprop if ( It's a spell! ) costmod @ 25 - costmod ! rpsystem str "Talents/" yipS @ "/element" cat getprop if ( It has elements! ) yipd @ "Special/Fire-Affinity" getstatint if ( I have Fire ) rpsystem str "Talents/" yipS @ "/element" cat getprop "Ice" instring if ( It has Ice, eep ) costmod @ yipd @ "Special/Fire-Affinity" getstatint + costmod ! then rpsystem str "Talents/" yipS @ "/element" cat getprop "Fire" instring if ( has Fire, yay ) costmod @ yipd @ "Special/Fire-Affinity" getstatint - costmod ! then then yipd @ "Special/Ice-Affinity" getstatint if ( I have Ice ) rpsystem str "Talents/" yipS @ "/element" cat getprop "Fire" instring if ( It has Fire, eep ) costmod @ yipd @ "Special/Ice-Affinity" getstatint + costmod ! then rpsystem str "Talents/" yipS @ "/element" cat getprop "Ice" instring if ( has Ice, yay ) costmod @ yipd @ "Special/Ice-Affinity" getstatint - costmod ! then then yipd @ "Special/air-Affinity" getstatint if ( I have air ) rpsystem str "Talents/" yipS @ "/element" cat getprop "Earth" instring if ( It has Earth, eep ) costmod @ yipd @ "Special/air-Affinity" getstatint + costmod ! then rpsystem str "Talents/" yipS @ "/element" cat getprop "air" instring if ( has air, yay ) costmod @ yipd @ "Special/air-Affinity" getstatint - costmod ! then then yipd @ "Special/Earth-Affinity" getstatint if ( I have Earth ) rpsystem str "Talents/" yipS @ "/element" cat getprop "Air" instring if ( It has Air, eep ) costmod @ yipd @ "Special/Earth-Affinity" getstatint + costmod ! then rpsystem str "Talents/" yipS @ "/element" cat getprop "Earth" instring if ( has Earth, yay ) costmod @ yipd @ "Special/Earth-Affinity" getstatint - costmod ! then then yipd @ "Special/White-Affinity" getstatint if ( I have White ) rpsystem str "Talents/" yipS @ "/element" cat getprop "Black" instring if ( It has Black, eep ) costmod @ yipd @ "Special/White-Affinity" getstatint + costmod ! then rpsystem str "Talents/" yipS @ "/element" cat getprop "White" instring if ( has White, yay ) costmod @ yipd @ "Special/White-Affinity" getstatint - costmod ! then then yipd @ "Special/Black-Affinity" getstatint if ( I have Black ) rpsystem str "Talents/" yipS @ "/element" cat getprop "White" instring if ( It has White, eep ) costmod @ yipd @ "Special/Black-Affinity" getstatint + costmod ! then rpsystem str "Talents/" yipS @ "/element" cat getprop "Black" instring if ( has Black, yay ) costmod @ yipd @ "Special/Black-Affinity" getstatint - costmod ! then then then then costmod @ ( check for other caps ) prof @ "mage" instring if yipD @ "Jobs/Mage" getstatint dup tier @ > if tier ! else pop then then prof @ "rogue" instring if yipD @ "Jobs/Rogue" getstatint dup tier @ > if tier ! else pop then then prof @ "mundane" instring if yipD @ "Jobs/Mundane" getstatint dup tier @ > if tier ! else pop then then prof @ "fighter" instring if yipD @ "Jobs/Fighter" getstatint dup tier @ > if tier ! else pop then then prof @ "acolyte" instring if yipD @ "Jobs/Acolytee" getstatint dup tier @ > if tier ! else pop then then prof @ "Monster" instring if yipD @ "Jobs/Monster" getstatint dup tier @ > if tier ! else pop then then ( end check ) yipD @ "Caps/" yipS @ strcat getstatint tier @ > if yipD @ "Caps/" yipS @ strcat getstatint tier ! else yipD @ "Caps/" yipS @ strcat getstatint tier @ < if 0 pop then then yipN @ tier @ 5 > if 5 tier ! then rpsystem str "Talents/" yipS @ "/Caps" cat getpropstr "/" tier @ eselect atoi > if pop 0 exit then YipI @ dup not if pop yipn @ 5.0 * * else sqrt 1.2 * * then 100.0 / rpsystem "cost/" YipS @ strcat getpropstr dup "." instring 1 = if "0" swap strcat then strtof dup not if pop rpsystem "cost/" YipS @ strcat getpropstr atoi then 1.0 + * 0.666 * .debug-off ; PUBLIC talentcost : reset ( d -- ) "d" checkargs dup caller "W2" flag? if RPBASE remove_prop else caller name " not allowed to reset props. it's not W2 set." strcat abort then ; PUBLIC reset : off-tell ( d s -- ) "ds" checkargs "^red^*^white^Official^red^*^ ^ " swap strcat swap location swap 0 swap ansi_notify_exclude ; PUBLIC off-tell lvar target lvar result lvar roll1 lvar roll2 lvar roll4 lvar roll3 lvar fumbles lvar crits lvar succs lvar repeat lvar temp lvar bonusstat lvar entered lvar dice lvar max lvar curr lvar toggle lvar private lvar message lvar modulous : find-target ( s -- i ) 0 target ! 0 crits ! "+" explode repeat ! begin 0 temp ! dup atoi dup 0 = if pop dup bonusstat ! crits @ not if rpsystem "Talents/" bonusstat @ strcat "/roll" strcat getpropstr dup not if pop else dup entered @ dup "+" instring dup not if pop dup strlen else 1 - then strcut swap pop strcat entered ! "+" explode repeat @ + repeat ! crits @ 1 + crits ! continue then then dup "-" instring 1 = if 1 strcut swap pop 1 temp ! else 0 temp ! then message @ swap dup bonusstat ! getstatint dup not if pop message @ bonusstat @ "special/" swap strcat getstatint then message @ "bonus/" bonusstat @ strcat getpropstr ":" explode 2 = not if pop else bonusstat @ " was modified by " strcat swap strcat ": " strcat over strcat dup .tell .otell atoi + then else swap pop then temp @ if target @ swap - target ! else target @ + target ! then crits @ 1 + crits ! crits @ repeat @ = until target @ #0 "day?" getstatint if message @ "Special/Day-Affinity" getstatint + message @ "Special/Night-Affinity" getstatint - else message @ "Special/Night-Affinity" getstatint + message @ "Special/Day-Affinity" getstatint - then ; : roller var stardepth depth 2 - stardepth ! dup not if pop "Incorrect syntax, please type +check stat1+stat2+-number+number+etc.+etc. " tellme pid kill then swap message ! dup entered ! "vs" explode 2 = not if "11" swap entered @ " vs 11" strcat entered ! then strip find-target ( me @ "kharma" getstatint + ) dup 5 % modulous ! 5 / dup 1 < if pop 1 then dup 20 > message @ player? and if pop 20 then max ! ( Restrict to 20 dice if not PC ) depth stardepth @ 1 + > if begin pop depth stardepth @ 1 + = until then find-target target ! max @ 0 = if "No dice to roll." .tell 0 exit then 0 crits ! 0 fumbles ! 0 succs ! 0 curr ! "" dice ! 0 private ! begin random 20 % 1 + message @ "jnote" "Bad Kharma" findboxitem if 1 - then message @ "jnote" "Good Kharma" findboxitem if 1 + then roll1 ! ( get a random number from 1-10) roll1 @ target @ < not if succs @ 1 + succs ! else roll1 @ private @ + private ! then roll1 @ 1 = if fumbles @ 1 + fumbles ! then roll1 @ 20 = if crits @ 1 + crits ! then dice @ roll1 @ intostr strcat " " strcat dice ! curr @ 1 + curr ! curr @ max @ = until succs @ crits @ + fumbles @ - private @ target @ / + message @ "lastrolled" dice @ setstat ; PUBLIC roller : 5d5 ( -- i ) ( outputs 5d5 ) random 5 % 1 + random 5 % 1 + random 5 % 1 + random 5 % 1 + random 5 % 1 + ( 5d5 on stack ) + + + + ( Add them together ) ; PUBLIC 5d5 : rpmatch ( i s -- s ) swap intostr "/" swap strcat strcat "/" swap strcat RPSYSTEM swap getpropstr ; PUBLIC rpmatch : gauntlet ( s -- ) AVATAR "gauntlet " rot strcat force ; PUBLIC gauntlet : growthfactor ( i/f d -- f ) swap tofloat swap "growth" getstatfloat 100 / 1 + * ; PUBLIC growthfactor : getmaxmp ( d -- i ) var target target ! target @ "Magery" getstatint target @ "Willpower" getstatint + 2 / target @ "Stamina" getstatint 3 / + target @ "Arcana" getstatint 3 / target @ "Arcana/Reserves" getstatint 2 / + + target @ "Jobs/Mage" getstatint + target @ "Jobs/Acolyte" getstatint 2 / + target @ "Jobs/Rogue" getstatint 2 / + target @ "Jobs/Fighter" getstatint 2.5 / int + target @ "Jobs/Monster" getstatint 1.5 / int + target @ "Jobs/Mundane" getstatint 3 / + 1.5 / int ; PUBLIC getmaxmp : main (testing section) "libRP v2.32.20010903hote" header tellhere "The library is installed properly" "TEST" pretty tellhere "$lib/alynna" "REQUIRES" pretty tellhere "5d5 cost envstat envstatobj envstatval findstat findstatobj findstatval" "PROVIDES" pretty tellhere "getstat getstatfloat getstatstr getstatint maxhp maxmp maxtp nextval" "PROVIDES" pretty tellhere "reset resolve-prop rpmatch rpstat setstat virtstat wise gauntlet growthfactor" "PROVIDES" pretty tellhere "MUFInstaller" footer tellhere ; . c q