@program #3691 1 1000 d i lvar target lvar param lvar monstertype lvar monsterlevel $include $lib/alynna $include $lib/rp $include $muf/rp/utils $def rpsys "$rpsystem" match $def backupcomponents { "Target-Self" "Target-Short" "Target-Long" "Target-Extreme" "Splash-Small" "Splash-Large" "Splash-Medium" "Target-Aura" "Duration-Rounds" "Duration-Minutes" } array_make $def badskill "{Artistry|Politics|Homekeeping|Streetwise|Sailing|Medicine}" lvar mstats lvar max lvar repeat lvar stat lvar limiter : primarystatmaker ( -- ) mstats @ "Strength" 1 setstat mstats @ "Dexterity" 1 setstat mstats @ "Stamina" 1 setstat mstats @ "Intelligence" 1 setstat mstats @ "Perception" 1 setstat mstats @ "Appearance" 1 setstat mstats @ "Magery" 1 setstat mstats @ "Willpower" 1 setstat 26 target @ 2 * + 2.5 * int max ! 1 repeat ! 0 limiter ! begin random 12 % stat ! stat @ 0 = if "Strength" then stat @ 1 = if "Dexterity" then stat @ 2 = if "Stamina" then stat @ 3 = if "Intelligence" then stat @ 4 = if "Perception" then stat @ 5 = if "Magery" then stat @ 6 = if "Willpower" then stat @ 7 = if "Appearance" then stat @ 8 = if "Strength" then stat @ 9 = if "Dexterity" then stat @ 10 = if "Perception" then stat @ 11 = if "Magery" then stat ! mstats @ stat @ getstatint dup 25 = if pop repeat @ 1 - repeat ! limiter @ 1 + limiter ! limiter @ 10 = if break then else 1 + mstats @ stat @ rot setstat 0 limiter ! then repeat @ 1 + repeat ! repeat @ max @ = until ; : skillmaker var lastone var x var repeater var allskills target @ 2 * 2.5 * int mstats @ "Magery" getstatint 12 > if target @ - else target @ + then "" lastone ! max ! 1 repeat ! "" stat ! { begin "Skill" stat @ RPUtils.nextitem dup stat ! stat @ not until pop "Brawl/Claws" "Brawl/Bite" "Defense/Dodge" "Alertness/Reactions" "Arcana/Shock" "Arcana/Reserves" "Arcana/Awareness" } array_make allskills ! begin allskills @ random allskills @ array_count % array_getitem stat ! stat @ badskill smatch if allskills @ random allskills @ array_count % array_getitem stat ! then stat @ badskill smatch if allskills @ random allskills @ array_count % array_getitem stat ! then stat @ not if "Skill" "" RPUtils.nextitem stat ! then mstats @ stat @ getstatint not stat @ lastone @ stringcmp and if stat @ lastone ! continue then mstats @ stat @ getstatint dup 23 > if limiter @ 1 + limiter ! limiter @ 50 = if break then pop repeat @ 1 - repeat ! else 3 + mstats @ stat @ rot setstat 0 limiter ! stat @ lastone ! then repeat @ 1 + repeat ! max @ repeat @ - dup 10 % not if intostr .tell else pop then repeat @ max @ = until ; : talentmaker var freebie var lastone var repeater var alltalents "" lastone ! target @ 2 * 2.5 * int mstats @ "Magery" getstatint 12 > if target @ + else target @ - then max ! 1 repeat ! "" stat ! { begin "Special" stat @ RPUtils.nextitem dup stat ! stat @ not until pop } array_make alltalents ! begin alltalents @ random alltalents @ array_count % array_getitem stat ! stat @ not if "Special" "" RPUtils.nextitem stat ! then mstats @ stat @ getstatint not stat @ lastone @ stringcmp and if stat @ lastone ! continue then mstats @ "Special/" stat @ strcat getstatint dup 23 > if pop repeat @ 1 - repeat ! limiter @ 1 + limiter ! limiter @ 50 = if break then else 3 + mstats @ "special/" stat @ strcat rot setstat stat @ if rpsys "Talents/" stat @ strcat "/Shock" strcat getprop if random 2 % not if backupcomponents random backupcomponents array_count % array_getitem freebie ! mstats @ "Special/" freebie @ strcat getstatint 25 < if mstats @ "Special/" freebie @ strcat getstatint 1 + mstats @ "Special/" freebie @ strcat rot setstat then then then then #4183 "cost/" stat @ strcat getpropstr atoi repeat @ swap + repeat ! 0 limiter ! stat @ lastone ! then repeat @ 1 + repeat ! max @ repeat @ - dup 10 % not if intostr .tell else pop then repeat @ max @ = repeat @ max @ > or until mstats @ "Special/Toughen" getstatint random target @ 2 * % + mstats @ "Special/Toughen" rot setstat mstats @ "Special/Raise-HP" getstatint random target @ 2 * % 2 / + mstats @ "Special/Raise-HP" rot setstat mstats @ "Special/Armor" getstatint random target @ 2 * % + mstats @ "Special/Armor" rot setstat mstats @ "Special/Armor2" getstatint random target @ 2 * % + mstats @ "Special/Armor2" rot setstat ; : template-apply var ps var skill var subskill var special var item var item2 var value1 var value2 var result str "Applying primary stats to " monstertype @ cat tellme ( Primary stats section ) { "Strength" "Dexterity" "Stamina" "Intelligence" "Perception" "Magery" "Willpower" "Appearance" } array_make foreach item ! pop rpsys str "/monster/" monstertype @ "/" item @ cat getprop toint value1 ! value1 @ 0 > if mstats @ item @ getstat toint value2 ! value1 @ value2 @ random 7 % 3 - 2 / int result ! mstats @ item @ result @ setstat else value1 @ -1 = if mstats @ item @ 0 setstat then then repeat str "Applying skills to " monstertype @ cat tellme ( Skills section ) { "Alertness" "Arcana" "Artistry" "Athletics" "Brawl" "Crafts" "Defense" "Empathy" "Etiquette" "Farming" "Folk-Lore" "Homekeeping" "Investigation" "Leadership" "Linguistics" "Lore" "Medicine" "Melee" "Performing" "Politics" "Ranged" "Riding" "Sailing" "Science" "Security" "Stealth" "Streetwise" "Subterfuge" "Survival" "Torture" } array_make foreach item ! pop rpsys str "/monster/" monstertype @ "/" item @ cat getprop toint value1 ! value1 @ 0 > if mstats @ item @ getstat toint value2 ! value1 @ value2 @ random 7 % 3 - 2 / int result ! mstats @ item @ result @ setstat else value1 @ -1 = if mstats @ item @ 0 setstat then then rpsys str "/monster/" monstertype @ "/" item @ cat propdir? if rpsys str "/monster/" monstertype @ "/" item @ cat array_get_propvals foreach value1 ! item2 ! value1 @ 0 > if mstats @ str item @ "/" item2 @ cat getstat toint value2 ! value1 @ value2 @ random 7 % 3 - 2 / int result ! mstats @ str item @ "/" item2 @ cat result @ setstat else value1 @ -1 = if mstats @ item @ 0 setstat then then repeat then repeat str "Applying specials to " monstertype @ cat tellme ( Specials section ) rpsys str "/monster/" monstertype @ "/special/" cat array_get_propvals foreach value1 ! item ! value1 @ 0 > if mstats @ item @ getstat toint value2 ! value1 @ value2 @ random 7 % 3 - 2 / int result ! mstats @ item @ result @ setstat else value1 @ -1 = if mstats @ item @ 0 setstat then then repeat str "Done creating " monstertype @ ", gwarrrr its alive" cat tellme ; : main ( s -- ) var runtype background param ! param @ not if "Please type +monster (number from 1 to 10) to create your random monster" .tell pop exit then param @ "=" explode runtype ! runtype @ 2 = if monstertype ! atoi monsterlevel ! then runtype @ 1 = if atoi dup target ! monsterlevel ! then target @ 1 < if 1 dup target ! monsterlevel ! then "Random Monster Stats" match dup thing? if recycle then me @ "Random Monster Stats" newobject mstats ! primarystatmaker skillmaker talentmaker runtype @ 2 = if template-apply then "Type +sheet random" .tell ; . c q