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

Auto cast trigger not working Need help!

Status
Not open for further replies.
Level 2
Joined
Sep 26, 2013
Messages
8
Hello everybody,

I was trying to write a trigger for the following scenario:

Unit attacks another unit. Casts a specific targeted spell on the unit it is attacking, each time it attacks.

To be more precise: I used a code for a knockback mechanism, which moves the target unit away from the caster of the spell for a certain time. The issue I'm having is: The trigger in question needs a caster and a target to work and if I simply replace the spell I used, which was Stormbolt with something auto-casted like Frost arrows it does not work since Frost arrows appears not to be a casted ability.

I tried out the following trigger:

Event:
-Every 0.01 seconds of game time
Actions:
- Set variable 1 (Bouncer) = Random unit from (Units in (Playable map area) matching ((Unit.type of (Attacking unit)) equals Unit type (Bounce Tower) )))
- Set Variable 2 (Bounced Unit) = Random unit from (Units in (Playable map area)))
-Unit group - Pick every unit in (Units in (Playable map area)) and do (Unit - Order Variable 1 (Bouncer) to Human - Mountain King Stormbolt - variable 2 (Bounced unit)

I hope you guys can help me out with this!

P.S. I know choosing the "random unit" part was probably not the most clever solution!
 
Level 9
Joined
Dec 12, 2007
Messages
489
Nope, don't use timer event, use event 'Unit is Attacked',
change the condition to 'Level of <AbilityName> for Attacking Unit is greater than 0'
change the action to 'Unit - Order Attacking Unit to Human - Storm Bolt Attacked Unit

and make sure the attacking unit has the storm bolt ability
 
Level 2
Joined
Sep 26, 2013
Messages
8
Nope, don't use timer event, use event 'Unit is Attacked',
change the condition to 'Level of <AbilityName> for Attacking Unit is greater than 0'
change the action to 'Unit - Order Attacking Unit to Human - Storm Bolt Attacked Unit

and make sure the attacking unit has the storm bolt ability

I tried out your suggested Trigger, still doesn't work for me though. I even tried to add the actual Mountain King, who had my changed spell but he didn't cast the spell when he attacked. If I ordered him to do so, he cast the correct spell, so it's not the problem on the spell side. Do you know any alternatives?
 
Level 9
Joined
Dec 12, 2007
Messages
489
I tried out your suggested Trigger, still doesn't work for me though. I even tried to add the actual Mountain King, who had my changed spell but he didn't cast the spell when he attacked. If I ordered him to do so, he cast the correct spell, so it's not the problem on the spell side. Do you know any alternatives?

Post your trigger please,
a few checklist:
1. does your hero has the spell?
2. does your hero has enough mana to cast it?
3. does the spell can be cast on attacked unit manually?


  • cast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Storm Bolt for (Attacking unit)) Greater than 0
    • Actions
      • Unit - Order (Attacking unit) to Human Mountain King - Storm Bolt (Attacked unit)
 
Level 2
Joined
Sep 26, 2013
Messages
8
Yup looks exactly the same! How can you post code on the forums by the way? Also as I said the unit itself (tried it with a few) can manually cast the spell, but does not cast it if he attacks another unit.
 
Level 9
Joined
Dec 12, 2007
Messages
489

Attachments

  • testmap2.w3x
    13.4 KB · Views: 47
Level 2
Joined
Sep 26, 2013
Messages
8
I tried out your map, which (surprise) worked perfectly for me after which I copy/pasted your code into my map and after comparing it to my version (which was the same) replaced mine with it. However it still doesn't trigger the ability. Could it be that the problem I'm having is not the trigger, but the fact that my ability is not "Stormbolt", but "Stormbolt", changed in the following ways:
- It's not a hero spell anymore
- It does not have any mana costs
- CD reduced to 1 second

I will look into how to post triggers, so that I can post my Bounce-Trigger later, because if it is not one of the issues listed above it's probably something concerning the Bounce. I will do so tonight only, since I got an exam in the evening.

Thank you for your help so far!
 
