summaryrefslogblamecommitdiff
path: root/example/scripts/monster/testmonster.lua
blob: 86d1592f4a037322fb5cf63bf1bc6d316adb2bb5 (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                                           
 
                          

                                  
                                           
       

   
                                       
                   

                                                      
        

                                                  
       
   
 
                                          
                        



                                   
--[[

 Example monster script.

 Makes the monster boost about his abilities and makes both the monster and
 the player talkative during battle.

--]]

local function update(mob)
    local r = math.random(0, 200);
    if r == 0 then
        being_say(mob, "Roar! I am a boss")
    end
end

local function strike(mob, victim, hit)
    if hit > 0 then
        being_say(mob, "Take this! "..hit.." damage!")
        being_say(victim, "Oh Noez!")
    else
        being_say(mob, "Oh no, my attack missed!")
        being_say(victim, "Whew...")
    end
end

local maggot = get_monster_class("maggot")
maggot:on_update(update)
local attacks = maggot:attacks();
for i, attack in ipairs(attacks) do
    attack:on_attack(strike)
end