| 08-28-2009, 02:45 PM | #1 |
Does anyone happen to know any common bugs with SetUnitX(u) and SetUnitY(u)? I tried using SetUnitX( GetTriggerUnit(), GetUnitX( GetSpellTargetUnit() ) ) and SetUnitY in a spell, but the caster ended up in the middle of the map. For me, this is a common problem which is usually solved by declaring a local real (x and y). However, when I call BJDebugMsg() displaying the value of the local and the value of GetUnitX( GetSpellTargetUnit() ), they both show the same value, which makes no sence cause when I pass them on in SetUnitX they are - apparently - both 0. I will probably solve this wierd issue by simply reorganizing the code, but that won't help me if the bug occurs again. So, does anyone of you know anything peculiar about SetUnitX()? -------- Simply put: JASS:function Actions takes nothing returns nothing local unit u = GetTriggerUnit() local real x = GetUnitX( GetSpellTargetUnit() ) local real y = GetUnitY( GetSpellTargetUnit() ) call BJDebugMsg( "x = " + R2S( x ) ) call BJDebugMsg( "GetUnitX( GetSpellTargetUnit() ) = " + R2S( GetUnitX( GetSpellTargetUnit() ) ) ) //Both of these BJDebugMsg'es display the same value; ~ -6000. call SetUnitX( u, x ) //This line sets his X coordinate to 0 call SetUnitY( u, GetUnitY( GetSpellTargetUnit() ) ) //This line sets his Y coordinate to 0 endfunction |
| 08-28-2009, 02:47 PM | #2 |
is GetSpellTargetUnit() perhaps equal to null? That would explain why x and y are 0.0 |
| 08-28-2009, 03:52 PM | #3 |
Nope, it's a unit, which makes it strange. |
| 08-28-2009, 03:53 PM | #4 |
Oh, check which event you are using. |
| 08-28-2009, 03:58 PM | #5 |
GetSpellTargetUnit() doesn't work with the event "Finishes a cast", i guess that's what happening to you there ;) |
| 08-28-2009, 04:02 PM | #6 |
SpellEvent kinda solves these problems, though. |
| 08-28-2009, 04:02 PM | #7 |
You seem to be missing the key point: GetUnitX( GetSpellTargetUnit() )'s value is not 0, its value is correct. What bothers me is why it is 0 when passed on with SetUnitX |
| 08-28-2009, 04:59 PM | #8 |
Damn stupidity... JUST STORE COORDINATE IN VARIABLE... |
| 08-28-2009, 05:40 PM | #9 |
SetUnitX/Y can make a unit enter a region, and events related to it can fire. Are you sure that's not the case? |
| 08-28-2009, 05:51 PM | #10 | ||
Quote:
Please, read my entire thread before you start insulting me :( Quote:
|
| 08-28-2009, 09:01 PM | #11 |
Very stupid question, but: Are you sure the coordinates at the centre of the map are 0? And if they are, try changing the camera/map bounds so it isn't, and see if it moves the unit to 0, or to the new centre, that could provide useful information in case there is a bug in WC3 and not in your map. |
| 08-28-2009, 09:20 PM | #12 |
Are the values displayed by the debug messages correct given the position of the targeted unit? |
| 08-28-2009, 09:50 PM | #13 |
@0zyx0 Well, I'd try out your hypothesis but the problem isn't it :/ Even if center of the map would be a little off-sync, it doesn't explain why 'x' is both 0 and the unit's correct x coordinate. Thanks for your help anyway :D @Anitarf Yes, both the BJDebugMsg()'es display the correct position, but the SetUnitX() always sets the casters' X to 0. -- Just like I said I would in the thread, I've solved the issue by reorganizing the code. I just replaced both of them with SetUnitPosition( caster, x, y ) and it works fine. However, as the dumb physicist I am, I'm not very interested in the result, but rather the process; Why does SetUnitX() fail to recieve the right x value? I'm not expecting anyone to really know the 'real' reason here, but any observations on the matter would be helpful towards future usage of it. Anyway I suggest you never use SetUnitX/Y(), they are buggy as hell... |
| 08-28-2009, 10:06 PM | #14 |
It works fine, you're using them wrong Please test it properly before posting a fail thread and looking stupid |
| 08-28-2009, 10:41 PM | #15 | |
Quote:
|
