Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hitMonster(id, damage, color, flair, damageType, championId)
- local monster = findEntity(id).monster
- local champion = party.party:getChampionByOrdinal(championId)
- if not monster then return end
- local resistances = monster:getResistance(damageType)
- if monster:getHitEffect() then
- local particle = monster.go:createComponent("Particle", "hit_effect")
- particle:setParticleSystem(monster:getHitEffect())
- particle:setOffset(vec(0,monster:getCapsuleHeight() * 0.5,0))
- end
- local tside = math.random(1,4) - 1
- local anim = ""
- if monster:getCurrentAction() == nil then
- if tside == 0 then
- if champion == party.party:getChampion(1) or champion == party.party:getChampion(3) then
- anim = "getHitFrontRight"
- else
- anim = "getHitFrontLeft"
- end
- elseif tside == 1 then
- anim = "getHitRight"
- elseif tside == 2 then
- anim = "getHitBack"
- elseif tside == 3 then
- anim = "getHitLeft"
- end
- if not monster.go.damaged then
- monster.go:createComponent("MonsterAction","damaged")
- end
- monster.go.damaged:setAnimation(anim)
- monster:performAction("damaged")
- end
- damage = math.ceil(damage)
- color = "CCCCCC"
- if resistances == "weak" then
- color = "FF0000"
- elseif resistances == "vulnerable" then
- color = "CC0000"
- elseif resistances == "resist" then
- color = "CCCCCC"
- elseif resistances == "immune" then
- color = "EEEEEE"
- elseif resistances == "absorb" then
- color = "00FF00"
- end
- if flair then
- monster.go.monster:showDamageText("" .. damage, color, flair)
- else
- monster.go.monster:showDamageText("" .. damage, color)
- end
- -------
- monster:setHealth(monster:getHealth() - math.ceil(damage))
- monster.go.brain:stopGuarding()
- monster.go.brain:pursuit()
- if monster:getHealth() <= 0 then
- monster:die()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment