• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit Upgrade System v1.0.0.0

This is a Unit Upgrade System.
It is based on the unit type of the unit. This system is MPI.
It can be used for 1 of every unit type upgrade per player.
More info in the Jass trigger header.

  • UnitUpgradeSystemVariables
    • Events
    • Conditions
    • Actions
      • Set uniUpgSysAbiTrig = (This trigger)
      • Set unitUpgSysAbilityBool[0] = False
      • Set unitUpgSysHash = (Last created hashtable)
      • Set unitUpgSysInRangeBool[0] = False
      • Set unitUpgSysIncludeBonuses[0] = False
      • Set unitUpgSysItemBool[0] = False
      • Set unitUpgSysLvlBool[0] = False
      • Set unitUpgSysMaxIndex = 0
      • Set unitUpgSysMinimumAgi[0] = 0
      • Set unitUpgSysMinimumInt[0] = 0
      • Set unitUpgSysMinimumStr[0] = 0
      • Set unitUpgSysMultiAbilities[0] = 0
      • Set unitUpgSysMultiItems[0] = 0
      • Set unitUpgSysMultiUnitsBool[0] = False
      • Set unitUpgSysMultiUnitsCounter[0] = 0
      • Set unitUpgSysMultiUnitsRemove[0] = False
      • Set unitUpgSysMultiUnitsTotal[0] = 0
      • Set unitUpgSysRegionBool[0] = False
      • Set unitUpgSysRegions[0] = 0
      • Set unitUpgSysStatBool[0] = False
      • Set unitUpgSysUnitLvl[0] = 0
      • Set unitUpgSysUpgradeUnitType[0] = 0
