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

[JASS] Fire Bomber

Status
Not open for further replies.
Hi guys, i am trying to make a spell which calls a plane that drops incendiary bombs.

Blizzard made a spell like i want to, it is in (6)BomberCommand map. I tried to evaluate the codes and to learn from them, but they are just to complex for me ... Can any1 plz tell me how i can use incendiary bomber in my map ?

I know you guys have the map, but i will attach it anyway ...

Plz help ? i would really love to learn this ..
 

Attachments

  • (6)BomberCommand.w3x
    581.2 KB · Views: 67
Thx for your reply. Well, you see, that is the problem. If the spell and code were contained in only 1 trigger, it would be no problem for me.

However, there are functions all over the map. The map header is of crucial importance for the entire system to work properly, than you have the fade out triggers, the damage triggers the unit triggers, the flight triggers and the effect triggers, all over the map together with the training triggers, score triggers, camera triggers and ability triggers.

It is nearly impossible to distinguish, you can't delete one trigger without causing problem in the others.

The fire bomber triggers can be found in the bomber trigger, plane trigger, plane type and others. I mainly studied this 3, but is impossible to distinguish things.

You also have Global variables.... which join to the party just to make our life more difficult than it already is ....

This is why I posted this question in this forum, because I really think I could use some help on this.

I already tried to isolate the main triggers, but the result was a complete failure, there is no way i can do it without destroying the map ....

Help !?

EDIT

Ok, so i've already waited too long from help. Therefore i decided to create my own bomber ability.
After some frustrated evaluation of the map, i searched for maps in the spell sections and the result was in fact better then i expected.

I will start simple.

JASS:
function Trig_Fire_Bomber_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//===========================================================================
function Trig_Fire_Bomber_Actions takes nothing returns nothing
    local unit bomber
    local unit bomb
    local player p = GetTriggerPlayer()
    local location m = GetSpellTargetLoc()
    call CreateUnit(p, 'h002', GetLocationX(m) + 500, GetLocationY(m) + 500, 90) 
    set bomber = GetLastCreatedUnit() 
    call IssuePointOrder( bomber, "move", GetLocationX(m)- 5000, GetLocationY(m)- 5000)
endfunction

//===========================================================================
function InitTrig_Fire_Bomber takes nothing returns nothing
    set gg_trg_Fire_Bomber = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fire_Bomber, Condition( function Trig_Fire_Bomber_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Bomber, function Trig_Fire_Bomber_Actions )
endfunction
here is my code.

This code does not work as it should.
I would like to create a unit (bomber) with polar offset, but my JASS knowledge does not allow me to do so freely.

I would like to create the bomber 500 meters away from the casting point, and facing that same casting point.
The bomber would move, pass through the casting point (500 meters) and then leave.

It would be something like this

JASS:
function Trig_Fire_Bomber_Actions takes nothing returns nothing
    local unit bomber
    local unit bomb
    local player p = GetTriggerPlayer()
    local location m = GetSpellTargetLoc()
    call **Create a unit facing the casting point, and that is 500 meters away from it**
    set bomber = GetLastCreatedUnit()
    call **Issue the unit an order to pass 500 meters through the casting point**
    //other actions.
endfunction

I tried to use a "Create Unit With Polar Offset" from GUI and to convert it after, but the result was confusing laggy and had lots of leaks.

Therefore i must ask for your help.
Can you guys tell me how to do this ?


EDIT

Guys i made some advances in my trigger.
Now the unit is created where i want, but the "move" part is messed up... when the unit is moving, it performs an arc .. and i just want it to move it a rect direct straight line ...

Can you guys please help me with the move call ??

Oh and my script now will surely lag like hell ... if you guys have good suggestions to reduce lag, i would like to hear them ...

JASS:
function Trig_Fire_Bomber_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//===========================================================================
function Trig_Fire_Bomber_Actions takes nothing returns nothing
    local unit bomber
    local unit bomb
    local player p = GetOwningPlayer(GetSpellAbilityUnit())
    local location m = GetSpellTargetLoc()          
    local real angle 
    call CreateNUnitsAtLoc( 1, 'h002', p, PolarProjectionBJ(m, -1500, AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), m)), bj_UNIT_FACING )
    set bomber = GetLastCreatedUnit() 
    set angle = AngleBetweenPoints(GetUnitLoc(bomber), m)
    call IssuePointOrderLoc( bomber, "move", PolarProjectionBJ(m, 1000.00, angle) )
    call RemoveLocation(m)
    set bomber = null
    set bomb = null
    set p = null
    set m = null
endfunction

//===========================================================================
function InitTrig_Fire_Bomber takes nothing returns nothing
    set gg_trg_Fire_Bomber = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fire_Bomber, Condition( function Trig_Fire_Bomber_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Bomber, function Trig_Fire_Bomber_Actions )
endfunction
 
Last edited:
Level 19
Joined
Aug 24, 2007
Messages
2,888
%100 GUI hmm sounds possible but Im talking about MUI and without variables
I never make anyspell with variables or not MUI that would suck
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Im too busy (lazy) for that for now
also it may (does) require some dummies (planes and may be projectiles for size change)
why dont you learn some vJass
 
I know it does dummies and i know how and when to use them.

Still, i do NOT need any dummies now !!!

and i do NOT need vjass to make a single move call !!!

For God sake read my post ! I don't acre about the spell, i just want to know, why my call "issueorder" is not working correctly !!!!! I just want to reduce some lag as well ...

