U
Unregistered
Guest
Hi, I've got a really bad problem and i thought this is the right playe to look for help...
I'm working on an AoS-type map with a concept like battle ships or tank wars... now i want to give players the ability to combine or upgrade certain weapons. I've written all the items into arrays like this:
Combination:
feature_CombineItem1[x] + feature_CombineItem2[x] + feature_CombineItem3[x] are needed in the inventory
to get=> feature_CombineItem4[x]
where not always 3 items are needed, if there are only 2 items to combine, CombineItem2 and 3 are the same.
Upgrades:
feature_UpgradeItem1[x] in the inventory + feature_UpgradeCost[x] of gold is needed to get=> feature_UpgradeItem2[x]
the upgrades and combinations should be launched by using an ability ("Combine/Upgrade Items") on an item in the inventory... then a trigger is launched that checks which upgrades or combinations are possible, those possibilities are listed on a dialog and saved in an array, the dialog is shown to the player and the selected option is done...
i haven't worked out the trigger fully because i couldn't test it yet... my problem is that everytime i want to test the map, the editor crashes down and i have no idea why... the error must be in this trigger because the editor works when i disable the trigger... can you please help me?
this is the trigger:
I'm working on an AoS-type map with a concept like battle ships or tank wars... now i want to give players the ability to combine or upgrade certain weapons. I've written all the items into arrays like this:
Combination:
feature_CombineItem1[x] + feature_CombineItem2[x] + feature_CombineItem3[x] are needed in the inventory
to get=> feature_CombineItem4[x]
where not always 3 items are needed, if there are only 2 items to combine, CombineItem2 and 3 are the same.
Upgrades:
feature_UpgradeItem1[x] in the inventory + feature_UpgradeCost[x] of gold is needed to get=> feature_UpgradeItem2[x]
the upgrades and combinations should be launched by using an ability ("Combine/Upgrade Items") on an item in the inventory... then a trigger is launched that checks which upgrades or combinations are possible, those possibilities are listed on a dialog and saved in an array, the dialog is shown to the player and the selected option is done...
i haven't worked out the trigger fully because i couldn't test it yet... my problem is that everytime i want to test the map, the editor crashes down and i have no idea why... the error must be in this trigger because the editor works when i disable the trigger... can you please help me?
this is the trigger:
JASS:
function Trig_CombineUpgrade_3_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 039;A036039; ) ) then
return false
endif
return true
endfunction
function IsItemUpgradeable takes nothing returns boolean
if ( ( GetItemTypeId(GetSpellTargetItem()) == udg_feature_UpgradeItem1[GetForLoopIndexA()] ) ) then
return true
endif
return false
endfunction
function IsItemCombinable takes nothing returns boolean
if ( ( GetItemTypeId(GetSpellTargetItem()) == udg_feature_CombineItem1[GetForLoopIndexA()] ) ) then
return true
endif
if ( ( GetItemTypeId(GetSpellTargetItem()) == udg_feature_CombineItem2[GetForLoopIndexA()] ) ) then
return true
endif
if ( ( GetItemTypeId(GetSpellTargetItem()) == udg_feature_CombineItem3[GetForLoopIndexA()] ) ) then
return true
endif
return false
endfunction
function IsUpgradePossible takes nothing returns boolean
if ( IsItemUpgradeable() ) then
if ( GetPlayerState(GetOwningPlayer(GetSpellAbilityUnit()), PLAYER_STATE_RESOURCE_GOLD) >= udg_feature_UpgradeCost[GetForLoopIndexA()] ) then
return true
endif
endif
return false
endfunction
function IsCombinePossible takes nothing returns boolean
if ( IsItemCombinable() ) then
if ( not ( UnitHasItemOfTypeBJ(GetSpellAbilityUnit(), udg_feature_CombineItem1[GetForLoopIndexA()] ) ) ) then
return false
else
if ( not ( UnitHasItemOfTypeBJ(GetSpellAbilityUnit(), udg_feature_CombineItem2[GetForLoopIndexA()] ) ) ) then
return false
else
if ( not ( UnitHasItemOfTypeBJ(GetSpellAbilityUnit(), udg_feature_CombineItem3[GetForLoopIndexA()] ) ) ) then
return false
else
return true
endif
endif
endif
endfunction
function GetFirstFreePossIndex takes nothing returns integer
local integer i = 1
loop
exitwhen i == 20
if ( poss<i> == 0 ) then
return i
endif
set i = i + 1
endloop
return 0
endfunction
function Trig_CombineUpgrade_3_Actions takes nothing returns nothing
local integer array poss
local string array posstype
local dialog possdialog
local button array possbutton
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 20
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( IsUpgradePossible() ) then
call DialogAddButtonBJ( possdialog, ( GetItemName(CreateItemLoc(udg_feature_UpgradeItem2[GetForLoopIndexA()], udg_temp_Point[0])) + ( ": " + ( I2S(udg_feature_UpgradeCost[GetForLoopIndexA()]) + " Gold" ) ) ) )
set possbutton[GetFirstFreePossIndex()] = GetLastCreatedButtonBJ()
set posstype[GetFirstFreePossIndex()] = "upgrade"
set poss[GetFirstFreePossIndex()] = GetForLoopIndexA()
endif
if ( IsCombinePossible() ) then
call DialogAddButtonBJ( possdialog, ( GetItemName(CreateItemLoc(udg_feature_CombineItem4[GetForLoopIndexA()], udg_temp_Point[0])) + ( ": " + ( GetItemName(CreateItemLoc(udg_feature_CombineItem1[GetForLoopIndexA()], udg_temp_Point[0])) + ( " + " + GetItemName(CreateItemLoc(udg_feature_CombineItem2[GetForLoopIndexA()], udg_temp_Point[0])) ) ) ) ) )
set possbutton[GetFirstFreePossIndex()] = GetLastCreatedButtonBJ()
set posstype[GetFirstFreePossIndex()] = "combine"
set poss[GetFirstFreePossIndex()] = GetForLoopIndexA()
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
//------------------------------------------------------------------------------------
call DialogSetMessageBJ( possdialog, "Possible Items:" )
call DialogAddButtonBJ( possdialog, "Cancel" )
call DialogDisplayBJ( true, possdialog, GetOwningPlayer(GetSpellAbilityUnit()) )
call WaitForDialogEvent( possdialog, 0.10 )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 20
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( GetClickedButtonBJ() == possbutton[GetForLoopIndexA()] ) then
if ( posstype[GetForLoopIndexA()] == "upgrade" ) then
call AdjustPlayerStateBJ( ( -1 * udg_feature_UpgradeCost[poss[GetForLoopIndexA()]] ), GetOwningPlayer(GetSpellAbilityUnit()), PLAYER_STATE_RESOURCE_GOLD )
call RemoveItem( GetItemOfTypeFromUnitBJ(udg_player_SpielerEinheit[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], udg_feature_UpgradeItem1[poss[GetForLoopIndexA()]]) )
call UnitAddItemByIdSwapped( udg_feature_UpgradeItem2[poss[GetForLoopIndexA()]], udg_player_SpielerEinheit[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))] )
else
endif
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call EnumItemsInRectBJ( gg_rct_Item, call RemoveItem( GetEnumItem() ) )
endfunction
//===========================================================================
function InitTrig_CombineUpgrade_3 takes nothing returns nothing
set gg_trg_CombineUpgrade_3 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CombineUpgrade_3, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_CombineUpgrade_3, Condition( function Trig_CombineUpgrade_3_Conditions ) )
call TriggerAddAction( gg_trg_CombineUpgrade_3, function Trig_CombineUpgrade_3_Actions )
endfunction</i>