HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Many IMPORTANT Questions about unit type id and ability id

02-24-2007, 10:01 PM#1
Mythic Fr0st
Ok when I do this, it creates 2 errors
Collapse JASS:
    loop
        exitwhen Loop > udg_Number_Of_HeroesNAbilities_Int
            if GetUnitTypeId(GetSoldUnit()) == udg_M2B_Unit_List[Loop] then
                call UnitAddAbilityBJ(udg_M2B_Spell_Book_List[Loop], udg_Hero[pn])
            endif
            set Loop = Loop + 1
    endloop

! Unable to convert ability (M2B_Spell_Book_List[]) to Integer
! Unable to convert unit type(M2B_Unit_List[]) to Integer

Im not sure why, but I think it may be causing errors in WE

Although when I actually do the same trigger in GUI, its looks exactly the same...

> whole trigger

Hidden information:
Collapse JASS:
globals
unit array udg_Hero
rect gg_rct_Rect_035
boolean array udg_Attack_Mastery
boolean array udg_Magic_Mastery
boolean array udg_Strength_Mastery
unit array udg_Backpack_Unit
unittype array udg_Backpack_Type
boolean array udg_Player_Has_Bought_Hero
dialog array udg_Alignment_Dialog
trigger gg_trg_SelectAlignmentDialog
button array udg_Alignment_Dialog_Button
integer array udg_Alignment_Level
boolean array udg_Alignment_Bool
string array udg_Alignment_String
trigger gg_trg_Move_To_Base_4
ability array udg_M2B_Spell_Book_List
unittype array udg_M2B_Unit_List
integer udg_Number_Of_HeroesNAbilities_Int
endglobals

function sell_c1 takes nothing returns boolean
 local boolean c1 = GetUnitTypeId(GetTriggerUnit()) == 'n00J'
    return c1
endfunction

function rem_hs takes nothing returns nothing
    call RemoveUnit(GetEnumUnit())
endfunction

function Alignment_Option takes nothing returns nothing
 local integer pn = GetPlayerId(GetTriggerPlayer())+1
 local string array al
 local integer i = 0
 local boolean array b
 local string array d
    set d[0] = GetPlayerName(Player(pn-1))+" has decided to become Righteous"
    set d[1] = GetPlayerName(Player(pn-1))+" has decided to become Unholy"
    set b[0] = true
    set b[1] = false
    set al[0] = "You are Righteous, [Level "+I2S(udg_Alignment_Level[pn])+"]"
    set al[1] = "You are Unholy, [Level "+I2S(udg_Alignment_Level[pn])+"]"
    loop
        exitwhen i > 1
            if udg_Alignment_Dialog_Button[i] == GetClickedButtonBJ() then
                set udg_Alignment_Bool[i] = b[i]
                set udg_Alignment_String[i] = al[i]
                call DisplayTextToForce(GetPlayersAll(), "|c00008B"+d[i]+"|r") 
            endif
            set i = i + 1
    endloop
endfunction

//            if udg_Alignment_Dialog_Button[i] == GetClickedButtonBJ() then
//    set udg_Alignment_Dialog_Button[1] = GetLastCreatedButtonBJ()
                  