I don't need vjass for this !
I just need help !

Btw, when can i learn vjass ?
 
Hi guys !.
Well as you already know I am making a fire bomb spell to post in the spell section. But I have a few troubles.

it seems that the movement thing is not a problem.
But I have Another one (or two soon).
How do I fade my bomber, while it is moving ?
Well to achieve this I use a loop... But problem is that everything stops when the code reaches it ! and I don't want that ...
JASS:
function Trig_Fire_Bomber_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//===========================================================================
function Trig_Fire_Bomber_Actions takes nothing returns nothing
    local unit bomber
    local unit bomb
    local player p = GetOwningPlayer(GetSpellAbilityUnit())
    local location m = GetSpellTargetLoc()          
    local real angle 
    local integer transparency = 255
    call CreateNUnitsAtLoc( 1, 'h002', p, PolarProjectionBJ(m, -1000, AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), m)), bj_UNIT_FACING )
    set bomber = GetLastCreatedUnit() 
    call SetUnitVertexColor(bomber, 255, 255, 255, 100)
    //where to put this loop ? or how to use it ?
    loop 
        exitwhen transparency == 0
        call TriggerSleepAction(0.1)
        call SetUnitVertexColor(bomber, 255, 255, 255, 100 - transparency)
        set transparency = transparency - 5
    endloop 
    //loop ends here
    set angle = AngleBetweenPoints(GetUnitLoc(bomber), m)
    call IssuePointOrderLoc( bomber, "move", PolarProjectionBJ(m, 1000.00, angle) )
    call RemoveLocation(m)
    set bomber = null
    set bomb = null
    set p = null
    set m = null
endfunction

//===========================================================================
function InitTrig_Fire_Bomber takes nothing returns nothing
    set gg_trg_Fire_Bomber = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fire_Bomber, Condition( function Trig_Fire_Bomber_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Bomber, function Trig_Fire_Bomber_Actions )
endfunction

So question is, what do I do with the loop ? How do I change the color of my bomber without making it wait until it is visible ?

I would like something like this:
1 - unit is created invisible. (done)
2 - Unit is ordered to move and it moves (done)
3 - While it is moving it will become visible (Not done)

But I have something like this:
1 - unit is created invisible. (done)
2 -We all wait unit it gets visible (bad)
3 - The unit only moves after the loop (boring and bad)

Can you guys help me solve this problem ? plz ?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
hmm lets see
JASS:
function FadeFunction takes nothing returns nothing
local unit f = bj_lastCreatedUnit
local integer fade = 0
loop
exitwhen fade == 10
call SetUnitVertexColor(bomber, 255, 255, 255, 100 - transparency*10)
call TriggerSleepAction(0.1)
set fade=fade+1
endloop
endfunction
function Trig_Fire_Bomber_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000' 
endfunction //=========================================================================== 
function Trig_Fire_Bomber_Actions takes nothing returns nothing 
local unit bomber local unit bomb 
local player p = GetOwningPlayer(GetSpellAbilityUnit()) 
local location m = GetSpellTargetLoc() 
local real angle 
local integer transparency = 255 
call CreateNUnitsAtLoc( 1, 'h002', p, PolarProjectionBJ(m, -1000, AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), m)), bj_UNIT_FACING ) 
set bomber = GetLastCreatedUnit() 
call SetUnitVertexColor(bomber, 255, 255, 255, 100) //where to put this loop ? or how to use it ? 
set bj_lastCreatedUnit = bomber
call ExecuteFunc("FadeFunction")
set angle = AngleBetweenPoints(GetUnitLoc(bomber), m) 
call IssuePointOrderLoc( bomber, "move", PolarProjectionBJ(m, 1000.00, angle) ) 
call RemoveLocation(m) set bomber = null 
set bomb = null set p = null set m = null 
endfunction //=========================================================================== 
function InitTrig_Fire_Bomber takes nothing returns nothing 
set gg_trg_Fire_Bomber = CreateTrigger( ) 
call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT ) 
call TriggerAddCondition( gg_trg_Fire_Bomber, Condition( function Trig_Fire_Bomber_Conditions ) ) 
call TriggerAddAction( gg_trg_Fire_Bomber, function Trig_Fire_Bomber_Actions ) 
endfunction

AND THIS LEAKS MUUUUUUUUUUCCCCCCCCHHHHHHHHHH
 
That seems useful and interesting, where can in find that spell ??
However i can use waits instead of timers, they are less accurate and precise, but they are far easier to use and understand.

EDIT

Meh, I know it leaks like hell, but I am not worry about that rit now.
WOW. Do you know what is stupid ?? Is that I tried that before and that didn't work ... but now it works ... what have you done dude !? LOL...

Anyway thx. I will fix lags and stuff like that.

Btw, great random spell pack you created =).



EDIT

MM, Hey I have two more questions. I know how timers are better then waits. IN a "wait" I can only have 0.1 as but in timers I can have 0.01
How do I replace the wait in my loop by a nice timer ??

(Well, I no longer need this, I figured a way out, but it would be nice if some1 could help me)

Also, can't I use parameters in ExecuteFunc("......") ??? Because using GetLasCreatedUnit is a little bad, it makes my spell not MUI (I guess).

Can you guys hep me out ?



EDIT EDIT

Hi, well, I have another problem. My code has grown and it is long now, so I just just put the parts of the code that are annoying me.

