Very Annoying Crash

Knocksious

Sweet, I got 2 little green bars!
Reaction score
46
Ok

I have an item ability that adds damage based on how many kills you have made with that item

and now whenever a unit attacks something with that item, game crash

The annoying part is that it never used to happen

I will post it's trigger, and all related triggers
please ask any questions whatsoever

somewhat unnecessary info/explanations to references

The name of the item is "Bloodthirster"
"Thundercaller" is another item that casts Chain lightning after 10 attacks



These next 2 triggers set up the event for the Bloodthirster attack ability

Code:
Takes Damage Trigger Setup1
    Events
        Time - Elapsed game time is 1.50 seconds
    Conditions
    Actions
        Set TempUnitGroup = (Units in (Entire map))
        Unit Group - Pick every unit in TempUnitGroup and do (Actions)
            Loop - Actions
                Trigger - Add to ThunderCaller <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Bloodthirster Attack <gen> the event (Unit - (Picked unit) Takes damage)

Code:
Takes Damage Trigger Setup2
    Events
        Unit - A unit enters (Entire map)
    Conditions
    Actions
        Trigger - Add to ThunderCaller <gen> the event (Unit - (Entering unit) Takes damage)
        Trigger - Add to Bloodthirster Attack <gen> the event (Unit - (Entering unit) Takes damage)


These Next triggers are the only 2 that bloodthirster uses it is referenced in one other

Code:
BloodthirsterCharge
    Events
        Unit - A unit Dies
    Conditions
        ((Killing unit) has an item of type Bloodthirster) Equal to True
    Actions
        Set AttackItem = (Item carried by (Killing unit) of type Bloodthirster)
        Item - Set charges remaining in AttackItem to ((Charges remaining in AttackItem) + 1)

Code:
Bloodthirster Attack
    Events
    Conditions
        ((Damage source) has an item of type Bloodthirster) Equal to True
    Actions
        Custom script:   local item AttackItem
        Set AttackItem = (Item carried by (Damage source) of type Bloodthirster)
        Unit - Cause (Damage source) to damage (Triggering unit), dealing (10.00 x (Real((Charges remaining in AttackItem)))) damage of attack type Hero and damage type Normal


This next trigger is the only one that Thundercaller uses, I included it because it has the same event as Bloodthirster


Code:
ThunderCaller
    Events
    Conditions
        ((Damage source) has an item of type ThunderCaller) Equal to True
    Actions
        Custom script:   local location AttackPos
        Set AttackItem = (Item carried by (Damage source) of type ThunderCaller)
        Set AttackPos = (Position of (Triggering unit))
        Item - Set charges remaining in AttackItem to ((Charges remaining in AttackItem) + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Charges remaining in AttackItem) Greater than or equal to 10
            Then - Actions
                Unit - Create 1 Dummy Caster for (Owner of (Damage source)) at AttackPos facing Default building facing degrees
                Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
                Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning (Triggering unit)
                Item - Set charges remaining in AttackItem to 0
            Else - Actions
                Do nothing
        Custom script:   call RemoveLocation (AttackPos)
------------------------------------------------------------------------------


Now, all of this worked fine until I added these seemingly unrelated triggers
(Note: In order to even pick up Bloodthirster the Player's class <Class[PlayerNumber(PickedPlayer)] Has to be equal to 1>


somewhat related trigger (similar event)
Code:
Ranged Unit Ammo
    Events
        Unit - A unit Is attacked
    Conditions
        Class[(Player number of (Owner of (Attacking unit)))] Equal to 3
    Actions
        Custom script:   local item AmmoItem
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Or - Any (Conditions) are true
                    Conditions
                        ((Attacking unit) has an item of type Rusty Javelins) Equal to True
                Or - Any (Conditions) are true
                    Conditions
                        (Unit-type of (Attacking unit)) Equal to Javlineer (human)
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Attacking unit) has an item of type Rusty Javelins) Equal to True
                    Then - Actions
                        Set AmmoItem = (Item carried by (Attacking unit) of type Rusty Javelins)
                    Else - Actions
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Attacking unit) has an item of type Quiver of Arrows) Equal to True
                Or - Any (Conditions) are true
                    Conditions
                        (Unit-type of (Attacking unit)) Equal to Archer (Elf)
            Then - Actions
                Set AmmoItem = (Item carried by (Attacking unit) of type Quiver of Arrows)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Charges remaining in AmmoItem) Greater than 0
            Then - Actions
                Item - Set charges remaining in AmmoItem to ((Charges remaining in AmmoItem) - 1)
                Skip remaining actions
            Else - Actions
        Unit - Order (Attacking unit) to Stop

------------------------------------------------------------------------------

The rest of the triggers I added (before I found out about this crash, and after it was working) are generic "unit enters region" hero selection type things



I need this to work, if it would help you at all to get a copy of my map, just PM me your email telling me so. I am deathly afraid of idea stealers, so if you have like 0 rep, or like 3 posts I am not going to give you my map (I hope this isn't too harsh)
 
Reaction score
456
In the triggers where you have Unit Takes Damage event, you should turn it off before the damaging action and after the damaging action turn it on again. Else it causes infinite loop.

Ex.

event
unit takes damage
condition
action
unit damage damage source

everytime the bolded part is executed, it runs the trigger again. So you gotta do:

event
unit takes damage
condition
action
turn off this trigger
unit damage damage source
turn on this trigger
 

Knocksious

Sweet, I got 2 little green bars!
Reaction score
46
works like a charm

and all that writing for such a simple answer

Shoulda seen that one. Thanks, Über
 
Reaction score
456
I asked same question when I was making backstab spell. SFilip tolhd hmehh hthat.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top