B
Bill_14
Guest
Code:
function RequestGryphon takes nothing returns boolean
if GetItemTypeId(GetSoldItem())=='I001' then
return true
endif
return false
endfunction
function H2Ix takes handle pTarg returns integer
return pTarg
return 0
endfunction
function H2Tx takes handle pTarg returns string
return I2S(H2Ix(pTarg))
endfunction
function FastFlush takes string pTable returns nothing
call FlushStoredMission(udg_Core,pTable)
endfunction
function SetHandle takes string pTable,string pKey,handle pData returns nothing
call StoreInteger(udg_Core,pTable,pKey,H2Ix(pData))
endfunction
function GetButton takes string pTable,string pKey returns button
return GetStoredInteger(udg_Core,pTable,pKey)
return null
endfunction
function GetUnit takes string pTable,string pKey returns unit
return GetStoredInteger(udg_Core,pTable,pKey)
return null
endfunction
function GetLocation takes string pTable,string pKey returns location
return GetStoredInteger(udg_Core,pTable,pKey)
return null
endfunction
function GetTrigAction takes string pTable,string pKey returns triggeraction
return GetStoredInteger(udg_Core,pTable,pKey)
return null
endfunction
function FlightMain takes nothing returns nothing
local trigger ltt= GetTriggeringTrigger()
local string lf5= H2Tx(ltt)
local unit lfo= GetUnit(lf5,"Traveller")
local location loc1= GetLocation(lf5, "Destination")
local unit lfO= GetUnit(lf5, "Gryphon")
if DistanceBetweenPoints(GetUnitLoc(lfO), loc1)<100 then
call DisableTrigger (ltt)
call PolledWait(2)
call UnitShareVision(lfO, GetOwningPlayer(lfo), false)
call SetUnitPositionLoc( lfo, loc1 )
call ShowUnit(lfo, true)
call ResetToGameCameraForPlayer( GetOwningPlayer(lfo), 0 )
call PanCameraTo(GetUnitX(lfo), GetUnitY(lfo))
call PolledWait(1.)
call RemoveUnit(lfO)
call TriggerRemoveAction(ltt, GetTrigAction(lf5, "TriggerAction"))
call FastFlush(lf5)
call DestroyTrigger(ltt)
endif
call RemoveLocation(loc1)
endfunction
function FlightSet takes nothing returns nothing
local trigger ltt=CreateTrigger()
local location loc1
local string lf5=H2Tx(ltt)
local button array dst
local integer price
local unit lfO
local unit lfo= GetUnit(H2Tx(GetTriggeringTrigger()), "Traveller")
local unit lf2= GetUnit(H2Tx(GetTriggeringTrigger()), "Trader")
set dst[1]=GetButton(H2Tx(GetTriggeringTrigger()),"DestinationA")
set dst[2]=GetButton(H2Tx(GetTriggeringTrigger()),"DestinationB")
if GetClickedButton()==dst[1] then
set loc1= Location(500, 1000)
set price=20
else
if GetClickedButton()==dst[2] then
set loc1= Location(1000, -1000)
set price=30
endif
endif
if DistanceBetweenPoints(GetUnitLoc(lf2), loc1)<800 then
call DisplayTimedTextToPlayer(GetOwningPlayer(lfo), 0, 0, bj_TEXT_DELAY_QUESTREQUIREMENT, "You are already in this location!")
else
call SetPlayerState(GetOwningPlayer(lfo),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(lfo),PLAYER_STATE_RESOURCE_GOLD)-price)
call SetHandle(lf5,"Destination",loc1)
call SetHandle(lf5,"Traveller",lfo)
set lfO=CreateUnit(GetOwningPlayer(lf2), 'hgry', GetUnitX(lf2), GetUnitY(lf2), AngleBetweenPoints(GetUnitLoc(lf2), GetUnitLoc(lfo)))
call SetUnitInvulnerable(lfO, true)
call UnitShareVision(lfO, GetOwningPlayer(lfo), true)
call ShowUnit(lfo, false)
call SetHandle(lf5,"Gryphon", lfO)
call SetHandle(lf5,"TriggerAction", TriggerAddAction(ltt, function FlightMain))
call SetCameraTargetControllerNoZForPlayer( GetOwningPlayer(lfo), lfO, 0, 0, false )
call PolledWait(1)
call TriggerRegisterTimerEvent(ltt, .5, true)
call IssuePointOrderLocBJ( lfO, "move", loc1 )
endif
call PolledWait(1)
call RemoveLocation(loc1)
call DestroyTrigger(GetTriggeringTrigger())
endfunction
function ChooseDestination takes nothing returns nothing
local trigger ltt
local dialog dlg
local button array dst
local unit lfo=GetBuyingUnit()
local unit lf2=GetSellingUnit()
set dlg=DialogCreate()
set ltt=CreateTrigger()
call SetHandle(H2Tx(ltt), "Traveller", lfo)
call SetHandle(H2Tx(ltt), "Trader", lf2)
call DialogSetMessage(dlg, "Travel to:")
set dst[1]=DialogAddButton(dlg, "Destination A"+" "+"|cffffcc0020G|r", 1)
call SetHandle(H2Tx(ltt), "DestinationA", dst[1])
set dst[2]=DialogAddButton(dlg, "Destination B"+" "+"|cffffcc0030G|r", 2)
call SetHandle(H2Tx(ltt), "DestinationB", dst[1])
call TriggerRegisterDialogEvent(ltt, dlg)
call TriggerAddAction(ltt, function FlightSet)
call DialogDisplay(GetOwningPlayer(lfo), dlg, true)
call PolledWait(20)
call DialogDisplay(GetOwningPlayer(lfo), dlg, false)
call DialogDestroy(dlg)
call FastFlush(H2Tx(ltt))
endfunction
function InitTrig_FlightSystem takes nothing returns nothing
local trigger ltt=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( ltt, EVENT_PLAYER_UNIT_SELL_ITEM )
call TriggerAddCondition(ltt, Condition (function RequestGryphon))
call TriggerAddAction (ltt, function ChooseDestination)
endfunction
shows no errors at editor, but after selecting a destination, it does nothing, why?