• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Unit not casting spell

Status
Not open for further replies.
Level 2
Joined
Feb 10, 2017
Messages
19
[PROBLEM SOLVED]


I've been a casual mapper for a pretty long time but i'm still an amateur and i'm quite ashamed to post a simple question like this, but can somebody tell me why the unit won't cast any spell?
It just stands there and does nothing.
It has enough mana to cast the spell, I'm pretty sure i've not forgotten anything obvious.

PS: Also bear in mind that i have the german version of the map editor, i tried to translate the important lines as good as possible.

OgerUndTrollSpellTrigger3
Events
Unit - Troll-Hauptmann Tekesh 0236 <gen> Notices a target within range
Conditions
Actions

Unit - Order Troll-Hauptmann Tekesh 0236 <gen> to Undead summoner - 'Unholy Frenzy' (Random unit from (Units within 600.00 of (Position of Troll-Hauptmann Tekesh 0236 <gen>) matching ((Owner of (Matching unit)) not equal Player 1 (Red))))
Wait 5.00 seconds
 
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Has it the techtree requirements? Can the spell be casted on the target? Units within range also affects dead units and buildings. So a unit might be chosen which you cannot cast unholy frenzy on.
Why are you using the wait?
Btw. there are leaks in your trigger.
 
Level 2
Joined
Feb 10, 2017
Messages
19
Has it the techtree requirements? Can the spell be casted on the target? Units within range also affects dead units and buildings. So a unit might be chosen which you cannot cast unholy frenzy on.
Why are you using the wait?
Btw. there are leaks in your trigger.

It's neutral hostile unholy frenzy so it doesn't need any techtree requirements.

Yes the spell can be casted on every target that's supposed to be in range in that fight.

I was using the wait because i was thinking the unit would get too many orders in a row (because everytime a unit notices a target is something like every 0.01 sec) and that'd be the cause of the "freeze".
But it doesn't matter if i put in the "wait".

What do you mean with "leaks"?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I tried this trigger on my map and it worked. The wait at the end does nothing because no actions follow after the wait.

If you want to stop the trigger from triggering you could do:
Turning the trigger off means, that the events will not be activated.
  • Wait
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Wait 5.00 seconds
      • Trigger - Turn on (This trigger)
Check out this sticky thread for leaks:

Things That Leak

Problem could be, that the unit that is randomly chosen from your unit group is an untargetable unit.
As I already said a building or a dead unit (corpse) could be chosen.

In warcraft orders that are given to a unit can be succesful or not. In GUI the order functions do not return whether they were succesful or not, but in JASS you can see it.