JASS:
function test takes integer getFade returns integer //this will set i to 100
    local integer i = getFade
    loop 
        exitwhen (i == 100)
        call TriggerSleepAction(0.1)
        set i = i + 35   
    endloop
    return i  // return i which is equal to 100 ( I think)
endfunction 
//===============================================
function test2 takes integer getFade returns integer  // this will set i to 0
    local integer i = getFade
    loop 
        exitwhen (i == 0)
        call TriggerSleepAction(0.1)
        set i = i - 35   
    endloop
    return i   //returns i which is 0 (I guess)
endfunction 
//=============================================================
function Trig_Fire_Bomber_Actions takes nothing returns nothing
    local integer fadeValue = 0  //dummy variable used to call other things
    //This loop waits until i (from test) is equal to 100 ( I think)
    loop
        exitwhen ( test(fadeValue) == 100)
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.1))
    endloop
    
    set fadeValue = 100  // because i = 100 ( I think) I have to set dummy var  to 100 too
    //this loop waits until i (from test2) is equal to 0 (I think)
    loop
        exitwhen ( test2(fadeValue) == 0)
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.1))
    endloop
    //When i = 0, (I think) I move on and kill some unit. 
    call KillUnit(bomber)
endfunction


This should work ... but it doesn't ...
Can you guys help me and tell me why ? plz ?
 
Last edited:
MMm, I see. Anyway, I don't need the time now.

and btw
Wait is unacceptable in spells.
is a barbarity. Sure Timer are useful in some situations, even I have to agree with such.
But waits are far more simple to use, and do exactly what timers do (not with such precision, but that is not a problem for me).

I am trying hard to make this spell simple. Timers are out of question because waits are more simple to use and understand.

STill thx for your comment.

More suggestions about how to fix my code ? plz.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
it will be ok if you store variable execute func
and store the global in a local in start of function
it will be MUI because even GetLastCreatedUnit gets changed sometime
it wont make problem because we stored it in a local and we use the local one
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
You shouldnt hate vJASS
Most Efficent Reason >Quote: "Blizzard doesnt support world editor directly"
I think they released it so quickly and didnt have time to improve
so here comes NewGen WE and does the parts that blizzard didnt have time to do

HappyTauren is extremly right about that
Well if you want to learn how to use structs
Best thing to do is exemine on Orbital Bombardment
Great example for using timers with structs
 
I see ...

Thx. However now that I probably fixed that, now I have another annoying error.

[jass=annoying mistake in the loop] call SetUnitFlyHeight(bomber, 370, 150.0)

loop
exitwhen ( GetUnitFlyHeight(bomber) < 369.0)
call TriggerSleepAction(1.0)
endloop

call SetUnitFlyHeight(bomber, 1000, 170.0)

set fadeValue = 255

call ExecuteFunc("FadeOut")[/code]

Well, first I start to make my fire bomber going down. It is a nice effect to look realistic.
After ordering it to going down I have a Wait for condition loop (improved by me).
What does that loop do ?
Well, every time the fly heigh of my beloved bomber is > to 370, the code waits 1 second (to give enough time for the bomber to go down).

After that loop I order the plane to go up again.
While it is going up, it will eventually fade out and disappear in the fog (lol).

Now the problem ?
The problem is in the loop !!! It just doesn't work. Although the bomber goes to 370 height, it dies never go up again ! and I don't understand why ...

I already tried with:
1 - GetUnitFlyHeigh <= 370 (it should be the logic and work but it doesn't, the plane doesn't go down, it just jumps the loop [I think] and goes up)

