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

Issuing orders effectively doing nothing

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
Ugh... I slightly remember this problem but I've been out of wc3 for a while now

I have this code

JASS:
    function FireWave takes integer playerId, integer id, real x, real y, real angle, integer this returns nothing
        local unit dummy
        set dummy = CreateUnit(Player(playerId), casterDummy, x - (Cos(angle) * 200), y - Sin(angle) * 200, 0)
        call setAttach(dummy, this)
        call UnitAddAbility(dummy, id)
        call IssuePointOrder(dummy, "carrionswarm", x + Cos(angle) * 100, y + Sin(angle) * 100)
    endfunction

(yeah i know it leaks and isnt optimized)

In a backup of my map this code works fine. However, in the latest version, the dummy spawns but nothing happens.

I put this code in both maps to debug

JASS:
library dsf initializer onInit

    private function ot takes nothing returns nothing
        call BJDebugMsg("ORDER : " + I2S(GetIssuedOrderId()))
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
        call TriggerAddAction(t, function ot)
    endfunction
endlibrary

and it shows the backup issuing the correct order (carrionswarm) and the latest version doesnt show anything (as expected)

the dummy unit is exactly the same, i even copy-pasted the dummy unit to double check.

any ideas?

the assembler in me is about to difference check the two .j scripts
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Check your ability's order string and raw code at object editor. Make sure the order string is "carrionswarm" and the raw code is the same as attached ability (call UnitAddAbility(dummy, id)).

Order string is indeed "carrionswarm"

Add a debug message before the issue order:
JASS:
call BJDebugMsg(GetUnitName(dummy) + ": " + GetObjectName(id))
And then you'll probably be able to fix it.
Dummy name is good, id is good

difference scan netted nothing of interest
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Then check if order is succesfully received by unit.

JASS:
function FireWave takes integer playerId, integer id, real x, real y, real angle, integer this returns nothing
        local unit dummy
        local boolean b
        set dummy = CreateUnit(Player(playerId), casterDummy, x - (Cos(angle) * 200), y - Sin(angle) * 200, 0)
        call setAttach(dummy, this)
        call UnitAddAbility(dummy, id)
        set b = IssuePointOrder(dummy, "carrionswarm", x + Cos(angle) * 100, y + Sin(angle) * 100)
        if b then
            call BJDebugMsg("TRUE")
        else
            call BJDebugMsg("FALSE")
        endif
    endfunction
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Then check if order is succesfully received by unit.

JASS:
function FireWave takes integer playerId, integer id, real x, real y, real angle, integer this returns nothing
        local unit dummy
        local boolean b
        set dummy = CreateUnit(Player(playerId), casterDummy, x - (Cos(angle) * 200), y - Sin(angle) * 200, 0)
        call setAttach(dummy, this)
        call UnitAddAbility(dummy, id)
        set b = IssuePointOrder(dummy, "carrionswarm", x + Cos(angle) * 100, y + Sin(angle) * 100)
        if b then
            call BJDebugMsg("TRUE")
        else
            call BJDebugMsg("FALSE")
        endif
    endfunction

false

add ability to any controlled unit and try to cast it youself
make sure dummy doesn't try to point on any kind of cliff which is forbidden target for this kind of spell

works fine (also target is fine)
Is the spell actually based on carrionswarm?

You can't change the order strings of non-channel spells.

yes
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
1. Make sure the ability is added correctly: call BJDebugMsg(I2S(GetUnitAbilityLevel(dummy, id))).
2. Make sure the ability type is "Point Target". In case you use channel based ability, there is a chance you accidentally changed the cast type.
3. Make sure the dummy unit has enough mana.
4. Make sure the target point is reachable by dummy unit (max cast distance > distance from dummy to cast target point) in case the dummy is immobile.
5. Make sure the owner of dummy is not AI (computer) controlled player.

If those points above still don't work, I might need to look at the map.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
1. Make sure the ability is added correctly: call BJDebugMsg(I2S(GetUnitAbilityLevel(dummy, id))).
2. Make sure the ability type is "Point Target". In case you use channel based ability, there is a chance you accidentally changed the cast type.
3. Make sure the dummy unit has enough mana.
4. Make sure the target point is reachable by dummy unit (max cast distance > distance from dummy to cast target point) in case the dummy is immobile.
5. Make sure the owner of dummy is not AI (computer) controlled player.

