Conditionals to generate magic items carried by an NPC?

This generator is intended to generate a Knight of random level. I'd like to include OSE's 5% chance per level of an NPC having a magic item. The rest of the generator seems to work well.

But I don't know how to implement a standard "X% chance of Y, if chance is met return a Y." So I thought I would declare a variable based on knight level and another based on d100 and compare them. If the knightlevelvariable<d100 roll, then it would roll on the specified item table.

The conditional for the magic item displays the comparison I asked it to make (I don't want that) and also doesn't seem to work. I may not be understanding the Conditionals documentation in the help pdf. Any suggestions?

Table:Knight
set: KnightLevel={2d4+1}
set: KnightHP={{KnightLevel}d10}
set:SwordChance={{KnightLevel}
5}
set:SwordRoll={1d100}
set:WeaponChance={{KnightLevel}5}
set:WeaponRoll={1d100}
set:ArmorChance={{KnightLevel}
5}
set:ArmorRoll={1d100}
set:PotionChance={{KnightLevel}*5}
set:PotionRoll={1d100}
Sir [!1 KnightName]\n &
AC 2 &
Level {KnightLevel} ( {KnightHP} HP) THACO19/17/14 AT 1 DAM 1-8 sword/1-6 lance &
MV 120(40) ML 10 &
\n Treasure Type: Nil /n &
Items Carried:[when]{SwordRoll}<{SwordChance} [do] [@MagicSword]

Comments

  • You don't have the "*" in SwordChance/WeaponChance/ArmorChance. Is that the problem? The basic approach seems sound.

  • That would make a difference presumably :) However, it must not have copied to this forum--the *'s are in the original and it's still not working.

    Here's a sample output:

    Sir Tayber
    AC 2 Level 7 (56 HP) THACO19/17/14 AT 1 DAM 1-8 sword/1-6 lance MV 120 (40) ML 10
    Treasure Type: Nil
    Items Carried:[when]67<35 do Short sword -1, Cursed, not sentient, no special purpose
    Activity: Resting

    As you can see, it's printing the comparison (67 is not less than 35 though, so the comparison is not being executed) and then rolling on the magic sword subtable(s) anyway.

  • I think it's just not evaluating your When condition because there is no End. This works:

    Table:Knight
    set: KnightLevel={2d4+1}
    set: KnightHP={{KnightLevel}d10}
    set:SwordChance={{KnightLevel}5}
    set:SwordRoll={1d100}
    set:WeaponChance={{KnightLevel}5}
    set:WeaponRoll={1d100}
    set:ArmorChance={{KnightLevel}5}
    set:ArmorRoll={1d100}
    set:PotionChance={{KnightLevel}*5}
    set:PotionRoll={1d100}
    Sir [!1 KnightName]\n &
    AC 2 &
    Level {KnightLevel} ( {KnightHP} HP) THACO19/17/14 AT 1 DAM 1-8 sword/1-6 lance &
    MV 120(40) ML 10 &
    \n Treasure Type: Nil \n &
    Items Carried: [when]{SwordRoll}<{SwordChance} [do] [@MagicSword][else]None[end]

    Table: MagicSword
    +1 Sword
    Flaming Sword
    Cursed Sword

    I added an "Else" condition but that's not required. The "End" statement is required though.

  • Thank you, thank you, thank you.

Leave a Comment