2 - GetUnitFlyHeigh < 370 (the plane goes down but doesn't go up)

3 - GetUnitFlyHeigh > 370 (the plane just goes up like in case 1)

4 - GetUnitFlyHeigh >= 370 (equal case 3)

I don't know what else to do.... can you guys help me ?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Dont have a solution for that
but I guess a local boolean can help you
like isgoingup
lets say action wont be executed again if it is executed already
change and ask for it inside actions

.... nvm that would be stupid

Nope maybe taurenguy can help
 
Mm, found the problem... It happens that it is a Blizzards bug and not mine.

JASS:
call SetUnitFlyHeight(bomber, 370, 150.0)
    //here the fly height is SET to 370. 
//Although the unit goes down gradually in the 
//animation, its fly heigh is set to 370. This way, 
//when the code enters the loop, it instantly quits it, 
//because the condition is true.
    loop
        exitwhen ( GetUnitFlyHeight(bomber) <= 370)
        call TriggerSleepAction(1)
    endloop
    //because the loop was jumped, the plane just 
//goes up.     
    call SetUnitFlyHeight(bomber, 1000, 170.0)
    
    set fadeValue = 255
    call ExecuteFunc("FadeOut")

So, I have only 1 choice left:
1 - use a wait... (or a timer, but I don't like those too much).

Well, I have to count the time that the plane takes to go down and place that time into a wait ....

If you guys have any other solution, plz I am willing to hear it, but I think this is the only way.

EDIT

Btw the wait has too many problems ... can you guys plz tell me a way to know where a bomb reaches the ground (fly height 0) that doesn't use a wait plz ??


EDIT

Can I use collision size to see if a bomb collides with ground ???
 
Last edited:
Level 5
Joined
Aug 16, 2007
Messages
149
heres a function by KaTTana some time back to fade vertex colors... works with alpha too and both ways. Could come in handy but uses KaTTana's local handle vars so you might not want to use it
JASS:
function FadeUnitVertexColor_Update takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local real r = GetHandleReal(t, "r") + GetHandleReal(t, "dr")
    local real g = GetHandleReal(t, "g") + GetHandleReal(t, "dg")
    local real b = GetHandleReal(t, "b") + GetHandleReal(t, "db")
    local real a = GetHandleReal(t, "a") + GetHandleReal(t, "da")
    local integer step = GetHandleInt(t, "step") - 1
    local unit u = GetHandleUnit(t, "u")
    call SetUnitVertexColor(u, R2I(r*255), R2I(g*255), R2I(b*255), R2I(a*255))
    if ( u == null or step <= 0 ) then
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
        call SetHandleHandle( u, "FadeUnitVertexColor_Timer", null )
        set t = null
        set u = null
        return
    endif
    call SetHandleReal(t, "r", r)
    call SetHandleReal(t, "g", g)
    call SetHandleReal(t, "b", b)
    call SetHandleReal(t, "a", a)
    call SetHandleInt(t, "step", step)
    set t = null
    set u = null
endfunction
function FadeUnitVertexColor takes unit u, real r1, real g1, real b1, real a1, real r2, real g2, real b2, real a2, real time returns nothing
    local timer t = GetHandleTimer( u, "FadeUnitVertexColor_Timer" )
    local real update = 0.05
    if ( time <= 0 ) then
        call SetUnitVertexColor(u, R2I(r2*255), R2I(g2*255), R2I(b2*255),  R2I(a2*255))
        if ( t != null ) then
            call PauseTimer( t )
            call DestroyTimer( t )
            call SetHandleHandle( u, "FadeUnitVertexColor_Timer", null )
            set t = null
        endif
        return
    endif
    call SetUnitVertexColor(u, R2I(r1*255), R2I(g1*255), R2I(b1*255),  R2I(a1*255))
    if ( t == null ) then
        set t = CreateTimer()
        call SetHandleHandle( u, "FadeUnitVertexColor_Timer", t )
    else
        call PauseTimer( t )
    endif
    call SetHandleReal(t, "r", r1)
    call SetHandleReal(t, "g", g1)
    call SetHandleReal(t, "b", b1)
    call SetHandleReal(t, "a", a1)
    call SetHandleReal(t, "dr", update*(r2-r1)/time)
    call SetHandleReal(t, "dg", update*(g2-g1)/time)
    call SetHandleReal(t, "db", update*(b2-b1)/time)
    call SetHandleReal(t, "da", update*(a2-a1)/time)
    call SetHandleHandle(t, "u", u)
    call SetHandleInt(t, "step", R2I(time/update + 0.99))
    call TimerStart(t, update, true, function FadeUnitVertexColor_Update)
    set t = null
endfunction
the params r1,g1,b1,a1,r2,g2,b2,a2 should be between 0-1, 0 = 0%, 1 = 100%
 
Level 5
Joined
Oct 27, 2007
Messages
158
Mm, found the problem... It happens that it is a Blizzards bug and not mine.

JASS:
call SetUnitFlyHeight(bomber, 370, 150.0)
    //here the fly height is SET to 370. 
//Although the unit goes down gradually in the 
//animation, its fly heigh is set to 370. This way, 
//when the code enters the loop, it instantly quits it, 
//because the condition is true.
    loop
        exitwhen ( GetUnitFlyHeight(bomber) <= 370)
        call TriggerSleepAction(1)
    endloop
    //because the loop was jumped, the plane just 
//goes up.     
    call SetUnitFlyHeight(bomber, 1000, 170.0)
    
    set fadeValue = 255
    call ExecuteFunc("FadeOut")
So, I have only 1 choice left:
1 - use a wait... (or a timer, but I don't like those too much).

Well, I have to count the time that the plane takes to go down and place that time into a wait ....

If you guys have any other solution, plz I am willing to hear it, but I think this is the only way.

EDIT

Btw the wait has too many problems ... can you guys plz tell me a way to know where a bomb reaches the ground (fly height 0) that doesn't use a wait plz ??


EDIT

Can I use collision size to see if a bomb collides with ground ???

From what height comes the unit? It descents from x? to 370 (absolute or relative height?) and then rises up and disappears (becomes transparent). Well the solution of static waits is not recommended. Since you need to change the delay for every bomber that is not coming from the same height. Why do you consider this a bug? Did you try debugging the descent with debug messages? Did you get the height in the loop and display it on screen? Are you sure that getheight will return the requested height at once or until the unit is actually at that height.

If get height gets you the current height that unit is at then use a timer to periodically check that. That also enables you to pass local variables to other functions or triggers, by using a locally created timer that you retreive in your timer function that checks the bomber's height.

btw, if you're creating units then don't use getlastcreatedunit. The natives that create the unit already return the unit or group that's made, so its quite pointless and can cause problems if you use getlastcreatedunit.
 
The unit starts at 570 height and descends to 370. The transparency is not a problem here, and neither it will affect the code.
I agree that polled waits are not a good idea, that's why I am asking for help.
What kind of Jasser do you think I am !? I nearly feel insulted ... Ofc I tested the program with Debug messages .... otherwise I would have never made this post. PurplePoot just thought me well.

Mm, ya, I will remove getlastcreatedunit soon, but for now, I just want to fix the Fly Heigh problem. I tested the getFlyHeigh. After that I created a function to check the hieght of the plane every 0.1 seconds. Both options did NOT work... why ?? because of SetUnitFlyHeight. It just sets immediately the fly heigh ... the descending part its just an animation to correct the fly height.

I tested your idea before posting this comment, and it didn't work .... that is why I say it is a Bllizard's bug, and that is why I need help ...
 
Level 11
Joined
Aug 25, 2006
Messages
971
JASS:
 SetUnitFlyHeight
It has a rate option. Can you make it instant, then make your own gradual descent using a timer? Thats what I would do...
 
Level 5
Joined
Oct 27, 2007
Messages
158
The unit starts at 570 height and descends to 370. The transparency is not a problem here, and neither it will affect the code.
I agree that polled waits are not a good idea, that's why I am asking for help.
What kind of Jasser do you think I am !? I nearly feel insulted ... Ofc I tested the program with Debug messages .... otherwise I would have never made this post. PurplePoot just thought me well.

Mm, ya, I will remove getlastcreatedunit soon, but for now, I just want to fix the Fly Heigh problem. I tested the getFlyHeigh. After that I created a function to check the hieght of the plane every 0.1 seconds. Both options did NOT work... why ?? because of SetUnitFlyHeight. It just sets immediately the fly heigh ... the descending part its just an animation to correct the fly height.

I tested your idea before posting this comment, and it didn't work .... that is why I say it is a Bllizard's bug, and that is why I need help ...


Relax and relax a bit more will you? I never said anything about your transparency code not working. I merely asked you if you tested this with the right parameters. We all can make mistakes right? The advice I tried to give you was nothing but good intent.

Bomber makes a good suggestion what you can do since the fly height is set at once. Just simulate the rate/seconds value to simulate the descent with a timer. You should use a timer and that's the thing you keep rejecting. Just continu to be stubborn and don't listen to the advice some people here have already given you.

Goodluck with your map
 
MMm
SetUnitFlyHeight
It has a rate option. Can you make it instant, then make your own gradual descent using a timer? That's what I would do...
Excellent idea ... I wonder why I didn't think about it. Although I don't know how to use timers ( I found the map Need_O2 suggested a little bit complicated for a timer beginner like me) I will try to use some PolledWaits (although I also know they are bad and evil, Can some1 please tell me tutorial about timers ?? A one that is not in JAssvault, because i already tried to understand them and I couldn't).

Relax and relax a bit more will you? I never said anything about your transparency code not working. I merely asked you if you tested this with the right parameters. We all can make mistakes right? The advice I tried to give you was nothing but good intent.
Meh... every1 keeps saying that to me ...
I know you have good intent and I appreciate your help .... but please just watch for the manner you type things as I can't know the true meaning of a sentence without looking to a person's face (you can always use emot icons for the weird effects :piru: ).

Bomber makes a good suggestion what you can do since the fly height is set at once. Just simulate the rate/seconds value to simulate the descent with a timer. You should use a timer and that's the thing you keep rejecting. Just continu to be stubborn and don't listen to the advice some people here have already given you.

I am not ignoring your suggestions people !!!! If i post stuff here to ignore you, then it only means I am stupid !! (lol) which I try not to be (lol).
I just didn't have the time to respond ...

Goodluck with your map

Thx. It has been a long time without people saying me that. I will post this spell in the forum as well =) so people can enjoy it =). After all this is a community.

thats what I do (rate of 0)
It means I can use this to make my bombs reach ground ??
I hope, because that would be awesome ... got to try ...
 
HI guys i have a quick problem. I know that this syntax exists for unit: GetUnitX(MyUnit), GetUnitY(MyUnit)

But I can't find a similar one to have the target location coordinates of a spell...
GetSpellX(TargetLoc), GetSpellY(TargetLoc)

Is there a way of getting a spell coordinate without using a region ???

EDIT

Guys a have a problem with locations (as usual)...
I can't create and order a unit to move to where I want ...

I will explain by using a didactic image that will illustrate my problem:
View attachment 21855

Now, As probably already realised, this is important for me, because otherwise I wouldn't be wasting my time in creating the image and the comment.

To solve this problem i tried to use a PolarProjectionBJ like this:
JASS:
local unit caster = GetTriggerUnit()
    local real angle = GetUnitFacing(caster)
local location point = GetSpellTargetLoc()
set bomber = CreateUnitAtLoc(p, 'h002', PolarProjectionBJ(point, - 1500, angle), angle )
 call IssuePointOrderLoc( bomber, "move",  PolarProjectionBJ(point, 10000, angle)  )

but after testing it, it is obvious that this is a buggy and very crappy way of doing stuff....
So it is impossible to work with it .. Can you guys help out here ? plz ??
PS: I hate PolarProjectionBJ's so is there a more efficient way for me to avoid them ?
 
O2 !!! YOU ARE BACK !!! YEE !!! lool
Well, i know I have to use coordinates ... aaannd I also know that trigonometry will be the answer ... BUT i don't know how to get the X and Y from a spell target location ... why ?? Because it is impossible ... there is no such function ... I must use a region to do so, and that is bad .... (HyndiHat told that to me after a little conversation we had on the chat).
So the question here is .... I know what to do but ... how to do it ????
This is mainly why I am asking for your helps ... guys.

Any suggestions ?
 
Level 4
Joined
Dec 14, 2004
Messages
85
GetSpellTargetLoc() hopefully you put that in a variable so it can be destroyed, btw, you need to look through all the functions you are using to see if they create new locations(That would be do they use the function Location(x,y)) because I saw a lot of leaks like using PolarProjectionBJ() that creates a new location which needs to be removed.

But yeah after that you use GetLocationX(TargetLoc) GetLocationY(TargetLoc)

Are you using timers yet, I only read the first page and I don't feel you should neglect doing something the right way. I just don't see the reason to do things in other ways.
 
Don't worry, that code was now heavily improved. And no, I am not using timers yet, because I managed my way using TriggerSleepAction. I only need to wait 0.1 secs max, so I believe that function is enough for me.
Still, here is the new code, for all you to see:

JASS:
globals
    rect gg_rct_Region_000
    rect gg_rct_Region_001
    trigger gg_trg_Bomber
endglobals
//=============================================================
function Trig_Bomber_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//=============================================================
function Trig_Bomber_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit bomber
    local unit bomb
    local player p = GetOwningPlayer(caster)
    local integer fade = 0
    local real height 
    local integer bombcounter = 0
    local real heightbomb
    local effect exp
    local group targets 
    local unit f
    
    set bomber = CreateUnitAtLoc(p, 'h002', GetRectCenter(gg_rct_Region_000), bj_UNIT_FACING )
    
    call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    set height = GetUnitFlyHeight(bomber)
    
    call IssuePointOrderLocBJ( bomber, "move", GetRectCenter(gg_rct_Region_001) )
    
    loop
        exitwhen(fade >= 255)
        call TriggerSleepAction(0.1)
        set fade = fade + 30
        call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    endloop
    
    loop 
        exitwhen(height <= 450)
        set height = height - 50
        call SetUnitFlyHeight(bomber, height, 80)
        call TriggerSleepAction(0.3)
    endloop
    
        call TriggerSleepAction(0.6)    
    loop 
        exitwhen(bombcounter == 6)
        set bomb = CreateUnitAtLoc(p, 'h003', GetUnitLoc(bomber), 270.0)
        call SetUnitFlyHeight(bomb, height, 0)
        set heightbomb = height
        loop
            exitwhen(heightbomb <= 0)
            set heightbomb = heightbomb - 120
            call SetUnitFlyHeight(bomb, heightbomb, 120)
        endloop
        set bombcounter = bombcounter + 1
        call TriggerSleepAction(0.25)
    endloop
    
    call TriggerSleepAction(0.2)
    loop 
        exitwhen(height >= 600)       
        set height = height + 50
        call SetUnitFlyHeight(bomber, height, 100)
        call TriggerSleepAction(0.2)
    endloop
    
    loop
        exitwhen(fade <= 0)
        call TriggerSleepAction(0.1)
        set fade = fade - 30
        call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    endloop
    
    call ShowUnit(bomber, false)
    call KillUnit(bomber)
    
    set bomber = null
    set bomb = null
    set caster = null
    set p = null
    set exp = null
    set f = null
    set targets = null
endfunction
//===========================================================================
function InitTrig_Bomber takes nothing returns nothing
    set gg_trg_Bomber = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bomber, Condition( function Trig_Bomber_Conditions ) )
    call TriggerAddAction( gg_trg_Bomber, function Trig_Bomber_Actions )
endfunction

Anyway, back to the point, can anyone plx help me with my problem ???
As you already probably already notest, I am using 2 regions in this code ... why ?? because I don't know how to solve my problem and how to do that GetSpellX or Y or whatever ... help ?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
TSA isnt enough for this
why is it so hard to work on some example spells for you
try to get how did they get created
ALL of my spells using sin cos as I remember (excluding ThunderPortation)
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
NO GETRECTCENTER

NO RECTS NO REGIONS

and no CreateUnitAtLoc
what is wrong with CreateUnit

If its a so bad problem for you to create this spell
send me a PM with ALL details of it
or simply request from spell request thread
 
O2:
1 - The reason why I don't use timers(for now), its because TSA IS enough ... if it is not enough, then please, explain me why my spell works just perfectly ... I mean no offence, but I sware for God, why is TSA so bad ??? it is not a BJ or whatever ... Are timers more precise ??? Does that makes much difference ?
2 - I haven't evaluated your spell pack yet ... why ?? because I think it requires NewGen Pack or something (can't remember well), and I don't have it. Also, I downloaded some map containing shapes like squares, circles, and so on, and I believe I can use that in my map.
3 - For the last time you can NOT use coordinates with "spells" if don't use a location first. This was explained to me by HyndiHat, and if you do not agree with him, than please explain us both (me and GhostWolf) why is that so.

