View Single Post
  #2  
Old 01-31-2014, 11:28 PM
MattCaspermeyer MattCaspermeyer is offline
Approved Member
 
Join Date: Aug 2010
Posts: 553
Default It is handled individually - see apply_damage in ARENA.LUA

The damage is handled individually.

So if you look in ARENA.LUA the "apply_damage" function handles the calculation (for tips) and actual damage done when attacking other units whether it is an attack, spell, ability, rage skill, etc.

A little ways into that function there is a for i = 0, dcnt - 1 do loop that cycles through all the resistance types returned from dcnt = AU.rescount(). The damage is returned from AU.minresdmg( attacker, i ) and AU.max... From here the appropriate resistance of the defender (receiver) is gathered and then the damage (res_damage) for that attack resistance type calculated. It then cycles through and the total damage is sdmg = sdmg + res_damage.

Here is a code snippet from TL (should be the same, pretty much, for all KB's):

Code:
  local uc = math.max( 1, AU.unitcount( attacker ) ); -- max íà ñëó÷àé, êîãäà àòàêóåò ìåðòâûé þíèò (count = 0)
  local dcnt = AU.rescount();
  local i
  local max_damage = 0

  for i = 0, dcnt - 1 do
    local min_ = uc * AU.minresdmg( attacker, i )
    local max_ = uc * AU.maxresdmg( attacker, i )

    if Attack.is_base_attack() then -- âñå èçìåíåíèÿ óðîíà ðàñïðîñòðàíÿþòñÿ òîëüêî íà áàçîâûå àòàêè
      min_, max_ = correct_damage_minmax( attacker, min_, max_ )
    end

    local dmg

    if ( minmax == 1 ) then dmg = min_
    elseif ( minmax == 2 ) then dmg = max_
    elseif ( minmax == 3 ) then dmg = ( min_ + max_ ) / 2
    else dmg = Game.Random( min_ , max_ ) end

    -- ÂÍÈÌÀÍÈÅ! Êðèò áåðåòñÿ íå èç äèàïàçîíà à ïî ìàêñèìóìó!
    if iskrit then dmg = max_ end

    local resi = AU.resistance( receiver, i ) + res_inc

    if resi > 95 then resi = 95 end

    local res_damage = dmg * ( 1 - resi / 100 )
    sdmg = sdmg + res_damage

    if res_damage > max_damage then
      max_damage = res_damage
      Attack.val_store( attacker, "damage_type_index", i )
    end
  end

  sdmg = sdmg * kdmg * dfactor
The last line factors in the Attack / Defense limit (kdmg) and dfactor is the "Defense Factor" - another scaler on the damage (usually this is always 1, but you'll see it in unit ATOM's).

So there you are - feel free to ask more questions!



***EDIT*** Oh by the way, I forgot to mention that you need to look in the unit's ATOM to see what the actual damage split is because the damage type and range are specified individually for each damage type. Here is an example of the Ent's throw ability from TL (ENT.ATOM):

Code:
  throw1 {
    reload=3
    class=throw
    picture=BA1_Wasp_
    picture_small=BA1_Wasp_small.png
    hinthead=special_swarm_head
    hint=special_swarm_hint
    ad_factor=1
    distance=5
    mindist=1
    penalty=1
    animation=cast/throw/thtarget
    throw=ent_wasps
    framekey=x
    damage {
      poison=12,15
      physical=12,15
    }
See how the damage is poison=12,15 and physical=12,15? That is a 50% split, but it doesn't have to be split evenly, it could have just as easily been poison=16,20 and physical=8,10 for a total of 24-30 (2/3's poison damage, and 1/3 physical).

/C\/C\

Last edited by MattCaspermeyer; 01-31-2014 at 11:36 PM. Reason: Forgot to mention look at damage in the unit's ATOM
Reply With Quote