| 05-14-2007, 05:01 AM | #1 |
Since I've started JASS... Yes im not lieing i've been working on an morhing system. Even after a 2 checks i still don't get why thios won't work. Here's the codefunction JASS:MS_Sfx_Morph takes unit target, integer morph, real time, string sfx, string sfxpoint returns unit local player p = GetOwningPlayer(target) local unit u local real x = GetUnitX(target) local real y = GetUnitY(target) call PolledWait (time) call DestroyEffect(AddSpecialEffectTarget(sfx,target,sfxpoint)) call RemoveUnit (target) set u = CreateUnit(p, morph, x, y, 270.) if IsUnitSelected(null,p)then call SelectUnitForPlayerSingle(u,p) endif call SelectUnit(u,true) set p = null return u endfunction The bits u might want to concentrate on are properly everything except the things tht relate to selection. THE EFFECT BIT IS WHAT I WANT TO KNOW ISN'T WORKIN. (And im feeling noobish) -Av3n |
| 05-14-2007, 05:18 AM | #2 | |
Quote:
_______ Well, I'm going to look at the selection thing anyway, because if IsUnitSelected(null, p) doesn't make any sense. That should never return true, and it might even cause a thread crash, but I'm not sure. Shouldn't it be if IsUnitSelected(target, p)? Actually... that doesn't make sense anyway. The selection check should be before removing the unit. Because you're passing the time as an argument, you should do a check for "null" to see if there should be a wait, because a wait time of "0.00" still waits the minimum time. This also eliminates the need to have two functions. Like so: JASS:if time != null then call PolledWait(time) endif //Here's how a function would call a morph with no time: call MS_Sfx_Morph(SomeUnit, 'h001', null, "SomeImportedModel.mdx", "origin") You're leaking the variable "u", but the only way to get around that would be to use a global for the unit and then null it after calling the function; use bj_ghoul[] perhaps. When you say that it "doesn't work", what specifically doesn't happen/work correctly? |
| 05-14-2007, 05:21 AM | #3 |
Perhaps it is the most silly way ever invented to check if the player's selection is empty. In that case, please reverse your logic and check for the unit NOT being selected instead of player selecting no unit, cause it doesn't work that way |
| 05-15-2007, 04:04 AM | #4 |
Ok Thank you for pointing out errors for the selection part *sigh* I just wanted to know why the effect is not working??? Well i done a few tests alrdy but it doesn't work. Just ingnore this for now. Im going to try an opther way to work around this -Av3n |
| 05-15-2007, 04:52 AM | #5 |
From what I can see you attach a special effect to a unit and then immediately remove the unit. Could this perhaps cause the effect to be removed along with the unit, not giving it enough time to even play its "death" animation. ---- This is just a hunch, I am not for certain, but it seems like it could be a source of error. Vex didn't say anything about it though so I am doubting myself. Try doing this: JASS:call DestroyEffect( AddSpecialEffect( sfx, GetUnitX( target ), GetUnitY( target ) ) ) call RemoveUnit( target ) |
| 05-15-2007, 04:57 AM | #6 |
okay tht was useful. I think that i gonna rework the system code abit thinking of other ways to make it better -Av3n |