GhostWolf:
1 - I may use that location stuff you suggested, thx. But I don't know yet, have to test some trig. stuff to see the result.
2 - I don't know if it will work properly, but, following the logic, I believe it will, and it may yet be a good optimization to implement. Thx also.

O2:
1 - I appreciate all you help until now, however, I will only PM you with help, only if I get something I can't solve. I do this kind of spell so I can learn. If some one else does them from me, well, I won't be learning.
Just know that I may yet accept your offer in a nearby future.

Both:
- Thx for you help guys. You will have +rep once I finish my spell, and O2, you will also get credit on it. Why ?? Well, because you have been helping since my first post, and I don't forget who has always been there for me, reading and posting all those comments, even when I am as smart as a monkey (lol, I am far superior to that, but you get the point).

I will evaluate the changes rit now, wish me luck guys !

PS, I will post again the results soon. =P


EDIT
Guys ... the GetLocX and all that stuff actually works kinda good ... But I still can not create my plane behind my caster ... its just static .. always from the same angle same point bla bla ...

Now questions is Maths ... rit ? i am trying to use Pita Theorem (C^2 = a^2 + b^2) but i don't even know if -I should be using this ... or what to do with it (I only get my plane created in the most stupid locations ever)

Any help guys ?
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
I don't know any names of math eqou's in english, but whats ^ ? if you say x^x its like x*x ?

