• 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.

How to make new classifications

Status
Not open for further replies.
Level 9
Joined
Dec 12, 2007
Messages
489
if you want, rather than make new classification, you can just change existing unit classification, possible unit classification to changes are Giant, Tauren, Mechanical, and Undead. you can change those in Advanced -> Game Interface.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
You can just use integers to simulare classes.
Example:
1 = Demon
2 = Forsaken
3 = etc...

To add a classification to a unit just use those integers as child key for a hashtable. Example:
Action - Save boolean "true" in hashtable "myHashtable" parent key (UnitTypeId of (Grunt)) child key "2"

This adds a classification "2" (=Forsaken) to the unittype "Grunt".


Its just an example, but i think you get my point? To check a units classification just read from the hashtable...
 
Level 8
Joined
Feb 3, 2013
Messages
277
^ WHat he said, if you have a unit indexer it should be easy.
like take bribes gui one.

Here's an example

JASS:
library UnitClassification initializer init

    globals
        integer array class
        integer array creep
        integer array hard
        integer array boss
        integer array ancient
        
        constant integer ANCIENT        = 4
        constant integer BOSS           = 3
        constant integer HARD           = 2
        constant integer CREEP          = 1
    endglobals
    
    private function setClass takes nothing returns boolean
        local integer i
        
        set i = 0
        loop
            exitwhen i == 3
            if GetUnitTypeId(udg_UDexUnits[udg_UDex]) == creep[i] then
                set class[GetUnitUserData(udg_UDexUnits[udg_UDex])] = CREEP
                call DisplayTextToPlayer(Player(0), 0, 0, GetUnitName(udg_UDexUnits[udg_UDex]) + " has entered as a creep type unit!")
            endif
            set i = i + 1
        endloop
        
        set i = 0
        loop
            exitwhen i == 2
            if GetUnitTypeId(udg_UDexUnits[udg_UDex]) == hard[i] then
                set class[GetUnitUserData(udg_UDexUnits[udg_UDex])] = HARD
                call DisplayTextToPlayer(Player(0), 0, 0, GetUnitName(udg_UDexUnits[udg_UDex]) + " has entered as a hard type unit!")
            endif
            set i = i + 1
        endloop
        
        set i = 0
        loop
            exitwhen i == 2
            if GetUnitTypeId(udg_UDexUnits[udg_UDex]) == boss[i] then
                set class[GetUnitUserData(udg_UDexUnits[udg_UDex])] = BOSS
                call DisplayTextToPlayer(Player(0), 0, 0, GetUnitName(udg_UDexUnits[udg_UDex]) + " has entered as a boss type unit!")
            endif
            set i = i + 1
        endloop
        
        set i = 0
        loop
            exitwhen i == 2
            if GetUnitTypeId(udg_UDexUnits[udg_UDex]) == ancient[i] then
                set class[GetUnitUserData(udg_UDexUnits[udg_UDex])] = ANCIENT
                call DisplayTextToPlayer(Player(0), 0, 0, GetUnitName(udg_UDexUnits[udg_UDex]) + " has entered as a ancient type unit!")
            endif
            set i = i + 1
        endloop
        
        return false 
    endfunction
        
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00)
        call TriggerAddCondition(t, function setClass)
        
        set t = null
        
        set creep[0] = 'opeo'
        set creep[1] = 'ogru'
        
        set hard[0] = 'ohun'
        set hard[1] = 'orai'
        
        set boss[0] = 'otau'
        set boss[1] = 'okod'
        
        set ancient[0] = 'owyv'
        set ancient[1] = 'otbr'
    endfunction
    
