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

[JASS] RemoveDestructable -> Crash

Status
Not open for further replies.
Level 13
Joined
Mar 19, 2010
Messages
870
Hey hivers,

what im doing?

Well, i created a destructable which looks like a gravestone. The players can just attack it by right click and im listen to the death event of it.
When the gravestone is destroyed i want to remove it but the call of RemoveDestructalbe() crashes the game.

It's strange that the destructable after killing is still there. it cant be attack but its visual there and that sucks... I could hide it, i think that should work but can i remove it correctly to avoid leaks... is hiding and d=null enough??


Reg.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Use an immobile(and non-attacking) unit instead of a destructable.
If you don't want to, post the map or the script for debugging.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
You could just set a unit's movespeed to 0 (in the object editor of world editor), that would make it immobile. It can be targeted by a smart command (right-click), but if you want player to be able to attack right-click on it then you need to make it owned by the player Neutral Hostile.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Oh right, why don't you just post the triggers, maybe someone could help. (the destructable triggers)
 
Level 13
Joined
Mar 19, 2010
Messages
870
im not@home

code looks like:

1. call CreateDestrcutable()
2. Add Death-Event to the Destructable
3. If Destrcutable dies ( GetDyingDestructable()) --> Call RemoveDestrcutable(d) <- Crash!!! because i think the destrcutable instance does not exist anymore and i want to remove it... but its still there ( Model), but you can select it or attack it again... its just there.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Is the destructable pre-placed using world editor or instantiated using a custom script (jass). Anyway I'm testing now, using a pre-placed destructable.

EDIT: can you tell me what destructable are you using? (i.e. Explosive Barrels Barrel of Explosives)
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Here's my test map:
View attachment TEST_0.w3x

The gravestone model doesn't have a death animation, looks weird when you kill it lol.

If you don't trust maps or is unable to open it, here are the triggers:

Here are the triggers I used:
First, I created the Destructable
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Destructible - Create a MyDestrucable at (Player 2 (Blue) start location) facing (Random angle) with scale 1.00 and variation 0
      • Set MyDestructable = (Last created destructible)
      • Trigger - Add to On Death <gen> the event (Destructible - MyDestructable dies)
Here is the death event trigger.
  • On Death
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) for 10.00 seconds the text: Destructable died.
      • Wait 1.00 game-time seconds
      • Game - Display to Player Group - Player 1 (Red) for 10.00 seconds the text: Removing Destructab...
      • Destructible - Remove MyDestructable
These triggers worked properly, upon destructable death, it waited 1 second then removed the destructable, in-game the destructable also vanished(the model).

EDIT: Looks like WaterKnight's answer is better than mine.
 
Status
Not open for further replies.
Top