Anyway, to make the bomber behind the caster, make something like this

JASS:
       local unit caster = GetTriggerUnit()
       local real angle = GetUnitFacing(caster) * bj_DEGTORAD
       local real x = GetUnitX(caster) - someNumber * Cos(angle)
       local real y = GetUnitY(caster) - someNumber * Sin(angle)
       local unit bomber = CreateUnit(GetOwningPlayer(caster), 'h000', x, y, GetUnitFacing(caster))


It will create him someNumber behind him.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Okay lets see if I can help

Smallest TSA wait is 0.5 (dont worry 5 TSA(0.1) in a loop waits 0.5 not 2.5)
You can see triggers without Jass NewGen Pack (I tought you use JNGP)
You SHOULD trust HINDYhat (he is x99999999 better than me, he teached me stuff actually and Earth Furry guy)

Well Im sorry. I really didnt help with your stuff (I wasnt trying to help)
Lets change this situation

Creating an unit with PolarProjectionBJ

[jass="Lets use CreateUnit instead of CreateUnitAtLoc"]set sourcex = GetUnitX(<source unit>) // or source x coordinate
set sourcey = GetUnitY(<source unit>) // or source y coordinate
set ang = <direction as degrees>*BJ_DEGTORAD // multipling with BJ_DEGTORAD will convert degrees to radians (you may use Radians too)
// Atan, Atan2, Asin, Acos returns radians, GetUnitFacing returns degrees
set dist = <distance>
set unitvar = CreateUnit(<player>,<unit raw code>,sourcex+dist*Cos(ang),sourcey+dist*Sin(ang),<unit facing as degrees>)[/code]
attachment.php


