- Joined
- Oct 9, 2019
- Messages
- 295
I'm working on adding a new casting system to a map I'm working on. The casting system works fine in the attached demo map which contains all the triggers it uses but in actual game play using the hero with the casting system will cause random (?) crashes to desktop. The crashes seem to happen when they cast abilities with the system. The map is a dota style map but I don't wish to share the full map. I'm hoping that someone can look at my test map and see where potential issues might be.
The following trigger may be what's crashing it in the actual map, but I could be wrong.
edit: Forgot to explain the system. You press the left arrow key to bring up a menu of abilities and when you click one you get a list of numberpad keys as dialog buttons. You choose a number pad key and pressing the key you assign the ability to will have the hero cast the ability if it doesn't target or let you click a target and then cast once you do if it does.
I also updated the file so you don't need to learn brilliance aura to at least level 1 before doing the above, its learned automatically now
edit2: For what its worth, here's a picture of the crash: imgur.com
edit3: It appears that the crash occurs as the hero starts casting, since I can see the timer on screen and the hero is performing a cast animation when it exists
The following trigger may be what's crashing it in the actual map, but I could be wrong.
function Trig_dynamic_cast_caster_begins_casting_Conditions takes nothing returns boolean
if ( not ( GetTriggerUnit() == udg_dynamic_cast_caster ) ) then
return false
endif
return true
endfunction
function Trig_dynamic_cast_caster_begins_casting_Actions takes nothing returns nothing
local integer orderid=GetUnitCurrentOrder(GetTriggerUnit())
local boolean b
local real cooldown
local integer abil=GetSpellAbilityId()
local timerdialog tdialog=null
local player p=GetTriggerPlayer()
set udg_dynamic_cast_ability=abil
call UnitAddAbility(udg_dynamic_cast_hero,abil)
call SetUnitAbilityLevel(udg_dynamic_cast_hero,abil,4)
if GetUnitAbilityLevel(udg_dynamic_cast_hero,abil) < 4 then
call SetUnitAbilityLevel(udg_dynamic_cast_hero,abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab'))
set cooldown = BlzGetAbilityCooldown(abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab')-1)
else
call SetUnitAbilityLevel(udg_dynamic_cast_hero,abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab') + 1)
set cooldown = BlzGetAbilityCooldown(abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab'))
endif
set b=IssueTargetOrderById(udg_dynamic_cast_hero,orderid,GetSpellTargetUnit())
if not b then
set b=IssuePointOrderById(udg_dynamic_cast_hero,orderid,GetSpellTargetX(),GetSpellTargetY())
if not b then
set b=IssueImmediateOrderById(udg_dynamic_cast_hero,orderid)
endif
endif
if not b then
call dynamic_cast_remove_caster()
call dynamic_cast_remove_hero()
endif
if b then
call TimerStart(LoadTimerHandle(udg_ability_menu_ht,GetHandleId(udg_dynamic_cast_hero),abil),cooldown,false,null)
set tdialog=CreateTimerDialog(LoadTimerHandle(udg_ability_menu_ht,GetHandleId(udg_dynamic_cast_hero),abil))
call TimerDialogSetTitle(tdialog,GetObjectName(abil))
call TimerDialogDisplayForPlayerBJ(true,tdialog,p)
endif
call dynamic_cast_remove_caster()
if GetLocalPlayer()==p then
call ClearSelection()
call SelectUnit(udg_dynamic_cast_hero,true)
endif
call IssueImmediateOrder( GetTriggerUnit(), "stop" )
if b then
loop
exitwhen TimerGetRemaining(LoadTimerHandle(udg_ability_menu_ht,GetHandleId(udg_dynamic_cast_hero),abil)) <= 0.0
call TriggerSleepAction(1.0)
endloop
call TimerDialogDisplayForPlayerBJ(false,tdialog,p)
call DestroyTimerDialog(tdialog)
set tdialog=null
endif
endfunction
//===========================================================================
function InitTrig_dynamic_cast_caster_begins_casting takes nothing returns nothing
set gg_trg_dynamic_cast_caster_begins_casting = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_dynamic_cast_caster_begins_casting, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_dynamic_cast_caster_begins_casting, Condition( function Trig_dynamic_cast_caster_begins_casting_Conditions ) )
call TriggerAddAction( gg_trg_dynamic_cast_caster_begins_casting, function Trig_dynamic_cast_caster_begins_casting_Actions )
endfunction
if ( not ( GetTriggerUnit() == udg_dynamic_cast_caster ) ) then
return false
endif
return true
endfunction
function Trig_dynamic_cast_caster_begins_casting_Actions takes nothing returns nothing
local integer orderid=GetUnitCurrentOrder(GetTriggerUnit())
local boolean b
local real cooldown
local integer abil=GetSpellAbilityId()
local timerdialog tdialog=null
local player p=GetTriggerPlayer()
set udg_dynamic_cast_ability=abil
call UnitAddAbility(udg_dynamic_cast_hero,abil)
call SetUnitAbilityLevel(udg_dynamic_cast_hero,abil,4)
if GetUnitAbilityLevel(udg_dynamic_cast_hero,abil) < 4 then
call SetUnitAbilityLevel(udg_dynamic_cast_hero,abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab'))
set cooldown = BlzGetAbilityCooldown(abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab')-1)
else
call SetUnitAbilityLevel(udg_dynamic_cast_hero,abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab') + 1)
set cooldown = BlzGetAbilityCooldown(abil,GetUnitAbilityLevel(udg_dynamic_cast_hero,'AHab'))
endif
set b=IssueTargetOrderById(udg_dynamic_cast_hero,orderid,GetSpellTargetUnit())
if not b then
set b=IssuePointOrderById(udg_dynamic_cast_hero,orderid,GetSpellTargetX(),GetSpellTargetY())
if not b then
set b=IssueImmediateOrderById(udg_dynamic_cast_hero,orderid)
endif
endif
if not b then
call dynamic_cast_remove_caster()
call dynamic_cast_remove_hero()
endif
if b then
call TimerStart(LoadTimerHandle(udg_ability_menu_ht,GetHandleId(udg_dynamic_cast_hero),abil),cooldown,false,null)
set tdialog=CreateTimerDialog(LoadTimerHandle(udg_ability_menu_ht,GetHandleId(udg_dynamic_cast_hero),abil))
call TimerDialogSetTitle(tdialog,GetObjectName(abil))
call TimerDialogDisplayForPlayerBJ(true,tdialog,p)
endif
call dynamic_cast_remove_caster()
if GetLocalPlayer()==p then
call ClearSelection()
call SelectUnit(udg_dynamic_cast_hero,true)
endif
call IssueImmediateOrder( GetTriggerUnit(), "stop" )
if b then
loop
exitwhen TimerGetRemaining(LoadTimerHandle(udg_ability_menu_ht,GetHandleId(udg_dynamic_cast_hero),abil)) <= 0.0
call TriggerSleepAction(1.0)
endloop
call TimerDialogDisplayForPlayerBJ(false,tdialog,p)
call DestroyTimerDialog(tdialog)
set tdialog=null
endif
endfunction
//===========================================================================
function InitTrig_dynamic_cast_caster_begins_casting takes nothing returns nothing
set gg_trg_dynamic_cast_caster_begins_casting = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_dynamic_cast_caster_begins_casting, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_dynamic_cast_caster_begins_casting, Condition( function Trig_dynamic_cast_caster_begins_casting_Conditions ) )
call TriggerAddAction( gg_trg_dynamic_cast_caster_begins_casting, function Trig_dynamic_cast_caster_begins_casting_Actions )
endfunction
edit: Forgot to explain the system. You press the left arrow key to bring up a menu of abilities and when you click one you get a list of numberpad keys as dialog buttons. You choose a number pad key and pressing the key you assign the ability to will have the hero cast the ability if it doesn't target or let you click a target and then cast once you do if it does.
I also updated the file so you don't need to learn brilliance aura to at least level 1 before doing the above, its learned automatically now
edit2: For what its worth, here's a picture of the crash: imgur.com
edit3: It appears that the crash occurs as the hero starts casting, since I can see the timer on screen and the hero is performing a cast animation when it exists
Attachments
Last edited: