- Joined
- Sep 18, 2007
- Messages
- 104
Ok before we begin, I am just starting JASS, so don't be to harsh for my ignorance.
Well made a GUI item system that upgrades an item everytime you buy said item. I converted the system to JASS and tried optimizing it but I ran into problems and now the items won't combine properly.
Here's the trigger:
Well made a GUI item system that upgrades an item everytime you buy said item. I converted the system to JASS and tried optimizing it but I ran into problems and now the items won't combine properly.
Here's the trigger:
JASS:
globals
integer ItemInt = 0
effect SFX
real x
real y
constant string STRING = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl"
constant string ATTACH = "overhead"
constant integer ITEM1 = 'I000'
constant integer ITEM2 = 'I001'
constant integer ITEM3 = 'I002'
endglobals
scope Boots initializer Init
private function Conditions takes nothing returns boolean
if ( not ( GetItemTypeId(GetManipulatedItem()) == ITEM1 ) ) then
return false
endif
return true
endfunction
private function Trig_Boots_ItemInt takes nothing returns boolean
if ( not (ItemInt == 2) ) then
return false
endif
return true
endfunction
private function Trig_Boots_Check takes nothing returns boolean
if (not (GetItemTypeId(UnitItemInSlot(GetManipulatingUnit(), GetForLoopIndexA())) == ITEM1 ) ) then
return false
endif
return true
endfunction
private function Trig_Boots_1 takes nothing returns boolean
return (GetItemTypeId(UnitItemInSlot(GetManipulatingUnit(), GetForLoopIndexA())) == ITEM1 )
endfunction
private function Trig_Boots_2 takes nothing returns boolean
return GetItemTypeId(UnitItemInSlot(GetManipulatingUnit(), GetForLoopIndexA())) == ITEM2
endfunction
private function Trig_Boots_Func002Func001C takes nothing returns boolean
if ( not GetBooleanOr( Trig_Boots_1(), Trig_Boots_2() ) ) then
return false
endif
return true
endfunction
private function Actions takes nothing returns nothing
set ItemInt = 0
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( Trig_Boots_Func002Func001C() ) then
if ( Trig_Boots_Check() ) then
set ItemInt = ( ItemInt + 1 )
if ( Trig_Boots_ItemInt() ) then
set x = GetUnitX(GetManipulatingUnit())
set y = GetUnitY(GetManipulatingUnit())
call AddSpecialEffectTarget( STRING, GetManipulatingUnit(), ATTACH )
set SFX = GetLastCreatedEffectBJ()
call RemoveItem( GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), ITEM1) )
call RemoveItem( GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), ITEM1) )
call CreateItem( ITEM2, x, y )
call UnitAddItem( GetManipulatingUnit(), GetLastCreatedItem() )
call DisplayTimedTextToPlayer(Player(0),0,0,60,"Debug1")
call DestroyEffect(SFX)
set x = 0
set y = 0
else
endif
else
set x = GetUnitX(GetManipulatingUnit())
set y = GetUnitY(GetManipulatingUnit())
call AddSpecialEffectTarget( STRING, GetManipulatingUnit(), ATTACH )
set SFX = GetLastCreatedEffectBJ()
call RemoveItem( GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), ITEM1) )
call RemoveItem( GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), ITEM2) )
call CreateItem( ITEM3, x, y )
call UnitAddItem( GetManipulatingUnit(), GetLastCreatedItem() )
call DisplayTimedTextToPlayer(Player(0),0,0,60,"Debug2")
call DestroyEffect(SFX)
set x = 0
set y = 0
endif
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trig, Condition( function Conditions ) )
call TriggerAddAction( trig, function Actions )
endfunction
endscope