• 🏆 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!

Custom Goblin land mines crashing the game

Status
Not open for further replies.
Level 15
Joined
Jan 27, 2007
Messages
948
Well, I made some goblin mines that damage 4x to 6x the casting unit agi, but when i explode about 3-6 mines with more than 5 or 6 units the game crashes! why is this happening?

here the trigger:
  • Explosive Trap
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetSummonedUnit())
      • Hashtable - Save Handle Of(Summoning unit) as 0 of ID in Hashtable
  • Explosive Trap Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetDyingUnit())
      • Set HashUnit = (Load 0 of ID in Hashtable)
      • Set TempPoint = (Position of (Dying unit))
      • Unit - Cause HashUnit to damage circular area after 0.00 seconds of radius 200.00 at TempPoint, dealing ((Real((Agility of HashUnit (Include bonuses)))) x (Random real number between 4.00 and 6.00)) damage of attack type Spells and damage type Normal
      • Hashtable - Clear all child hashtables of child ID in Hashtable
      • Custom script: call RemoveLocation( udg_TempPoint )
For the ability I just used a custom gob mine skill. (different stats, cooldown, name etc. but the same base ability).
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
It's always better to use "Triggering unit" than "Dying unit" and else. If the event is "A unit dies" the dying unit would be the triggering unit, but the game likes triggering unit more than other event response units, so, if you can, use triggering unit.

The "Cause area damage" action is a bit bugget. It's better if you pick every unit in range and damage them 1 by 1.

It's crashing probably because the dying unit would be probably damaging itself even if it's already dead, or something. This kind of crashes are caused for endeless loops (It explodes, kills itself, explodes again, kills itself, etc.) or something like that.

The trigger looks fine, try changing the area damage for individual damage in a Pick units loop and it'll work for sure.
 
Level 15
Joined
Jan 27, 2007
Messages
948
that's some amazing info! I did this so far from what you said:

  • Explosive Trap Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetTriggerUnit())
      • Set HashUnit = (Load 0 of ID in Hashtable)
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 200.00 of TempPoint matching ((Unit-type of (Picked unit)) Not equal to Explosive Trap))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause HashUnit to damage (Picked unit), dealing ((Real((Agility of (Casting unit) (Include bonuses)))) x (Random real number between 4.80 and 6.20)) damage of attack type Spells and damage type Normal
      • Hashtable - Clear all child hashtables of child ID in Hashtable
      • Custom script: call RemoveLocation( udg_TempPoint )
      • Custom script: set udg_TempGroup = null
to avoid the endless loop I used a matching condition
I'm going to test it right now !

edit: somehow it doesn't cause any damage at all, i'm trying to figure out why

edit2: "Unit - Cause HashUnit to damage (Picked unit), dealing ((Real((Agility of (Casting unit) (Include bonuses)))) x (Random real number between 4.80 and 6.20)) damage of attack type Spells and damage type Normal" ........ :p

anyway, it still crashes when multiple mines explode... the trigger ended up like:

  • Explosive Trap Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetTriggerUnit())
      • Set HashUnit = (Load 0 of ID in Hashtable)
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 200.00 of TempPoint matching ((Unit-type of (Picked unit)) Not equal to Explosive Trap))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause HashUnit to damage (Picked unit), dealing ((Real((Agility of HashUnit (Include bonuses)))) x (Random real number between 4.80 and 6.20)) damage of attack type Spells and damage type Normal
      • Hashtable - Clear all child hashtables of child ID in Hashtable
      • Custom script: call RemoveLocation( udg_TempPoint )
      • Custom script: set udg_TempGroup = null
by the way; when the mines caused no damage at all, they didn't crash



edit 3: it's working! it doesn't crash anymore!!! the mistake was the TempGroup, it was setted "picked unit" somewhere, and it had to be "matching unit".
you were right, it was the endless loop, the mine was making the other mines explode and that created some kind of uber explosion that exploded even the game!

so this is the final result (working)
  • Explosive Trap Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetTriggerUnit())
      • Set HashUnit = (Load 0 of ID in Hashtable)
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 200.00 of TempPoint matching ((Unit-type of (Matching unit)) Not equal to Explosive Trap))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause HashUnit to damage (Picked unit), dealing ((Real((Agility of HashUnit (Include bonuses)))) x (Random real number between 4.80 and 6.20)) damage of attack type Spells and damage type Normal
      • Hashtable - Clear all child hashtables of child ID in Hashtable
      • Custom script: call RemoveLocation( udg_TempPoint )
      • Custom script: set udg_TempGroup = null
many thanks for the help spartipilo!!
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Clearing removes units from the group. The group is still in the memory.
Destroying a group removes it from the memory.
Nulling a variable makes the variable not point to any object (unit group in this case) in memory.

There's no need to clear a group if you're going to destroy it. There's also no need to null global variables since they are going to be used again most likely.
 
Level 15
Joined
Jan 27, 2007
Messages
948
Damn, I thought this was solved, but they still crash the game!
It doesn't matter how much mines there are, one mine is enough. The problem is when there are several units together. When about 5 or 7 units recibe damage from the mine the game crashes!

Here the code:

  • Explosive Trap
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetSummonedUnit())
      • Hashtable - Save Handle Of(Summoning unit) as 0 of ID in Hashtable
  • Explosive Trap Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Explosive Trap
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetTriggerUnit())
      • Set HashUnit = (Load 0 of ID in Hashtable)
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 200.00 of TempPoint matching ((Unit-type of (Matching unit)) Not equal to Explosive Trap))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause HashUnit to damage (Picked unit), dealing ((Real((Agility of HashUnit (Include bonuses)))) x (Random real number between 4.80 and 6.20)) damage of attack type Spells and damage type Normal
      • Hashtable - Clear all child hashtables of child ID in Hashtable
      • Custom script: call RemoveLocation( udg_TempPoint )
      • Custom script: call DestroyGroup(udg_TempGroup)
Any ideas guys? :(

Edit: after several tests, I think it only crashes not when many units are affected, but when many units die because of this (going to test if ONLY because of this or if it's the event). Anyway the crash proves to not appear always, sometimes I kill about 5 units at the same time and it still doesn't crash.
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
The trigger is fine. I think it has to do with the Ability itself. I've worked with it before and I never had problems of this kind.

I think that, if the unit is HashUnit is not a Hero it could crash because there's no Agility to damage.

Don't set any of the ability values to 0. If you need them to be 0, set them 0.01, and test again.
 
Level 15
Joined
Jan 27, 2007
Messages
948
The trigger is fine. I think it has to do with the Ability itself. I've worked with it before and I never had problems of this kind.

I think that, if the unit is HashUnit is not a Hero it could crash because there's no Agility to damage.

Don't set any of the ability values to 0. If you need them to be 0, set them 0.01, and test again.

I just can't understand how you do it! you rock xD

Actually I can't be 100% certain but I killed 10 units at once with 1 mine and no problems, no crashes this time, not even lag.

I did what you suggested about the values. The damage was set to "0" so I changed it to 0.01.

Hope it is really working this time ^^

Thanks!!!!!!!!!!!!!!!!
 
Status
Not open for further replies.
Top