7Soul

LoG2 monster hit

Aug 28th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. function hitMonster(id, damage, color, flair, damageType, championId)
  2.     local monster = findEntity(id).monster
  3.     local champion = party.party:getChampionByOrdinal(championId)
  4.     if not monster then return end
  5.     local resistances = monster:getResistance(damageType)
  6.     if monster:getHitEffect() then
  7.         local particle = monster.go:createComponent("Particle", "hit_effect")
  8.         particle:setParticleSystem(monster:getHitEffect())
  9.         particle:setOffset(vec(0,monster:getCapsuleHeight() * 0.5,0))
  10.     end
  11.    
  12.     local tside = math.random(1,4) - 1
  13.     local anim = ""
  14.     if monster:getCurrentAction() == nil then
  15.         if tside == 0 then
  16.             if champion == party.party:getChampion(1) or champion == party.party:getChampion(3) then
  17.                 anim = "getHitFrontRight"
  18.             else
  19.                 anim = "getHitFrontLeft"
  20.             end
  21.         elseif tside == 1 then
  22.             anim = "getHitRight"
  23.         elseif tside == 2 then
  24.             anim = "getHitBack"
  25.         elseif tside == 3 then
  26.             anim = "getHitLeft"
  27.         end
  28.    
  29.         if not monster.go.damaged then
  30.             monster.go:createComponent("MonsterAction","damaged")
  31.         end
  32.         monster.go.damaged:setAnimation(anim)
  33.         monster:performAction("damaged")
  34.     end
  35.    
  36.     damage = math.ceil(damage)
  37.    
  38.     color = "CCCCCC"
  39.  
  40.     if resistances == "weak" then
  41.         color = "FF0000"
  42.     elseif resistances == "vulnerable" then
  43.         color = "CC0000"
  44.     elseif resistances == "resist" then
  45.         color = "CCCCCC"
  46.     elseif resistances == "immune" then
  47.         color = "EEEEEE"
  48.     elseif resistances == "absorb" then
  49.         color = "00FF00"
  50.     end
  51.  
  52.     if flair then
  53.         monster.go.monster:showDamageText("" .. damage, color, flair)
  54.     else
  55.         monster.go.monster:showDamageText("" .. damage, color)
  56.     end
  57.  
  58.     -------
  59.     monster:setHealth(monster:getHealth() - math.ceil(damage))
  60.    
  61.     monster.go.brain:stopGuarding()
  62.     monster.go.brain:pursuit()
  63.     if monster:getHealth() <= 0 then
  64.         monster:die()
  65.     end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment