• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Individual Upgrades?

Status
Not open for further replies.
Upgrades refer to unit-type, rather than individual unit.
Instead, you could manipulate adding/removing "hidden" abilities to such unit.

SpellBooks. Spellbooks #2.
There is also tutorial in regard to: "make ability available/unavailable for single unit rather than player".

Hiding abilities via spellbooks involves adding given ability to spell book and disabling spell ability (by id) for that player.
 
Level 12
Joined
May 20, 2009
Messages
822
One way to do it has a lot of good stuff to it, but it's also highly limited. You can change the level of abilities individually to units. This can make one unit have an upgraded ability and all the others of the same unit-type not have it. You can also add abilities individually to units. This can be used to give Armor, Attack Damage, Attack and Movement Speed, and Health bonuses to one single unit.

To do so you can use some of the abilities that ruleroffiron99 suggested. Blades of Attack (Attack Damage) and Ring of Protection (Armor). For others you can do Pendant of Vitality (Health), Boots of Speed (Movement Speed), and Gloves of Haste (Attack Speed).
 
Last edited:
Level 15
Joined
Nov 30, 2007
Messages
1,202
There is no function for that.

Go take a look in the spells section, I remember someone making a system that does the hard work of counting it for you. (hero attribute, items, etc)

He did this, if I am not misstaken:
  • Actions
    • Hashtable - Save DCS_NumberOfDice as (Key NumberOfDice) of DCS_UnitInt in DCS_Hash
    • Hashtable - Save DCS_SidesPerDie as (Key SidesPerDie) of DCS_UnitInt in DCS_Hash
    • Hashtable - Save DCS_BaseDamage as (Key BaseDamage) of DCS_UnitInt in DCS_Hash
    • -------- --- --------
    • Set DCS_NumberOfDice = (Load (Key NumberOfDice) of DCS_UnitInt from DCS_Hash)
    • Set DCS_SidesPerDie = (Load (Key SidesPerDie) of DCS_UnitInt from DCS_Hash)
    • Set DCS_BaseDamage = (Load (Key BaseDamage) of DCS_UnitInt from DCS_Hash)
    • Set DCS_Damage = (Random real number between ((Real(DCS_NumberOfDice)) + (Real(DCS_BaseDamage))) and (((Real(DCS_NumberOfDice)) x (Real(DCS_SidesPerDie))) + (Real(DCS_BaseDamage))))
Should I use this formula: ((NumberOfDice + BaseDamae) + (NumberOfDice x SidesPerDie + BaseDamage))/2 to get a good damage to base upgrades on?

That worked fine, now how to do the same thing for armor, what formula does it use? I think +1 works fine.

Ah! ;)
"A knight was trained...
Damage: 31
Upgrade: 9 (30%)"

A side effect is that its hard to tell how upgraded a unit is. Should I place Items in the inventory of the unit to represent upgrades - would this option be valid??
 
Last edited:
Level 15
Joined
Nov 30, 2007
Messages
1,202
Not sure if Im doing it correctly.... Could someone show me how its done? Also need some way to split between melee units and ranged units in the main function. ah! Found these:
  • Conditions
    • ((Unit-type of (Triggering unit)) is A melee attacker) Equal to True
    • ((Unit-type of (Triggering unit)) is A ranged attacker) Equal to True
JASS:
library UpgradeUnit  initializer init

globals
    private hashtable hash
    integer array MeleeDmgUpg
    integer array MeleeArmUpg
    integer array RangeDmgUpg
    integer array RangeArmUpg
endglobals

private function main takes nothing returns boolean
    local unit u = GetTrainedUnit()
    local integer uType = GetUnitTypeId(u)
    local integer city = OwningCity[GetUnitUserData(GetTriggerUnit())]
    local integer damage
    
    
    set damage = LoadInteger(hash, GetUnitTypeId(u), StringHash("Damage"))
    call BJDebugMsg(I2S(uType) + " damage: " + I2S(damage)) // works!
    call BJDebugMsg("City: " + I2S(city)) // works!
    
    if (IsUnitIdType(uType, UNIT_TYPE_MELEE_ATTACKER) == true ) then
        if (MeleeDmgUpg[city] > 0) then
            set damage = LoadInteger(hash, GetUnitTypeId(u), StringHash("Damage"))
            //call SetUnitAbilityLevel(u, 'xxxx', 0)
        endif
        if (MeleeArmUpg[city] > 0) then
            call SetUnitAbilityLevel(u, 'uArm', (MeleeArmUpg[city] + 1))
        
        endif
    elseif (IsUnitIdType(uType, UNIT_TYPE_RANGED_ATTACKER) == true) then
        if (RangeDmgUpg[city] > 0) then
            set damage = LoadInteger(hash, GetUnitTypeId(u), StringHash("Damage"))
            //call SetUnitAbilityLevel(u, 'xxxx', 0)
        endif
        if (RangeArmUpg[city] > 0) then
            call SetUnitAbilityLevel(u, 'uArm', (RangeArmUpg[city] + 1))
        endif
        set u = null    
    endif
    return false 
endfunction

private function save takes integer db, integer nod, integer spd, integer ut returns nothing 
    local integer dmg = ((nod + db) + (nod*spd+db))/2 
    // Either use this
    call SaveInteger(hash, ut, StringHash("Damage"), dmg) 
    // ... or this
    call SaveInteger(hash, ut, StringHash("DamageBase"), db) 
    call SaveInteger(hash, ut, StringHash("NumberOfDice"), nod)
    call SaveInteger(hash, ut, StringHash("SidesPerDice"), spd) 
endfunction

private function init takes nothing returns nothing
    local integer uType
    local integer DamageBase 
    local integer NumberOfDice  
    local integer SidesPerDice 
    
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
    call TriggerAddCondition( t, Condition( function main))
    set t = null
    
    // Save Damage of Unit Types
    
    set hash = InitHashtable() 
    
    set uType = 'hfoo' // Footman
    set DamageBase = 11
    set NumberOfDice = 1
    set SidesPerDice = 2
    call save(DamageBase, NumberOfDice, SidesPerDice, uType)
    
    set uType = 'hmil'
    set DamageBase = 11
    set NumberOfDice = 1
    set SidesPerDice = 2
    call save(DamageBase, NumberOfDice, SidesPerDice, uType)
    
endfunction

endlibrary
 
Last edited:
Level 15
Joined
Nov 30, 2007
Messages
1,202
The ability used should have multiple levels. You can check the level of the ability, and to upgrade it is easy: just increase the level of that ability.


- Should Armor give +1 armor per upgrade both for ranged and melee units or should I base it on a percentage?
- Should Damage increase based on Number of Dice and Side per Dice or a %? What would the differences be?
- I'm currently using claws of attack for dmg and ring pf protection for armor; as such there is no good visual information to find on the unit to find out the amount upgraded. What buffs that don't "stack" with others can I use to display the information to enemies selecting the unit? Or... do you have any other suggestion on how the visuals of upgrades could work?
 
Last edited:
Status
Not open for further replies.
Top