yes yes yes yes and yes
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
Make sure the dummy unit is setup correctly. It must not need to rotate to cast (ward classification? or was it 0 movement speed?) and must have 0 cast backswing (instant cast).

Also remember that the JASS Sin and Cos functions take angle in Radians. Unit facing is returned in degrees.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Make sure the dummy unit is setup correctly. It must not need to rotate to cast (ward classification? or was it 0 movement speed?) and must have 0 cast backswing (instant cast).

Also remember that the JASS Sin and Cos functions take angle in Radians. Unit facing is returned in degrees.


The dummy unit is copy and pasted over from the version that works perfectly.

I know the trig fact, but this shouldn't be an issue because no Matter what angle is input, target point is the same and distance from target is the same
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Try importing it into a blank map and testing it to rule out any mistakes during the copying.

It is possible that another trigger is interfering and "cancelling" out the order. Make sure no other order events are running to rule this out.

but the order isn't even being recieved in the first place
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
create a test map, slap the ability and the dummy in (and whatever other necessary things) with the code and upload it here. no one will steal, i promise

It's not about theft (hell I've tried to push the rest of the community to use my code lol) it's just that sections of my code are rather obfuscated. I'll see what I can do.
 
You said this showed false:

JASS:
call UnitAddAbility(dummy, id)
         set b = IssuePointOrder(dummy, "carrionswarm", x + Cos(angle) * 100, y + Sin(angle) * 100)
         if b then
             call BJDebugMsg("TRUE")
         else
             call BJDebugMsg("FALSE")
         endif
Orders only return false if the unit can not execute the order, this may be for the following reasons:
-> the unit is silenced, rooted or anything that prevents it from reaching the target or casting the spell
-> not enough mana
-> target type does not match with the target types defined in the OE
-> unit does not have an ability with the defined order string

I suspect the last. Check the id and string again. Check the spell again.
Then check the unit; what is cast point and backswing point?

A return value of false is a clear giveaway that you changed something critical compared to back when it still worked.

Also, did you define any research dependencies in the spell?
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
You said this showed false:

JASS:
call UnitAddAbility(dummy, id)
         set b = IssuePointOrder(dummy, "carrionswarm", x + Cos(angle) * 100, y + Sin(angle) * 100)
         if b then
             call BJDebugMsg("TRUE")
         else
             call BJDebugMsg("FALSE")
         endif
Orders only return false if the unit can not execute the order, this may be for the following reasons:
-> the unit is silenced, rooted or anything that prevents it from reaching the target or casting the spell
-> not enough mana
-> target type does not match with the target types defined in the OE
-> unit does not have an ability with the defined order string

I suspect the last. Check the id and string again. Check the spell again.
Then check the unit; what is cast point and backswing point?

A return value of false is a clear giveaway that you changed something critical compared to back when it still worked.

Also, did you define any research dependencies in the spell?

To be clear - I changed the model of the dummy and tried to cast it manually and it worked fine. No mana cost, no cast time, no cooldown, etc.



So I just ported it to a different map and tested it and it worked great. FML.

Heres the original map. To test

1) Hit right arrow (or left arrow if u overshoot) untill you get to Runemaster
2) type -pick (not esc)
3) learn the Q spell
4) cast anywhere
5) note the 5 abominations in a circle that spawn and sit there. they're supposed to cast the ability in the middle of the 5. you can select one and try to cast it yourself



the "Fire Wave" function is located in the map header. The calling of it is under Spells -> WizardFireSpells (just Ctrl+F "FireWave")

apologies for the huge load/save time
 
Last edited:
To be clear - I changed the model of the dummy and tried to cast it manually and it worked fine. No mana cost, no cast time, no cooldown, etc.



So I just ported it to a different map and tested it and it worked great. FML.
If you ported the same spell to another map and it worked there, it's in some of your other triggers. Show us the whole thing, not just a function that clearly works.
 
the map was attached in my previous post
Ah, come on, you know how this works;
It's your map, you are gonna find the culprit. Don't expect us to do the dirty work for you.

The trigger section is for asking the community how to fix it, not for the community to trial and error out script parts until they found the bad script.

