Addstatsobj Stat Amount

Main.AddstatsobjStatAmount History

Hide minor edits - Show changes to markup

December 30, 2008, at 10:12 PM EST by admin
Added lines 1-20:
     addstats - syntax: addstats(obj,stat,amount) 

Prog Types: Mob, Object, Room

Addstats allows stats to be added to an object. It should not be used without consulting an imm first - all addstats are also logged to luasec.

For the first argument, an OBJ type variable is required. The second argument is the name of the stat, available stats are str, int, wis, dex, con, luck, hp, mana, move, hitroll, damroll and saves. The second argument can also be "random" in which case one of the 6 main stats is selected for each stat. The third argument is the amount to add - using Math.random this can also be random.

   --- Used in academy, small skeleton loads skeleton bone at death with 
   --- 2 random stats and random hp between 10 and 30.
   local tobj = oload("academy-36")
   addstats(tobj,"random",2)
   addstats(tobj,"hp",math.random(10,30))

   --- Also, rarely, add two more random stats.
   if math.random(1,60) == 3 then
      addstats(tobj,"random",2)
   end