So, I'm rather new at JASS. I know how to look at a lot of the coding now, but I really have no idea how to make it from scratch. I tried my best on this, and clearly I cannot get it right, nor do I know how many memory leaks it has. I'd greatly appreciate if you could fix this up for me so that I could use it, with the concept of making a unit that is buildable do the forging, not a preplaced unit. Here it is:
function Forge_System_Actions takes nothing returns nothing
local unit u = GetAttachedUnit()
local item i = GetAttachedItem()
if GetUnitTypeId(u) == 'hbla' then
if GetItemTypeId(belv) == true and GetItemTypeId(bspd) == true then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl",u,"origin"))
call DisplayTextToForce(bj_FORCE_PLAYER[GetConvertedPlayerId(GetOwningPlayer(u))-1],"|cff00dd00Item Forged|r")
call RemoveItem(belv)
call RemoveItem(bspd)
call UnitAddItemByIdSwapped('rat6',u)
endif
endif
set i = null
set u = null
endfunction
//===========================================================================
function InitTrig_Forge_System takes nothing returns nothing
set gg_trg_Forge_System = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Forge_System, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Forge_System, function Forge_System_Actions )
endfunction
function Forge_System_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local item i = GetManipulatedItem()
if GetUnitTypeId(u) == 'hbla' then
//second if should reference 2 items. GetItemTypeId is used the same as GetUnitTypeId
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl",u,"origin"))
call DisplayTextToForce(bj_FORCE_PLAYER[GetPlayerId(GetOwningPlayer(u))],"|cff00dd00Item Forged|r")//GetConvertedPlayerId-1 is the same as GetPlayerId because GetConvertedPlayerId is GetPlayerId + 1
//where you remove the items, this would be done just like removing a unit.
call UnitAddItemById(u,'rat6')//swapped funcs suck
endif
endif
set i = null
set u = null
endfunction
//===========================================================================
function InitTrig_Forge_System takes nothing returns nothing
set gg_trg_Forge_System = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Forge_System, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Forge_System, function Forge_System_Actions )
endfunction
So the main function that I jacked up was my variables? Heh.
And as far as the adding new units and junk, I got those right, I think... in my post, or did I do them incorrectly? Blah.
function Forge_System_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local item i = GetManipulatedItem()
if GetUnitTypeId(u) == 'hbla' then
if GetItemTypeId(belv) == true and GetItemTypeId(bspd) == true then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl",u,"origin"))
call DisplayTextToForce(bj_FORCE_PLAYER[GetPlayerId(GetOwningPlayer(u))],"|cff00dd00Item Forged|r")//GetConvertedPlayerId-1 is the same as GetPlayerId because GetConvertedPlayerId is GetPlayerId + 1
call RemoveItem('belv')
call RemoveItem('bspd')
call UnitAddItemById(u,'rat6')
endif
endif
set i = null
set u = null
endfunction
//===========================================================================
function InitTrig_Forge_System takes nothing returns nothing
set gg_trg_Forge_System = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Forge_System, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Forge_System, function Forge_System_Actions )
endfunction
Thank you very much, that helped a lot. I'm still new at JASS, so I'll make n00b mistakes nonstop because I really haven't seen how things are supposed to be done much at all. But I'm running into another problem:
call RemoveItem('belv')
How to change this for it to work? Everything else works except this part now.... which was that which was causing my error.
Everything in computers is numbers. An item(like i) is a number pointing to more numbers in memory, which control all aspects of the "item". 'belv' is another number(or several, really), which labels the type of item.
So picture this:
Item in memory: [number] ItemType [number] Model [number] Position X [number] Position Y [number] ChargesLeft [number] ...
Ok, so an item has all these numbers contained within, and JASS functions let you aquire them to compare:
function myItemFunc takes nothing returns nothing
local item i = GetManipulatedItem()
if(GetItemTypeId(i) == 'belv') then
endif
if(GetItemTypeId(i) == 1650814070) then
endif
if(GetItemX(i) == 1024.00) then
if(GetItemY(i) == -512.00) then
endif
endif
if(GetItemCharges(i) == 4) then
endif
endfunction
[number] Model [number] Position X [number] Position Y
if(GetItemTypeId(i) == 1650814070) then endif
if(GetItemX(i) == 1024.00) then if(GetItemY(i) == -512.00) then endif endif
Anyways, it's all excess weight to me, what I'm truely looking for is a way to combine items into another item, I don't are whether triggered by the casting of an ability, or by instant transmutating upon placing the items in the required unit.
It's not working at the minute, so I feel troubled, hah.
is the X - Coordinate of the Item on the map ( yes, wc3 runs points like a graph )
any location is an (x,y) data field.
and that string of random numbers is what some item rawcode, maybe 'belv' really is. that 4-digit letter-number sequence is just an easier way to write it, it really refers to a ten-digit number