HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

GetAtkDamage Min & Max

08-08-2008, 06:46 AM#1
Chaos-Mapper
yeah.

my threadname says all.

i wamnt to get an function to get the damage of an unit, min and max dmg.
but i havent any idea if this is possible. i could create the unit new and order it to atk an enemy but then i have only a random value.

is there any solution? but without adding all dmg bonuses of items and buffs in globals and adding them to the base damage value??
08-08-2008, 08:00 AM#2
Pyrogasm
Depends... are there a lot of different unit-types you need to get the damage of, or just a few?
08-08-2008, 02:41 PM#3
BestZero
There is on way on my mind but it may not be a good solution though.

Let's see in Object Editor for min&max damage for every units you used in your map then store them to global variables with integer and array type. like this
Collapse JASS:
globals
integer MinDmg[number of your units]
integer MaxDmg[number of your units]
endglobals
You may use Unit - Point Value to locate and replace in array slot or if you wouldn't like you may create your unit id with your own. But be warned if you use unit value or your own unit id, it must match in array of global variables (I shall begin with 1,2,3,4,...).

Now you just store your min&max damage to that global variables.
08-08-2008, 03:18 PM#4
Pyrogasm
I think GameCache like so would be better, but if he needs it for a lot of unit types it might be easier to do it some other way:
Collapse JASS:
function GetUnitDamageRange takes unit U, integer Type returns integer
    if Type == 1 then
        return GetStoredInteger(Cache, "MinDamages", S2I(GetUnitTypeId(U))+GetUnitLevel(U))
    elseif Type == 2 then
        return GetStoredInteger(Cache, "MaxDamages", S2I(GetUnitTypeId(U))+GetUnitLevel(U))
    endif

    return -1
endfunction
08-09-2008, 02:44 AM#5
DioD
Data base is best and only way.

Use Unit Point Value for indexing.