Calculating Distance between Coordinates

SquareRoot(Pow(targety-sourcey,2)+Pow(targetx-sourcex,2))

If you are gonna use GetSpellTargetLoc()
[jass="Use it in this way"]local location targetloc = GetSpellTargetLoc()
local real spellx = GetLocationX(targetloc)
local real spelly = GetLocationY(targetloc)
call RemoveLocation(targetloc)
set targetloc = null // nullling is powerful I know why you should null handles
// Then you wont need to use that location again use spellx, spelly instead[/code]
Every location function like GetSpellTargetLoc(), GetUnitLoc(<unit>) creates a new location and they arent suggested (creating a new location is slow)

Anything else ?
 
Last edited:
Hi and thx for your fast posts. Well, allow me to explain myself better.
When I said the plain was supposed to be created behind the caster, I didn't explained myself correctly.

I want the plane to be created behind the caster, yes, but with the SpellLocation as a parameter and not the casters location.

I tried to use both your suggestions, but both didn't work ... the plane is just created in the middle of the map ... (why ?? no idea).

I will post the code I am using:
JASS:
local unit caster = GetTriggerUnit()
    local real DEGangle = GetUnitFacing(caster)
    local real RADangle = DEGangle * bj_DEGTORAD
    local location loc = GetSpellTargetLoc()
    local real X = GetLocationX(loc) - 1550 * Cos(RADangle)
    local real Y = GetLocationY(loc) * Sin(RADangle)
    local player p = GetOwningPlayer(caster)

    local unit bomber = CreateUnit(p, 'h002', X , Y, DEGangle)

    call IssuePointOrder( bomber, "move", X - 10000, Y)

This is Wolfs, suggestion ... what I am doing wrong ?

And now, O2's way:
JASS:
local unit caster = GetTriggerUnit()
    local real DEGangle = GetUnitFacing(caster)
    local real RADangle = DEGangle * bj_DEGTORAD
    local location loc = GetSpellTargetLoc()
    local real X = GetLocationX(loc)
    local real Y = GetLocationY(loc)
    local player p = GetOwningPlayer(caster)

    local unit bomber = CreateUnit(p, 'h002', X + 1550 * Cos(RADangle), Y + 0 * Sin(RADangle), DEGangle)

    call IssuePointOrder( bomber, "move", X - 10000 * Cos(RADangle), Y + 0 * Sin(RADangle))

The plane is created in front of the caster, and it has no Y, I mean, If I cast my spell, and my hero is facing a diagonal angle, the plane will just ignore that angle ...

So what am I doing wrong guys ? any suggestions ??

