@program $lib/rps 1 99999 d 1 i ( Pokemon RPsystem ) $include $lib/rp $include $lib/rps2 $include $lib/alynna $include $lib/pokedex $include $muf/cron $pubdef : $def INFORM "PokeRP" pretty tellme $def AVATAR #851 $def MAXVOTES me @ staff? if 256 else 3 then $def ATMAX? target @ "/@rp/xp" getprop toint 10000 >= $def PARANOIA? prog "?" flag? $def VERBOSE? "_prefs/verbose" getprop if 1 else 0 then $def dlev4 dup 100 >= if toint 4 rj else tofloat 1 fchop 4 rj then $def CONDVEC 250 $def puppy { $def kitty }cat var param var target var stat var value var dicestore var dicestore4 $libdef character? : character? ( d -- i ) dup player? swap dup "X" flag? swap dup "Z" flag? swap -3 rotate and swap "@rp/npc?" getstat or or ; PUBLIC character? : iam ( d -- s ) "pokemon" getstatstr ; PUBLIC iam $libdef iam $libdef human? : human? ( d -- i ) dup "pokemorph" getstat toint 0 = swap iam toint not or ; PUBLIC human? $libdef mon? : mon? ( d -- i ) dup "pokemorph" getstat toint 1 = swap iam toint and ; PUBLIC mon? $libdef morph? : morph? ( d -- i ) dup "pokemorph" getstat toint 2 = swap iam toint and ; PUBLIC morph? $libdef meta? : meta? ( d -- i ) dup "pokemorph" getstat toint 3 = swap iam toint and ; PUBLIC meta? $libdef mtype $def NUMMORPHS 4 : mtype ( i -- s ) { "Human" "Pokemon" "Pokemorph" "Metahuman" } array_make swap array_getitem ; : ansi_strcut ( s i -- s1 s2 ) swap dup strlen ( i s i ) swap dup ( i i s s ) 0 unparse_ansi 1 unparse_ansi 2 unparse_ansi 3 unparse_ansi strlen ( i i s i ) 3 pick swap - rot pop ( i s i ) rot ( s i i ) + ( s i ) strcut ; : ansi_strlen ( s -- i ) 0 unparse_ansi 1 unparse_ansi 2 unparse_ansi 3 unparse_ansi strlen ; : xpspent ( d -- i ) var target var xpspentf var stat var value target ! 0.0 xpspentf ! target @ character? if target @ "@rp/a/" array_get_propvals foreach value ! stat ! value @ 625.00 > if target @ "a/" stat @ strcat 625.00 setstat then repeat target @ "@rp/e/" array_get_propvals foreach value ! stat ! value @ 64.00 > if target @ "e/" stat @ strcat 64.00 setstat then repeat target @ "@rp/m/" array_get_propvals foreach value ! stat ! value @ 99.00 > if target @ "m/" stat @ strcat 99.00 setstat then repeat target @ "@rp/p/" array_get_propvals foreach value ! stat ! value @ character? not if target @ "p/" stat @ strcat 0 setstat then repeat target @ "@rp/q/" array_get_propvals foreach value ! stat ! value @ character? not if target @ "q/" stat @ strcat 0 setstat then repeat target @ "@rp/s/" array_get_propvals foreach value ! stat ! value @ 256.00 > if target @ "s/" stat @ strcat 256.00 setstat then repeat target @ "@rp/t/" array_get_propvals foreach value ! stat ! value @ 100.00 > if target @ "t/" stat @ strcat 100.00 setstat then repeat target @ "@rp/t/" array_get_propvals foreach value ! stat ! value @ -100.0 < if target @ "t/" stat @ strcat -100.0 setstat then repeat then target @ "@rp/a/" array_get_propvals foreach value ! stat ! value @ xpspentf @ + xpspentf ! repeat target @ "@rp/e/" array_get_propvals foreach value ! stat ! value @ xpspentf @ + xpspentf ! repeat target @ "@rp/i/" array_get_propvals foreach value ! stat ! value @ xpspentf @ + xpspentf ! repeat target @ "xpspent" xpspentf @ setstat xpspentf @ ; PUBLIC xpspent $libdef xpspent : nd6 ( i/f -- i ) var temp var neg dup 0 < if 1 neg ! else 0 neg ! then dup float? if int then abs temp ! temp @ not if 0 exit then 0 begin temp @ while random 6 % 1 + + temp @ 1 - temp ! repeat neg @ if 0 swap - then ; PUBLIC nd6 $libdef nd6 : nd4 ( i/f -- i ) var temp var neg dup 0 < if 1 neg ! else 0 neg ! then dup float? if int then abs temp ! temp @ not if 0 exit then 0 begin temp @ while random 4 % 1 + + temp @ 1 - temp ! repeat neg @ if 0 swap - then ; PUBLIC nd4 $libdef nd4 : successlevel ( i/f -- s ) toint dup 5 <= if pop "Unskilled" exit then dup 10 <= if pop "Barely touched" exit then dup 15 <= if pop "Glancing" exit then dup 25 <= if pop "Beginner" exit then dup 35 <= if pop "Novice" exit then dup 45 <= if pop "Average" exit then dup 60 <= if pop "Notable" exit then dup 80 <= if pop "Above-average" exit then dup 100 <= if pop "Skilled" exit then dup 150 <= if pop "Gifted" exit then dup 200 <= if pop "Reknown" exit then dup 300 <= if pop "Heroic" exit then dup 450 <= if pop "Master" exit then dup 700 <= if pop "Legendary" exit then dup 1000 <= if pop "Unbelievable" exit then dup 1500 <= if pop "Ultimate" exit then 2000 > if pop "Godlike (Please contact staff)" exit then ; PUBLIC successlevel $libdef successlevel $libdef fmt76 : fmt76 ( s -- s ) "|" swap strcat " " dup strcat dup strcat dup strcat strcat 77 ansi_strcut pop "|" strcat ; PUBLIC fmt76 $libdef fmt76 : level ( i/f -- f ) var technic tofloat technic ! technic @ 0 >= if technic @ sqrt else 0 technic @ fabs sqrt - then ; PUBLIC level $libdef level : level2xp ( i/f -- f ) var technic tofloat technic ! (L 1) (technic @ 1.0 < if 1.0 exit then) technic @ 0 >= if technic @ dup * else 0 technic @ fabs dup * - then ; PUBLIC level2xp $libdef level2xp : maxhp ( d -- i ) var target target ! target @ "xp" getstatint level target @ "s/Max-HP" getstatint level + toint 8 * target @ "t/Max-HP" getstatint + target @ exit? target @ "@rp/npc?" getprop not and if pop 250 then target @ room? target @ "@rp/npc?" getprop not and if pop 999 then target @ program? target @ "@rp/npc?" getprop not and if pop 999 then target @ thing? target @ character? not and if pop 500 then ; PUBLIC maxhp $libdef maxhp : isfainted? ( d -- i ) var target target ! target @ "hp" getstatint 0 <= if target @ "hp" 0 setstat target @ exit? target @ "@rp/npc?" getprop not and if target @ "hp" target @ maxhp setstat { target @ " has fainted!!!" }cat "PokeBattle" pretty tellhere then target @ room? target @ "@rp/npc?" getprop not and if target @ "hp" target @ maxhp setstat { target @ " has fainted!!!" }cat "PokeBattle" pretty tellhere then target @ program? target @ "@rp/npc?" getprop not and if target @ "hp" target @ maxhp setstat { target @ " has fainted!!!" }cat "PokeBattle" pretty tellhere then target @ thing? target @ character? not and if target @ "hp" target @ maxhp setstat { target @ " has fainted!!!" }cat "PokeBattle" pretty tellhere then target @ "status" 9 setstat 1 exit then 0 ; PUBLIC isfainted? $libdef isfainted? : adjusthp ( d i -- ) var target var amount amount ! target ! target @ "hp" over over getstat amount @ + 0 target @ maxhp limit setstat target @ isfainted? pop ; PUBLIC adjusthp $libdef adjusthp : attackok? ( d s -- i ) var target var tlev var ttype var item item ! target ! target @ "xp" getstatint level tlev ! target @ "pokemorph" getstatint ttype ! ttype @ case 0 = when item @ "/attacks/mExcept/Human" getdex "{" swap "}" strcat strcat smatch if 1 exit then end 1 = when item @ "/attacks/mExcept/Pokemon" getdex "{" swap "}" strcat strcat smatch if 1 exit then end 2 = when item @ "/attacks/mExcept/Pokemorph" getdex "{" swap "}" strcat strcat smatch if 1 exit then end 3 = when item @ "/attacks/mExcept/Metahuman" getdex "{" swap "}" strcat strcat smatch if 1 exit then end endcase { "/pokemon/" target @ iam "/attacks/" item @ }cat getdex if tlev @ { "/pokemon/" target @ iam "/attacks/" item @ }cat getdex toint >= if 1 else 0 then else 0 then ; PUBLIC attackok? $libdef attackok? : tmhmok? ( d s -- i ) var target var item var ttype item ! target ! { "/pokemon/" target @ iam "/tmhm" }cat getdex if item @ { "{" "/pokemon/" target @ iam "/tmhm" item @ }cat getdex "|" ":" subst "}" smatch if 1 else 0 then else 0 then ; PUBLIC tmhmok? $libdef tmhmok? : itemok? ( s -- i ) var target var item var ttype item ! { "/pokemon/" item @ "/desc" }cat getdex if 1 else 0 then ; PUBLIC itemok? $libdef itemok? : cost ( d s -- f ) getstatfloat level toint dup 100 = if 0 else 2.0 swap 1.0 + pow then ; PUBLIC cost $libdef cost : init param @ "RESET" strcmp not if AVATAR { "@set *" me @ "=@rp:" }cat force AVATAR { "wc " me @ " reset their sheet using " command @ " " param @ "!" }cat force "Thy sheet hath been cleared." INFORM me @ "xp" 100 setstat me @ "hp" 33 setstat me @ "yen" 100 setstat me @ "votes" 25 setstat "At chargen: 25 votes, 100xp, 100 yen, 30hp to start, you may start buying specials with +buy." INFORM else { "To reset your sheet, use " command @ " RESET" }cat INFORM then ; : init-partial param @ "RESET" strcmp not if AVATAR { "@set *" me @ "=@rp/a:" }cat force AVATAR { "@set *" me @ "=@rp/e:" }cat force AVATAR { "@set *" me @ "=@rp/m:" }cat force me @ "valid?" 0 setstat else { "To wipe yer skills, use " command @ " RESET" }cat INFORM then ; : rpset me @ "W" flag? if param @ "=" explode pop dup match dup ok? not if pop resolve dup character? not if pop "Invalid target" "RPset" pretty tellme exit then else swap pop then target ! stat ! value ! command @ "+rp" stringcmp not if target @ stat @ value @ toint dup value ! setstat then command @ "+rpi" stringcmp not if target @ stat @ value @ toint dup value ! setstat then command @ "+rps" stringcmp not if target @ stat @ value @ tostr dup value ! setstat then command @ "+rpf" stringcmp not if target @ stat @ value @ tofloat dup value ! setstat then command @ "+rpd" stringcmp not if target @ stat @ value @ todbref dup value ! setstat then command @ "+rpo" stringcmp not if target @ stat @ value @ todbref dup value ! setstat then { "[rpset] " me @ " set RP stat [" stat @ "] on " target @ " to: " value @ }cat dup tellme prog swap prog "/logs" getpropval 1 + dup prog swap "/logs" swap setprop intostr "/logs/" swap strcat swap setprop else "Must be a W to use." "RPset" pretty tellme AVATAR { "wc " me @ " tried to +rpset without a W bit!" }cat force then ; : qtystr dup -1 = if pop "PERM" exit then tostr ; : sheet var pokemon var target2 debug_off param @ "" stringcmp not if me @ target ! else param @ pmatch target ! then target @ #-1 dbcmp if param @ match target ! target @ #-1 dbcmp if { "Target " param @ " not found." }cat "Pokedex" pretty tellme exit then then target @ #-2 dbcmp if { "Target " param @ " matched more than once, be more specific." }cat "Pokedex" pretty tellme exit then target @ "pokemon" getstat pokemon ! { "Pokedex scan of " target @ name }cat header tellme target @ xpspent pop pokemon @ if { " Pokemon:[^GREEN^" { "pokemon/" pokemon @ "/name" }cat getdex 14 lj "^NORMAL^] " " Type:[^CYAN^" { "pokemon/" pokemon @ "/type" }cat getdex 14 lj "^NORMAL^] " " Morphology:[^CYAN^" target @ "pokemorph" getstat mtype 9 lj "^NORMAL^] " }cat fmt76 tellme then { " HP:[^GREEN^" target @ "hp" getstatint tostr 3 rj "/" target @ maxhp tostr 3 rj "^NORMAL^] " "XP:[^CYAN^" target @ "xp" getstatfloat 2 fchop 8 rj "^NORMAL^] " "XP Free:[^CYAN^" target @ "xp" getstatfloat target @ "xpspent" getstatfloat - 2 fchop 8 rj "^NORMAL^] " "Y:[$^YELLOW^" target @ "yen" getstatfloat 2 fchop 12 rj "^NORMAL^] " "Valid:[^GRAY^" target @ "validated?" getstatint if "Yes" else "No " then "^NORMAL^]" }cat fmt76 tellme { " Votes:[^GREEN^" target @ "votes" getstatint tostr 2 rj "/25^NORMAL^] " "VoteQ:[^CYAN^" target @ "voteq" getstatint tostr 2 rj "^NORMAL^] " "Lv:[^CYAN^" target @ "xp" getstatint level 2 fchop 7 rj "^NORMAL^] " "Gym:[" target @ "gymleader" getstat dup if "^YELLOW^" swap else pop target @ "gym" getstat dup if "^GRAY^" swap else pop "None" then then 9 lj "^NORMAL^] " "Stat:[^YELLOW^" { "status/" target @ "status" getstatint }cat getdex tostr 9 rj "^NORMAL^]" }cat fmt76 tellme pokemon @ if { " " "^RED^Cool ^CYAN^[^WHITE^" target @ "c/Cool" getstat tostr 1 lj "^CYAN^] " "^BLUE^Beauty ^CYAN^[^WHITE^" target @ "c/Beauty" getstat tostr 1 lj "^CYAN^] " "^PURPLE^Cute ^CYAN^[^WHITE^" target @ "c/Cute" getstat tostr 1 lj "^CYAN^] " "^GREEN^Smart ^CYAN^[^WHITE^" target @ "c/Smart" getstat tostr 1 lj "^CYAN^] " "^YELLOW^Tough ^CYAN^[^WHITE^" target @ "c/Tough" getstat tostr 1 lj "^CYAN^]^NORMAL^" }cat fmt76 tellme then ( Stats ) target @ "@rp/s/" nextprop "" stringcmp target @ "@rp/t/" nextprop "" stringcmp or if "Stat modifiers" header tellme "|^UNDERLINE^Stat |T| SP |Lev.^NORMAL^| |^UNDERLINE^Stat |T| SP |Lev.^NORMAL^|" tellme { target @ "@rp/s/" array_get_propvals foreach value ! stat ! { "|" stat @ dup "/" rinstr strcut swap pop 24 lj (ability) "| " "|" value @ toint tostr 4 rj (XP in that pool) "|" value @ toint level toint intostr 4 rj "|" (current level) }cat over string? not if " " strcat else strcat tellme then repeat target @ "@rp/t/" array_get_propvals foreach value ! stat ! { "|" stat @ dup "/" rinstr strcut swap pop 24 lj (ability) "|*" "|" value @ toint tostr 4 rj (XP in that pool) "|" value @ toint level toint intostr 4 rj "|" (current level) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( abilities ) target @ "@rp/a/" nextprop "" stringcmp if "Attacks / Knowledges" header tellme "|^UNDERLINE^Ability |PP| XP |Next|Lev.^NORMAL^| |^UNDERLINE^Ability |PP| XP |Next|Lev.^NORMAL^|" tellme #-2 target @ "@rp/a/" array_get_propvals foreach value ! stat ! { "|" stat @ capitalize dup "/" rinstr strcut swap pop 18 lj (ability) "|" target @ { "a/" stat @ "/pp" }cat getstatint tostr 2 rj (XP in that pool) "|" value @ toint tostr 4 rj (XP in that pool) "|" value @ level int 1 + level2xp value @ - toint intostr 4 rj (XP to next level) "|" value @ toint level dlev4 "|" (current level) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Equipment ) target @ "@rp/e/" nextprop "" stringcmp if "Equipment" header tellme "|^UNDERLINE^Equipment | XP |Lev.^NORMAL^| |^UNDERLINE^Equipment | XP |Lev.|^NORMAL^" tellme #-2 target @ "@rp/e/" array_get_propvals foreach value ! stat ! { "|" stat @ capitalize dup "/" rinstr strcut swap pop 26 lj (ability) "|" value @ toint tostr 4 rj (XP in that pool) "|" value @ toint level dlev4 "|" (current level) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Training ) target @ "@rp/i/" nextprop "" stringcmp if "Training" header tellme "|^UNDERLINE^Pokemon | XP |Lev.^NORMAL^| |^UNDERLINE^Pokemon | XP |Lev.^NORMAL^|" tellme #-2 target @ "@rp/i/" array_get_propvals foreach value ! stat ! { "|" stat @ capitalize dup "/" rinstr strcut swap pop 26 lj (ability) "|" value @ toint tostr 4 rj (XP in that pool) "|" value @ toint level dlev4 "|" (current level) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Pokemon ) target @ "@rp/p/" nextprop "" stringcmp if "Pokemon" header tellme "|^UNDERLINE^Name |Species |Lev.^NORMAL^| |^UNDERLINE^Name |Species |Lev.^NORMAL^|" tellme #-2 target @ "@rp/p/" array_get_propvals foreach value ! stat ! { "|" stat @ dup "/" rinstr strcut swap pop 18 lj (Pokemon name) "|" { "/pokemon/" value @ iam "/name" }cat getdex 12 lj (Pokemon species) "|" value @ "xp" getstatint level dlev4 "|" (Pokemon level) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Trainers ) target @ "@rp/q/" nextprop "" stringcmp if "Trainers" header tellme "|^UNDERLINE^Name |Inv.|Species |Lv^NORMAL^| |^UNDERLINE^Name |Inv.|Species |Lv^NORMAL^|" tellme #-2 target @ "@rp/q/" array_get_propvals foreach value ! stat ! { "|" stat @ dup "/" rinstr strcut swap pop 17 lj (Pokemon name) "|" value @ { "i/" target @ name }cat getstat toint intostr 4 rj (Pokemon investment) "|" { "/pokemon/" value @ iam "/name" }cat getdex 10 lj (Pokemon species) "|" value @ "xp" getstatint level int intostr 2 rj "|" (Pokemon level) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Badges ) target @ "@rp/b/" nextprop "" stringcmp if "Badges" header tellme "|^UNDERLINE^Badge |Type ^NORMAL^| |^UNDERLINE^Name |Type ^NORMAL^|" tellme #-2 target @ "@rp/b/" array_get_propvals foreach value ! stat ! { "|" stat @ capitalize dup "/" rinstr strcut swap pop 22 lj (Badge name) "|" value @ capitalize 13 lj "|" (Badge type) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Materials ) target @ "@rp/m/" nextprop "" stringcmp if "Items" header tellme "|^UNDERLINE^Materials |Qty.^NORMAL^| |^UNDERLINE^Materials |Qty.^NORMAL^|" tellme #-2 target @ "@rp/m/" array_get_propvals foreach value ! stat ! { "|" stat @ capitalize dup "/" rinstr strcut swap pop 31 lj (ability) "|" value @ qtystr 4 rj "|" (XP in that pool) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then ( Key items ) target @ "@rp/k/" nextprop "" stringcmp if "Key items" header tellme "|^UNDERLINE^Key item |Type ^NORMAL^| |^UNDERLINE^Key item |Type ^NORMAL^|" tellme #-2 target @ "@rp/k/" array_get_propvals foreach value ! stat ! { "|" stat @ capitalize dup "/" rinstr strcut swap pop 23 lj (ability) "|" value @ capitalize 12 lj "|" (XP in that pool) }cat over string? not if " " strcat else strcat tellme then repeat dup string? if " |" strcat tellme then pop then { "Pokedex" }cat footer tellme ; : xpshow var pokemon param @ "" stringcmp not if me @ target ! else param @ pmatch target ! then target @ #-1 dbcmp if param @ match target ! target @ #-1 dbcmp if { "Target " param @ " not found." }cat "Pokedex" pretty tellme exit then then target @ #-2 dbcmp if { "Target " param @ " matched more than once, be more specific." }cat "Minidex" pretty tellme exit then target @ xpspent pop target @ "pokemon" getstat pokemon ! { "Pokedex summary for " me @ }cat header tellme pokemon @ if { " Pokemon:[^GREEN^" { "pokemon/" pokemon @ "/name" }cat getdex 14 lj "^NORMAL^] " " Type:[^CYAN^" { "pokemon/" pokemon @ "/type" }cat getdex 14 lj "^NORMAL^] " " Morphology:[^CYAN^" target @ "pokemorph" getstat mtype 9 lj "^NORMAL^] " }cat fmt76 tellme then { " HP:[^GREEN^" target @ "hp" getstatint tostr 3 rj "/" target @ maxhp tostr 3 rj "^NORMAL^] " "XP:[^CYAN^" target @ "xp" getstatfloat 2 fchop 8 rj "^NORMAL^] " "XP Free:[^CYAN^" target @ "xp" getstatfloat target @ "xpspent" getstatfloat - 2 fchop 8 rj "^NORMAL^] " "Y:[$^YELLOW^" target @ "yen" getstatfloat 2 fchop 12 rj "^NORMAL^] " "Valid:[^GRAY^" target @ "validated?" getstatint if "Yes" else "No " then "^NORMAL^]" }cat fmt76 tellme { " Votes:[^GREEN^" target @ "votes" getstatint tostr 2 rj "/25^NORMAL^] " "VoteQ:[^CYAN^" target @ "voteq" getstatint tostr 2 rj "^NORMAL^] " "Lv:[^CYAN^" target @ "xp" getstatint level 2 fchop 7 rj "^NORMAL^] " "Gym:[" target @ "gymleader" getstat dup if "^YELLOW^" swap else pop target @ "gym" getstat dup if "^GRAY^" swap else pop "None" then then 9 lj "^NORMAL^] " "Stat:[^YELLOW^" { "status/" target @ "status" getstatint }cat getdex tostr 9 rj "^NORMAL^]" }cat fmt76 tellme { " Sheet last validated by [^GREEN^" target @ "validatedby" getstat "^NORMAL^] on [^CYAN^" target @ "validatedat" getstatint "%X %x" swap timefmt "^NORMAL^] " }cat fmt76 tellme "Pokedex" footer tellme ; : buy var spent var total var unspent var xp command @ "+buy" stringcmp not if me @ "validated?" getstatint if "You can only +buy skills like this while unvalidated. Please use +train." "Buy" pretty tellme exit else param @ "=" explode 2 = not if "+buy =" "Buy" pretty tellme exit else stat ! tofloat value ! me @ stat @ attackok? not me @ { "a/" stat @ }cat getstatint not and if "This attack is not yet available to you." "Buy" pretty tellme exit then me @ "xp" getstatfloat total ! me @ "xpspent" getstatfloat spent ! total @ spent @ - unspent ! me @ "a/" stat @ strcat getstatfloat xp ! ( value @ unspent @ > if { "You dont have enough XP to put in that pool. Value:[" value @ "] Unspent:[" unspent @ "] Needed:[" value @ unspent @ - "]" }cat "Buy" pretty tellme exit then value @ 0 xp @ - < if { "You dont have enough XP in that pool to take out. Value:[" value @ "] In pool:[" xp @ "] Over by:[" 0 xp @ - value @ - "]" }cat "Buy" pretty tellme exit then ) me @ "a/" stat @ strcat xp @ value @ + setstat me @ xpspent pop me @ "xpspent" getstatfloat spent ! me @ "a/" stat @ strcat getstatfloat xp ! total @ spent @ - unspent ! { stat @ " was adjusted by " value @ 2 fchop "xp. Current:[" xp @ 2 fchop "] Level:[" xp @ level 2 fchop "] XP left:[" unspent @ 2 fchop "]" }cat "Buy" pretty tellme then then then command @ "+buyequip" stringcmp not if param @ "=" explode 2 = not if "+buyequip =" "Buy" pretty tellme exit else stat ! toint value ! me @ { "e/" stat @ }cat getstatint not if "You must equip an item before you can improve upon it." "BuyEquip" pretty tellme exit then me @ "xp" getstatfloat total ! me @ "xpspent" getstatfloat spent ! total @ spent @ - unspent ! me @ "e/" stat @ strcat getstatfloat xp ! value @ unspent @ > if { "You dont have enough XP to put into that equipment. Value:[" value @ 2 fchop "] Unspent:[" unspent @ 2 fchop "] Needed:[" value @ unspent @ - 2 fchop "]" }cat "BuyEquip" pretty tellme exit then value @ 0 xp @ - < if { "You dont have enough XP in that equipment to take out. Value:[" value @ 2 fchop "] In pool:[" xp @ 2 fchop "] Over by:[" 0 xp @ - value @ - 2 fchop "]" }cat "BuyEquip" pretty tellme exit then me @ "e/" stat @ strcat xp @ value @ + setstat me @ xpspent pop me @ "xpspent" getstatfloat spent ! me @ "e/" stat @ strcat getstatfloat xp ! total @ spent @ - unspent ! { stat @ " was adjusted by " value @ 2 fchop "xp. Current:[" xp @ 2 fchop "] Level:[" xp @ level 2 fchop "] XP left:[" unspent @ 2 fchop "]" }cat "BuyEquip" pretty tellme then then ; : train var spent var total var unspent var xp me @ "validated?" getstatint not if "You can only +learn skills while validated. Please use +buy." "Learn" pretty tellme exit else param @ "=" explode 2 = not if "+learn =" "Learn" pretty tellme exit else stat ! tofloat value ! me @ stat @ attackok? not me @ { "a/" stat @ }cat getstatint not and if "This attack is not yet available to you." "Buy" pretty tellme exit then me @ "xp" getstatfloat total ! me @ "xpspent" getstatfloat spent ! total @ spent @ - unspent ! me @ "a/" stat @ strcat getstatfloat xp ! value @ unspent @ > if { "You dont have enough XP to put in that pool. Value:[" value @ 2 fchop "] Unspent:[" unspent @ 2 fchop "] Needed:[" value @ unspent @ - 2 fchop "]" }cat "Learn" pretty tellme exit then value @ 0 < if { "You cannot take XP out of a pool while validated. Value:[" value @ 2 fchop "]" }cat "Learn" pretty tellme exit then me @ "a/" stat @ strcat xp @ value @ + setstat me @ xpspent pop me @ "xpspent" getstatfloat spent ! me @ "a/" stat @ strcat getstatfloat xp ! total @ spent @ - unspent ! { stat @ " was increased by " value @ 2 fchop "xp. Current:[" xp @ 2 fchop "] Level:[" xp @ level 2 fchop "] XP left:[" unspent @ 2 fchop "]" }cat "Learned" pretty tellme then then ; : poketrain var tmp me @ mon? if "Pokemon cannot train anyone else." "PokeTrain" pretty tellme exit then param @ "=" explode 2 = not if "+pokemon/train =" "Poketrain" pretty tellme exit else target ! tofloat value ! target @ resolve target ! target @ int 0 < if { "Unknown or ambiguous target." }cat "Poketrain" pretty tellme exit then value @ 0 < if "You cannot take XP from your pokemon." "Poketrain" pretty tellme exit then me @ { "p/" target @ name }cat getstat not if "You must 0wn the pokemon you want to train." "PokeTrain" pretty tellme exit then me @ "xp" getstatfloat me @ "xpspent" getstatfloat value @ + > if me @ "xpspent" getstatfloat value @ + me @ "xpspent" rot setstat me @ "i/" target @ name strcat getstatfloat value @ + me @ "i/" target @ name strcat rot setstat target @ "xp" getstatfloat value @ + target @ swap "xp" swap setstat { me @ " trains " target @ " for " value @ 2 fchop " XP." }cat "Poketrain" pretty tellhere { me @ " trains " target @ " for " value @ 2 fchop " XP." }cat "Poketrain" pretty target @ swap ansi_notify else { "You dont have enough XP! Value:[" value @ "]." }cat "$" pretty tellme then then ; : spend var tmp command @ "+pay" stringcmp not if param @ "=" explode 2 = not if "+pay =" "$" pretty tellme exit else target ! tofloat value ! target @ resolve target ! target @ int 0 < if { "Unknown or ambiguous target." }cat "$" pretty tellme exit then value @ 0 < if "You cannot give someone negative yen." "$" pretty tellme exit then me @ target @ alt? if { "You cannot give money to your alt [" target @ "]! You lost the $" value @ 2 fchop " in the attempt and staff has been notified." }cat "Pay" pretty tellme paranoia? if AVATAR { "wc #CHEATER/PAYALT: " me @ unparseobj " -> " target @ unparseobj ": (" value @ 6 fchop ") - The yen was confiscated." }cat force then exit then me @ owner target @ dbcmp me @ target @ dbcmp not and if { "You cant take your puppet's money, cheater. [" target @ "]! You lost the $" value @ 2 fchop " in the attempt and staff has been notified." }cat "Pay" pretty target @ swap ansi_notify me @ "yen" over over getstat value @ - setstat paranoia? if AVATAR { "wc #CHEATER/GETPUPPETMONEY: " me @ unparseobj " -> " target @ unparseobj ": (" value @ 6 fchop ") - The yen was confiscated." }cat force then exit then target @ #-2 dbcmp if { "Target " param @ " matched more than once, be more specific." }cat "$" pretty tellme exit then me @ "yen" getstatfloat value @ >= if me @ "yen" getstatfloat value @ - me @ swap "yen" swap setstat target @ "yen" getstatfloat value @ + target @ swap "yen" swap setstat { me @ " gives $" value @ 2 fchop " to " target @ "." }cat "$" pretty tellhere { me @ " gives $" value @ 2 fchop " to " target @ "." }cat "$" pretty target @ swap ansi_notify else { "You dont have enough yen! Value:[" value @ "]." }cat "$" pretty tellme then then then command @ "+give" stringcmp not if param @ "=" explode 2 = if pop pop param @ "=1" strcat param ! then param @ "=" explode 3 = not if "+give =[=]" "Give" pretty tellme exit else target ! stat ! toint value ! target @ resolve target ! target @ int 0 < if { "Unknown or ambiguous target." }cat "Give" pretty tellme exit then value @ 0 < if "You cannot give someone a negative amount of an item." "Give" pretty tellme exit then me @ target @ alt? if { "You cannot give items your alt " target @ ", cheater. You lost the " stat @ " in the attempt and staff has been notified." }cat "Pay" pretty tellme me @ "m/" stat @ strcat over over getstat value @ - setstat paranoia? if AVATAR { "wc #CHEATER/GIVEALT: " me @ unparseobj " -> " target @ unparseobj ": (" stat @ "/" value @ ") - The items were confiscated." }cat force then exit then me @ owner target @ dbcmp me @ target @ dbcmp not and if { "You cant take your puppet's items, cheater. [" target @ "]! You lost the $" value @ 2 fchop " in the attempt and staff has been notified." }cat "Pay" pretty target @ swap ansi_notify me @ "m/" stat @ strcat over over getstat value @ - setstat paranoia? if AVATAR { "wc #CHEATER/GETPUPPETITEMS: " me @ unparseobj " -> " target @ unparseobj ": (" stat @ "/" value @ ") - The items were confiscated." }cat force then exit then me @ "m/" stat @ strcat getstatint value @ >= if me @ "m/" stat @ strcat getstatint value @ - me @ swap "m/" stat @ strcat swap setstat target @ "m/" stat @ strcat getstatint value @ + target @ swap "m/" stat @ strcat swap setstat { me @ " gives " value @ " " stat @ "(s) to " target @ "." }cat "Give" pretty tellhere else { "You dont have enough " stat @ " to give! Value:[" value @ "]." }cat "Give" pretty tellme then then then command @ "+use" stringcmp not if param @ not if "+use [=]" "Use" pretty tellme exit then param @ "=" explode tmp ! tmp @ 1 = if stat ! me @ target ! then tmp @ 2 = if stat ! target ! target @ resolve target ! target @ int 0 < if { "Unknown or ambiguous target." }cat "Use" pretty tellme exit then then me @ target @ alt? if { "You cannot use items on your alt " target @ ", cheater. The item " stat @ " had no effect,and staff has been notified." }cat "Pay" pretty tellme me @ "m/" stat @ strcat over over getstat 1 - setstat paranoia? if AVATAR { "wc #CHEATER/USEALT: " me @ unparseobj " -> " target @ unparseobj ": (" stat @ ") - The item had no effect." }cat force then exit then me @ owner target @ dbcmp me @ target @ dbcmp not and if { "Your puppets cant use items on you, cheater. [" target @ "]! The item " stat @ " had no effect and staff has been notified." }cat "Pay" pretty target @ swap ansi_notify me @ "m/" stat @ strcat over over getstat 1 - setstat paranoia? if AVATAR { "wc #CHEATER/USEPUPPETITEMS: " me @ unparseobj " -> " target @ unparseobj ": (" stat @ ") - The item had no effect." }cat force then exit then me @ "m/" stat @ strcat getstatint dup 1 >= swap -1 = or if me @ "m/" stat @ strcat getstatint dup -1 = not if target @ stat @ itemhandler - me @ swap "m/" stat @ strcat swap setstat then { target @ me @ dbcmp if me @ " uses an item: [^CYAN^" stat @ "^NORMAL^]." }cat "Use" pretty tellhere else me @ " uses an item: [^CYAN^" stat @ "^NORMAL^] on [" target @ "]." }cat "Use" pretty tellhere then else { "You dont have any ^CYAN^" stat @ "^NORMAL^ to use!" }cat "Use" pretty tellme then then command @ "+spendhp" stringcmp not if param @ "=" explode 1 = not if "+spendhp " "HP" pretty tellme exit else toint value ! value @ 0 < if me @ "hp" getstatint value @ - me @ swap "hp" swap setstat { me @ " has healed themselves. Value:[" value @ "] HP:[" me @ "hp" getstatint "]" }cat "Heal" pretty tellhere AVATAR { "wc " me @ " has healed themselves. Value:[" value @ "] HP:[" me @ "hp" getstatint "]" }cat force then me @ "hp" getstatint value @ >= if me @ "hp" getstatint value @ - me @ swap "hp" swap setstat { me @ " adjustes their Health Points by [" value @ "]." }cat "SpendHP" pretty tellhere else me @ "hp" getstatint value @ - me @ swap "hp" swap setstat { me @ " has adjusted their HP below zero, and is in KO status. Value:[" value @ "] HP:[" me @ "hp" getstatint "]" }cat "SpendHP" pretty tellhere AVATAR { "wc " me @ " has adjusted their HP below zero, and is in KO status. Value:[" value @ "] HP:[" me @ "hp" getstatint "]" }cat force then then then ; : validate param @ "" stringcmp not if "me" target ! else param @ target ! then target @ resolve target ! target @ int 0 < if { "Unknown or ambiguous target." }cat "Validate" pretty tellme exit then target @ player? me @ staff? not and if "Only staff may validate players." "Validate" pretty tellme exit then target @ thing? if me @ staff? not if me @ target @ controls not if "You can only validate your own puppets." "Validate" pretty tellme exit then then then command @ "+validate" stringcmp not if target @ "validated?" 1 setstat target @ "validatedby" me @ setstat target @ "validatedat" systime setstat target @ { me @ " has validated your sheet. RP on!" }cat "RPStaff" pretty ansi_notify AVATAR { "wc " me @ " has validated " target @ "'s sheet." }cat force { "You have validated " target @ "'s sheet." }cat INFORM then command @ "+invalidate" stringcmp not if target @ "validated?" 0 setstat AVATAR { "wc " me @ " has invalidated " target @ "'s sheet." }cat force { "You have unvalidated " target @ "'s sheet." }cat INFORM then ; : voteadj ( d f -- f ) var target var votes var adj votes ! target ! me @ player? if 1.0 target @ "voteq" getstat tofloat 1 10 limit / adj ! else 0.75 then votes @ adj @ * ; : vote var temp var newvalue me @ "G" flag? if { "Guests cant vote." }cat "Vote" pretty tellme then command @ "+vote" stringcmp not if param @ "=" explode temp ! temp @ 0 <= temp @ 3 > or if "+vote =<0..3>" "vote" pretty tellme exit else temp @ 1 = if match target ! 1.0 value ! ( Moeru changed pmatch to match... ) else match target ! tofloat value ! ( and probably broke it ) then target @ #-1 dbcmp if param @ match target ! target @ #-1 dbcmp if { "Target " param @ " not found." }cat "Pokedex" pretty tellme exit then then target @ #-2 dbcmp if { "Target " param @ " matched more than once, be more specific." }cat "Vote" pretty tellme exit then me @ target @ alt? if { "You cannot vote for your alt [" target @ "]! You lost " value @ 6 fchop "xp for trying, and staff has been notified." }cat "Vote" pretty tellme me @ "xp" over over getstat value @ - setstat paranoia? if AVATAR { "wc #CHEATER/VOTEALT: " me @ unparseobj " -> " target @ unparseobj ": (" value @ 6 fchop ") - XP was deducted." }cat force then exit then me @ owner target @ dbcmp me @ target @ dbcmp not and if { "Your puppet [" me @ "] cant vote for you [" target @ "], cheater. You (not your puppet) lost " value @ 6 fchop "xp for trying, and staff has been notified." }cat "Vote" pretty target @ swap ansi_notify target @ "xp" over over getstat value @ - setstat paranoia? if AVATAR { "wc #CHEATER/PUPPETVOTEOWNER: " me @ unparseobj " -> " target @ unparseobj ": (" value @ 6 fchop ") - XP was deducted." }cat force then exit then me @ "@rp/votedfor" target @ reflist_find if { "You can only vote for someone once every WorldHeart tick. Sorry." "Vote" pretty tellme ( paranoia? if AVATAR { "wc #CHEATER/VOTEBLITZ: " me @ unparseobj " -> " target @ unparseobj ": (" value @ ")" }cat force then ) exit then atmax? if "That person is already at max XP!" "Vote" pretty tellme exit then (Added for 10000XP cap) target @ me @ dbcmp if { "You cannot vote for yourself, foo!" }cat "Vote" pretty tellme exit then target @ owner me @ dbcmp if { "You cannot vote for your puppet, foo!" }cat "Vote" pretty tellme exit then ( puppet exception added by Moeru ) value @ 0 <= if me @ "W" flag? not if 1.0 value ! then then value @ MAXVOTES > if MAXVOTES value ! then me @ staff? me @ "votes" getstatfloat value @ >= or if me @ staff? not if me @ "votes" getstatfloat value @ - me @ "votes" rot setstat then value @ 3.0 > value @ 0.0 < or if paranoia? if AVATAR { "wc #WIZ/SpecialVote: " me @ unparseobj " -> " target @ unparseobj ": (" value @ ")" }cat force then then target @ value @ voteadj newvalue ! target @ owner "xp" getstatfloat newvalue @ + target @ owner "xp" rot setstat me @ player? if target @ "voteq" over over getstat ++ 1 10 limit setstat then target @ "lastvote" systime setstat { "You vote for " target @ owner " with " value @ 1 = if value @ 2 fchop " vote" else value @ 2 fchop " votes" then "." }cat "Vote" pretty tellme target @ owner { "You gained " newvalue @ 2 fchop "xp from " value @ 2 fchop " vote(s) by " me @ "." }cat "Vote" pretty ansi_notify me @ "@rp/votedfor" target @ reflist_add target @ owner levelhandler pop (BEGIN VOID ADDITION) value @ 1.0 = not if AVATAR { "wc #Player/MultiVote: " me @ " -> " target @ ": (" value @ ")" }cat force then (VOID ADDITION <- Notification of votes higher than 1) else { "You dont have enough votes! Target:[" target @ "] Value:[" value @ "]." }cat "Vote" pretty tellme then then then command @ "+voteall" stringcmp not if (BEGIN VOID ADDITION) AVATAR { "wc #" me @ name " has just used +voteall at " loc @ name }cat force (Void added notification - END ADDITION) me @ location contents_array foreach target ! pop target @ character? if target @ awake? if target @ "validated?" getstatint if atmax? if else (Added to put 10000 XP cap) target @ owner idletime 900 <= if ( "owner" added by Moeru to make it work with puppets ) target @ owner me @ dbcmp not if me @ target @ alt? not if me @ "@rp/votedfor" target @ reflist_find not if ( <---- Moeru added "owner" here ) 1 value ! target @ value @ voteadj newvalue ! me @ "votes" getstatfloat value @ >= if me @ "votes" getstatfloat value @ - me @ "votes" rot setstat target @ owner "xp" getstatfloat newvalue @ + target @ owner "xp" rot setstat me @ player? if target @ "voteq" over over getstat ++ 1 10 limit setstat then target @ "lastvote" systime setstat { "You vote for " target @ owner " with " value @ 1 = if value @ 2 fchop " vote" else value @ 2 fchop " votes" then "." }cat "Vote" pretty tellme target @ owner { "You gained " newvalue @ 2 fchop "xp from " value @ 2 fchop " vote(s) by " me @ "." }cat "Vote" pretty ansi_notify me @ "@rp/votedfor" target @ reflist_add target @ owner levelhandler pop else { "You dont have enough votes! Target:[" target @ "] Value:[" value @ "]." }cat "Vote" pretty tellme then then then then then then then then then (added an extra then for the atmax? if else line) repeat then ; : pokemon { "pokemon/" param @ "/name" }cat getdex not if { "pokemon/byname/" param @ }cat getdex param ! then param @ not if "Couldn't find that pokemon, by name or number." "Pokedex" pretty tellme exit then me @ "pokemon" param @ setstat { "You are now " param @ " (" { "/pokemon/" param @ "/name" }cat getdex ")" }cat "Pokemon" pretty tellme AVATAR { "wc # " me @ " has used the +pokemon command to turn into a " { "pokemon/" param @ "/name" }cat getdex }cat force ; : pokemorph me @ "pokemorph" over over getstat toint ++ NUMMORPHS % setstat { "Pokemon morphology: " me @ "pokemorph" getstat mtype }cat "Pokemorph" pretty tellme me @ "pokemorph" getstat toint 1 2 .. if me @ "POKEMON" set else me @ "!POKEMON" set then AVATAR { "wc # " me @ " has used the +pokemorph command" }cat force ; : install prog "_defs/fmt76" "\"$lib/rps\" match \"fmt76\" call" setprop prog "_defs/cost" "\"$lib/rps\" match \"cost\" call" setprop prog "_defs/level" "\"$lib/rps\" match \"level\" call" setprop prog "_defs/level2xp" "\"$lib/rps\" match \"level2xp\" call" setprop prog "_defs/maxhp" "\"$lib/rps\" match \"maxhp\" call" setprop prog "_defs/nd6" "\"$lib/rps\" match \"nd6\" call" setprop prog "_defs/nd4" "\"$lib/rps\" match \"nd4\" call" setprop prog "_defs/successlevel" "\"$lib/rps\" match \"successlevel\" call" setprop prog "_defs/idletime" "\"$lib/rps\" match \"idletime\" call" setprop prog "_defs/iam" "\"$lib/rps\" match \"iam\" call" setprop prog "_defs/attackok?" "\"$lib/rps\" match \"attackok?\" call" setprop prog "_defs/tmhmok?" "\"$lib/rps\" match \"tmhmok?\" call" setprop prog "_defs/itemok?" "\"$lib/rps\" match \"itemok?\" call" setprop prog "_defs/adjusthp" "\"$lib/rps\" match \"adjusthp\" call" setprop prog "_defs/isfainted?" "\"$lib/rps\" match \"isfainted?\" call" setprop "PokeRPSystem v1.1" header tellhere "The Windows 3.1 of RP systems." "DESCRIPTION" pretty tellhere "$lib/rp $lib/alynna BOY LINK_OK AUTOSTART" "REQUIRES" pretty tellhere "fmt76 cost level level2xp maxhp nd6 nd4 successlevel idletime" "INCLUDES" pretty tellhere "iam attackok? tmhmok? itemok? isfainted? adjusthp" "INCLUDES" pretty tellhere "+init;+chargen +sheet;sheet +buy;buyequip +train;+learn +roll;+check" "INSTALLS" pretty tellhere "+pay;+spendhp;+give;+use +validate;+invalidate +rp;+rpi;+rps;+rpf;+rpd" "INSTALLS" pretty tellhere "+vote;+voteall +xp;+votes;+points +sl +pokemon" "INSTALLS" pretty tellhere "+store;+store/buy;+store/sell;+store/trash" "INSTALLS" pretty tellhere "fmt76 cost level level2xp" "TESTABLE" pretty tellhere "Alynna's MUFInstaller" footer tellhere ; : sysheart var target var gained var factor background online_array foreach target ! pop pi target @ location numplayers * 10.0 / factor ! target @ "validated?" getstatint if ( Got to be validated ) target @ "lifecycle" getstatint 1 + target @ "lifecycle" rot setstat target @ owner idletime 900 < if ( Only score points if not idle ) ( "owner" added by Moeru to make it work with puppets ) target @ "~status" getpropstr "{OOC|IDLE|IDL}" smatch not if ( And not OOC ) ( Always degenerate while IC, whether people are around or not ) target @ location name "*OOC*" smatch not if ( And not in OOC location ) ( Maybe lose a bit of condition stats ) random 10000 % CONDVEC < if paranoia? if AVATAR { "!wc #DEBUG: " target @ unparseobj " lost 1 COOL" }cat force then target @ "c/Cool" over over getstat -- 0 9 limit setstat then random 10000 % CONDVEC < if paranoia? if AVATAR { "!wc #DEBUG: " target @ unparseobj " lost 1 BEAUTY" }cat force then target @ "c/Beauty" over over getstat -- 0 9 limit setstat then random 10000 % CONDVEC < if paranoia? if AVATAR { "!wc #DEBUG: " target @ unparseobj " lost 1 CUTE" }cat force then target @ "c/Cute" over over getstat -- 0 9 limit setstat then random 10000 % CONDVEC < if paranoia? if AVATAR { "!wc #DEBUG: " target @ unparseobj " lost 1 SMART" }cat force then target @ "c/Smart" over over getstat -- 0 9 limit setstat then random 10000 % CONDVEC < if paranoia? if AVATAR { "!wc #DEBUG: " target @ unparseobj " lost 1 TOUGH" }cat force then target @ "c/Tough" over over getstat -- 0 9 limit setstat then target @ location numplayers 3 >= if ( and more than me here ) ( IC and active section ) ( Earn Refresh points and gain more XP ) atmax? if 100 tofloat gained ! else target @ "xp" getstatfloat target @ location numplayers 2 >= if factor @ else 0.0 then + target @ "xp" rot setstat target @ "xp" getstatint level tofloat 1.00 * gained ! target @ verbose? if target @ { "Roleplaying XP: " factor @ 6 fchop }cat "WorldHeart" pretty ansi_notify then then ( get Yen ) systime target @ "@/logintime" getprop toint - 60.0 / dup 250.00 > if pop 250.00 then gained ! target @ "yen" over over getstat gained @ + setstat ( paranoia? if AVATAR { "wc #DEBUG: " target @ unparseobj ": " gained @ " -> " target @ "yen" getstat }cat force then ) target @ verbose? if target @ { "Yen earned: " gained @ 2 fchop }cat "WorldHeart" pretty ansi_notify then ( Regain HP ) target @ "hp" getstatint target @ maxhp < if target @ stathandler pop target @ "Regeneration" getstatint level 1 + toint gained ! target @ "hp" getstatint gained @ + dup target @ maxhp > if pop target @ maxhp then target @ "hp" rot setstat target @ verbose? if target @ { "You gained " gained @ "hp, from natural regeneration." }cat "WorldHeart" pretty ansi_notify then then then then then then ( All validated section ) ( Clear voted list ) target @ "@rp/votedfor" 0 setprop ( Remove a voteq ) target @ "voteq" over over getstat -- 1 10 limit setstat target @ verbose? if target @ { "VotedFor cleared, VoteQ reduced by 1 .. (" target @ "voteq" getstat dup ";" swap 1.0 swap / 2 fchop ")" }cat "WorldHeart" pretty ansi_notify then ( Regenerate votes ) target @ "votes" getstatint 2 + dup 25 > if pop 25 then target @ "votes" rot setstat then ( Common section ) ( Tell them if they gained a level. ) target @ levelhandler pop repeat ; : compare me @ location ; : main param ! param @ mufcron? if sysheart exit then ( Sysheart: Initialize the system heart ) command @ "{+sysheart}" smatch if sysheart exit then ( Install: First time use setup ) command @ "+BASICRPSystem/install" smatch if install exit then ( Init: Clear an invalidated sheet, and set it up for chargen ) command @ "{+init|+chargen}" smatch if init exit then ( Wipe: Wipe all your information, but keep your XP ) command @ "{+wipe}" smatch if init-partial exit then ( Pokemon: Specify your pokemon type ) command @ "{+pokemon}" smatch if pokemon exit then ( Pokemorph: Toggles your pokemorph setting ) command @ "{+pokemorph}" smatch if pokemorph exit then ( Sheet: Display my sheet, or someone elses sheet ) command @ "{+sheet|sheet|+dex|+pokedex}" smatch if sheet exit then ( Buy: Adjust skills while chargenning or invalidated ) command @ "{+buy|+buyequip}" smatch if buy exit then ( Train: Adjust skills while validated ) command @ "{+train|+learn}" smatch if train exit then ( PokeTrain: Give XP to someone ) command @ "{+pokemon/train}" smatch if poketrain exit then ( Compare: Compare the last two rolls to the pokemon database ) command @ "{+compare|+cmp}" smatch if compare exit then ( Spend: Give yen or spend HP ) command @ "{+pay|+spendhp|+give|+use}" smatch if spend exit then ( Validate: (Staff only) Mark a sheet valid or invalid ) command @ "{+validate|+invalidate}" smatch if validate exit then ( RPSet: (Staff only) Set an RPStat manually ) command @ "{+rp|+rpi|+rps|+rpf|+rpd|+rpo}" smatch if rpset exit then ( Vote: Give a player 1-3 xp ) command @ "{+vote|+voteall}" smatch if vote exit then ( XPShow: Show sheet summary ) command @ "{+xp|+votes|+points}" smatch if xpshow exit then ( Store: Buy/Sell items in a store ) command @ "{+store|+store/buy|+store/sell|+store/trash}" smatch if pokestore exit then ( Pokemon/X: Own or disown pokemon ) command @ "{+pokemon/owner|+pokemon/disown|+pokemon/leave|+pokemon/trade}" smatch if pokeown exit then ( Pokemon: Heal pokemon at the pokemon center ) command @ "{+pokemon/heal}" smatch if pokeheal exit then ( Pokemon: Heal pokemon at the pokemon center ) command @ "{+pokemon/train}" smatch if poketrain exit then ( Roll: Roll one of the abilities you have ) command @ "{+roll|+check}" smatch if pokebattle exit then ( testing section ) command @ "+rps/cost" smatch if { me @ param @ cost }cat "COST" pretty tellme exit then command @ "+rps/fmt76" smatch if { param @ .debug-on fmt76 .debug-off }cat tellme exit then command @ "+rps/level" smatch if { param @ tofloat level }cat tellme exit then command @ "+rps/level2xp" smatch if { param @ tofloat level2xp }cat tellme exit then command @ "+rps/idletime" smatch if { param @ pmatch owner idletime }cat tellme exit then ( "owner" added by Moeru to make it work with puppets ) command @ "+sl" smatch if { param @ toint successlevel }cat "Success Level" pretty tellme exit then ; . c q @program $lib/rps2 1 99999 d 1 i $pubdef : $include $lib/rp $include $lib/rps $include $lib/alynna $include $lib/pokedex $include $muf/inline var param var target var stat var value var dicestore var dicestore4 var attacklevel var attacklevel2 var mytemp var thestat var metype $def INFORM "PokeRP" pretty tellme $def AVATAR #21 $def MAXVOTES me @ staff? if 256 else me @ "maxvotes" getstatint if me @ "maxvotes" getstatint else 4 then then $libdef getpokestat : getpokestat ( d s -- ? ) var target var item item ! target ! target @ "s/" item @ strcat getstat toint level dup 2 * swap nd4 + target @ "t/" item @ strcat getstat toint + ; PUBLIC getpokestat $libdef levelhandler : levelhandler ( d -- i ) var target var lastlevel var curlevel target ! target @ "lastlevel" getstat toint lastlevel ! target @ "xp" getstatint level toint curlevel ! curlevel @ lastlevel @ > if { target @ " grew to level " curlevel @ "!" }cat "Level" pretty target @ swap ansi_notify target @ "lastlevel" target @ "xp" getstatint level setstat 1 else 0 then ; PUBLIC levelhandler $libdef ballhandler : ballhandler ( i s d s -- i ) var item var target var isubtype var ballpower var roll var stat var value var tmp var cmpme var cmptgt var speed var accuracy item ! target ! Isubtype ! isubtype @ toint 0 > if isubtype @ tofloat ballpower ! else 10.0 ballpower ! then { "Ball power of '" item @ "': " ballpower @ 2 fchop }cat "Pokeball" pretty tellhere me @ "xp" getstatint target @ "xp" getstatint - level tmp ! ballpower @ tmp @ 100.0 / 1.0 + * ballpower ! { "Level factor of '" me @ "', trying to capture '" target @ "': " tmp @ toint "%%, new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere target @ "hp" getstatint 1.0 * target @ maxhp 1.0 * / tmp ! tmp @ 1.0 < if ballpower @ 1 tmp @ / * ballpower ! { "Weakness factor of '" target @ "': " 100 tmp @ 100 * - toint "%%, new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere then target @ "pokemorph" getstatint case 0 = when ballpower @ 0.00 * ballpower ! { "Pokeballs cannot be used on humans: new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere end 1 = when end 2 = when ballpower @ 0.10 * ballpower ! { "Pokemorph strength against ball, 90%% penalty: new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere end 3 = when ballpower @ 0.02 * ballpower ! { "Pokemorph strength against ball, 98%% penalty: new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere end endcase ( Now factor in different ball types ) { "pokemon/" target @ iam "/type" }cat getdex tostr isubtype @ tostr smatch if ballpower @ 50 + ballpower ! { "Pokemon type match using '" item @ "' to capture '" target @ "': +50 to ballpower, new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere then ( Love ball ) isubtype @ "Love" smatch if me @ "sex" getpropstr capitalize 1 strcut pop cmpme ! target @ "sex" getpropstr capitalize 1 strcut pop cmptgt ! 0 cmpme @ "M" smatch cmptgt @ "F" smatch and if pop 1 then cmpme @ "F" smatch cmptgt @ "M" smatch and if pop 1 then cmpme @ "H" smatch cmptgt @ "H" smatch or if pop 1 then if ballpower @ 50 + ballpower ! { "Pokemon ball type match using '" item @ "' to capture '" target @ "': +50 to ballpower, new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere then then ( Level ball ) isubtype @ "Level" smatch if target @ "xp" getstatint level 20 < if ballpower @ 50 + ballpower ! { "Pokemon ball type match using '" item @ "' to capture '" target @ "': +50 to ballpower, new ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere then then ( Friend ball ) isubtype @ "Friend" smatch if 0 ballpower ! { "Pokemon ball type match using '" item @ "' to capture '" target @ "': New ball power [" ballpower @ 2 fchop "]" }cat "Pokeball" pretty tellhere then ( Try to capture ) isubtype @ "Friend" smatch not if me @ "accuracy" getpokestat toint accuracy ! target @ "speed" getpokestat toint speed ! accuracy @ 0 > if { me @ "'s accuracy modifier increased chances of capture by " accuracy @ "!" }cat "Pokeball" pretty tellme then accuracy @ 0 < if { me @ "'s accuracy modifier decreased chances of capture by " accuracy @ abs "!" }cat "Pokeball" pretty tellme then speed @ 0 > if { me @ "'s speed modifier decreased chances of capture by " speed @ "!" }cat "Pokeball" pretty tellme then speed @ 0 < if { me @ "'s speed modifier increased chances of capture by " speed @ abs "!" }cat "Pokeball" pretty tellme then { "Attempting to capture '" target @ "'... rolling 1d100-" accuracy @ speed @ - " against " ballpower @ toint }cat "Pokeball" pretty tellhere random 100 % accuracy @ - speed @ + roll ! roll @ ballpower @ <= if { target @ " was captured! " me @ " now owns " target @ ". (" roll @ ")" }cat "Pokeball" pretty tellhere me @ "p/" target @ name strcat target @ setstat target @ "q/" me @ name strcat me @ setstat else { target @ " got away! (" roll @ ")" }cat "Pokeball" pretty tellhere then else target @ { me @ " just dropped a friend ball in front of you! If you wish to be owned by them type '+pokemon/owner " me @ "'" }cat "Pokeball" pretty notify then pop 1 ; PUBLIC ballhandler $libdef itemhandler : itemhandler ( d s -- i ) var target var item var itype var isubtype var stat var value item ! target ! { "item/" item @ "/type" }cat getdex tostr itype ! { "item/" item @ "/subtype" }cat getdex tostr isubtype ! 0 ( Ball handler, pass off to ball handler ) itype @ "Ball" smatch if isubtype @ target @ item @ ballhandler then ( Key item handler ) itype @ "Key" smatch if target @ "k/" item @ strcat isubtype @ setstat { target @ " just received key item " item @ "!" }cat "Item" pretty tellhere pop 1 then ( Lucky Egg ) itype @ "XP" smatch if target @ "xp" over over getstat isubtype @ tofloat + setstat { target @ " just received " isubtype @ "xp from " item @ "!" }cat "Item" pretty tellhere pop 1 then ( Apricorn handler ) itype @ "Apricorn" smatch if target @ "m/" isubtype @ " Ball" strcat strcat over over getstat 1 + setstat { target @ " just refined a " item @ " into an " isubtype @ " Ball!" }cat "Item" pretty tellhere pop 1 then ( TM handler ) itype @ "TM" smatch if isubtype @ toint 100 <= if isubtype @ { "{" { "pokemon/" target @ iam "/tmhm" }cat getdex { "pokemon/" target @ iam "/tmhm2" }cat getdex dup if tostr "|" swap strcat strcat else pop then "|" ":" subst "}" }cat smatch if target @ { "a/" { "tm/" isubtype @ "/name" }cat getdex tostr }cat over over getstat 1 + setstat { "TM" isubtype @ " was installed on " target @ "." }cat "Item/TM" pretty tellhere pop 1 else { "TM" isubtype @ " is incompatible with " target @ "!" }cat "Item/TM" pretty tellhere then else target @ { "a/" { "tm/" isubtype @ "/name" }cat getdex tostr }cat over over getstat 1 + setstat { "TM" isubtype @ " was installed on " target @ "." }cat "Item/TM" pretty tellhere pop 1 then then ( HM handler ) itype @ "HM" smatch if isubtype @ toint 100 <= if "H" isubtype @ strcat { "{" { "pokemon/" target @ iam "/tmhm" }cat getdex { "pokemon/" target @ iam "/tmhm2" }cat getdex dup if tostr "|" swap strcat strcat else pop then "|" ":" subst "}" }cat smatch if target @ { "a/" { "hm/" isubtype @ "/name" }cat getdex tostr }cat over over getstat 1 + setstat { "HM" isubtype @ " was installed on " target @ "." }cat "Item/HM" pretty tellhere pop 1 else { "HM" isubtype @ " is incompatible with " target @ "!" }cat "Item/HM" pretty tellhere then else target @ { "a/" { "hm/" isubtype @ "/name" }cat getdex tostr }cat over over getstat 1 + setstat { "HM" isubtype @ " was installed on " target @ "." }cat "Item/HM" pretty tellhere pop 1 then then ( Cure Handler ) itype @ "Cure" smatch if isubtype @ toint 0 > if target @ "HP" getstatint isubtype @ toint + dup target @ maxhp > if pop target @ maxhp then target @ "HP" rot setstat { target @ "'s HP was raised by " isubtype @ "." }cat "Item/Cure" pretty tellhere pop 1 else isubtype @ "All" smatch if target @ "hp" target @ maxhp setstat target @ "status" 0 setstat target @ "@rp/a/" array_get_propvals foreach value ! stat ! target @ { "a/" stat @ "/pp" }cat { "attack/" stat @ "/pp" }cat getdex toint setstat repeat { target @ " was completely healed and all PP restored!" }cat "Item/Cure" pretty tellhere pop 1 then isubtype @ "PP" smatch if target @ "@rp/a/" array_get_propvals foreach value ! stat ! target @ { "a/" stat @ "/pp" }cat { "attack/" stat @ "/pp" }cat getdex toint setstat repeat { target @ "'s PP was completely restored!" }cat "Item/Cure" pretty tellhere pop 1 then isubtype @ "Confusion" smatch if target @ "status" getstat 1 = if target @ "status" 0 setstat { target @ "'s confused no more!" }cat "Item/Cure" pretty tellhere pop 1 else { "It had no effect on " target @ "!" }cat "Item/Cure" pretty tellhere pop 1 then then isubtype @ "Frozen" smatch if target @ "status" getstat 2 = if target @ "status" 0 setstat { target @ "'s not frozen anymore!" }cat "Item/Cure" pretty tellhere pop 1 else { "It had no effect on " target @ "!" }cat "Item/Cure" pretty tellhere pop 1 then then isubtype @ "Burn" smatch if target @ "status" getstatint 3 = if target @ "status" 0 setstat { target @ " is no longer burned!" }cat "Item/Cure" pretty tellhere pop 1 else { "It had no effect on " target @ "!" }cat "Item/Cure" pretty tellhere pop 1 then then isubtype @ "Sleep" smatch if target @ "status" getstatint 4 = if target @ "status" 0 setstat { target @ " woke up!" }cat "Item/Cure" pretty tellhere pop 1 else { "It had no effect on " target @ "!" }cat "Item/Cure" pretty tellhere pop 1 then then isubtype @ "Paralyze" smatch if target @ "status" getstat 5 = if target @ "status" 0 setstat { target @ " can move again!" }cat "Item/Cure" pretty tellhere pop 1 else { "It had no effect on " target @ "!" }cat "Item/Cure" pretty tellhere pop 1 then then isubtype @ "Poison" smatch if target @ "status" getstat 6 = if target @ "status" 0 setstat { target @ " is no longer poisoned!" }cat "Item/Cure" pretty tellhere pop 1 else { "It had no effect on " target @ "!" }cat "Item/Cure" pretty tellhere pop 1 then then then then ( Moo Handler ) itype @ "Moo" smatch if isubtype @ toint 0 > if target @ "HP" getstatint target @ maxhp isubtype @ toint 100 / * + dup target @ maxhp > if pop target @ maxhp then target @ "HP" rot setstat { target @ "'s HP was raised by " isubtype @ "." }cat "Item/Cure" pretty tellhere pop 1 then then ( Equip handler ) itype @ "Equip" smatch if target @ { "e/" item @ capitalize }cat tostr over over getstat 1 + setstat { "Equip " item @ "(type " isubtype @ ") was set up on " target @ "." }cat "Item/Equip" pretty tellhere pop 1 then ( permstat handler ) itype @ "Attack" smatch if isubtype @ atoi value ! target @ "s/Attack" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Defense" smatch if isubtype @ atoi value ! target @ "s/Defense" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Special" smatch if isubtype @ atoi value ! target @ "s/Special" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Special-Def" smatch if isubtype @ atoi value ! target @ "s/Special-Def" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Accuracy" smatch if isubtype @ atoi value ! target @ "s/Accuracy" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Speed" smatch if isubtype @ atoi value ! target @ "s/Speed" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Fertility" smatch if isubtype @ atoi value ! target @ "s/Fertility" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Max-HP" smatch if isubtype @ atoi value ! target @ "s/Max-HP" over over getstat level value @ + level2xp dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s level in " itype @ " by " value @ abs "." }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Attack" smatch if isubtype @ atoi value ! target @ "t/Attack" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Defense" smatch if isubtype @ atoi value ! target @ "t/Defense" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Special" smatch if isubtype @ atoi value ! target @ "t/Special" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Special-Def" smatch if isubtype @ atoi value ! target @ "t/Special-Def" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Accuracy" smatch if isubtype @ atoi value ! target @ "t/Accuracy" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Speed" smatch if isubtype @ atoi value ! target @ "t/Speed" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Fertility" smatch if isubtype @ atoi value ! target @ "t/Fertility" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then itype @ "Temp-Max-HP" smatch if isubtype @ atoi value ! target @ "t/Max-HP" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 < if { "Item " item @ " has lowered " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere else { "Item " item @ " has raised " target @ "'s " itype @ " by " value @ abs " temporarily!" }cat "Item" pretty tellhere then pop 1 then ( NEW item: Pokeblocks ) itype @ "Pokeblock" smatch if { "/Pokeblock/" isubtype @ }cat getdex dup not if pop { "Invalid pokeblock type!" }cat "Item" pretty tellme pop 1 else "|" explode_array foreach value ! pop target @ { "c/" value @ }cat over over getstat ++ 0 9 limit setstat { "/item/" isubtype @ " pokeblock/desc" }cat getdex "Item" pretty tellhere { target @ "'s condition in " value @ toupper " rose by 1!" }cat "Item" pretty tellhere repeat pop 1 then then ( Inline handler ) itype @ "Inline" smatch if isubtype @ target @ { "var! target var! isubtype" { "/item/" item @ "/inline" }cat getdex }cat inline pop 1 then ( handle virtual items ) "$pokedex" match "/item/" item @ "/" strcat strcat propdir? not if pop 1 then ; PUBLIC itemhandler : isepic ( s -- i ) var value var stat var rollx var target target ! me @ "@rp/e/" array_get_propvals foreach value ! stat ! { "item/" stat @ "/type" }cat getdex tostr "Equip" smatch if { "item/" stat @ "/subtype" }cat getdex tostr { "attack/" target @ "/type" }cat getdex tostr smatch if value @ level toint nd4 rollx ! { "Equipment '" stat @ "' enhanced attack '" target @ "'! (+" rollx @ ")" }cat "Equip" pretty tellhere rollx @ exit then then repeat 0 ; $libdef stathandler : stathandler ( target.d -- abort?.i ) var target var status var factor var rtg var roll var halt var inlinemsg target ! ( by default, dont abort ) 0 ( Status ailments ) target @ "status" getstatint 0 > if target @ "status" getstat toint status ! target @ "statusfactor" getstat toint factor ! target @ "statustarget" getstat rtg ! status @ case ( Confuse ) 1 = when target @ "statusfactor" factor @ 1 - dup factor ! setstat factor @ if random 100 % 50 < if { target @ " is confused! It hurt itself in the confusion! ^RED^" random target @ "xp" getstat toint level 2 * int % dup roll ! "^NORMAL^ damage!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except target @ 0 roll @ - adjusthp target @ isfainted? if { target @ " has fainted!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 then pop 1 else { target @ " is confused!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except then else target @ "status" 0 setstat { target @ " is confused no more!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except then end ( Frozen ) 2 = when { target @ " is frozen! They cannot attack!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 end ( Burn ) 3 = when { target @ " is hurt by the burn! ^RED^" random factor @ % dup roll ! "^NORMAL^ damage!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except target @ 0 roll @ - adjusthp target @ isfainted? if { target @ " has fainted!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 then end ( Sleep ) 4 = when target @ "statusfactor" factor @ 1 - dup factor ! setstat factor @ if { target @ " is asleep! They cannot attack!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 else target @ "status" 0 setstat { target @ " woke up!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except then end ( Paralyze ) 5 = when random 100 % 50 < if { target @ " is paralyzed! They cannot attack!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 then end ( Poison ) 6 = when { target @ " is hurt by the poison! ^RED^" random factor @ % dup roll ! "^NORMAL^ damage!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except target @ 0 roll @ - adjusthp target @ isfainted? if { target @ " has fainted!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 then end ( Leech ) 7 = when { target @ " is being leeched! ^RED^" factor @ "^NORMAL^ HP was sent to " rtg @ }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except target @ 0 factor @ - adjusthp target @ isfainted? if { target @ " has fainted!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 then rtg @ factor @ adjusthp end ( Trap ) 8 = when target @ "statusfactor" factor @ 1 - dup factor ! setstat factor @ if { target @ " is trapped! ^RED^" random factor @ % dup roll ! "^NORMAL^ damage!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except target @ 0 roll @ - adjusthp target @ isfainted? if { target @ " has fainted!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 then else target @ "status" 0 setstat { target @ " is no longer trapped!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except then end ( Fainted ) 9 = when { target @ " is fainted! They cannot attack! Heck, they shouldn't even be here, they should be at a pokemon center recovering!" }cat "PokeBattle" pretty target @ location #-1 rot ansi_notify_except pop 1 end endcase then ( Handle type 13 statuses ) target @ "ts/status" getstat if target @ "ts/status" getstat status ! { "/attack/" status @ "/inline-status" }cat getdex if rtg @ factor @ status @ target @ { "var! target var! status var! factor var! rtg \"\" var! inlinemsg var halt " { "/attack/" status @ "/inline-status" }cat getdex " inlinemsg @ halt @" }cat inline halt ! inlinemsg ! inlinemsg @ if { inlinemsg @ }cat "PokeInline" pretty tellhere then halt @ if pop 1 then then then ; PUBLIC stathandler : damagemodifiers ( d i s -- s i ) var target var attack var attacktype var message var orig var damage var tmp1 var tmp2 var morphpower attack ! dup orig ! damage ! target ! "" message ! { "attack/" param @ "/type" }cat getdex attacktype ! attacktype @ "{Bug|Fighting|Flying|Ghost|Ground|Normal|Poison|Rock|Steel}" smatch if (physical) me @ "Attack" getpokestat if damage @ me @ "Attack" getpokestat dup tmp1 ! + damage ! { message @ me @ "(" tmp1 @ int "%%)" }cat message ! then target @ "Defense" getpokestat if damage @ target @ "Defense" getpokestat dup tmp2 ! - damage ! { message @ " - " target @ "(" tmp2 @ int "%%)" }cat message ! then message @ if { "Physical damage mods: Original(" orig @ "%%) + (" message @ " = " tmp1 @ tmp2 @ - int "%% damage modifier) = new target " damage @ int "%% damage." }cat message ! then else (special) me @ "Special" getpokestat if damage @ me @ "Special" getpokestat dup tmp1 ! + damage ! { message @ me @ "(" tmp1 @ int "%%)" }cat message ! then target @ "Special-Def" getpokestat if damage @ target @ "Special-Def" getpokestat dup tmp2 ! - damage ! { message @ " - " target @ "(" tmp2 @ int "%%)" }cat message ! then message @ if { "Special damage mods: Original(" orig @ "%%) + (" message @ " = " tmp1 @ tmp2 @ - int "%% damage modifier) = new target " damage @ int "%% damage." }cat message ! then then damage @ 0 < if random 10 % 1 + damage ! then me @ morph? if "$pokedex" match "morph-power" getstat morphpower ! ( { me @ " is a morph, attack power is reduced by " 1 morphpower @ - 100 * "%%." }cat "PokeBattle" pretty tellhere ) damage @ morphpower @ * damage ! then me @ meta? if "$pokedex" match "meta-power" getstat morphpower ! ( { me @ " is a meta, attack power is reduced by " 1 morphpower @ - 100 * "%%." }cat "PokeBattle" pretty tellhere ) damage @ morphpower @ * damage ! then message @ damage @ ; $libdef attackhandler : attackhandler ( attackfactor.i target.d damage.i stat.i param.s -- damage.i stat.i ) var stat var param var damage var target var subtype var factor var tmp var value var rawdmg var attackfactor var attacklevel "" var! inlinemsg param ! stat ! damage ! target ! attackfactor ! attacklevel ! { "attack/" param @ "/subtype" }cat getdex tostr subtype ! { "attack/" param @ "/factor" }cat getdex tostr factor ! { "attack/" param @ "/damage" }cat getdex tostr rawdmg ! ( begin handling ) ( Inline handler ) { "/attack/" param @ "/inline" }cat getdex if param @ stat @ damage @ target @ subtype @ factor @ rawdmg @ attackfactor @ attacklevel2 @ { "var! attacklevel var! attackfactor var! rawdmg var! factor var! subtype var! target var! damage var! stat var! param \"\" var! inlinemsg " { "/attack/" param @ "/inline" }cat getdex " inlinemsg @ param @ stat @ damage @ target @ subtype @ factor @ rawdmg @ attackfactor @ attacklevel @" }cat inline attacklevel2 ! attackfactor ! rawdmg ! factor ! subtype ! target ! damage ! stat ! param ! inlinemsg ! inlinemsg @ if inlinemsg @ "PokeInline" pretty tellhere then target @ damage @ param @ damagemodifiers toint damage ! pop then ( tempstat handler ) subtype @ "Attack" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Attack" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s attack power raised by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s attack power fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then subtype @ "Defense" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Defense" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s defense power raised by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s defense power fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then subtype @ "Special" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Special" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s special power rose by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s special power fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then subtype @ "Special-Def" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Special-Def" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s special defense rose by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s special defense fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then subtype @ "SpecialDef" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Special-Def" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s special defense rose by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s special defense fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then subtype @ "Accuracy" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Accuracy" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s accuracy rose by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s accuracy fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then subtype @ "Speed" smatch if factor @ toint value ! value @ stat @ 50.0 / dup 2.0 > if pop 2.0 then * toint value ! target @ "t/Speed" over over getstat value @ + dup -64 < if pop -64 then dup 64 > if pop 64 then setstat value @ 0 > if { target @ "'s speed rose by " value @ dup float? if int then "!" }cat "PokeBattle" pretty tellhere then value @ 0 < if { target @ "'s speed fell by " value @ dup float? if int then abs "!" }cat "PokeBattle" pretty tellhere then then ( Status effects ) subtype @ "{Confuse|Freeze|Burn|Sleep|Poison|Paralyze|Flinch|Leech|Trap}" smatch if random 100 % dup tmp ! factor @ atoi < if subtype @ case "Confuse" smatch when target @ "status" 1 setstat target @ "statusfactor" random 4 % 2 + setstat { target @ " is confused! (" factor @ "/" tmp @ ")" }cat "PokeBattle" pretty tellhere end "Freeze" smatch when target @ "status" 2 setstat { target @ " is frozen! It wont be able to attack! (" factor @ "/" tmp @ ")" }cat "PokeBattle" pretty tellhere end "Burn" smatch when target @ "status" 3 setstat target @ "statusfactor" damage @ setstat { target @ " is burned! (" factor @ "/" tmp @ ")" }cat "PokeBattle" pretty tellhere end "Sleep" smatch when target @ "status" 4 setstat target @ "statusfactor" random 4 % 2 + setstat { target @ " has been put to sleep! (" factor @ "/" tmp @ ")" }cat "PokeBattle" pretty tellhere end "Paralyze" smatch when target @ "status" 5 setstat { target @ " is paralyzed! It may not be able to attacked! (" factor @ "/" tmp @ ")" }cat "Pokebattle" pretty tellhere end "Poison" smatch when target @ "status" 6 setstat target @ "statusfactor" damage @ setstat { target @ " is poisoned! (" factor @ "/" tmp @ ")" }cat "PokeBattle" pretty tellhere end "Flinch" smatch when { target @ " flinched! " me @ " gets to attack again! (" factor @ "/" tmp @ ")" }cat "Pokebattle" pretty tellhere end "Leech" smatch when target @ "status" 7 setstat target @ maxhp rawdmg @ toint 100.0 / * dup value ! target @ "statusfactor" value @ setstat target @ "statustarget" me @ setstat { target @ " is being leeched for " value @ " HP! (" damage @ "/" value @ ")" }cat "Pokebattle" pretty tellhere end "Trap" smatch when target @ "status" 8 setstat target @ "statusfactor" random 4 % 2 + setstat { target @ " has been trapped! (" factor @ "/" tmp @ ")" }cat "PokeBattle" pretty tellhere end endcase then then damage @ stat @ param @ attackfactor @ attacklevel @ ; PUBLIC attackhandler : dostab me @ "/@rp/pokemon" getprop "$pokedex" match swap "/pokemon/" swap strcat "/type" strcat getprop ":" explode array_make 0 swap foreach swap pop "$pokedex" match swap "/types/attack/byname/" swap strcat getprop metype @ stringcmp if else 1 break then repeat if else exit then pop .2 + "(STAB) Attack is the same type as the pokemon using it." "PokeBattle" pretty tellhere ; : doAddMulti attacklevel @ ":" explode array_make foreach swap pop dup string? if "-3" smatch if "-3" attacklevel ! exit then else pop then repeat thestat @ -3 < if "-3" attacklevel ! exit then thestat @ 3 > if "3" attacklevel ! exit then thestat @ intostr attacklevel ! ("DEBUG! " attacklevel @ strcat tellhere) ; : pokebattle ( -- ) var params var target var targettype var accuracy var critical var canattack var attackfactor var damage var critlevel var tmp var inlinemsg var status 0 dup stat ! value ! ( Stat handler. If it returns true, abort now. ) me @ stathandler if exit then param @ "=" explode params ! params @ 1 = if ( Using attack on myself ) param ! me @ target ! me @ "ts/lastmove" param @ setstat ( PP check ) me @ { "a/" param @ "/pp" }cat getstatint 0 <= if { "You are out of PP in the attack [" param @ "]." }cat "Battle" pretty tellme exit then ( Roll it ) me @ "a/" param @ strcat getstatint level toint 1 + nd6 stat ! ( Show it ) { me @ " rolled [^GREEN^" param @ "^NORMAL^]: ^CYAN^" stat @ " (" stat @ successlevel ")" }cat "PokeBattle" pretty tellhere ( Factor in any equip bonuses ) stat @ param @ isepic dup tmp ! + stat ! ( And if there were any show those ) tmp @ if { "[^GREEN^" param @ "^NORMAL^]: ^CYAN^" stat @ " (" stat @ successlevel ")" }cat "PokeBattle" pretty tellhere then 0 0 target @ 0 stat @ param @ attackhandler attacklevel ! attackfactor ! param ! stat ! damage ! ( Describe the attack ) { "attack/" param @ "/desc" }cat getdex tostr "PokeBattle" pretty tellme ( And take a PP away ) me @ { "a/" param @ "/pp" }cat me @ { "a/" param @ "/pp" }cat getstatint 1 - setstat then params @ 2 = if param ! target ! me @ "ts/lastmove" param @ setstat ( Using attack on someone else ) me @ { "a/" param @ "/pp" }cat getstatint 0 <= if { "You are out of PP in the attack [" param @ "]." }cat "PokeBattle" pretty tellme exit then ( Check for 'self' attacks ) ({ "attack/" param @ "/accuracy" }cat getdex tostr "--" smatch if { "You can only use this ability on yourself!" }cat "PokeBattle" pretty tellme exit then) ( Roll it ) me @ "a/" param @ strcat getstatint level toint 1 + nd6 stat ! ( If the target is not ok, roll it on myself ) target @ match target ! target @ ok? not if me @ target ! { me @ " rolled [^GREEN^" param @ "^NORMAL^]: ^CYAN^" stat @ " (" stat @ successlevel ")" }cat "PokeBattle" pretty tellhere ( Factor in any equip bonuses ) stat @ param @ isepic dup tmp ! + stat ! ( Show them if there are any ) tmp @ if { "[^GREEN^" param @ "^NORMAL^]: ^CYAN^" stat @ " (" stat @ successlevel ")" }cat "PokeBattle" pretty tellhere then ( Describe the attack ) { "attack/" param @ "/desc" }cat getdex tostr "PokeBattle" pretty tellme ( Else If the target is ok, roll it them ) else ( Show the roll ) { me @ " rolled [^GREEN^" param @ "^NORMAL^] against [^GREEN^" target @ "^NORMAL^]: ^CYAN^" stat @ " (" stat @ successlevel ")" }cat "PokeBattle" pretty tellhere ( Factor in any equip bonuses ) stat @ param @ isepic dup tmp ! + stat ! ( And show them, if any ) tmp @ if { "[^GREEN^" param @ "^NORMAL^]: ^CYAN^" stat @ " (" stat @ successlevel ")" }cat "PokeBattle" pretty tellhere then ( And compare the pokemon to see if its No effect, Not effective, normal or effective ) target @ "ts/type" getstatstr "0" smatch if { "Attack type [^GREEN^" { "attack/" param @ "/type" }cat getdex dup not if pop "Normal" then "^NORMAL^] " "against pokemon type [^GREEN^" { "pokemon/" target @ "pokemon" getstat "/type" }cat getdex "^NORMAL^] " }cat "PokeBattle" pretty tellhere "/types/attack/byname/" { "attack/" param @ "/type" }cat getdex dup not if pop "Normal" then strcat getdex metype ! "/types/attack/byname/" { "pokemon/" target @ "pokemon" getstat "/type" }cat getdex dup not if pop "Normal" then ":" explode array_make "" mytemp ! foreach swap pop swap dup rot strcat getdex mytemp @ swap ":" strcat strcat mytemp ! repeat mytemp @ targettype ! pop (type:type:type: setup for ttype) else { "Attack type [^GREEN^" { "attack/" param @ "/type" }cat getdex dup not if pop "Normal" then "^NORMAL^] " "against pokemon type [^GREEN^" target @ "ts/type" getstatstr "^NORMAL^] " }cat "PokeBattle" pretty tellhere "/types/attack/byname/" { "attack/" param @ "/type" }cat getdex dup not if pop "Normal" then strcat getdex metype ! "/types/attack/byname/" target @ "ts/type" getstatstr dup not if pop "Normal" then ":" explode array_make "" mytemp ! foreach swap pop swap dup rot strcat getdex mytemp @ swap ":" strcat strcat mytemp ! repeat mytemp @ targettype ! pop (type:type:type: setup for ttype) then ( Inline-Pre handler ) { "/attack/" param @ "/inline-pre" }cat getdex if param @ stat @ target @ metype @ targettype @ { "var! targettype var! metype var! target var! stat var! param \"\" var! inlinemsg " { "/attack/" param @ "/inline-pre" }cat getdex " inlinemsg @ param @ stat @ target @ metype @ targettype @ " }cat inline targettype ! metype ! target ! stat ! param ! inlinemsg ! inlinemsg @ if inlinemsg @ "PokeInline" pretty tellhere then then ( Test for a critical hit or a critical miss ) random 100 % me @ "Speed" getpokestat + target @ "Speed" getpokestat - int { "attack/" param @ "/accuracy" }cat getdex toint dup 0 = if pop 100 then 100 - + critlevel ! critlevel @ 10 <= if { target @ " evades! (" critlevel @ ")" }cat "Pokebattle" pretty tellhere ( And take a PP away ) me @ { "a/" param @ "/pp" }cat me @ { "a/" param @ "/pp" }cat getstatint 1 - setstat ( Inline-Post handler ) { "/attack/" param @ "/inline-post" }cat getdex if param @ stat @ target @ metype @ targettype @ { "var! targettype var! metype var! target var! stat var! param \"\" var! inlinemsg " { "/attack/" param @ "/inline-post" }cat getdex " inlinemsg @ param @ stat @ target @ metype @ targettype @ " }cat inline targettype ! metype ! target ! stat ! param ! inlinemsg ! inlinemsg @ if inlinemsg @ "PokeInline" pretty tellhere then then ( Handle type 12 statuses ) target @ "ts/defense" getstat if target @ "ts/defense" getstat status ! { "/attack/" status @ "/inline-defense" }cat getdex if param @ status @ target @ damage @ { "var! damage var! target var! status var! param \"\" var! inlinemsg " { "/attack/" status @ "/inline-defense" }cat getdex " inlinemsg @" }cat inline inlinemsg ! inlinemsg @ if { inlinemsg @ }cat "PokeInline" pretty tellhere then then then exit then critlevel @ 90 >= if { "Critical hit! (+" stat @ random critlevel @ 50 - % dup tmp ! + stat ! tmp @ ") (" critlevel @ ")" }cat "CritCheck" pretty tellhere then ( Do an accuracy test on the attack ) random 100 % me @ "Accuracy" getpokestat - critlevel ! critlevel @ { "attack/" param @ "/accuracy" }cat getdex toint dup 0 = if pop 100 then >= if { "Rolling 1d100 against " { "attack/" param @ "/accuracy" }cat getdex toint dup 0 = if pop 100 then "... Missed! (" critlevel @ int ") (Accuracy: " me @ "Accuracy" getpokestat int ")" }cat "PokeBattle" pretty tellhere ( And take a PP away ) me @ { "a/" param @ "/pp" }cat me @ { "a/" param @ "/pp" }cat getstatint 1 - setstat ( Inline-Post handler ) { "/attack/" param @ "/inline-post" }cat getdex if param @ stat @ target @ metype @ targettype @ { "var! targettype var! metype var! target var! stat var! param \"\" var! inlinemsg " { "/attack/" param @ "/inline-post" }cat getdex " inlinemsg @ param @ stat @ target @ metype @ targettype @ " }cat inline targettype ! metype ! target ! stat ! param ! inlinemsg ! inlinemsg @ if inlinemsg @ "PokeInline" pretty tellhere then then ( Handle type 12 statuses ) target @ "ts/defense" getstat if target @ "ts/defense" getstat status ! { "/attack/" status @ "/inline-defense" }cat getdex if param @ status @ target @ damage @ { "var! damage var! target var! status var! param \"\" var! inlinemsg " { "/attack/" status @ "/inline-defense" }cat getdex " inlinemsg @" }cat inline inlinemsg ! inlinemsg @ if { inlinemsg @ }cat "PokeInline" pretty tellhere then then then exit else { "Rolling 1d100 against " { "attack/" param @ "/accuracy" }cat getdex toint dup 0 = if pop 100 then "... Hit! (" critlevel @ int ") (Accuracy: " me @ "Accuracy" getpokestat int ")" }cat "PokeBattle" pretty tellhere then ( If this attack has no damage factor, indicate so ) { "attack/" param @ "/damage" }cat getdex tostr "--" smatch if "This attack does no damage." "PokeBattle" pretty tellhere ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ 0 stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! target @ "ts/lastdamage" 0 setstat ( or else lets do an attack by the attack type ) else ( Save the attack factor as a percentage ) { "attack/" param @ "/damage" }cat getdex toint attackfactor ! ( Damage modifiers ) target @ attackfactor @ param @ damagemodifiers attackfactor ! dup if "PokeBattle" pretty tellhere else pop then attackfactor @ 100.0 / attackfactor ! ( And the attack level as a string based number ) ( **BEGIN MULTITYPE CODE** ) ({ "/types/attack/" metype @ "/" targettype @ }cat getdex attacklevel !) (<-- Old code) "" mytemp ! targettype @ ":" explode depth rotate pop 1 - array_make (This will give us an array of all set types) foreach swap pop thestat ! { "/types/attack/" metype @ "/" thestat @ }cat getdex ":" strcat mytemp @ swap strcat mytemp ! repeat (This leaves the various numerical values in val:val:val: format) mytemp @ attacklevel ! attacklevel @ ":" explode depth rotate pop 1 - array_make 0 swap foreach swap pop atoi + repeat thestat ! doAddMulti ( ** END MULTITYPE CODE** ) ( No effect! ) attacklevel @ "-3" smatch if ( Calculate damage and store ) 0 damage ! { "It has no effect! ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere then ( Its not very effective... ) attacklevel @ "-2" smatch if ( Calculate damage and store ) stat @ 0.25 dostab dup attacklevel2 ! random 50 % 100.0 / + * attackfactor @ * toint damage ! ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ damage @ stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! ( Display final call ) { "It's not very effective (x2), ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere ( hurt them ) target @ 0 damage @ - adjusthp target @ "ts/lastdamage" damage @ setstat then ( Its not very effective... ) attacklevel @ "-1" smatch if ( Calculate damage and store ) stat @ 0.5 dostab dup attacklevel2 ! random 50 % 100.0 / + * attackfactor @ * toint damage ! ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ damage @ stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! ( Display final call ) { "It's not very effective, ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere ( hurt them ) target @ 0 damage @ - adjusthp target @ "ts/lastdamage" damage @ setstat then ( Normal attack... ) attacklevel @ "0" smatch if ( Calculate damage and store ) stat @ 1 dostab dup attacklevel2 ! random 50 % 100.0 / + * attackfactor @ * toint damage ! ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ damage @ stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! ( Display final call ) { "Normal attack, ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere ( hurt them ) target @ 0 damage @ - adjusthp target @ "ts/lastdamage" damage @ setstat then ( Its super-effective... ) attacklevel @ "1" smatch if ( Calculate damage and store ) stat @ 1.5 dostab dup attacklevel2 ! random 50 % 100.0 / + * attackfactor @ * toint damage ! ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ damage @ stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! ( Display final call ) { "It's super-effective! ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere ( hurt them ) target @ 0 damage @ - adjusthp target @ "ts/lastdamage" damage @ setstat then ( Its super-effective... ) attacklevel @ "2" smatch if ( Calculate damage and store ) stat @ 2 dostab dup attacklevel2 ! random 50 % 100.0 / + * attackfactor @ * toint damage ! ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ damage @ stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! ( Display final call ) { "It's super-effective! (x2) ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere ( hurt them ) target @ 0 damage @ - adjusthp target @ "ts/lastdamage" damage @ setstat then ( Its super-effective... ) attacklevel @ "3" smatch if ( Calculate damage and store ) stat @ 2.5 dostab dup attacklevel2 ! random 50 % 100.0 / + * attackfactor @ * toint damage ! ( Call the attackhandler ) attacklevel2 @ attackfactor @ target @ damage @ stat @ param @ attackhandler attacklevel2 ! attackfactor ! param ! stat ! damage ! ( Display final call ) { "It's super-effective! (x2.5) ^Red^" damage @ "^ ^ damage. (Attack power is " attackfactor @ 100.0 * toint "%%)" }cat "PokeBattle" pretty tellhere ( hurt them ) target @ 0 damage @ - adjusthp target @ "ts/lastdamage" damage @ setstat then then ( Describe the attack ) { "Notes on this attack: " { "attack/" param @ "/desc" }cat getdex tostr }cat "%%" "%" subst "PokeBattle" pretty tellhere then ( And take a PP away ) me @ { "a/" param @ "/pp" }cat me @ { "a/" param @ "/pp" }cat getstatint 1 - setstat ( Faint check ) target @ isfainted? if { target @ " has fainted!!!" }cat "PokeBattle" pretty tellhere then then ( Inline-Post handler ) { "/attack/" param @ "/inline-post" }cat getdex if param @ stat @ target @ metype @ targettype @ { "var! targettype var! metype var! target var! stat var! param \"\" var! inlinemsg " { "/attack/" param @ "/inline-post" }cat getdex " inlinemsg @ param @ stat @ target @ metype @ targettype @ " }cat inline targettype ! metype ! target ! stat ! param ! inlinemsg ! inlinemsg @ if inlinemsg @ "PokeInline" pretty tellhere then then ( Handle type 12 statuses ) target @ "ts/defense" getstat if target @ "ts/defense" getstat status ! { "/attack/" status @ "/inline-defense" }cat getdex if param @ status @ target @ damage @ { "var! damage var! target var! status var! param \"\" var! inlinemsg " { "/attack/" status @ "/inline-defense" }cat getdex " inlinemsg @" }cat inline inlinemsg ! inlinemsg @ if { inlinemsg @ }cat "PokeInline" pretty tellhere then then then ; PUBLIC pokebattle $libdef pokebattle : coststr ( f -- s ) dup 0.001 = if pop "FREE " exit then dup -0.001 = if pop "FREE*" exit then dup -0.001 < if 2 fchop "*" strcat exit then 2 fchop " " strcat ; : pokestore ( -- ) var stat var value var icost var item var qty var target me @ location target ! me @ mon? if "Pokemon cant buy things at stores!" "Store" pretty tellme exit then command @ case "+store" stringcmp not when "^YELLOW^+--------------------------------+----------+----------+^NORMAL^" tellme "^YELLOW^|^NORMAL^Items available ^YELLOW^|^NORMAL^ Buy$ ^YELLOW^|^NORMAL^ Sell $ ^YELLOW^|^NORMAL^" tellme "^YELLOW^+--------------------------------+----------+----------+^NORMAL^" tellme target @ "@rp/m/" array_get_propvals foreach value ! stat ! { "^YELLOW^|^NORMAL^" stat @ 32 lj "^YELLOW^|^NORMAL^" value @ coststr 10 rj "^YELLOW^|^NORMAL^" value @ 2 / coststr 10 rj "^YELLOW^|^NORMAL^" }cat tellme repeat "^YELLOW^+--------------------------------+----------+----------+^NORMAL^" tellme end "+store/buy" stringcmp not when param @ "=" explode case 2 = when item ! toint qty ! end 1 = when item ! 1 qty ! end default "+store/buy [=]" "$" pretty tellme exit end endcase me @ target ! qty @ 1 < if "You cannot buy zero or negative amount of an item." "$" pretty tellme exit then me @ location "m/" item @ strcat getstatfloat icost ! icost @ 0 = if { "Item [" item @ "] not available in the store." }cat "$" pretty tellme exit then ( Handle free items ) icost @ -0.001 = if me @ "m/" item @ strcat -1 setstat { me @ " got item [^YELLOW^" item @ "^NORMAL^] for ^GREEN^FREE^NORMAL^ for unlimited use." }cat "$" pretty tellhere exit then icost @ 0.001 = if me @ "m/" item @ strcat getstatint 1 + me @ "m/" item @ strcat rot setstat { me @ " got item [^YELLOW^" item @ "^NORMAL^] for ^GREEN^FREE^NORMAL^." }cat "$" pretty tellhere exit then ( Handle items that manipulate money ) icost @ 0 < if ( Pay for unlimited use ) 0 icost @ - icost ! me @ "yen" getstatfloat icost @ >= if me @ "yen" getstatfloat icost @ - me @ swap "yen" swap setstat me @ "m/" item @ strcat -1 setstat { me @ " buys [^YELLOW^" item @ "^NORMAL^] for ^GREEN^$" icost @ qty @ * 2 fchop "^NORMAL^ for unlimited uses" }cat "$" pretty tellhere else { "You dont have enough yen! Cost: [$" icost @ qty @ * 2 fchop "]." }cat "$" pretty tellme then else ( pay per use ) me @ "yen" getstatfloat icost @ qty @ * >= if me @ "yen" getstatfloat icost @ qty @ * - me @ swap "yen" swap setstat me @ "m/" item @ strcat getstatint qty @ + me @ "m/" item @ strcat rot setstat { me @ " buys " qty @ " [^YELLOW^" item @ "^NORMAL^](s) for ^GREEN^$" icost @ qty @ * 2 fchop "^NORMAL^." }cat "$" pretty tellhere else { "You dont have enough yen! Cost: [$" icost @ qty @ * 2 fchop "]." }cat "$" pretty tellme then then end "+store/sell" stringcmp not when param @ "=" explode case 2 = when item ! toint qty ! end 1 = when item ! 1 qty ! end default "+store/sell [=]" "$" pretty tellme exit end endcase me @ target ! qty @ 1 < if "You cannot sell zero or negative amount of an item." "$" pretty tellme exit then me @ location "m/" item @ strcat getstatfloat icost ! icost @ 0 = if { "Item [" item @ "] not sellable in the store." }cat "$" pretty tellme exit then me @ "m/" item @ strcat getstatint if ( Handle free items ) icost @ 0.001 <= if me @ "m/" item @ strcat 0 setstat { me @ " trashes item [^YELLOW^" item @ "^NORMAL^]. (Sold for FREE)." }cat "$" pretty tellme exit then ( Handle items that manipulate money ) me @ "m/" item @ strcat getstatint qty @ >= if me @ "yen" getstatfloat icost @ qty @ * 2 / + me @ swap "yen" swap setstat me @ "m/" item @ strcat getstatint qty @ - me @ "m/" item @ strcat rot setstat { me @ " sells " qty @ " [^YELLOW^" item @ "^NORMAL^](s) for ^GREEN^$" icost @ qty @ * 2 / 2 fchop "^NORMAL^." }cat "$" pretty tellhere else { "You dont have enough of these!" }cat "$" pretty tellme then then end "+store/trash" stringcmp not when param @ item ! me @ "m/" item @ strcat getstatint 0 = if "None of that item to trash." "$" pretty tellme else me @ "m/" item @ strcat 0 setstat { "Item(s) " item @ " trashed." }cat "$" pretty tellme then end default "Invalid command." "Store" pretty tellme end endcase ; PUBLIC pokestore $libdef pokestore : pokeheal ( -- ) var target var stat var value param @ "" stringcmp not if me @ target ! else param @ pmatch target ! then target @ #-1 dbcmp if param @ match target ! target @ #-1 dbcmp if { "Target " param @ " not found." }cat "PokeHeal" pretty tellme exit then then target @ #-2 dbcmp if { "Target " param @ " matched more than once, be more specific." }cat "PokeHeal" pretty tellme exit then me @ "pokecenter" envstat toint not if "This isnt a PokeCenter!" "PokeHeal" pretty tellme exit then { "Welcome to our PokeCenter, " me @ ", would you like us to heal your pokemon?" }cat "PokeHeal" pretty tellhere { "We will need your pokemon (" target @ ") for a moment..." }cat "PokeHeal" pretty tellhere { "( Now healing " target @ "... )" }cat "PokeHeal" pretty tellhere target @ "hp" target @ maxhp setstat target @ "status" 0 setstat target @ "statusfactor" 0 setstat target @ "statustarget" 0 setstat target @ "@rp/a/" array_get_propvals foreach value ! stat ! target @ { "a/" stat @ "/pp" }cat { "attack/" stat @ "/pp" }cat getdex toint setstat repeat target @ "@rp/t/" array_get_propvals foreach value ! stat ! target @ { "t/" stat @ }cat 0 setstat repeat target @ "@rp/ts" remove_prop { "Your pokemon (" target @ ") are healed, please come again. Bye!" }cat "PokeHeal" pretty tellhere ; PUBLIC pokeheal $libdef pokeheal : pokeown ( -- ) var source var target var tmp param @ "" stringcmp not if { "Format: " command @ " " }cat "PokeOwn" pretty tellme exit then command @ "+pokemon/trade" smatch if param @ "=" explode tmp ! tmp @ 2 = not if { "Format: " command @ " =" }cat "PokeOwn" pretty tellme exit then source ! target ! source @ tmp ! tmp @ pmatch source ! source @ #-1 dbcmp if tmp @ match source ! source @ #-1 dbcmp if { "Source " tmp @ " not found." }cat "PokeOwn" pretty tellme exit then then source @ #-2 dbcmp if { "Target " tmp @ " matched more than once, be more specific." }cat "PokeOwn" pretty tellme exit then target @ tmp ! tmp @ pmatch target ! target @ #-1 dbcmp if tmp @ match target ! target @ #-1 dbcmp if { "Target " param @ " not found." }cat "PokeOwn" pretty tellme exit then then target @ #-2 dbcmp if { "Target " tmp @ " matched more than once, be more specific." }cat "PokeOwn" pretty tellme exit then me @ { "p/" source @ name }cat getstat not if { "Gee, you dont own " source @ "!" }cat "PokeOwn" pretty tellme exit then target @ "p/" source @ name strcat source @ setstat source @ "q/" target @ name strcat target @ setstat source @ "q/" me @ name strcat 0 setstat me @ "p/" source @ name strcat 0 setstat { me @ " just traded " source @ " to " target @ "." }cat "PokeOwn" pretty tellhere { "pokemon/" source @ iam "/evomethod" }cat getdex tostr "Trade" smatch if { source @ " can evolve when traded! This, if you are trying to evolve this pokemon, occurs now." }cat "PokeOwn" pretty tellhere then exit then param @ pmatch target ! target @ #-1 dbcmp if param @ match target ! target @ #-1 dbcmp if { "Target " param @ " not found." }cat "PokeOwn" pretty tellme exit then then target @ #-2 dbcmp if { "Target " param @ " matched more than once, be more specific." }cat "Pokedex" pretty tellme exit then command @ "+pokemon/owner" smatch if target @ "p/" me @ name strcat me @ setstat me @ "q/" target @ name strcat target @ setstat { target @ " now owns you." }cat "PokeOwn" pretty tellme target @ { me @ " just let you own them." }cat "PokeOwn" pretty ansi_notify then command @ "+pokemon/leave" smatch if target @ "p/" me @ name strcat 0 setstat me @ "q/" target @ name strcat 0 setstat { "You just left " target @ "!" }cat "PokeOwn" pretty tellme target @ { me @ " just left you!" }cat "PokeOwn" pretty ansi_notify then command @ "+pokemon/disown" smatch if target @ "q/" me @ name strcat 0 setstat me @ "p/" target @ name strcat 0 setstat { "You just disowned " target @ "!" }cat "PokeOwn" pretty tellme target @ { me @ " just disowned you!" }cat "PokeOwn" pretty ansi_notify then ; PUBLIC pokeown $libdef pokeown : main pop ; . c q @program $lib/rps3 1 99999 d 1 i $pubdef : $include $lib/alynna $include $lib/rp $include $lib/rps $include $lib/rps2 $include $lib/pokedex $def POKEDEX "$pokedex" match lvar param : pokedex-pokemon var pokemon var pokenum var attack var attacklev var count var item var value var linestore param @ not if "Known Pokemon" header tellme -1 count ! "" linestore ! POKEDEX "pokemon/byname/" array_get_propvals foreach item ! value ! count @ 1 + count ! linestore @ { "^Green^" item @ tostr 4 lj "^Yellow^" value @ 16 lj "^NORMAL^" }cat strcat linestore ! count @ 4 % 3 = if linestore @ tellme "" linestore ! then repeat count @ 4 % 3 < if linestore @ tellme "" linestore ! then "Pokedex" footer tellme exit then { "pokemon/" param @ "/name" }cat getdex not if { "pokemon/byname/" param @ }cat getdex param ! then param @ not if "Couldn't find that pokemon, by name or number." "Pokedex" pretty tellme exit then param @ pokenum ! { "pokemon/" param @ "/name" }cat getdex pokemon ! { "Pokedex information for " pokemon @ }cat header tellme { "Number: ^Green^" pokenum @ "^NORMAL^" }cat tellme { "Type: ^Green^" { "pokemon/" pokenum @ "/type" }cat getdex "^NORMAL^" }cat tellme { "Height: ^Green^" { "pokemon/" pokenum @ "/height" }cat getdex "^NORMAL^" }cat tellme { "Weight: ^Green^" { "pokemon/" pokenum @ "/weight" }cat getdex "^NORMAL^" }cat tellme { "pokemon/" pokenum @ "/evolution" }cat getdex if { "Evolves to: ^Green^" { "pokemon/" pokenum @ "/evolution" }cat getdex "^NORMAL^" }cat tellme then { "pokemon/" pokenum @ "/evomethod" }cat getdex if { "Evolve method: ^Green^" { "pokemon/" pokenum @ "/evomethod" }cat getdex "^NORMAL^" }cat tellme then "Attacks: " tellme POKEDEX { "pokemon/" pokenum @ "/attacks/" }cat array_get_propvals foreach attacklev ! attack ! { " ^Yellow^" attack @ attacklev @ "0" smatch if " ^Green^learned^NORMAL^" else attacklev @ tofloat me @ "xp" getstat level < if " ^Green^learned at level " attacklev @ "^NORMAL^" else " ^Red^learned at level " attacklev @ "^NORMAL^" then then }cat tellme repeat "TM/HM Compatibility:" tellme { "^Green^" { "pokemon/" pokenum @ "/tmhm" }cat getdex tostr ":" { "pokemon/" pokenum @ "/tmhm2" }cat getdex tostr strcat strcat " " ":" subst "^NORMAL^" }cat tellme "Pokedex info:" tellme { "pokemon/" pokenum @ "/desc" }cat getdex if { "^Red^Red^Normal^/^Blue^Blue^Normal^: ^Green^" { "pokemon/" pokenum @ "/desc" }cat getdex "^NORMAL^" }cat tellme then { "pokemon/" pokenum @ "/descg" }cat getdex if { "^Yellow^Gold^Normal^: ^Green^" { "pokemon/" pokenum @ "/descg" }cat getdex "^NORMAL^" }cat tellme then { "pokemon/" pokenum @ "/descs" }cat getdex if { "^Grey^Silver^Normal^: ^Green^" { "pokemon/" pokenum @ "/descs" }cat getdex "^NORMAL^" }cat tellme then "Breeding Info" header tellme "^White^Can breed with:^Normal" tellme { "pokemon/" pokenum @ "/breedcompat" }cat getdex if -1 count ! "" linestore ! { "pokemon/" pokenum @ "/breedcompat" }cat getdex { "pokemon/" pokenum @ "/osbreedcompat" }cat getdex dup if ":" swap strcat strcat else pop then ":" explode array_make foreach value ! pop count @ 1 + count ! linestore @ { "^Green^" value @ 16 lj "^NORMAL^" }cat strcat linestore ! count @ 4 % 3 = if linestore @ tellme "" linestore ! then repeat count @ 4 % 3 < if linestore @ tellme "" linestore ! then else "^Yellow^This pokemon can only breed with its own kind or with pokemon that can breed with anything, like Ditto and Mew.^normal^" tellme then "^White^Breeding attacks:^Normal" tellme { "^Green^" { "pokemon/" pokenum @ "/breedmoves" }cat getdex if { "^Green^" { "pokemon/" pokenum @ "/breedmoves" }cat getdex " : " ":" subst "^NORMAL^" }cat tellme else "^Red^None or Unknown^normal^" tellme then "Pokedex" footer tellme ; : pokedex-attack var count var item var value var linestore param @ not if "Known attacks" header tellme -1 count ! "" linestore ! POKEDEX "/attack/" array_get_propdirs foreach item ! pop count @ 1 + count ! linestore @ { "^Green^" item @ tostr 15 lj "^NORMAL^" }cat strcat linestore ! count @ 5 % 4 = if linestore @ tellme "" linestore ! then repeat count @ 5 % 4 < if linestore @ tellme "" linestore ! then "Pokedex" footer tellme exit then { "attack/" param @ "/desc" }cat getdex not if "Couldn't find that special attack." "Pokedex" pretty tellme exit then { "Pokedex information for attack: " param @ }cat header tellme { "Name: ^Green^" param @ "^NORMAL^" }cat tellme { "Type: ^Green^" { "attack/" param @ "/type" }cat getdex "^NORMAL^" }cat tellme { "PP: ^Green^" { "attack/" param @ "/pp" }cat getdex "^NORMAL^" }cat tellme { "Base Damage: ^Green^" { "attack/" param @ "/damage" }cat getdex dup "--" smatch if pop "No damage" then "%^NORMAL^" }cat tellme { "Accuracy: ^Green^" { "attack/" param @ "/accuracy" }cat getdex dup "--" smatch if pop "Used on self, 100" then "%^NORMAL^" }cat tellme { "Desc: ^Green^" { "attack/" param @ "/desc" }cat getdex "^NORMAL^" }cat tellme { "Misc: ^Green^Calls '" { "attack/" param @ "/subtype" }cat getdex "' subsystem with factor '" { "attack/" param @ "/factor" }cat getdex "'^NORMAL^" }cat tellme "Pokedex" footer tellme ; : pokedex-item var count var item var value var linestore param @ not if "Known items" header tellme -1 count ! "" linestore ! POKEDEX "/item/" array_get_propdirs foreach item ! pop count @ 1 + count ! linestore @ { "^Green^" item @ tostr 18 lj "^NORMAL^" }cat strcat linestore ! count @ 4 % 3 = if linestore @ tellme "" linestore ! then repeat count @ 4 % 3 < if linestore @ tellme "" linestore ! then "Pokedex" footer tellme exit then { "/item/" param @ "/desc" }cat getdex not if "Couldn't find that item." "Pokedex" pretty tellme exit then { "Pokedex information for item: " param @ }cat header tellme { "Name: ^Green^" param @ "^NORMAL^" }cat tellme { "Type: ^Green^" { "item/" param @ "/type" }cat getdex "^NORMAL^" }cat tellme { "Subtype: ^Green^" { "item/" param @ "/subtype" }cat getdex "^NORMAL^" }cat tellme { "Desc: ^Green^" { "item/" param @ "/desc" }cat getdex "^NORMAL^" }cat tellme "Pokedex" footer tellme ; : pokedex-tm var tmname var count var item var value var linestore var oldparam param @ not if "Known TMs" header tellme -1 count ! "" linestore ! POKEDEX "TM/byname/" array_get_propvals foreach swap value ! ":" explode array_make foreach swap pop item ! count @ 1 + count ! linestore @ { "^Green^" item @ tostr 3 rj " ^Yellow^" value @ 16 lj "^NORMAL^" }cat strcat linestore ! count @ 4 % 3 = if linestore @ tellme "" linestore ! then repeat repeat count @ 4 % 3 < if linestore @ tellme "" linestore ! then "Pokedex" footer tellme exit then { "TM/" param @ "/name" }cat getdex not if { "TM/byname/" param @ }cat getdex param ! param @ dup oldparam ! ":" explode 1 - popn param ! (***) then { "TM/" param @ "/name" }cat getdex not if "Couldn't find that TM." "Pokedex" pretty tellme exit then { "TM/" param @ "/name" }cat getdex tmname ! { "Pokedex information for TM" oldparam @ }cat header tellme { "Name: ^Green^" { "TM/" param @ "/name" }cat getdex "^NORMAL^" }cat tellme { "Type: ^Green^" { "attack/" tmname @ "/type" }cat getdex "^NORMAL^" }cat tellme { "PP: ^Green^" { "attack/" tmname @ "/pp" }cat getdex "^NORMAL^" }cat tellme { "Desc: ^Green^" { "attack/" tmname @ "/desc" }cat getdex "^NORMAL^" }cat tellme { "Average cost: ^Green^" { "TM/" param @ "/cost" }cat getdex "^NORMAL^" }cat tellme "Pokedex" footer tellme ; : pokedex-hm var hmname var item var value var count var linestore param @ not if "Known HMs" header tellme -1 count ! "" linestore ! POKEDEX "HM/byname/" array_get_propvals foreach item ! value ! count @ 1 + count ! linestore @ { "^Green^" item @ tostr 3 lj "^Yellow^" value @ 17 lj "^NORMAL^" }cat strcat linestore ! count @ 4 % 3 = if linestore @ tellme "" linestore ! then repeat count @ 4 % 3 < if linestore @ tellme "" linestore ! then "Pokedex" footer tellme exit then { "HM/" param @ "/name" }cat getdex not if { "HM/byname/" param @ }cat getdex param ! then { "HM/" param @ "/name" }cat getdex not if "Couldn't find that HM." "Pokedex" pretty tellme exit then { "HM/" param @ "/name" }cat getdex hmname ! { "Pokedex information for HM" param @ }cat header tellme { "Name: ^Green^" { "HM/" param @ "/name" }cat getdex "^NORMAL^" }cat tellme { "Type: ^Green^" { "attack/" hmname @ "/type" }cat getdex "^NORMAL^" }cat tellme { "PP: ^Green^" { "attack/" hmname @ "/pp" }cat getdex "^NORMAL^" }cat tellme { "Desc: ^Green^" { "attack/" hmname @ "/desc" }cat getdex "^NORMAL^" }cat tellme "Pokedex" footer tellme ; : pokedex-breed var pokemon var pokenum var target1 var target2 var tmp var attack var attacklev var count var item var value var linestore param @ not if { "Format: +pokemon/breed =" "Pokedex/Breed" pretty tellme exit then param @ "=" explode tmp ! tmp @ 2 = if target1 ! target2 ! then tmp @ 1 = if me @ target1 ! target2 ! then tmp @ 0 = if { "Format: +pokemon/breed =" "Pokedex/Breed" pretty tellme exit then { "pokemon/" target1 @ "/name" }cat getdex not if { "pokemon/byname/" target1 @ }cat getdex tmp ! tmp @ not if target1 @ pmatch target1 ! target1 @ ok? if target1 @ "pokemon" getstat target1 ! else "" target1 ! then else tmp @ target1 ! then then target1 @ not if "Target 1: Couldn't find that pokemon, by name, number or player." "Pokedex/Breed" pretty tellme exit then { "pokemon/" target2 @ "/name" }cat getdex not if { "pokemon/byname/" target2 @ }cat getdex tmp ! tmp @ not if target2 @ pmatch target2 ! target2 @ ok? if target2 @ "pokemon" getstat target2 ! else "" target2 ! then else tmp @ target2 ! then then target2 @ not if "Target 2: Couldn't find that pokemon, by name, number or player." "Pokedex/Breed" pretty tellme exit then { "Comparing " target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex " " "with " target2 @ " " { "/pokemon/" target2 @ "/name" }cat getdex "..." }cat "Pokedex/Breed" pretty tellme target1 @ target2 @ smatch if "These two pokemon seem to be breeding compatible. (They are the same species of pokemon)" "Pokemon/Breed" pretty tellme { "Chances of successful breeding: " 254.0 256.0 / 100.0 * 2 fchop "%" }cat "Pokedex/Breed" pretty tellme exit then { "pokemon/" target1 @ "/breedcompat" }cat getdex tostr "ALL" smatch if "These two pokemon seem to be breeding compatible. (Target 1 compatible with all)" "Pokemon/Breed" pretty tellme { "Chances of successful breeding: " 128.0 256.0 / 100.0 * 2 fchop "%" }cat "Pokedex/Breed" pretty tellme exit then { "pokemon/" target2 @ "/breedcompat" }cat getdex tostr "ALL" smatch if "These two pokemon seem to be breeding compatible. (Target 2 compatible with all)" "Pokemon/Breed" pretty tellme { "Chances of successful breeding: " 128.0 256.0 / 100.0 * 2 fchop "%" }cat "Pokedex/Breed" pretty tellme exit then ( One is type compatible and theres a type match ) { "pokemon/" target1 @ "/breedcompat" }cat getdex tostr "Type" smatch { "pokemon/" target2 @ "/breedcompat" }cat getdex tostr "Type" smatch or if { "pokemon/" target1 @ "/type" }cat getdex { "pokemon/" target2 @ "/type" }cat getdex smatch if "These two pokemon seem to be breeding compatible. (Type match with a type breeding pokemon or metahuman)" "Breed" pretty tellhere { "Chances of successful breeding: " 160.0 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere exit then then { "/pokemon/" target1 @ "/name" }cat getdex { "{" { { "/pokemon/" target2 @ "/breedcompat" }cat getdex tostr ":" { "/pokemon/" target2 @ "/osbreedcompat" }cat getdex tostr }cat "|" ":" subst "}" }cat smatch if "These two pokemon seem to be breeding compatible." "Pokedex/Breed" pretty tellme { "Approximate chances of successful breeding: " { "/pokemon/" target1 @ "/type" }cat getdex { "/pokemon/" target2 @ "/type" }cat getdex smatch if 177.0 else 51.0 then 256.0 / 100.0 * 2 fchop "%" }cat "Pokemon/Breed" pretty tellme else "These two pokemon cannot (technically) breed with eachother." "Pokemon/Breed" pretty tellme then ; : breedcrit ( i -- i ) 16 - fabs sqrt ; : breed var pokemon var pokenum var target1 var target2 var t1name var t2name var t1ref var t2ref var t1mod var t2mod var tmp var attack var attacklev var count var item var value var linestore var chance var roll param @ not if { "Format: +breed =" "Breed" pretty tellme exit then param @ "=" explode tmp ! tmp @ 2 = if target1 ! target2 ! then tmp @ 1 = if me @ target1 ! target2 ! then tmp @ 0 = if { "Format: +breed =" "Breed" pretty tellme exit then { "pokemon/" target1 @ "/name" }cat getdex not if { "pokemon/byname/" target1 @ }cat getdex tmp ! tmp @ not if target1 @ pmatch target1 ! target1 @ ok? if target1 @ t1ref ! target1 @ name t1name ! target1 @ "pokemon" getstat target1 ! else #-1 t1ref ! "" target1 ! "" t1name ! then else tmp @ target1 ! "" t1name ! then then target1 @ not if "Target 1: Couldn't find that pokemon, by name, number or player." "Breed" pretty tellme exit then { "pokemon/" target2 @ "/name" }cat getdex not if { "pokemon/byname/" target2 @ }cat getdex tmp ! tmp @ not if target2 @ pmatch target2 ! target2 @ ok? if target2 @ t2ref ! target2 @ name t2name ! target2 @ "pokemon" getstat target2 ! else #-1 t2ref ! "" target2 ! "" t2name ! then else tmp @ target2 ! "" t2name ! then then target2 @ not if "Target 2: Couldn't find that pokemon, by name, number or player." "Breed" pretty tellme exit then { "Initiatied by " me @ "..." }cat "Pokedex/Breed" pretty tellhere { "Attempting to breed " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") " "with " t2name @ "(" target2 @ " " { "/pokemon/" target2 @ "/name" }cat getdex ")..." }cat "Pokedex/Breed" pretty tellhere t1ref @ ok? if t1ref @ "Fertility" getpokestat toint dup t1mod ! if { t1name @ " has a fertility modifier of " t1mod @ "!" }cat "Breed" pretty tellhere then then t2ref @ ok? if t2ref @ "Fertility" getpokestat toint dup t2mod ! if { t2name @ " has a fertility modifier of " t2mod @ "!" }cat "Breed" pretty tellhere then then ( Same species ) target1 @ target2 @ smatch if "These two pokemon seem to be breeding compatible. (Both pokemon are the same species)" "Breed" pretty tellhere { "Chances of successful breeding: " 254.0 t1mod @ t2mod @ + + 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere { "Rolling 1d256-" t1mod @ t2mod @ + " against " 254 "..." }cat "Breed" pretty tellhere random 256 % t1mod @ t2mod @ + - dup roll ! 254 > if { "Breeding unsuccessful. (" roll @ ")" }cat "Breed/Official" pretty tellhere else { "Breeding successful! (" roll @ "): " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is now pregnant!" }cat "Breed/Official" pretty tellhere roll @ 16 <= if "Critical hit! Its super-effective!" "Breed/Official" pretty tellhere { t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is going to have " roll @ breedcrit toint " kids!" }cat "Breed/Official" pretty tellhere then then exit then ( Target 1 compatible with all ) { "pokemon/" target1 @ "/breedcompat" }cat getdex tostr "ALL" smatch if "These two pokemon seem to be breeding compatible. (Target 1 compatible with all)" "Breed" pretty tellhere { "Chances of successful breeding: " 128.0 t1mod @ t2mod @ + + 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere { "Rolling 1d256-" t1mod @ t2mod @ + " against " 128 "..." }cat "Breed" pretty tellhere random 256 % t1mod @ t2mod @ + - dup roll ! 128 > if { "Breeding unsuccessful. (" roll @ ")" }cat "Breed/Official" pretty tellhere else { "Breeding successful! (" roll @ "): " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is now pregnant!" }cat "Breed/Official" pretty tellhere roll @ 16 <= if "Critical hit! Its super-effective!" "Breed/Official" pretty tellhere { t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is going to have " roll @ breedcrit toint " kids!" }cat "Breed/Official" pretty tellhere then then exit then ( Target 2 compatible with all ) { "pokemon/" target2 @ "/breedcompat" }cat getdex tostr "ALL" smatch if "These two pokemon seem to be breeding compatible. (Target 2 compatible with all)" "Breed" pretty tellhere { "Chances of successful breeding: " 128.0 t1mod @ t2mod @ + + 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere { "Rolling 1d256-" t1mod @ t2mod @ + " against " 128 "..." }cat "Breed" pretty tellhere random 256 % t1mod @ t2mod @ + - dup roll ! 128 > if { "Breeding unsuccessful. (" roll @ ")" }cat "Breed/Official" pretty tellhere else { "Breeding successful! (" roll @ "): " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is now pregnant!" }cat "Breed/Official" pretty tellhere roll @ 16 <= if "Critical hit! Its super-effective!" "Breed/Official" pretty tellhere { t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is going to have " roll @ breedcrit toint " kids!" }cat "Breed/Official" pretty tellhere then then exit then ( One is type compatible and theres a type match ) { "pokemon/" target1 @ "/breedcompat" }cat getdex tostr "Type" smatch { "pokemon/" target2 @ "/breedcompat" }cat getdex tostr "Type" smatch or if { "pokemon/" target1 @ "/type" }cat getdex { "pokemon/" target2 @ "/type" }cat getdex smatch if "These two pokemon seem to be breeding compatible. (Type match with a type breeding pokemon or metahuman)" "Breed" pretty tellhere { "Chances of successful breeding: " 160.0 t1mod @ t2mod @ + + 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere { "Rolling 1d256-" t1mod @ t2mod @ + " against " 160 "..." }cat "Breed" pretty tellhere random 256 % t1mod @ t2mod @ + - dup roll ! 160 > if { "Breeding unsuccessful. (" roll @ ")" }cat "Breed/Official" pretty tellhere else { "Breeding successful! (" roll @ "): " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is now pregnant!" }cat "Breed/Official" pretty tellhere roll @ 16 <= if "Critical hit! Its super-effective!" "Breed/Official" pretty tellhere { t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is going to have " roll @ breedcrit toint " kids!" }cat "Breed/Official" pretty tellhere then then exit then then ( Pokemon breedlist match ) { "/pokemon/" target1 @ "/name" }cat getdex { "{" { { "/pokemon/" target2 @ "/breedcompat" }cat getdex tostr ":" { "/pokemon/" target2 @ "/osbreedcompat" }cat getdex tostr }cat "|" ":" subst "}" }cat smatch if "These two pokemon seem to be breeding compatible." "Breed" pretty tellhere { "Approximate chances of successful breeding: " { "/pokemon/" target1 @ "/type" }cat getdex { "/pokemon/" target2 @ "/type" }cat getdex smatch if 177.0 else 51.0 then dup toint chance ! t1mod @ t2mod @ + + 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere { "Rolling 1d256-" t1mod @ t2mod @ + " against " chance @ "..." }cat "Breed" pretty tellhere random 256 % t1mod @ t2mod @ + - dup roll ! chance @ > if { "Breeding unsuccessful. (" roll @ ")" }cat "Breed/Official" pretty tellhere else { "Breeding successful! (" roll @ "): " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is now pregnant!" }cat "Breed/Official" pretty tellhere roll @ 16 <= if "Critical hit! Its super-effective!" "Breed/Official" pretty tellhere { t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is going to have " roll @ breedcrit toint " kids!" }cat "Breed/Official" pretty tellhere then then else "These two pokemon cannot (technically) breed with eachother." "Pokemon/Breed" pretty tellhere { "Chances of successful breeding: " 1 t1mod @ t2mod @ + + 256.0 / 100.0 * 2 fchop "%%" }cat "Breed" pretty tellhere { "Rolling 1d256-" t1mod @ t2mod @ + " against " 1 "..." }cat "Breed" pretty tellhere random 256 % t1mod @ t2mod @ + - dup roll ! 1 > if { "Breeding unsuccessful. (" roll @ ")" }cat "Breed/Official" pretty tellhere else { "Breeding successful! (" roll @ "): " t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is now pregnant!" }cat "Breed/Official" pretty tellhere roll @ 1 <= if "Critical hit! Its super-effective!" "Breed/Official" pretty tellhere { t1name @ "(" target1 @ " " { "/pokemon/" target1 @ "/name" }cat getdex ") is going to have " 15 roll @ + breedcrit toint " kids!" }cat "Breed/Official" pretty tellhere then then then ; : main param ! command @ "+dex/pokemon" smatch if pokedex-pokemon exit then command @ "+dex/breed" smatch if pokedex-breed exit then command @ "+breed" smatch if breed exit then command @ "+dex/attack" smatch if pokedex-attack exit then command @ "+dex/item" smatch if pokedex-item exit then command @ "+dex/tm" smatch if pokedex-tm exit then command @ "+dex/hm" smatch if pokedex-hm exit then pokedex-pokemon ; . c q @program $lib/pokedex 1 10000 d i $def POKEDEX "$POKEDEX" match lvar param : getdex ( s -- ? ) POKEDEX swap getprop ; PUBLIC getdex : main getdex ; . c q