JASS:
// Unit Upgrade System by deathismyfriend
    // version 1.0.0.0

    //                          PROS
    //
    // This system is able to upgrade units with a few different options.
    // This system can use restrictions from all of these at the same time.
    // This can upgrade units by these next several things.
    // Based on the lvl of the unit. 
    // Based on unit enter a region. 
    // Based on a units stat/stats.  
    // // Example: Str/Agi/Int
    // Based on an ability being used. 
    // Based on how many units of the base units unit type owned by player. 
    // Based on up to 6 items that unit has. 
    // You can use multiple of the same item to require upgrade.
    
    //                          CONS
    //
    // Can only make units require multiple units of the same unit type as the base unit.
    // Can only make a unit upgrade to one other unit.
    // // Example: unit A can upgrade to unit B but it can't upgrade to unit B / C / and D 
    
    //                                 FUNCTION LIST
    //
    //
    //                               REGISTER UNIT MULTI UNITS
    // This function allows you to register an amount of the units that player has that will trigger the unit to upgrade.
    // Custom script: call UnitUpgSysRegisterMultiUnits( unit-type, integer, boolean)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // The integer variable is the amount of units required for the unit to upgrade.
    // The boolean is whether or not i want to remove the units to upgrade the unit.
    //
    //
    //                               REGISTER UNIT LEVEL
    // This function allows you to register a lvl requirement that will trigger the unit to upgrade.
    // Custom script: call UnitUpgSysRegisterUnitLvl( unit-type, integer)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // The integer variable is the lvl required for the unit to upgrade.
    //
    //
    //                               REGISTER UNIT ENTER REGION/S
    // This function registers an enter region to a specific unit. This way you can make different units use different regions to upgrade.
    // Custom script: call UnitUpgSysRegisterUnitEnterRegion( unit-type, region)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // The region should be a region variable made in the variable editor. Then you can null the variable ( do not remove the region).
    // This function allows you to register as many regions that will trigger the unit to upgrade.
    //
    //
    //                               REGISTER UNIT CASTS ABILITY/IES
    // This function registers an ability to a specific unit. This way you can make different units use different abilities to upgrade.
    // Max of 50 different abilities allowed for upgrade per base unit type.
    // Custom script: call UnitUpgSysRegisterUnitAbility( unit-type, ability, integer)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // The ability can be the ability you want to register to the unit that will allow the unit to upgrade.
    // The integer is the minimum allowed lvl of the ability that allows the unit to upgrade.
    // This function allows you to register as many abilities that will trigger the unit to upgrade.
    //
    //
    //                               REGISTER UNIT HAS ITEM/S
    // This function registers an item to a specific unit. This way you can make different units use different items to upgrade.
    // Max of 50 different items allowed for upgrade per base unit type.
    // Custom script: call UnitUpgSysRegisterUnitItem( unit-type, item-type, boolean)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // The item-type should be done the same way as the unit-type is done in the suggestion above.
    // Set the boolean to true if you want the item you registered to be removed from the unit when all requirements are met.
    // This function allows you to register as many items that will trigger the unit to upgrade. 
    // Max of 6 items.
    //
    //
    //                               REGISTER UNIT STATS
    // This function is for adding a stat requirement for the unit to upgrade. Example: Agility, Intel, Strength
    // These are the minimum requirements for the unit to upgrade.
    // Custom script: call UnitUpgSysRegisterUnitStats( unit-type, agi, intel, str, boolean)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // The boolean is wheather or not it includes bonuses. True means it includes bonuses for the stats.
    // The agility / intel / strength arguments are integers and can be placed right in the custom script.
    // Example: Custom script: call UnitUpgSysRegisterUnitStats( unit-type, 20, 0, 0, false)
    //
    //
    //                               REGISTER UNIT TYPE
    // Custom script: call UnitUpgSysRegisterUnitType( unit-type, unit-type, boolean)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // For the boolean it only needs to know if the base unit is a hero not the upgraded unit.
    // If false the unit is not a hero.
    // I did it this way so you can have normal units upgrade into heroes after the other requirements are met.
    // Example: Custom script: call UnitUpgSysRegisterUnitType( unit-type, unit-type, boolean)
    //
    //
    //                               REMOVE UNIT TYPE
    // This function removes a unit type upgrade. ( this is the base unit not the upgraded unit that it removes)
    // Custom script: call UnitUpgSysRemoveUnitType( unit-type)
    // The unit type argument should be set in a unit-type variable in the Variable editor then put it in here using that variable.
    // Example: Custom script: call UnitUpgSysRemoveUnitType( unit-type)
    //
    //
    
    
    
    function UnitUpgSysRegisterUnitAbility takes integer baseUnit, integer abi, integer lvl returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        set udg_unitUpgSysAbilityBool[ i] = true
        set udg_unitUpgSysMultiAbilities[ i] = udg_unitUpgSysMultiAbilities[ i] + 1
        call SaveInteger( udg_unitUpgSysHash, baseUnit, udg_unitUpgSysMultiAbilities[ i], abi)
        call SaveInteger( udg_unitUpgSysHash, baseUnit, udg_unitUpgSysMultiAbilities[ i] + 50, lvl)
    endfunction
    
    function UnitUpgSysRegisterUnitItem takes integer baseUnit, integer itm, boolean removeItm returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        set udg_unitUpgSysItemBool[ i] = true
        set udg_unitUpgSysMultiItems[ i] = udg_unitUpgSysMultiItems[ i] + 1
        call SaveInteger( udg_unitUpgSysHash, baseUnit, udg_unitUpgSysMultiItems[ i], itm)
        call SaveBoolean( udg_unitUpgSysHash, baseUnit, udg_unitUpgSysMultiItems[ i] + 50, removeItm)
    endfunction
    
    function UnitUpgSysRegisterUnitLvl takes integer baseUnit, integer lvl returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        set udg_unitUpgSysUnitLvl[ i] = lvl
        set udg_unitUpgSysLvlBool[ i] = true
    endfunction
    
    function UnitUpgSysRegisterMultiUnits takes integer baseUnit, integer amount, boolean b returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        set udg_unitUpgSysMultiUnitsBool[ i] = true
        set udg_unitUpgSysMultiUnitsTotal[ i] = amount
        set udg_unitUpgSysMultiUnitsCounter[ i] = 0
        set udg_unitUpgSysMultiUnitsRemove[ i] = b
    endfunction
    
    function UnitUpgSysRegisterUnitEnterRegion takes integer baseUnit, region r returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        local integer id = GetHandleId( r)
        set udg_unitUpgSysRegions[ i] = udg_unitUpgSysRegions[ i] + 1
        call SaveRegionHandle( udg_unitUpgSysHash, baseUnit, udg_unitUpgSysRegions[ i], r)
        // This checks if that region handle is already present in the system.
        set udg_unitUpgSysRegionBool[ i] = true
        if LoadInteger( udg_unitUpgSysHash, id, 0) != id then
            call SaveInteger( udg_unitUpgSysHash, id, 0, id)
            call TriggerRegisterEnterRegion( udg_uniUpgSysAbiTrig, r, null)
        endif
    endfunction
    
    function UnitUpgSysRegisterUnitStats takes integer baseUnit, integer agi, integer intel, integer str, boolean b returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        set udg_unitUpgSysStatBool[ i] = true
        set udg_unitUpgSysMinimumAgi[ i] = agi
        set udg_unitUpgSysMinimumStr[ i] = intel
        set udg_unitUpgSysMinimumInt[ i] = str
        set udg_unitUpgSysIncludeBonuses[ i] = b
    endfunction
    
    function UnitUpgSysRegisterUnitType takes integer baseUnit, integer upgradeUnit, boolean isHero returns nothing
        if not HaveSavedInteger( udg_unitUpgSysHash, baseUnit, 0) then
            set udg_unitUpgSysMaxIndex = udg_unitUpgSysMaxIndex + 1
            call SaveInteger( udg_unitUpgSysHash, baseUnit, 0, udg_unitUpgSysMaxIndex)
            call SaveInteger( udg_unitUpgSysHash, udg_unitUpgSysMaxIndex, 0, baseUnit)
            set udg_unitUpgSysUpgradeUnitType[ udg_unitUpgSysMaxIndex] = upgradeUnit
            set udg_unitUpgSysAbilityBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysItemBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysLvlBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysMultiUnitsBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysRegionBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysStatBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysMultiUnitsRemove[ udg_unitUpgSysMaxIndex] = false
            
            set udg_unitUpgSysMultiAbilities[ udg_unitUpgSysMaxIndex] = 0
            set udg_unitUpgSysMultiItems[ udg_unitUpgSysMaxIndex] = 100
            set udg_unitUpgSysRegions[ udg_unitUpgSysMaxIndex] = 200
        endif
    endfunction
    
    function UnitUpgSysRemoveUnitType takes integer baseUnit returns nothing
        local integer i = LoadInteger( udg_unitUpgSysHash, baseUnit, 0)
        local integer i1 = LoadInteger( udg_unitUpgSysHash, udg_unitUpgSysMaxIndex, 0)
        // if i is not greater then 0 then this unit upgrade doesn't exist.
        if i > 0 then
            // I have to de-index everything and then flush the hashtable.
            set udg_unitUpgSysUpgradeUnitType[ i] = udg_unitUpgSysUpgradeUnitType[ udg_unitUpgSysMaxIndex]
            
            set udg_unitUpgSysAbilityBool[ i] = udg_unitUpgSysAbilityBool[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysAbilityBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysItemBool[ i] = udg_unitUpgSysItemBool[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysItemBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysLvlBool[ i] = udg_unitUpgSysLvlBool[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysLvlBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysMultiUnitsBool[ i] = udg_unitUpgSysMultiUnitsBool[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMultiUnitsBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysRegionBool[ i] = udg_unitUpgSysRegionBool[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysRegionBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysStatBool[ i] = udg_unitUpgSysStatBool[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysStatBool[ udg_unitUpgSysMaxIndex] = false
            set udg_unitUpgSysMultiUnitsRemove[ i] = udg_unitUpgSysMultiUnitsRemove[ i1]
            
            // This moves the max index to the index being removed.
            call SaveInteger(  udg_unitUpgSysHash, i, 0, i1)
            set udg_unitUpgSysIncludeBonuses[ i] = udg_unitUpgSysIncludeBonuses[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMinimumAgi[ i] = udg_unitUpgSysMinimumAgi[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMinimumStr[ i] = udg_unitUpgSysMinimumStr[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMinimumInt[ i] = udg_unitUpgSysMinimumInt[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMultiUnitsCounter[ i] = udg_unitUpgSysMultiUnitsCounter[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMultiUnitsTotal[ i] = udg_unitUpgSysMultiUnitsTotal[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMultiAbilities[ i] = udg_unitUpgSysMultiAbilities[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMultiItems[ i] = udg_unitUpgSysMultiItems[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysRegions[ i] = udg_unitUpgSysRegions[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysUnitLvl[ i] = udg_unitUpgSysUnitLvl[ udg_unitUpgSysMaxIndex]
            set udg_unitUpgSysMaxIndex = udg_unitUpgSysMaxIndex - 1
            call FlushChildHashtable( udg_unitUpgSysHash, baseUnit)
        endif
    endfunction
    
    function UnitUpgSysUnitInRegion takes unit u, integer id, integer i returns boolean
        local integer L2 = 201 // Used for region checking
        loop
            exitwhen L2 > udg_unitUpgSysRegions[ i]
            // If it is equal to one of these it will return true and continue with the upgrade check.
            if IsUnitInRegion( LoadRegionHandle( udg_unitUpgSysHash, id, L2), u) then
                return true
            endif
            set L2 = L2 + 1
        endloop
        return false
    endfunction
    
    
    function UnitUpgSysUnitHasItems takes unit u, integer id, integer i returns boolean
        local integer L = 1 // Used for items
        local integer L1 = 1 // used for items
        local integer array ia
        local boolean array b
        local integer array itm
        local boolean array remove
        loop
            exitwhen L > udg_unitUpgSysMultiItems[ i]
            set b[ L] = false
            set ia[ L] = LoadInteger( udg_unitUpgSysHash, id, 100 + L)
            set remove[ L] = LoadBoolean( udg_unitUpgSysHash, id, 150 + L)
            set itm[ L] = GetItemTypeId( UnitItemInSlot( u, L - 1))
            set L = L + 1
        endloop
        set L = 0
        
        loop
            exitwhen L > udg_unitUpgSysMultiItems[ i]
            loop
                exitwhen L1 > 6
                    if ia[ L] == itm[ L1] and not b[ L1] then
                        set b[ L1] = true
                        set L1 = 6
                    endif
                set L1 = L1 + 1
            endloop
            set L1 = 1
            set L = L + 1
        endloop
        set L = 1
        
        loop
            exitwhen L > udg_unitUpgSysMultiItems[ i]
            // If any of these are false then it does not have the required item.
            if not b[ L] then
                return false
            endif
        endloop
        set L = 1
        loop
            exitwhen L > udg_unitUpgSysMultiItems[ i]
            // If true then it removes the item.
            if remove[ L] then
                call RemoveItem( UnitItemInSlot( u, L - 1))
            endif
            set L = L + 1
        endloop
        
        return true
    endfunction
    
    // This function checks if the unit is able to upgrade by checking all other conditions.
    // I put this in a few different condition checks because it is horrible to check everything in one ITE.
    function UnitUpgSysUpgradeUnitCheck takes unit u, integer id, integer i returns nothing
        local group g
        local real x
        local real y
        local player P
        local integer c = 0
        call BJDebugMsg( "check 1")
        // This checks if certain stats are required for the unit to upgrade.
        if udg_unitUpgSysStatBool[ i] then
            // If these are greater than the heroes agi / intel / str then it exits the check since the unit is not allowed to upgrade.
            if udg_unitUpgSysMinimumAgi[ i] >= GetHeroAgi( u, udg_unitUpgSysIncludeBonuses[ i]) and udg_unitUpgSysMinimumInt[ i] >= GetHeroInt( u, udg_unitUpgSysIncludeBonuses[ i]) and udg_unitUpgSysMinimumStr[ i] >= GetHeroStr( u, udg_unitUpgSysIncludeBonuses[ i]) then
                return
            endif
        endif
        
        // This checks if the unit is the required level to upgrade.
        if udg_unitUpgSysLvlBool[ i] then
            // if false it exits the rest of the unit upgrade check.
            if udg_unitUpgSysUnitLvl[ i] >= GetHeroLevel( u) then
                return
            endif
        endif
        
        // This checks if the unit requires multiple units of the same type to upgrade.
        if udg_unitUpgSysMultiUnitsBool[ i] then
            // if false it exits the rest of the unit upgrade check.
            if udg_unitUpgSysMultiUnitsTotal[ i] > udg_unitUpgSysMultiUnitsCounter[ i] then
                return
            endif
        endif
        
        // This checks if the unit is in the region.
        if udg_unitUpgSysRegionBool[ i] then
            // if false it exits the rest of the unit upgrade check.
            if not UnitUpgSysUnitInRegion( u, id, i) then
                return
            endif
        endif
        
        // This checks if certain items are required for the unit to upgrade.
        // This needs to be last so that it will remove the items if all other requirements are met.
        if udg_unitUpgSysItemBool[ i] then
            // if false it exits the rest of the unit upgrade check.
            if not UnitUpgSysUnitHasItems( u, id, i) then
                return
            endif
        endif
        
        
        set x = GetUnitX( u)
        set y = GetUnitY( u)
        set P = GetOwningPlayer( u)
        // This is where i remove the multiple units to make the upgrade since everything else is true.
        if udg_unitUpgSysMultiUnitsRemove[i] then
            set g = CreateGroup()
            call GroupEnumUnitsInRect( g, bj_mapInitialPlayableArea, null)
            set udg_unitUpgSysMultiUnitsCounter[ i] = 0
            loop
                set u = FirstOfGroup( g)
                exitwhen u == null
                if id == GetUnitTypeId( u) or c >= udg_unitUpgSysMultiUnitsTotal[ i] then
                    set c = c + 1
                    call RemoveUnit( u)
                endif
                call GroupRemoveUnit( g, u)
            endloop
        endif
        call CreateUnit( P, udg_unitUpgSysUpgradeUnitType[ i], x, y, 0.00)
        
        return
    endfunction
    
    function UnitUpgSysRegionCheck takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer id = GetUnitTypeId( u)
        local integer i = LoadInteger( udg_unitUpgSysHash, id, 0)
        if LoadRegionHandle( udg_unitUpgSysHash, id, udg_unitUpgSysRegions[ i]) == GetTriggeringRegion() then
            call UnitUpgSysUpgradeUnitCheck( u, id, i)
        endif
        set u = null
        return false
    endfunction
    
    function UnitUpgSysAbiCastCheck takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer id = GetUnitTypeId( u)
        local integer i = LoadInteger( udg_unitUpgSysHash, id, 0)
        local integer abiId = GetSpellAbilityId()
        local integer abiLvl = GetUnitAbilityLevel( u, abiId)
        local integer L = 1
        loop
            exitwhen L > udg_unitUpgSysMultiAbilities[ i]
            if LoadInteger( udg_unitUpgSysHash, id, L) == abiId and abiLvl >= LoadInteger( udg_unitUpgSysHash, id, L + 50) then
                call UnitUpgSysUpgradeUnitCheck( u, id, i)
            endif
            set L = L + 1
        endloop
        set u = null
        return false
    endfunction
    
    function UnitUpgSysUnitGainsLvl takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer id = GetUnitTypeId( u)
        local integer i = LoadInteger( udg_unitUpgSysHash, id, 0)
        if udg_unitUpgSysUnitLvl[ i] >= GetHeroLevel( u) then
            call UnitUpgSysUpgradeUnitCheck( u, id, i)
        endif
        return false
    endfunction
    
    function UnitUpgSysEnterRegion takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer id = GetUnitTypeId( u)
        local integer i = LoadInteger( udg_unitUpgSysHash, id, 0)
        if udg_unitUpgSysMultiUnitsBool[ i] then
            set udg_unitUpgSysMultiUnitsCounter[ i] = udg_unitUpgSysMultiUnitsCounter[ i] + 1
            if udg_unitUpgSysMultiUnitsCounter[ i] >= udg_unitUpgSysMultiUnitsTotal[ i] then
                call UnitUpgSysUpgradeUnitCheck( u, id, i)
            endif
        endif
        return false
    endfunction
    
    function UnitUpgSysLeaveRegion takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer id = GetUnitTypeId( u)
        local integer i = LoadInteger( udg_unitUpgSysHash, id, 0)
        if udg_unitUpgSysMultiUnitsBool[ i] then
            set udg_unitUpgSysMultiUnitsCounter[ i] = udg_unitUpgSysMultiUnitsCounter[ i] - 1
        endif
        return false
    endfunction

    //===========================================================================
    function InitTrig_UnitUpgradeSystemCode takes nothing returns nothing
        local trigger t = CreateTrigger()
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local trigger t3 = CreateTrigger()
        local region r = CreateRegion()
        call RegionAddRect( r, bj_mapInitialPlayableArea)
        set udg_uniUpgSysAbiTrig = CreateTrigger()
        set udg_unitUpgSysHash = InitHashtable()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerRegisterEnterRegion( t1, r, null)
        call TriggerRegisterLeaveRegion( t2, r, null)
        call TriggerRegisterAnyUnitEventBJ( t3, EVENT_PLAYER_HERO_LEVEL)
        call TriggerAddCondition( t, Condition( function UnitUpgSysAbiCastCheck))
        call TriggerAddCondition( t1, Condition( function UnitUpgSysEnterRegion))
        call TriggerAddCondition( t2, Condition( function UnitUpgSysLeaveRegion))
        call TriggerAddCondition( t3, Condition( function UnitUpgSysUnitGainsLvl))
        call TriggerAddCondition( udg_uniUpgSysAbiTrig, Condition( function UnitUpgSysRegionCheck))
        set t = null
        set t1 = null
        set t2 = null
        set t3 = null
        set r = null
    endfunction

  • DemoCode
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player - Set Player 1 (Red) Current gold to 100000
      • Set tempUnitType1 = Peasant
      • Set tempUnitType2 = Archmage
      • -------- What i am doing here is first creating the upgrade in the system. Then i can assign data to it. --------
      • Custom script: call UnitUpgSysRegisterUnitType( udg_tempUnitType1, udg_tempUnitType2, false)
      • -------- In this i use the base unit to assign a minimum of those units to be created, --------
      • Custom script: call UnitUpgSysRegisterMultiUnits( udg_tempUnitType1, 10, true)

version 1.0.0.0
First version released​


Keywords:
deathismyfriend, dimf, unit upgrade system, unit upgrade, upgrade system, system
Contents

Template Map (Map)

Reviews
Unit Upgrade System v1.0.0.0 | Reviewed by Maker | 29th Sep 2013 APPROVED [tr] The system works, but the demo map could better demonstrate the different possibilities of the system

Moderator

M

Moderator


Unit Upgrade System v1.0.0.0 | Reviewed by Maker | 29th Sep 2013
APPROVED


126248-albums6177-picture66521.png


  • The system works, but the demo map could better demonstrate the
    different possibilities of the system
[tr]
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
Well i'm not even going to review your code, too lazy xd. But there are a few things that i don't understand:
How you upgrade the units.
// // Example: unit A can upgrade to unit B but it can't upgrade to unit B / C / and D
What do you really mean?
You give gold but not lumber (not a big deal to type the lumber cheat but it should give lumber too).
But i believe this system can be useful for some maps.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Well i'm not even going to review your code, too lazy xd. But there are a few things that i don't understand:
How you upgrade the units.

by upgrading units i meant that you can only have one base unit type upgrade.
So if i have a peon upgrade to an archmage then the system can't upgrade the peon to something else.

What do you really mean?
You give gold but not lumber (not a big deal to type the lumber cheat but it should give lumber too).

Not sure what you mean for this...
 
So if i have a peon upgrade to an archmage then the system can't upgrade the peon to something else.

--> sad... it should be doable to make multi-upgrades via utilizing the different methods of upgrading that you made...

it will surely include a few extra calcs on some parts, but at least it gives you more functionality...

Like a squire that obtains a greatsword item will become a knight, while a squire that obtains 10 agi will become a rogue... things like that...
 
You can even simply separate the resource per triggering type [level,stat,number of units etc]... I actually recommend this one... that way we can involve multiple possible paths, while we keep the calculations to minimum since each triggering type becomes independent of each other...

Looking at your code, this isn't hard to implement, you just need to add another parameter for each registry, separate unit-type result entry per triggering type, remove the 2nd unit-type parameter for register unit type and some extra calc to determine which unit-type to transform into

because IMO, a single headed upgrade path is usually simply boring... plus it forces the player to follow a specific path per unit...
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Because it is more efficient and complex than GUI.

Yes Jass is more efficient than GUI. But that is not why I combine GUI and JASS.

I combine it with GUI to make it easy for GUIers to use. This way more people can use the resources since a JASSer can easily change the stuff to pure jass if they want.
Another reason is writing JASS code is a lot faster for me. I wrote this in about 35 minutes. If i wrote this in GUI it would take at minimum a few hours.
 
Top