• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

The game sometimes crashes when choosing a character

Level 4
Joined
Feb 16, 2017
Messages
54
Hi everyone
I'm working on a map where characters can be selected by selecting them with the mouse.
The selection trigger is like the pictures I shared below.
There is no problem when I test with the editor, but when I log in from the game and open the map, something like this happens; Sometimes the game crashes when I select a character.
War3 version 1.26 editor;normal editor
1.png
2.png
3.png
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
I'd assume it's because you're running the action in response to a Selection event:
  • Selection - Select (Last created unit) for (Triggering player)
I would also be careful with Removing the hero immediately.

If I were to make adjustments to your current trigger I would do something like this:
  • Events
    • ...
  • Conditions
    • ...
    • HS_Has_A_Hero[(Player number of (Triggering player))] Equal to False
    • ((Triggering unit) is in HS_Was_Picked) Equal to False
  • Actions
    • Custom script: local unit hero
    • Unit Group - Add (Triggering unit) to HS_Was_Picked
    • Set HS_Player = (Triggering player)
    • Set HS_PN = (Player number of HS_Player)
    • Set HS_Has_A_Hero[HS_PN] = True
    • Set HS_Hero_Type = (Unit-type of (Triggering unit))
    • Unit - Create 1 HS_Hero_Type for HS_Player...
    • Set HS_Hero = (Last created unit)
    • Set Player_Hero[HS_PN] = HS_Hero
    • Custom script: set hero = udg_HS_Hero
    • ...
    • -------- use HS_Hero_Type to determine the picked hero and set your necessary variables for HS_Hero/HS_Player --------
    • ...
    • -------- apply settings for HS_Hero/HS_Player (camera stuff, etc) --------
    • ...
    • Wait 0.01 seconds of game-time
    • Custom script: set udg_HS_Hero = hero
    • Custom script: set hero = null
    • Unit - Remove (Triggering unit) from the game
    • Selection - Clear selection for (Owner of (HS_Hero))
    • Selection - Select HS_Hero for (Owner of (HS_Hero))
I figured just to be safe you could delay the Removal and Re-Selection stuff for a short time. That being said, it may be unnecessary if you just make sure to do those two things at the very end of your Actions. The variables help keep things efficient, bug free, and organized.

You also have some memory leaks with your unit creation -> (Center of region).
That wouldn't break anything but it's something you may want to take a look into.
 
Last edited:
Top