• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Trigger Function Problem

Status
Not open for further replies.
Level 7
Joined
Feb 23, 2020
Messages
253
Hello, i'm having an issue with my trigger, which is that the chance of a dummy spawning, is (Now in this trigger) based on the hero getting ATTACKED, not the hero itself attacking (Which it's supposed to be). And also the damage dealt is supposed to be based on the base damage of the hero. What am i missing/doing wrong?

Thanks in advance! :)

  • Cast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Copycat for (Triggering unit)) Not equal to 0
    • Actions
      • Set VariableSet Copycat_Target = (Attacked unit)
      • Set VariableSet Copycat_Caster = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random real number between 0.00 and 1.00) Less than or equal to Copycat_Chance[(Level of Copycat for (Triggering unit))]
        • Then - Actions
          • Unit - Create 1 Glaivemaster Dummy for (Owner of Copycat_Caster) at ((Position of Copycat_Caster) offset by ((Random real number between 50.00 and 400.00), (Random real number between 50.00 and 400.00))) facing (Facing of Copycat_Target) degrees
          • Unit - Cause Copycat_Dummy to damage Copycat_Target, dealing (Real((Base Damage of Copycat_Caster for weapon index 0))) damage of attack type Spells and damage type Normal
          • Unit - Order Copycat_Dummy to Attack Once Copycat_Target
          • Set VariableSet Copycat_Dummy = (Last created unit)
          • Unit - Add a 1.50 second Generic expiration timer to Copycat_Dummy
        • Else - Actions
 
Level 7
Joined
Feb 23, 2020
Messages
253
So my guess is the dummy barely spawns at all?
The dummy spawns and works, except that it spawns when the hero gets attacked, which i dont want, i want it to spawn when the hero attacks. And the damage should be based on the heros base damage, that is my problem
 
Level 13
Joined
Feb 5, 2018
Messages
567
In the condition block where you have the if ability of level not equal to 0, add if unit type of attacking unit equal to your unit.
 
Last edited:
Level 7
Joined
Feb 23, 2020
Messages
253
  • Set VariableSet Copycat_Target = (Attacked unit)
  • Set VariableSet Copycat_Caster = (Triggering unit)
For "A unit Is attacked" event, "Triggering Unit" is the same as "Attacked Unit".
Hmm, so how should i do?
 
Level 13
Joined
Feb 5, 2018
Messages
567
Like this:
  • Attack Event
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of YourAbilty for (Attacking unit)) Greater than 0
    • Actions
      • Set VariableSet Caster = (Attacking unit)
      • Set VariableSet Target = (Triggering unit)
      • Unit - Cause Caster to damage Target, dealing 250.00 damage of attack type Spells and damage type Normal
Also you should store the location into variable, before creating the dummy unit.

This might be useful to you:
Things That Leak
Memory Leaks

And for another issue at hand. You should never use the Event - A unit is attacked. I highly recommend you to download a DDS. It looks a bit scary at first, but it is actually really easy to use.
Damage Engine 5.5.0.0
 
Level 7
Joined
Feb 23, 2020
Messages
253
Like this:
  • Attack Event
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of YourAbilty for (Attacking unit)) Greater than 0
    • Actions
      • Set VariableSet Caster = (Attacking unit)
      • Set VariableSet Target = (Triggering unit)
      • Unit - Cause Caster to damage Target, dealing 250.00 damage of attack type Spells and damage type Normal
Also you should store the location into variable, before creating the dummy unit.

This might be useful to you:
Things That Leak
Memory Leaks

And for another issue at hand. You should never use the Event - A unit is attacked. I highly recommend you to download a DDS. It looks a bit scary at first, but it is actually really easy to use.
Damage Engine 5.5.0.0
Like this the dummy wont spawn at all like this :/

Yeah i've seen a lot of those but i really dont understand how they work. What is the primary use of a DDS?
 
