[vJASS] Can't cast "cluster rockets" using triggers...

Status
Not open for further replies.
I'm trying to trigger it so that when a unit attacks, it also casts "cluster rockets". The way i solved this was to attach a dummy unit to it, give the spell to the dummy, and order it to cast it at the target location. Problem is, it doesn't work.

I'm not gonna paste all of the code, but here is the attack part (pretty straightforward):

JASS:
        method attack takes unit target returns nothing
            call SetUnitX(.dummy, GetUnitX(.u))
            call SetUnitY(.dummy, GetUnitY(.u))
            
            if IssuePointOrderById(.dummy, OrderId("clusterrockets"), GetUnitX(target), GetUnitY(target)) == false then
                call BJDebugMsg("Failed to cast...")
            endif
        endmethod

When the unit attacks, the debug text "failed to cast" appears. However, if i make the dummy visible and selectable, i can manually order it to cast the spell without problem. The dummy will move instantly to the location of the attacking unit, just as it is supposed to. The dummy does not have "locust", and is owned by the same player as the attacker. I feel like i've tried everything here, but it just won't work. :ogre_rage:
 
The code looks fine. There must be some object editor data that isn't allowing the dummy to cast the spell. Does resetting the Cluster Rockets ability to default make it work? Can the dummy cast other spells and it is just the cluster rockets that isn't working?

Not that it matters, but:
JASS:
if IssuePointOrderById(.dummy, OrderId("clusterrockets"), GetUnitX(target), GetUnitY(target)) == false then

->

if not IssuePointOrderById(.dummy, OrderId("clusterrockets"), GetUnitX(target), GetUnitY(target)) then
 
Level 7
Joined
Oct 19, 2015
Messages
286
Is the target a valid unit? If not, then GetUnitX would be returning 0.0 and the dummy could be trying to cast out of its cast range - if you disabled its movement, then that could cause the casting to fail.
 
I tried it with the "rain of fire" spell, and it actually works. Then i tried resetting the cluster rockets spell back to normal, changing only the mana cost, level, and the "hero ability" checkbox - and it still doesn't work. Why?? I've made sure 100 times that the order string is the exact same. The unit HAS the ability, and can cast it manually. I have no idea why it doesn't work.

Btw,
Code:
statement == false

Is computationally the exact same as

Code:
!statement

Either way, i just added that if-statement for debugging and don't intend to keep it.
 
if you disabled its movement, then that could cause the casting to fail.
I'm not sure if "removing the move ability" or disabling the movement are the same things, but I always do the former and it's a must for almost all dummy casters.

I tried it with the "rain of fire" spell, and it actually works. Then i tried resetting the cluster rockets spell back to normal, changing only the mana cost, level, and the "hero ability" checkbox - and it still doesn't work. Why?? I've made sure 100 times that the order string is the exact same. The unit HAS the ability, and can cast it manually. I have no idea why it doesn't work.
Hmm that's very odd. I'm not sure then what's wrong. Do you mind posting a test map so I can do it myself on your map? I've just recreated a JASS snippet that just orders a locust dummy caster to cast cluster rockets anywhere and it works just fine for me. Could you also maybe add a debug message that displays the values of x and y of target?

Either way, i just added that if-statement for debugging and don't intend to keep it.
I know you did, that's why I just said "it doesn't matter" :p I was just letting you know for future reference that if it returns a boolean, you don't have to directly check for that boolean.
 
Is the target a valid unit? If not, then GetUnitX would be returning 0.0 and the dummy could be trying to cast out of its cast range - if you disabled its movement, then that could cause the casting to fail.

Already thought of that - i had made the range of the ability larger than the map bounds, to make sure that this wasn't the case. The X and Y values seem valid, since apparently, the system works fine with other spells (see previous response).

I recommend creating a simple trigger which prints out the order ID of any order issued and then manually casting your ability off of a unit to see what the order ID actually is. Sometimes/often the object editor lies when it comes to order strings.

I tried a statement which checked whether GetIssuedOrderId() == OrderId("clusterrockets"), and it confirms that this is indeed the orderid when i cast the spell manually.

EDIT: I tried using the default "cluster rockets" ability instead of copying my own (i only changed a couple of small things), and it still doesn't work.
 
Last edited:
Level 7
Joined
Oct 19, 2015
Messages
286
Did you try using IssuePointOrder isntead of IssuePointOrderById?

I really can't think of any good reason this could fail, if you are able to cast the spell manually.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
I had a problem of this a year ago but it is from carrion swarm, same events of unit attacking. It doesn't work on my own map so I tried debugging it in a new map and it works, so it is just a user faulty in my map. I backup my map and tried resetting custom abilities to default except for the carrion swarm and it works like hell. So I guess the root cause of the problem is from my custom abilities and since the ordering is the problem I managed to change the order ids involving in channel abilities that has a carrion swarm orders and it fixed the issue. It is like an issue from where the unit have 2 abilities with a same order ids will cause definitely a problem that the engine is confused how it will execute the same order.
 
Status
Not open for further replies.
Top