( LibRPS.muf.so -- Alynna Trypnotk ) ( It lives again ) $pubdef : $def RPSYSTEM "$rpsystem" match $def RPBASE "/@rp/" $pubdef RPSYSTEM "$rpsystem" match $pubdef RPBASE "/@rp/" $include $lib/alynna $include $muf/inline $undef resolve $def doinline { { "#" target @ int " var! target " }cat rot tostr strcat inline }array array_sum $def getinline getraw dup if doinline then ( Define some modes for charmode ) $def CHAR : rpstat[ str:item -- value ] RPSYSTEM item @ getprop ; PUBLIC rpstat $libdef rpstat : }rpstat ( cripped array -- value ) }array "/" array_join RPSYSTEM swap getprop ; PUBLIC }rpstat $libdef }rpstat : }rpinfo ( cripped array -- value ) }array "/" array_join RPSYSTEM swap getpropstr ; PUBLIC }rpinfo $libdef }rpinfo : enumType[ str:type -- arr:types ] RPSYSTEM { "/" type @ "/" }cat array_get_propdirs ; PUBLIC enumType $libdef enumType : envraw[ ref:target str:item -- ref:newtarget value ] target @ RPBASE item @ strcat envprop ; PUBLIC envraw $libdef envraw : envrawobj[ ref:target str:item -- ref:newtarget ] target @ item @ envraw pop ; PUBLIC envrawobj $libdef envrawobj : envrawval[ ref:target str:item -- value ] target @ item @ envraw swap pop ; PUBLIC envrawval $libdef envrawval : getraw[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop ; PUBLIC getraw $libdef getraw : getrawint[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop 0 else toint then ; PUBLIC getrawint $libdef getrawint : getrawfloat[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop 0.0 else tofloat then ; PUBLIC getrawfloat $libdef getrawfloat : getrawobj[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop #-1 else todbref then ; PUBLIC getrawobj $libdef getrawobj : getrawstr[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop "" else tostr then ; PUBLIC getrawstr $libdef getrawstr : envstat[ ref:target str:item -- ref:newtarget value ] target @ RPBASE item @ strcat envprop target @ RPBASE "@/" item @ strcat strcat getprop + ; PUBLIC envstat $libdef envstat : envstatobj[ ref:target str:item -- ref:newtarget ] target @ item @ envstat pop ; PUBLIC envstatobj $libdef envstatobj : envstatval[ ref:target str:item -- value ] target @ item @ envstat swap pop ; PUBLIC envstatval $libdef envstatval : getstat[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop var! x x @ int? x @ float? or if target @ RPBASE "/@/" item @ strcat strcat getprop x @ + target @ RPBASE "/!/" item @ strcat strcat getprop dup not if pop else doinline + then else x @ then ; PUBLIC getstat $libdef getstat : getstatint[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop 0 else toint then target @ RPBASE "/@/" item @ strcat strcat getprop dup not if pop 0 else toint then target @ RPBASE "/!/" item @ strcat strcat getprop dup not if pop 0 else doinline then + + ; PUBLIC getstatint $libdef getstatint : getstatfloat[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop 0.0 else tofloat then target @ RPBASE "/@/" item @ strcat strcat getprop dup not if pop 0.0 else tofloat then target @ RPBASE "/!/" item @ strcat strcat getprop dup not if pop 0.0 else doinline then + + ; PUBLIC getstatfloat $libdef getstatfloat : getstatobj[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop #-1 else todbref then ; PUBLIC getstatobj $libdef getstatobj : getstatstr[ ref:target str:item -- value ] target @ RPBASE item @ strcat getprop dup not if pop "" else tostr then ; PUBLIC getstatstr $libdef getstatstr : findstat[ ref:target str:item -- ref:newtarget value ] target @ item @ envstat dup if exit else pop pop RPSYSTEM item @ getstat dup if RPSYSTEM swap else #-1 0 then then ; PUBLIC findstat $libdef findstat : findstatobj[ ref:target str:item -- ref:newtarget ] findstat pop ; PUBLIC findstatobj $libdef findstatobj : findstatval[ ref:target str:item -- value ] findstat swap pop ; PUBLIC findstatval $libdef findstatval : setstat[ ref:target str:item value -- ] target @ RPBASE item @ strcat value @ setprop ; PUBLIC setstat $libdef setstat : resetstat[ ref:target str:item -- ] target @ "m/" item @ strcat getstat dup if target @ item @ rot setstat then ; PUBLIC resetstat $libdef resetstat : resetall[ ref:target -- ] target @ "/@rp/m/" target @ "/@rp/" 1 copyprops ; PUBLIC resetall $libdef resetall : todir[ s:input -- s:output ] input @ "* (*)" smatch if input @ strip " (" split dup strlen -- strcut pop "/" swap strcat strcat else input @ then ; PUBLIC todir $libdef todir : fromdir[ s:input -- s:output ] input @ "*/*" smatch if { input @ "/" split " (" swap ")" }join else input @ then ; PUBLIC fromdir $libdef fromdir : chopsub[ s:input -- s:output ] input @ dup "*/*" smatch if "/" split pop then dup "* (*)" smatch if " (" split pop then ; PUBLIC chopsub $libdef chopsub : chopallsub[ a/s:input -- a/s:output ] var isString input @ string? if 1 isString ! input @ ", " explode_array input ! then { input @ foreach swap pop chopsub repeat }array isString @ if ", " array_join then ; PUBLIC chopallsub $libdef chopallsub : chopmain[ s:input -- s:output ] input @ dup "*/*" smatch if "/" split swap pop then dup "* (*)" smatch if " (" split swap pop dup strlen -- strcut pop then ; PUBLIC chopmain $libdef chopmain : chopallmain[ a/s:input -- a/s:output ] var isString input @ string? if 1 isString ! input @ ", " explode_array input ! then { input @ foreach swap pop chopmain repeat }array isString @ if ", " array_join then ; PUBLIC chopallmain $libdef chopallmain : mklist[ str:input -- array:output ] input @ dup string? if ", " explode_array then ; PUBLIC mklist $libdef mklist : mkstr[ array:input -- str:output ] input @ dup array? if ", " array_join then ; PUBLIC mkstr $libdef mkstr : smatchstrlist[ str:input str:find -- int:pos ] input @ ", " explode_array find @ array_matchval array_count ; PUBLIC smatchstrlist $libdef smatchstrlist : smatcharrlist[ arr:input str:find -- int:pos ] input @ find @ array_matchval array_count ; PUBLIC smatcharrlist $libdef smatcharrlist : emerge[ str/arr:list1 str/arr:list2 -- b:result ] list1 @ dup string? if ", " explode_array then list2 @ dup string? if ", " explode_array then array_intersect array_count ; PUBLIC emerge $libdef emerge ( FFa2 Expansion: Attrs and Traits macros ) : DP "DP" getstat ; PUBLIC DP $libdef DP : power "power" getstat ; PUBLIC power $libdef power $pubdef XP DP $pubdef rawXP DP $pubdef rawDP DP : getCost[ i:point s:table -- f:cost ] { "System" table @ "Cost" point @ 1 10 limit tostr }rpinfo tofloat ; PUBLIC getCost $libdef getcost $pubdef getCostDP getCost $pubdef getCostXP getCost : spendDP[ d:target f/i:amount -- i:errorcode ] var tmp var tamount ( Cant spend if sheetlocked ) target @ "sheetlocked" getstat if 2 exit then ( Cant spend if enough DP isnt had ) amount @ target @ DP > if 1 exit then ( Deduct DP ) target @ "DP" over over getstat amount @ - setstat ( Then add what was spent to Power ) target @ "power" over over getstat amount @ + setstat 0 ; PUBLIC spendDP $libdef spendDP $pubdef spendXP spendDP $pubdef spend spendDP : npc?[ ref:target -- int:npc? ] target @ "npc" getstat ; PUBLIC npc? $libdef npc? : exp[ ref:target -- int:exp ] { target @ "m/physical" getraw 10 * target @ "m/mental" getraw 10 * target @ "m/spiritual" getraw 10 * target @ "m/social" getraw 10 * target @ "/@rp/s/" array_get_propvals array_vals pop }array array_sum ; PUBLIC exp $libdef exp : growth[ ref:target -- int:genkai ] target @ exp 400 >= if target @ npc? not if 7 exit else target @ exp 400 - 50 / 7 + toint exit then then target @ exp 350 >= if 6 exit then target @ exp 300 >= if 5 exit then target @ exp 250 >= if 4 exit then target @ exp 200 >= if 3 exit then target @ exp 150 >= if 2 exit then 1 ; PUBLIC growth $libdef growth : magic-formula-calc[ i:test -- i:magic ] test @ 1 inf limit 1.0 + 2.0 / int 1 inf limit ; PUBLIC magic-formula-calc $libdef magic-formula-calc : magic-formula[ d:target -- i:magic ] target @ growth magic-formula-calc ; PUBLIC magic-formula $libdef magic-formula $pubdef magic-number #351 "magic-formula" call : magic-formula2-calc[ i:test -- i:magic ] test @ 1 inf limit 2.0 + 3.0 / int 1 inf limit ; PUBLIC magic-formula2-calc $libdef magic-formula2-calc : magic-formula2[ d:target -- i:magic ] target @ growth magic-formula2-calc ; PUBLIC magic-formula2 $libdef magic-formula2 $pubdef magic-number2 #351 "magic-formula2" call : genkai[ ref:target str:value -- int:genkai ] value @ target @ growth 3 + <= if 1 else 0 then ; PUBLIC genkai $libdef genkai : gtype[ d:target s:powah -- i:count ] var special { RPSYSTEM "/Powers/" array_get_propdirs foreach var! dir1 pop RPSYSTEM "/Powers/" dir1 @ "/" strcat strcat array_get_propdirs foreach var! item pop { "Powers" dir1 @ powah @ "Growth" }rpinfo dup if item @ swap else pop then repeat repeat }dict special ! special @ powah @ [] "" " " subst case "1,2,3,4,5,6,7" smatch when target @ growth end "1,3,5,7" smatch when target @ magic-formula end "1,4,7" smatch when target @ magic-formula2 end default pop 1 end endcase ; PUBLIC gtype $libdef gtype : numactiveplayers[ d:room -- i:activeplayers ] 0 var! activeplayers room @ contents_array foreach var! target pop target @ player? not if continue then target @ awake? not if continue then target @ "~status" getprop "{ooc|afk|idl|bzy|dnd}" smatch if continue then target @ descrleastidle descridle 900 > if continue then activeplayers ++ repeat activeplayers @ ; PUBLIC numactiveplayers $libdef numactiveplayers : aplimit[ d:target -- i:limit ] ( 1.5 hours ) 90 ( +10 minutes per point of growth above 1 ) target @ growth -- 10 * + ( -5 minutes per each vote less than 7 days old ) target @ "/@rp/votes/" array_get_propvals array_count 5 * - ; PUBLIC aplimit $libdef aplimit : apgen[ d:target -- i:limit ] ( The number of active people in the room ) target @ location numactiveplayers ( minus 1 divided by 2, limited 0 to 10 ) 2 / 0 10 limit ; PUBLIC apgen $libdef apgen : physical "physical" getstat ; PUBLIC physical $libdef physical : mental "mental" getstat ; PUBLIC mental $libdef mental : spiritual "spiritual" getstat ; PUBLIC spiritual $libdef spiritual : social "social" getstat ; PUBLIC social $libdef social : essence "essence" getstat ; PUBLIC essence $libdef essence : health "health" getstat ; PUBLIC health $libdef health : defence "defence" getstat ; PUBLIC defence $libdef defence : resistance "resistance" getstat ; PUBLIC resistance $libdef resistance : resolve "resolve" getstat ; PUBLIC resolve $libdef resolve : size "size" getstat ; PUBLIC size $libdef size : init "initiative" getstat ; PUBLIC init $libdef init : initiative "initiative" getstat ; PUBLIC initiative $libdef initiative : speed "speed" getstat ; PUBLIC speed $libdef speed : resources "resources" getstat ; PUBLIC resources $libdef resources : mana "mana" getstat ; PUBLIC mana $libdef mana : soak "soak" getstat ; PUBLIC soak $libdef soak : primal "primal" getstat ; PUBLIC primal $libdef primal : mphysical "m/physical" getstat 0 inf limit ; PUBLIC mphysical $libdef mphysical : mmental "m/mental" getstat 0 inf limit ; PUBLIC mmental $libdef mmental : mspiritual "m/spiritual" getstat 0 inf limit ; PUBLIC mspiritual $libdef mspiritual : msocial "m/social" getstat 0 inf limit ; PUBLIC msocial $libdef msocial : msize "m/size" getstat ; PUBLIC msize $libdef msize : mresources "m/resources" getstat 0 inf limit ; PUBLIC mresources $libdef mresources : msoak ( soak + (armour * 3) ) var! target target @ physical target @ size + target @ "@/m/soak" getraw + target @ "!/m/soak" getinline + 0 inf limit ; PUBLIC msoak $libdef msoak : minit ( (physical + mental) ) var! target target @ physical target @ mental + target @ size - target @ "@/m/initiative" getraw + target @ "!/m/initiative" getinline + 1 inf limit ; PUBLIC minit $libdef minit : minitiative ( (physical + mental) ) var! target target @ physical target @ mental + target @ size - target @ "@/m/initiative" getraw + target @ "!/m/initiative" getinline + 1 inf limit ; PUBLIC minitiative $libdef minitiative : mresistance ( < (mental, spiritual) ) var! target target @ mental target @ spiritual over over < if pop else swap pop then target @ "@/m/resistance" getraw + target @ "!/m/resistance" getinline + 0 inf limit ; PUBLIC mresistance $libdef mresistance : mresolve ( < (mental, social) ) var! target target @ mental target @ social over over < if pop else swap pop then target @ "@/m/resolve" getraw + target @ "!/m/resolve" getinline + 0 inf limit ; PUBLIC mresolve $libdef mresolve : mdefence ( < (mental, social) - size ) var! target target @ mental target @ physical over over < if pop else swap pop then target @ size - target @ "@/m/defence" getraw + target @ "!/m/defence" getinline + 0 inf limit ; PUBLIC mdefence $libdef mdefence : mspeed ( (physical * 2) + size ) var! target target @ physical 2 * target @ size + target @ "@/m/speed" getraw + target @ "!/m/speed" getinline + 1 inf limit ; PUBLIC mspeed $libdef mspeed : messence ( social + spiritual + if(Strong Soul, growth + 1) ) var! target target @ social target @ spiritual + target @ "@/m/essence" getstat + target @ "!/m/essence" getinline + 2 inf limit ; PUBLIC messence $libdef messence : mhealth ( physical + mental + size + if(Vitality, growth + 1) ) var! target target @ physical target @ mental + target @ "@/m/health" getstat + target @ "!/m/health" getinline + 2 inf limit ; PUBLIC mhealth $libdef mhealth : mmana ( physical + mental + social + spiritual + if(True Spirit, growth - 1) ) var! target target @ physical target @ mental + target @ social + target @ spiritual + target @ "@/m/mana" getstat + target @ "!/m/mana" getinline + 2 inf limit ; PUBLIC mmana $libdef mmana : mprimal ( physical + mental + social + spiritual + if(True Spirit, growth - 1) ) var! target target @ physical target @ mental < if target @ physical else target @ mental then target @ social < if target @ mental else target @ social then target @ spiritual < if target @ social else target @ spiritual then target @ growth + target @ "@/m/primal" getstat + target @ "!/m/primal" getinline + 0 inf limit ; PUBLIC mprimal $libdef mprimal