• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Casting System crashes wc3 to desktop

Status
Not open for further replies.
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.

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

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

  • dynamic cast script test map v2.w3m
    67.2 KB · Views: 22
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,596
What exactly are you trying to achieve with this system?

Also, there's no need to hide/show or use the ghost ability on your Dummy unit, all you need to do is add the Locust ability to it. Unless there's a good reason for doing this but I don't see one.
Some more info about Dummy units can be found in this thread: Dummy Casting Problem

Additionally, you can simplify your dialog buttons clicked trigger:
  • dynamic cast button clicked new
    • Events
      • Dialog - A dialog button is clicked for dynamic_casts_dialog
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to dynamic_casts_dialog_button[(Integer A)]
            • Then - Actions
              • Set Variable dynamic_cast_bindings[(Integer A)] = dynamic_cast_ability
            • Else - Actions
No need for 10 different Dialog Button variables when you can use an Array.

Anyway, I see you have Order events. One common crash that occurs is when you create an infinite order loop. IE -> A unit is issued an order with no target -> Order triggering unit to Stop

Also, if the game desyncs when playing online then it could be because of your use of GetLocalPlayer(). It's easy to cause a desync if you don't use it properly.
 
Last edited:
What exactly are you trying to achieve with this system?

Also, there's no need to hide/show or use the ghost ability on your Dummy unit, all you need to do is add the Locust ability to it. Unless there's a good reason for doing this but I don't see one.
Some more info about Dummy units can be found in this thread: Dummy Casting Problem

Additionally, you can simplify your dialog buttons clicked trigger:
  • dynamic cast button clicked new
    • Events
      • Dialog - A dialog button is clicked for dynamic_casts_dialog
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to dynamic_casts_dialog_button[(Integer A)]
            • Then - Actions
              • Set Variable dynamic_cast_bindings[(Integer A)] = dynamic_cast_ability
            • Else - Actions
No need for 10 different Dialog Button variables when you can use an Array.

Anyway, I see you have Order events. One common crash that occurs is when you create an infinite order loop. IE -> A unit is issued an order with no target -> Order triggering unit to Stop

Also, if the game desyncs when playing online then it could be because of your use of GetLocalPlayer(). It's easy to cause a desync if you don't use it properly.

Thanks for the quick reply. I added more information to the above post. Locust won't work for me because the way the system works is that the dummy unit tries to cast the desired ability and then the dummy is interrupted and the hero is ordered to cast the same ability on the same target if it targets. Using locust would break targeted abilities at least.
 
Status
Not open for further replies.
Top