function sell takes nothing returns nothing
 local unit u = GetTriggerUnit()
 local unit s = GetSoldUnit()
 local integer pn = GetPlayerId(GetOwningPlayer(s))+1
 local player p = Player(pn-1)
 local rect r = gg_rct_Rect_035
 local group g = GetUnitsOfPlayerAndTypeId(p, 'n000')
 local location loc = GetUnitLoc(s)
 local integer x = GetRandomInt(0,1)
 local location loc2 = GetRectCenter(r)
 local integer Loop = 1
    call PanCameraToTimedLocForPlayer(p, loc2, 0.00)
    set udg_Hero[pn] = s
    call ForGroup(g, function rem_hs)
    call DisplayTextToForce(GetPlayersAll(), "|c9400D3"+GetPlayerName(p)+" has just bought the hero "+GetUnitName(s)+"|r")
    call DisplayTextToPlayer(p, 0, 0, "|c8B4513The default stat that has been set is \"attack\", you can change this by typing -strength, or -magic|r")
    set udg_Attack_Mastery[pn] = true
    set udg_Strength_Mastery[pn] = false
    set udg_Magic_Mastery[pn] = false
    call AdjustPlayerStateBJ(400, p, PLAYER_STATE_RESOURCE_GOLD)
    call SetUnitPositionLoc(udg_Hero[pn], loc2)
    set udg_Backpack_Unit[pn] = CreateUnit(p, udg_Backpack_Type[x], GetRectCenterX(r), GetRectCenterY(r), 270.00)
    call SetUnitPositionLoc(udg_Backpack_Unit[pn], loc2)
    call UnitAddTypeBJ(UNIT_TYPE_MECHANICAL, GetSoldUnit())
    call SelectUnitForPlayerSingle(s, p)
    set udg_Player_Has_Bought_Hero[pn] = true
    if GetUnitTypeId(s) == 'N00U' then
        call UnitAddAbility(s, 'A01G')
    endif
    call DialogSetMessageBJ(udg_Alignment_Dialog[pn], "|cffff0000Select your alignment|r")
    call DialogAddButtonBJ(udg_Alignment_Dialog[pn], "|cfffff000Become Righteous|r")
    set udg_Alignment_Dialog_Button[0] = GetLastCreatedButtonBJ()
    call DialogAddButtonBJ(udg_Alignment_Dialog[pn], "|cffff0000Become Unholy|r")
    set udg_Alignment_Dialog_Button[1] = GetLastCreatedButtonBJ()
    call DialogDisplayBJ(true, udg_Alignment_Dialog[pn], p)
    call BJDebugMsg("This trigger should work, and you should see an alignment dialog, however if it doesnt or you dont see the dialog, email me at [email][email protected][/email]")
    call ResetTrigger(gg_trg_SelectAlignmentDialog)
    call TriggerRegisterDialogEventBJ(gg_trg_SelectAlignmentDialog, udg_Alignment_Dialog[pn])
    call TriggerAddAction(gg_trg_SelectAlignmentDialog, function Alignment_Option)
    loop
        exitwhen Loop > udg_Number_Of_HeroesNAbilities_Int
            if GetUnitTypeId(GetSoldUnit()) == udg_M2B_Unit_List[Loop] then
                call UnitAddAbilityBJ(udg_M2B_Spell_Book_List[Loop], udg_Hero[pn])
            endif
            set Loop = Loop + 1
    endloop
    call RemoveLocation(loc)
    call RemoveLocation(loc2)
    call DestroyGroup(g)
    set loc = null
    set loc2 = null
    set g = null
    set p = null
    set r = null
endfunction

//===========================================================================
function InitTrig_Move_To_Base takes nothing returns nothing
    set gg_trg_Move_To_Base = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Move_To_Base, EVENT_PLAYER_UNIT_SELL )
    call TriggerAddCondition(gg_trg_Move_To_Base, Condition(function sell_c1))
    call TriggerAddAction(gg_trg_Move_To_Base, function sell)