Open your map, deactivate triggers one by one and find out which one is causing this behaviour. Then post it.
 
Level 18
Joined
Nov 21, 2012
Messages
835
I think your problem is map size. I had very similar problem with carrionsworm on dummy, had all set right (mana, cast range, target point, etc) like you did. But it didnt work for me. The problem was map size.

You can easy check if I'm right by doing this:
1. copy your ability+dummy+hero+trigger to new empty map. DO NOT exceed 224x224. Check if working.
2. do the same on new empty map 480x480. Check if working.

I bet that you will have no problems on 1st map (small one). Big maps over 224x224 are know that sometimes generate strange errors, sometimes random errors. Personally I experienced that dummy does not execute order (but order can be executed manually by select dummy and click ability..)

zibi
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Ah, come on, you know how this works;
It's your map, you are gonna find the culprit.
Indeed. When it's only about triggers reacting with each other it should be the mappers job.

I think your problem is map size. I had very similar problem with carrionsworm on dummy, had all set right
Can you prove that with a testmap/two testmaps?
 
Level 18
Joined
Nov 21, 2012
Messages
835
I had this problem while working on TreasureHunt map for Arena , here on Hive.
Unfortunatelly I didnt keep old buged map, I replaced map after fix.

Anyway I found other problem with big-size map. It looks like game treat maths conditions in diffrent ways for normal-size (<224x224) and big maps.

2 example maps attached.
For 224x224 map game ignores small diffences for real-type value. Like 2 reals: 120.000 == 120.001 are equal.
For 480x480 map it is diffrent. Sometimes game treats 120.000 == 120.001 as true, sometimes as false.
So for example IfThenElse with GetUnitX or GetLocationX etc can mess all up on big-size maps.
 

Attachments

  • Test224x224.w3x
    89.9 KB · Views: 41
  • Test480x480.w3x
    350.1 KB · Views: 38
Level 12
Joined
Mar 13, 2012
Messages
1,121
You are right, in the 480x480 map casting fails considerably more often. Funny though, when casting in the lower left corner on the 480x480 map it always was successful for me..

I guess you know though that reals should not be compared this way.

Though being a minor "bug", I currently can only guess where this comes from.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Real numbers in computers use floating point arithmetic. Most basically that means that they are represented only approximately to be able to fit in 32- or 64-bit of memory.

As we have many different types of machines and processors, all of those will deal a little bit different with those numbers. Sometimes even the exact same machine can get a little bit different results when calculating the same thing two times when floating point numbers are involved.

This leads to problems for several applications, for example games that should be deterministic, like wc3, where every player runs his own simulation of the game where only the inputs of players are shared among each other and nothing else.

Warcraft 3 uses (IEEE 754) 32-bit floating point numbers for it's reals, and if I'm not mistaken also reduced precision in most places to keep errors down.
As we have seen in your testmap, there are still errors, though not necessarily caused by floating point problems this time, you experienced a similar problem that many (poorly written) banking applications and other programs also have experienced.


As for your specific use case, do not use such a x==y check at all and code it differently. If you absolutely have to you can make use of a cheap workaround like
abs(x-y)<0.01
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Ah, come on, you know how this works;
It's your map, you are gonna find the culprit. Don't expect us to do the dirty work for you.

The trigger section is for asking the community how to fix it, not for the community to trial and error out script parts until they found the bad script.

Open your map, deactivate triggers one by one and find out which one is causing this behaviour. Then post it.

.. seriously?

Just upload the map if possible.


not possible

create a test map, slap the ability and the dummy in (and whatever other necessary things) with the code and upload it here. no one will steal, i promise

If you ported the same spell to another map and it worked there, it's in some of your other triggers. Show us the whole thing, not just a function that clearly works.

alright warcraft 3 can go burn. Sounds good to me. Not worth my time to fix an issue like this (and deactivate triggers one by one when nearly every library is dependent on the other and in the end its due to something stupid like the map size)
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
When this is already enough to throw you off the track, I wonder how you even got there to begin with.

Mapping is not for guys with low patience.

I'm sorry I only waited seven years to be able to issue a damn order to a unit and still can't do it.
 
Status
Not open for further replies.
Top