Last edited:
Level 13
Joined
Feb 5, 2018
Messages
567
  • Attack Event
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of YourSpell for (Attacking unit)) Greater than 0
    • Actions
      • Set VariableSet Chance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Chance Greater than or equal to 50
        • Then - Actions
          • Set VariableSet Caster = (Attacking unit)
          • Set VariableSet Target = (Triggering unit)
          • Set VariableSet Player = (Owner of Caster)
          • Set VariableSet Location = ((Position of Caster) offset by ((Random real number between 40.00 and 400.00), (Random real number between 40.00 and 400.00)))
          • Unit - Create 1 Footman for Player at Location facing Default building facing degrees
          • Set VariableSet Dummy = (Last created unit)
          • Unit - Add a 1.50 second Generic expiration timer to Dummy
          • Custom script: call RemoveLocation (udg_Location)
        • Else - Actions
Modify as you like, but this works. Tested.
 

Attachments

  • AttackEvent.w3m
    17.3 KB · Views: 19
Level 7
Joined
Feb 23, 2020
Messages
253
  • Attack Event
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of YourSpell for (Attacking unit)) Greater than 0
    • Actions
      • Set VariableSet Chance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Chance Greater than or equal to 50
        • Then - Actions
          • Set VariableSet Caster = (Attacking unit)
          • Set VariableSet Target = (Triggering unit)
          • Set VariableSet Player = (Owner of Caster)
          • Set VariableSet Location = ((Position of Caster) offset by ((Random real number between 40.00 and 400.00), (Random real number between 40.00 and 400.00)))
          • Unit - Create 1 Footman for Player at Location facing Default building facing degrees
          • Set VariableSet Dummy = (Last created unit)
          • Unit - Add a 1.50 second Generic expiration timer to Dummy
          • Custom script: call RemoveLocation (udg_Location)
        • Else - Actions
Modify as you like, but this works. Tested.
Aahh yes, thank you a lot mate! :)

Edit: Well although that worked correctly it did not seem like mine did, idk what i'm missing, cant seem to figure it out.

  • Cast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Copycat for (Attacking unit)) Not equal to 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random real number between 0.00 and 1.00) Less than or equal to Copycat_Chance[(Level of Copycat for (Triggering unit))]
        • Then - Actions
          • Set VariableSet Copycat_Caster = (Attacking unit)
          • Set VariableSet Copycat_Target = (Triggering unit)
          • Set VariableSet Copycat_Player = (Owner of Copycat_Caster)
          • Set VariableSet Copycat_Location = ((Position of Copycat_Caster) offset by ((Random real number between 40.00 and 400.00), (Random real number between -40.00 and -400.00)))
          • Unit - Create 1 Glaivemaster Dummy for Copycat_Player at Copycat_Location facing (Facing of Copycat_Target) degrees
          • Unit - Order Copycat_Dummy to Attack Once Copycat_Target
          • Unit - Cause Copycat_Dummy to damage Copycat_Target, dealing (Real((Base Damage of Copycat_Caster for weapon index 0))) damage of attack type Spells and damage type Normal
          • Set VariableSet Copycat_Dummy = (Last created unit)
          • Unit - Add a 1.50 second Generic expiration timer to Copycat_Dummy
          • Custom script: call RemoveLocation (udg_Copycat_Location)
        • Else - Actions
 
Last edited:
Level 13
Joined
Feb 5, 2018
Messages
567
if.gif
(Random real number between 0.00 and 1.00) Less than or equal to Copycat_Chance[(Level of Copycat for (Triggering unit))]

Try changing this to attacking unit. Then see if it works :)

set.gif
Set VariableSet Copycat_Dummy = (Last created unit)

Also this needs to be right after you create unit or the orders you are issuing will fail.
 
Level 7
Joined
Feb 23, 2020
Messages
253
Try changing this to attacking unit. Then see if it works :)



Also this needs to be right after you create unit or the orders you are issuing will fail.
Yes now it all works they way its intended too! Thank you for your time! :)
 
Status
Not open for further replies.
Top