endlibrary
JASS:
library ChangeDamage initializer init 

    globals
        string array PLAYER_COLOR
    endglobals
    
    private function mod takes nothing returns boolean
        if class[GetUnitUserData(udg_DamageEventSource)] == CREEP then
            set udg_DamageEventAmount = udg_DamageEventAmount * .85
        elseif class[GetUnitUserData(udg_DamageEventSource)] == HARD then
            set udg_DamageEventAmount = udg_DamageEventAmount * 1.05
        elseif class[GetUnitUserData(udg_DamageEventSource)] == BOSS then
            set udg_DamageEventAmount = udg_DamageEventAmount * 1.25
        elseif class[GetUnitUserData(udg_DamageEventSource)] == ANCIENT then
            set udg_DamageEventAmount = udg_DamageEventAmount * 1.45
        endif
        
        return false 
    endfunction
    
    private function dmgText takes nothing returns boolean
        if class[GetUnitUserData(udg_DamageEventSource)] == CREEP then
            call ArcingTextTag.create(PLAYER_COLOR[GetPlayerId(GetOwningPlayer(udg_DamageEventSource))] + "CREEP: " + I2S(R2I(udg_DamageEventAmount)), udg_DamageEventTarget)
        elseif class[GetUnitUserData(udg_DamageEventSource)] == HARD then
            call ArcingTextTag.create(PLAYER_COLOR[GetPlayerId(GetOwningPlayer(udg_DamageEventSource))] + "HARD: " + I2S(R2I(udg_DamageEventAmount)), udg_DamageEventTarget)
        elseif class[GetUnitUserData(udg_DamageEventSource)] == BOSS then
            call ArcingTextTag.create(PLAYER_COLOR[GetPlayerId(GetOwningPlayer(udg_DamageEventSource))] + "BOSS: " + I2S(R2I(udg_DamageEventAmount)), udg_DamageEventTarget)
        elseif class[GetUnitUserData(udg_DamageEventSource)] == ANCIENT then
            call ArcingTextTag.create(PLAYER_COLOR[GetPlayerId(GetOwningPlayer(udg_DamageEventSource))] + "ANCIENT: " + I2S(R2I(udg_DamageEventAmount)), udg_DamageEventTarget)
        endif
        
        return false 
    endfunction
        
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local trigger t2 = CreateTrigger()
        
        call TriggerRegisterVariableEvent(t, "udg_DamageModifierEvent", EQUAL, 1.00)
        call TriggerAddCondition(t, function mod)
        call TriggerRegisterVariableEvent(t2, "udg_DamageEvent", EQUAL, 1.00)
        call TriggerAddCondition(t2, function dmgText)
            
        set PLAYER_COLOR[0] = "|c00FF0303"
        set PLAYER_COLOR[1] = "|c000042FF"
        set PLAYER_COLOR[2] = "|c001CE6B9"
        set PLAYER_COLOR[3] = "|c00540081"
        set PLAYER_COLOR[4] = "|c00FFFC01"
        set PLAYER_COLOR[5] = "|c00fEBA0E"
        set PLAYER_COLOR[6] = "|c0020C000"
        set PLAYER_COLOR[7] = "|c00E55BB0"
        set PLAYER_COLOR[8] = "|c00959697"
        set PLAYER_COLOR[9] = "|c007EBFF1"
        set PLAYER_COLOR[10] = "|c00106246"
        set PLAYER_COLOR[11] = "|c004E2A04"
        set t = null
        set t2 = null
    endfunction
    
endlibrary
 

Attachments

  • aaa.w3x
    33.2 KB · Views: 54
Level 14
Joined
Jun 27, 2008
Messages
1,325
You dont need a unit indexer since unit classifications are unittype specific, not unit specific.

Also i think he doesnt know jass ... ppl who know jass should be able to come up with such a solution on their own.
 
@msongyboi
You could use textmacro in your code to reduce it's size and make it more readable.
It's not a big deal now, but if you add like 4 more classes it will become messy, not to
mention if you decide to add just 1 variable into if statement, pain in the ass.

JASS:
library ChangeDamage initializer init 

    globals
        string array PLAYER_COLOR
    endglobals
    
    //! textmacro class_mod takes CLASS, VALUE
        if class[GetUnitUserData(udg_DamageEventSource)] == $CLASS$ then
            set udg_DamageEventAmount = udg_DamageEventAmount * $VALUE$
        endif
    //! endtextmacro
    
    //! textmacro class_dmgText takes CLASS
        if class[GetUnitUserData(udg_DamageEventSource)] == $CLASS$ then
            call ArcingTextTag.create(PLAYER_COLOR[GetPlayerId(GetOwningPlayer(udg_DamageEventSource))] + "$CLASS$: " + I2S(R2I(udg_DamageEventAmount)), udg_DamageEventTarget)
        endif
    //! endtextmacro
    
    private function mod takes nothing returns boolean
        //! runtextmacro class_mod("CREEP","0.85")
        //! runtextmacro class_mod("HARD","1.05")
        //! runtextmacro class_mod("BOSS","1.25")
        //! runtextmacro class_mod("ANCIENT","1.45")
        
        return false 
    endfunction
    
    private function dmgText takes nothing returns boolean
        //! runtextmacro class_dmgText("CREEP")
        //! runtextmacro class_dmgText("HARD")
        //! runtextmacro class_dmgText("BOSS")
        //! runtextmacro class_dmgText("ANCIENT")
        
        return false 
    endfunction
        
    private function init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterVariableEvent(trig, "udg_DamageModifierEvent", EQUAL, 1.00)
        call TriggerAddCondition(trig, function mod)
        set trig = CreateTrigger()
        call TriggerRegisterVariableEvent(trig, "udg_DamageEvent", EQUAL, 1.00)
        call TriggerAddCondition(trig, function dmgText)
        set trig = null  
        
        set PLAYER_COLOR[0] = "|c00FF0303"
        set PLAYER_COLOR[1] = "|c000042FF"
        set PLAYER_COLOR[2] = "|c001CE6B9"
        set PLAYER_COLOR[3] = "|c00540081"
        set PLAYER_COLOR[4] = "|c00FFFC01"
        set PLAYER_COLOR[5] = "|c00fEBA0E"
        set PLAYER_COLOR[6] = "|c0020C000"
        set PLAYER_COLOR[7] = "|c00E55BB0"
        set PLAYER_COLOR[8] = "|c00959697"
        set PLAYER_COLOR[9] = "|c007EBFF1"
        set PLAYER_COLOR[10] = "|c00106246"
        set PLAYER_COLOR[11] = "|c004E2A04"
    endfunction
    
endlibrary

True, IF-s are not nested here but even that can be easily handled.
 
Status
Not open for further replies.
Top