endfunction
02-24-2007, 10:06 PM#2
Softmints
Perhaps it's a quick fix, but there are variable types called 'Unit Type' and 'Ability'. Using these over integers could help, at least for the time being?
02-24-2007, 10:09 PM#3
The)TideHunter(
Unit Type and Ability are both integers. They are wrapped in the ' character.
02-24-2007, 10:10 PM#4
Mythic Fr0st
SO DO I need to about the ' tags around my unittype & ability variables in that context
02-24-2007, 10:29 PM#5
The)TideHunter(
An Ability is an integer
An Unit Type is a integer.

An ability is something like 'aloc'. The first letter defines the type, in this case "ability", then the next 3 letters/numbers somehow describe it, if its a blizzard made ability thats comes with wc3, it will be part of the abilities name.
If its a custom ability, it will be a Id of the ability, like 'a000', 'a001'.
Unit Type's, upgrades, destructables, items, buffs, doodads, they are all integers to define types.

First Letters of Rawcodes:

Human Meele Type = h
Human Campaign Type = n
Orc Meele Type = o
Orc Campgin Type = o
Undead Meele Type = u
Undead Campaign Type = u
Nightelf Meele Type = e
Nightelf Campaign Type = e & n
Item = Nickname for item
Destrucable = Unknown
Doodad = Unknown
Ability (Normal) = a
Ability (Special) = s
Buffs (Normal) = b
Buffs (Effect) = x
Upgrade = r

To find out a rawcode (these numbers and letters, which are integers, also know as unit types, abilities etc), you go into the object editor and Ctrl+D.

They are all integers, wrapped in ' to form integers.
Like 'hpea' is peasent.
'hfoo' is footmen.
If the editor is giving you a error, please take a screenshot, because its seriously fucked up if its not a mistake.
02-25-2007, 07:48 AM#6
Mythic Fr0st
uhh, I think I thought I mentioned it was Jasscraft, giving the error, and not WE, I was just wondering why jasscraft did it

I didnt know that about the first letter though o_O
02-25-2007, 08:05 AM#7
Captain Griffen
Correction: itemtype, unittype and ability types are not integers. They are handles.

Collapse JASS:
type ability            extends     handle
type unittype           extends     handle
type itemtype           extends     handle

However, these are very rarely (if ever?) used in JASS. Normally it wants the ID, which is an integer, given in the object editor like 'A000' (ASCII).
02-25-2007, 10:25 AM#8
The)TideHunter(
Yes, maybe itemtype, unittype and ability are, but Ability, Unit Type, and Item Type, the GUI variables we are talking about, are not, they are integers.
02-25-2007, 10:40 AM#9
Rising_Dusk
Collapse JASS:
    globals
        unit array udg_Hero
        rect gg_rct_Rect_035
        boolean array udg_Attack_Mastery
        boolean array udg_Magic_Mastery
        boolean array udg_Strength_Mastery
        unit array udg_Backpack_Unit
        unittype array udg_Backpack_Type
        boolean array udg_Player_Has_Bought_Hero
        dialog array udg_Alignment_Dialog
        trigger gg_trg_SelectAlignmentDialog
        button array udg_Alignment_Dialog_Button
        integer array udg_Alignment_Level
        boolean array udg_Alignment_Bool
        string array udg_Alignment_String
        trigger gg_trg_Move_To_Base_4
        ability array udg_M2B_Spell_Book_List
        unittype array udg_M2B_Unit_List
        integer udg_Number_Of_HeroesNAbilities_Int
    endglobals


    loop
        exitwhen Loop > udg_Number_Of_HeroesNAbilities_Int
            if GetUnitTypeId(GetSoldUnit()) == udg_M2B_Unit_List[Loop] then
                call UnitAddAbility(udg_Hero[pn], udg_M2B_Spell_Book_List[Loop])
            endif
            set Loop = Loop + 1
    endloop
    
    native UnitAddAbility takes unit whichUnit, integer AbilityId returns boolean

Datatype ability is a HANDLE, not an INTEGER.
The ID's are all of datatype INTEGER, that is how ALL raw codes are.
You can not typecast an ability to an integer. [Without H2I() granted, but that gives the wrong integer for our purposes here]

You're simply using the wrong datatype as an argument to the function.
Just store the ability ids as datatype integer into an integer array and you avert this problem.
02-25-2007, 11:07 AM#10
Chocobo
There's also some errors :

Collapse JASS:
unittype array udg_M2B_Unit_List

if GetUnitTypeId(GetSoldUnit()) == udg_M2B_Unit_List[Loop] then //line 99

Should return an integer, not a unittype.
integer array udg_M2B_Unit_List then.


Collapse JASS:
unittype array udg_Backpack_Type

set udg_Backpack_Unit[pn] = CreateUnit(p, udg_Backpack_Type[x], GetRectCenterX(r), GetRectCenterY(r), 270.00)

Again.
integer array udg_Backpack_Type

That are the only problems.