Crash

Cyte

New Member
Reaction score
0
Any idea why a Custom map keep crashing? I'm working on a RPG map and I tested it with my friend. Then I found out that my map sometimes crash when he change job and when he buy item from a shop.

The triggers are here:
Job Change:
Trigger:
  • Kenny Lee
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) has an item of type Kenny Lee`) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • |cCFFF0202Noob`|r Equal to (Unit-type of (Triggering unit))
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Kenny Lee`)
          • Hero - Drop (Item carried by (Triggering unit) in slot 1) from (Triggering unit)
          • Hero - Drop (Item carried by (Triggering unit) in slot 2) from (Triggering unit)
          • Hero - Drop (Item carried by (Triggering unit) in slot 3) from (Triggering unit)
          • Hero - Drop (Item carried by (Triggering unit) in slot 4) from (Triggering unit)
          • Hero - Drop (Item carried by (Triggering unit) in slot 5) from (Triggering unit)
          • Hero - Drop (Item carried by (Triggering unit) in slot 6) from (Triggering unit)
          • Unit - Remove (Triggering unit) from the game
          • Unit - Create 1 Kenshi` for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Position of (Triggering unit))
          • Selection - Select (Last created unit) for (Owner of (Triggering unit))
          • Wait 0.50 seconds
          • Special Effect - Create a special effect attached to the overhead of (Last created unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
          • Game - Display to (All players) for 5.00 seconds the text: |cCF7DBEF1Dave - Jo...
        • Else - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Kenny Lee`)
          • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
          • Game - Display to (All players) for 5.00 seconds the text: |cCF7DBEF1Dave - Jo...
          • Player - Add 200 to (Owner of (Triggering unit)) Current gold


And trigger for the item:

Trigger:
  • Chicken Eggs
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Chicken Eggs
    • Actions
      • Set ChickenEggCI[((Player number of (Owner of (Triggering unit))) + 20)] = (ChickenEggCI[((Player number of (Owner of (Triggering unit))) + 20)] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ChickenEggCI[((Player number of (Owner of (Triggering unit))) + 20)] Equal to 2
        • Then - Actions
          • Set ChickenEggCharges[((Player number of (Owner of (Triggering unit))) + 20)] = (Charges remaining in (Item being manipulated))
          • Item - Remove (Item being manipulated)
          • Set ChickenEggCarrying[((Player number of (Owner of (Triggering unit))) + 20)] = (Charges remaining in (Item carried by (Triggering unit) of type Chicken Eggs))
          • Item - Remove (Item carried by (Triggering unit) of type Chicken Eggs)
          • Hero - Create Chicken Eggs and give it to (Triggering unit)
          • Item - Set charges remaining in (Last created item) to (ChickenEggCarrying[((Player number of (Owner of (Triggering unit))) + 20)] + ChickenEggCharges[((Player number of (Owner of (Triggering unit))) + 20)])
        • Else - Actions
 
Reaction score
7
Job Change:
Trigger:
  • Kenny Lee
    • ...
    • Actions
      • ...
        • Unit - Remove (Triggering unit) from the game
        • Unit - Create 1 Kenshi` for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Position of (Triggering unit)) [––– Invalid reference to Triggering Unit. –––]
        • Selection - Select (Last created unit) for (Owner of (Triggering unit)) [––– Invalid reference to Triggering Unit. –––]
      • ...

I notice you're referring to the triggering unit after removing it.
Consider changing your trigger to this:

Trigger:
  • Kenny Lee
    • ...
    • Actions
      • ...
        • Set TempPoint = Position of (Triggering unit)
        • Unit - Create 1 Kenshi` for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing 270 degrees.
        • Selection - Select (Last created unit) for (Owner of (Triggering unit))
        • Unit - Remove (Triggering unit) from the game
        • Unit - Move (Last created unit) to TempPoint facing 270 degrees.
      • ...

TempPoint is a new variable of type Point.

This also allows you to fix the memory leak created by Position of (Triggering unit) by destroying the variable TempPoint.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top