Level 9
Joined
Dec 12, 2007
Messages
489
but "Stormbolt", changed in the following ways:
- It's not a hero spell anymore
- It does not have any mana costs
- CD reduced to 1 second

I will look into how to post triggers, so that I can post my Bounce-Trigger later, because if it is not one of the issues listed above it's probably something concerning the Bounce.
about that changes, it doesn't matter, as long its based from the Human Storm Bolt ability and has the same orderstring "thunderbolt".
Perhaps you have other trigger that catches unit order, or event a unit is issued order etc, that can interfere.
 
Level 2
Joined
Sep 26, 2013
Messages
8
That's the one you posted and the one I'm using although it's the translated (German) version I'm afraid


  • Autocast Bouncing shot
    • Ereignisse
      • Einheit - A unit Wird angegriffen
    • Bedingungen
      • (Level of Sturmschlag for (Attacking unit)) Greater than 0
    • Aktionen
      • Einheit - Order (Attacking unit) to Menschen-Bergkoenig - 'Sturmschlag' (Attacked unit)


Here comes the Bounce Trigger

  • Knockback GUI
    • Ereignisse
      • Einheit - A unit Startet den Effekt einer Faehigkeit
    • Bedingungen
      • (Ability being cast) Gleich Sturmschlag
    • Aktionen
      • Set target = (Target unit of ability being cast)
      • Set caster = (Triggering unit)
      • Set location = (Position of caster)
      • Ausloeser - Turn on Push <gen>
      • Wait 1.00 seconds
      • Ausloeser - Turn off Push <gen>


The second part is:

  • Push
    • Ereignisse
      • Zeit - Every 0.04 seconds of game time
    • Bedingungen
    • Aktionen
      • Einheit - Move target instantly to (location offset by ((Distance between location and (Position of target)) + 5.00) towards ((Angle from location to (Position of target)) + 1.00) degrees)


Small Translation: Bedingungen=conditions, Aktionen=actions, Einheit=unit, Zeit=time, Ereignisse=events, Faehigkeit=ability

I did notice, that if I changed the version of "Sturmschlag" (Stormbolt) in the Ability being cast = X Menu from the Unit version to the hero version my trigger stopped working. I don't know if that actually makes a difference but never the less. If it helps you I would be willing to post the map too just like you did with the test map!
 
Level 2
Joined
Sep 26, 2013
Messages
8
Alright here it comes, mind you it's a crappy old version of Kodo Tag, editing it a little for personal use. The units in question are "Runner" "Mountain King" and also "Bounce tower", but I'll be able to work out everything once it works on one of them I think! Thanks a lot!
 

Attachments

  • Kodo Tag 3.1 project.w3x
    61.8 KB · Views: 52
Level 9
Joined
Dec 12, 2007
Messages
489
I found the problem, the condition for Autocast check for the Storm Bolt ability from the Neutral Hostile - Heroes.
You change the original Human Storm Bolt 'AHtb' ability into Unit ability, while add condition check for the Storm Bolt in Hero tab which is addressed at Storm Bolt 'ANsb' of Neutral Hostile.
Try to use custom abilities, don't just edit default abilities or units. Using GUI with that habit won't go well if not cautious.
Anyway, code fixed for that specific Mountain King.
 

Attachments

  • Kodo Tag 3.1 project.w3x
    61.3 KB · Views: 79
Hm.. Most leaks are variable/function related. Here are some tips:
- Always use variables when referencing to points. Yes, even in conditions. Don't forget to clean them after usage with the custom script: 'call RemoveLocation(udg_Var)'
- Always destroy unit groups in the same manner above: 'call DestroyGroup(udg_Var)'
- Or, if you don't want to use variables for temporary groups, you could use this before a unit group pick: 'set bj_wantDestroyGroup = true'
- Anything that you use more than twice, store it into a variable, remove leaks and null it
- How to null: set udg_Var = null

Variable examples above are respectively points and groups, the third having no variable and the last could be used for points, units and unit groups.

Links: Leaks/Things a GUI user should know
 
Status
Not open for further replies.
Top