This trigger will do the same as your trigger, but also shows you if the order was succesful.
  • OgerUndTrollSpellTrigger3
    • Events
      • Unit - Troll-Hauptmann Tekesh 0236 <gen> Notices a target in range
    • Conditions
    • Actions
      • Set UNIT = (Triggering unit)
      • Set UNIT2 = (Random unit from (Units within 600.00 of (Position of UNIT) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red))))
      • Custom script: set udg_BOOLEAN = IssueTargetOrder(udg_UNIT,"unholyfrenzy",udg_UNIT2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BOOLEAN Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: true
        • Else - Actions
          • Game - Display to (All players) the text: false
You could try to replace your trigger with this one to see if the order was succesful. You could also send me your map so I can see what's going on.



Which player does the Troll-Hauptmann Tekesh belong to? Is this player a user or a computer?
 
Level 2
Joined
Feb 10, 2017
Messages
19
How do i get to: "If (All Conditions are True) then do (Then Actions) else do (Else Actions)"?
I can't seem to find (All Conditions are True) under "If/Then/Else" --> "Condition".

Troll Hauptmann Tekesh belongs to the computer and is neutral hostile.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Are you using the reign of chaos editor? I just checked the roc editor and there seems to be no if then else multiple conditions.
 
Level 2
Joined
Feb 10, 2017
Messages
19
No, i'm using the FT Editor.
I was just too stupid to realize "If/Then/Else, multiple functions" was the function i was supposed to be looking for. ^^
What kind of variable did you use for BOOLEAN?
 
Level 2
Joined
Feb 10, 2017
Messages
19
I've tested it 8 times and it said:

2x (the first 2 tries)
true
false
true

6x
true



And then Troll-Hauptmann Tekesh stops completely in doing anything.
I'm not exactly sure what that means.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I tried this trigger and it happened as well. The caster stopped within the animation. I don't know what this means, because it never happened to me this way before. I guess it has something to do with the event "Notices a target within range". Because the order action on itself works. You should try using a different event.
I would go with:
  • OgerUndTrollSpellTrigger3
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacking unit) Equal to Troll-Hauptmann Tekesh 0236 <gen>
    • Actions
      • Set UNIT = (Attacking unit)
      • Set UNIT2 = (Random unit from (Units within 600.00 of (Position of UNIT) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red))))
      • Custom script: set udg_BOOLEAN = IssueTargetOrder(udg_UNIT,"unholyfrenzy",udg_UNIT2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BOOLEAN Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: true
        • Else - Actions
          • Game - Display to (All players) the text: false
 
Level 2
Joined
Feb 10, 2017
Messages
19
The chat now spams "false".
Is this how it's supposed to be?
Tekesh is casting unholy frenzy now but it seems more like an "AI-autocast" ignoring the trigger because he always unholy frenzy himself and maybe 1 or 2 more mobs but then he just stops although there are plenty of other mobs around him.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
He will try to cast unholy frenzy when he attacks. If he cannot cast unholy frenzy he will just attack. Every time he starts attacking a text message will be displayed, so yes this is how it is supposed to be. False means, that there is no target available or he cannot cast unholy frenzy at all (cooldown/mana).
You should probably add a condition to the unit group so only units are picked that do not have the buff unholy frenzy already so he does not cast multiple times on the same unit.

He could stop, because he is not attacking anymore or because he cannot cast anymore (cooldown, mana).
 
Level 2
Joined
Feb 10, 2017
Messages
19
He has enough mana, the cd is 1 sec, there are plenty of mobs around him but he doesn't cast.

I've tried another way of fixing it and it seems to work like that now although i have no idea why this works:

Events

Unit - Troll-Hauptmann Tekesh 0236 <gen> Notices target within range

Conditions

TekeshFlag equals 0

Actions

Unit - Order Troll-Hauptmann Tekesh 0236 <gen> to Undead summoner - 'Unholy frenzy' (Random unit from (Units within 700.00 of (Position of Troll-Hauptmann Tekesh 0236 <gen>) matching ((Owner of (Matching unit)) not equal Player 1 (Red))))

Set TekeshFlag = 1

Wait 2.00 Seconds

If (TekeshFlag equals 1) then do (Set TekeshFlag = 0) else do (Do nothing)

Set UNIT = (Triggering unit)

Set UNIT2 = (Random unit from (Units within 700.00 of (Position of UNIT) matching ((Owner of (Matching unit)) not equal Player 1 (Red))))

Custom script: set udg_BOOLEAN = IssueTargetOrder(udg_UNIT,"unholyfrenzy",udg_UNIT2)

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Conditions
BOOLEAN equals True
'THEN'-Actions
Game - Display to (All players) the text: true (deactivated)
'ELSE'-Aktionen
Game - Display to (All players) the text: false (deactivated)

______________________________________

I made it like that because i thought that Tekesh had to pick a random unit everytime he notices a target (so: like every 0.01 sec) and because of that he was unable to decide for 1 target or he just got stuck in the animation because the animation takes too much time to go through or something like that.

If i deactivate your part (you know the part with the script etc) it doesn't work anymore although it should i think.
It's really weird but i'm glad it finally works.

If you have any ideas why it's like that please let me know.

Anyways, cheers mate for helping me out.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I don't know why he should stop casting, but what you said about the noticing every 0.01 sec is not true. I don't know how the notices a target event works, but it does not trigger every 0.01 sec. I found out, that if you add a wait of 0.1 sec to the trigger with notices a target and after that you order the unit to cast it works.
I assume you should never order a unit to do someting at the same time as it notices a target (I also tried to order it to move and the unit stopped its animation). Using 0.00 timer however works as well.

The wait is probaly the reason why it works now. You should be able to use the trigger you posted in your first post, but with a short wait before the order action.
 
Level 2
Joined
Feb 10, 2017
Messages
19
I don't know why he should stop casting, but what you said about the noticing every 0.01 sec is not true. I don't know how the notices a target event works, but it does not trigger every 0.01 sec. I found out, that if you add a wait of 0.1 sec to the trigger with notices a target and after that you order the unit to cast it works.
I assume you should never order a unit to do someting at the same time as it notices a target (I also tried to order it to move and the unit stopped its animation). Using 0.00 timer however works as well.

The wait is probaly the reason why it works now. You should be able to use the trigger you posted in your first post, but with a short wait before the order action.

Yep, it works.

So the solution to this problem is simply to put a 0.1 sec "Wait" before the spell-cast trigger.

Thanks for your help.
Topic done.
 
Status
Not open for further replies.
Top