PS: Calm down O2, I remove and nullify the locations in my trigger, however i don't show it here to save some space, I know my comments are usually big enough =P
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
If I got it right (didn't read from the start of the thread), you want the bomber to be behind the caster and then just move infront of himself untill something happens ?

Anyway, you didn't put -number in the y value, the final code should be something like this probably

JASS:
local unit caster = GetTriggerUnit()
    local real DEGangle = GetUnitFacing(caster)
    local real RADangle = DEGangle * bj_DEGTORAD
    local location loc = GetSpellTargetLoc()
    local real X = GetLocationX(loc) - 1550 * Cos(RADangle)
    local real Y = GetLocationY(loc) - 1550 * Sin(RADangle)
    local unit bomber = CreateUnit(GetOwningPlayer(caster), 'h002', X , Y, DEGangle)
    local real orderx = GetLocationX(loc) + 1550 * Cos(RADangle)
    local real ordery = GetLocationY(loc) + 1550 * Sin(RADangle)
    call IssuePointOrder( bomber, "move", orderx, ordery)
    // if this is the end of the code add this
    call RemoveLocation(loc)
    set loc = null
    set bomber = null
 
Mm, you don't need to read it from the start.

What I want:

- A caster starts the effect of the ability. The plane is create 1550 meters away from that point, but behind the caster. After that It just moves 1000000000000000000 meters away from that point.

I have an image that illustrates this concept in page 3. I will try to put it here.
I will test your code, further news soon.

EDIT

Well, the spell works ... almost ... The plane misses the area, miss the target ... and I don't know why .... Sometimes it is even created in a wrong angle ...
Is there any solution to fix this ??

Here is the full code I am using atm:
JASS:
function Trig_Bomber_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//=============================================================
function Trig_Bomber_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real angle = GetUnitFacing(caster)
    local location loc = GetSpellTargetLoc()
    local real X = GetLocationX(loc) 
    local real Y = GetLocationY(loc)
    local player p = GetOwningPlayer(caster)
    local unit bomb
    local integer fade = 0
    local real height 
    local integer bombcounter = 0
    local real heightbomb
    
    local unit bomber = CreateUnit(p, 'h002', X - 1550 * Cos(angle * (3.14159 / 180.0)), Y - 1550 * Sin(angle * (3.14159 / 180.0)), angle)
    
    call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    set height = GetUnitFlyHeight(bomber)
    
    call IssuePointOrder( bomber, "move", X + 1550 * Cos(angle * (3.14159 / 180.0)), Y + 1550 * Sin(angle * (3.14159 / 180.0)))
    
    loop
        exitwhen(fade >= 255)
        call TriggerSleepAction(0.1)
        set fade = fade + 30
        call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    endloop
    
    loop 
        exitwhen(height <= 450)
        set height = height - 50
        call SetUnitFlyHeight(bomber, height, 80)
        call TriggerSleepAction(0.3)
    endloop
    
        call TriggerSleepAction(0.6)    
    loop 
        exitwhen(bombcounter == 6)
        set bomb = CreateUnitAtLoc(p, 'h003', GetUnitLoc(bomber), 270.0)
        call SetUnitFlyHeight(bomb, height, 0)
        set heightbomb = height
        loop
            exitwhen(heightbomb <= 0)
            set heightbomb = heightbomb - 120
            call SetUnitFlyHeight(bomb, heightbomb, 120)
        endloop
        set bombcounter = bombcounter + 1
        call TriggerSleepAction(0.25)
    endloop
    
    call TriggerSleepAction(0.2)
    loop 
        exitwhen(height >= 600)       
        set height = height + 50
        call SetUnitFlyHeight(bomber, height, 100)
        call TriggerSleepAction(0.2)
    endloop
    
    loop
        exitwhen(fade <= 0)
        call TriggerSleepAction(0.1)
        set fade = fade - 30
        call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    endloop
    
    call ShowUnit(bomber, false)
    call KillUnit(bomber)
    call RemoveLocation(loc)
    
    set loc = null
    set bomber = null
    set bomb = null
    set caster = null
    set p = null
endfunction
//===========================================================================
function InitTrig_Bomber takes nothing returns nothing
    set gg_trg_Bomber = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bomber, Condition( function Trig_Bomber_Conditions ) )
    call TriggerAddAction( gg_trg_Bomber, function Trig_Bomber_Actions )
endfunction

But there is still that problem ...
Any way of not using PolarProjectionBJ, that results in a 100% safe spell ?

Here is the Image I want you guys to see:
View attachment 21855


Oh Btw, I also attached my test map here.
Remember that the spell is not finished yet, so the bombs won't explode!! (lol)
 

Attachments

  • Plane !.w3x
    91.1 KB · Views: 44
Last edited:
Level 4
Joined
Dec 14, 2004
Messages
85
Don't worry about leaks, you're obviously learning still so just know, getting the spell to work can be the first priority and then remove the leaks after the spell works(and don't post in the spells section till you're sure they are gone) and then when you get better you'll know about leaks better and be able to remove leaks first thing, but unless you know leaks very well it's usually ok to wait till after being done with the spell to worry about it(This rules does not carry over into entire maps, just spells because they are small and removing leaks can be done easily. You should know leaks before creating entire maps, unless they are beyond simple)

Leaks can be removed(if coded properly), so any function that leaks is fine to use, just make sure you remove the leak later. but as a tip, just make sure you put all locations in a variable and then use the variable in your functions, this will make removing the leaks easier later.

JASS:
function MovePolarProjection takes location source, real dist, real angle returns nothing
    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    call MoveLocation(source, x, y)
endfunction

That is the version of PolarProjection I use. It's just a functions that moves a location in polar projection instead of creating a new location to do it. Do this to your GetSpellTargetLoc() (Make sure you put it in the local variable still) and then move it away from the target location in the direction that you want and then all you have to do is remove the location that was created with GetSpellTargetLoc() instead of also removing one created by PolarProjectionBJ. But keep in mind that this will make it so you lose the coordinates where the spell was cast because it will move that location away.
 
Mmm more locations equals to deficient code ... which is what I am trying to avoid. Coordinates replace locations and therefore they are more precise and will cause less lag.

Still, You are correct about leaks.
And btw, we learn until we die. So ya, I am learning =). However, I don't think my spell leaks ... for now.

Still, is there a way out of this problem that doesn't use PolarProjectionBJ ?? Because this function is not precise at all, if you download my map, you will see that the plane misses the target ... and the error bound is way to large to be allowed ...

Any more suggestions please ?
 
Status
Not open for further replies.
Top