• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] i need help

Status
Not open for further replies.
Level 6
Joined
Sep 4, 2007
Messages
157
Im new in jass and im trying this trigger that makes a unit for 8 lanes but when there are so many units out the game crashs

JASS:
function Trig_IncomeSends_Func011Func001C takes nothing returns boolean
    if ( not ( ConvertedPlayer(GetForLoopIndexA()) != GetOwningPlayer(GetTriggerUnit()) ) ) then
        return false
    endif
    if ( not ( IsPlayerInForce(ConvertedPlayer(GetForLoopIndexA()), udg_Players) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_IncomeSends_Actions takes nothing returns nothing
    set udg_IncomeSends[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = ( udg_IncomeSends[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] + GetUnitPointValue(GetTriggerUnit()) )
    set udg_Income[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = ( udg_Income[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] + GetUnitPointValue(GetTriggerUnit()) )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 8
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_IncomeSends_Func011Func001C() ) then
            call CreateUnitAtLoc(Player(11), GetUnitTypeId(GetSoldUnit()), GetRectCenter(udg_PlayerSpawnPoint[GetForLoopIndexA()]), 180.00 )
            call SetUnitUserData( GetTriggerUnit(), GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) )
            call SetUnitPathing( GetTriggerUnit(), false )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveUnit( GetSoldUnit() )
endfunction

//===========================================================================
function InitTrig_IncomeSends takes nothing returns nothing
    set gg_trg_IncomeSends = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(0), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(1), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(2), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(3), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(4), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(5), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(6), EVENT_PLAYER_UNIT_SELL )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(7), EVENT_PLAYER_UNIT_SELL )
    call TriggerAddAction( gg_trg_IncomeSends, function Trig_IncomeSends_Actions )
endfunction

Thats the code im useing i was changing it from gui to jass. Thanks for any help
 
HOLY MACAROLY
You have it (nearly) all wrong.

First, please explain your idea better.

My exp: if you want to create a "wave" of units in all lanes you should do:
1 - Create regions: Regions ARE necessessary, as they can be used to create, order and move units, thus making our job a lot easir.
2 - Use locals instead of globals: locals are faster and take less memory.
3 - Remove leaks: it prevents lag
4 - Use a single player for the spwans: It makes your job easier

I can make the job for you, but you have to tell me what you have in mind.
Also, avoid loops, as they are very complicated for begginers (i have some little experience and i find them "a pain in the arse" if you understand what i mean)
Also that GUI converted script is all messed up, no wonder it crashes.
 
Also, download JassCraft from this website, and use it when coding, as it is a really usefull program.

EDIT: I have a demonstration about what you should do:

JASS:
globals
    rect create_point //Here you place your globals, like regions and timers
    rect end_point    // This is only needed in JassCraft, you don't need
    timer My_timer    // this "global" part in the trigger editor, as the computer
endglobals            // already knows which globals he will use     
//============================================================================================
function Create_and_move_units takes nothing returns nothing  // This isa function, this function has all actions inside it
    local unit My_Unit // Here i create a local variable
    set My_Unit = CreateUnit(Player(0), 'h000', GetRectCenterX(create_point), GetRectCenterY(create_point), 270)
    //Here i set my unit variable. I changed my variable's value to create
    // a unit of type 'h000' for player 1 (Player(0)) at the region create_point
    call IssuePointOrder(My_Unit, "move", GetRectCenterX(end_point), GetRectCenterY(end_point))
    //Here i prder my created unit to move to the next
    //lLocation(end_point)
    set My_Unit = null  //as you can see, i have 2 dif ways of setting a var
    //Now to prevent leaks, i nullify my variabe to null
    // Unit vars take computer memory, and if not nullified
    // (like in GUI) they can cause serious lag in game
endfunction
//============================================================================================
function Trig_name takes nothing returns nothing //This function, is the main function. It activates the actions when the timer expires
    local trigger My_trig = CreateTrigger( ) // Here is my local trigger  
    call TriggerRegisterTimerExpireEvent(My_trig, My_timer )// Thru this call, i tell the computer which event will run the trigger    
    call TriggerAddAction( My_trig, function Create_and_move_units ) //Thru this call, i tell the activated trigger, which actions he must do 
    set My_trig = null // Again, to prevent leaks, i nullify my local trigger variable
endfunction

Now there are two ways of setting a local variable:
JASS:
local VarType VarName
set VarNAme = VarValue
Here you create the variable, and then give it a value on the next line.

JASS:
local VarType VarNAme = VarValue
Here you create and give a value to the variable in the same line.

You choose which options you prefer.
Also, ALWAYS nullify a local variable, to prevent leaks and lag. The only variables you can NOT nullify are booleans, integers and reals.

I used a local trigger in this example. There are also global triggers. Globals triggers are slower than local triggers and they can cause crashes and confusions some types. However in advantage you have more freedom to program stuff if you use them, as they allow you to do more things.

Local triggers are 100% safe and faster, but they are more limited than global triggers.

Using locals is always an advantage because you can nullify them and because by using the, the spell is automatically MUI (it means all players can use it at the same time).

In these example i used a timer, a unit and two regions.
When the timer expires, the trigger is activated, and it runs the actions. This means that when the timer expires, a single unit is created in Create_point and it is ordered to move to end_point. Once the order has been given, i nullify the variable, and i prevent leaks.

Now this is the basic concept of a TD. You can use other events, as you may which, but these are the main ideas you should have in mind.

Also visit some JASS tutorials from our JASS sections.
 
Last edited:
Level 20
Joined
Apr 22, 2007
Messages
1,960
I don't know if global triggers are slower than local triggers (...?... Where did you learn that?), but global triggers are defintely better to use, since the map will still generate the global trigger variable... you might aswell use it.

Also, I believe that code variables don't have to be nulled, since they aren't handles either.

Please, explain to me how local triggers are 'safer' and faster than global triggers...

Also, try to avoid using location variables. They leak and have to be nulled/removed. Instead, you should use coordinates, since most (if not all) native functions use coordinates instead of locations. The functions that use locations are BJ's, which definitely slow your map, are unefficient and (sometimes) leak.

Too nullify a local, you simply do this:
JASS:
set VarName=null
You do that after the variable is no longer needed, but remember, ALL local variable types except integers, reals, booleans, strings and codes must be nulled after you are done using them, else they could leak.
 
I know that locals are faster then globals because i read that in a Dealin tutorial and because i think PurplePoot said that as well (don't remember very well).

Also, what he means, is that you should have a look my code.
Also using regions is ok, since it is for a TD, there is no other way to do it.
Finally, you can also nullify strings, and i advise you to do so every time you can.

All types of variables MUST be nullified in order to avoid leaks, it is in our JASS tutorials and in JASS Vault.

Loclas are safer then globals because when using them you don't have the risk of over-run a global var. With locals, every time a local var is fired, the computer creates new value that is nullified after (if you set it to null) thus being safier. With globals you have the risk of overruning that same value.
Locals are faster, but Daeling doesn't explain why .. (at least i didn't find such info)
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
FP, I don't think there's a difference in speed between local/global 'triggers', but in terms of units or something. Like instead of using
JASS:
local unit u=BLAH
You'd have a pre-created global which would refer to BLAH. Locals, in that case, would be faster. I don't think there's a difference in speed between local and globals triggers.

Also, no, FP. Only local handles have to be nulled. Handles are every type of variable except integer/real/string/code/boolean (just look at common.j, where it's written [type BLAH extends handle])

And what's the point of nulling strings? I've already asked Poot about that, and he said it was unnecessary since strings are not handles.

And FP, I really can't see a reason for someone to change the value of a global trigger -.-. I'd say they are safer than locals, since you'd HAVE to refer to either globals or gamecache (unsafe) to refer to that trigger in some other function. Might aswell use the gg_trg_ global...

About regions, I was just speaking in general. And no, you don't need regions for ordering units to move to a location. Just use the coordinates (hover your mouse over a point in the world editor, and the x,y,z coordinates should pop up on the bottom left corner of the editor). You'd still need regions to detect when a unit gets to the target location, but still, you're best to avoid locations/regions when you can.

I've also asked Poot about global/local triggers (I think), and he said that global triggers were better.
 
OMG, you guys are both againts me lol ...

Well, about strings, i can go to the JASS Vault and prove what i am saying.
About locals ... all your JASS tutorials teach people to use local triggers and locals because they are safer and bla and bleu and bla bla bla, i will try to find a tutorial where that is explained (again).


About regions , i think they don't leak much. I mean, b4 you set a region to null i think you must destroy it first and then nullify it, but if you destroy the region, you will loose the purpose why they were created. Regions are permanent, that's why they exist (mostly).

Also, if you think using coordinates is the solution, please give an example to b_a_d about how to use coordinates instead of regions, like i did. Because i really don't see how to do it.

EDIT
Jass Vault said:
A handle is an object in the game.
An object can be a unit, group, player, trigger, timer, boolexpr, effect, lightning or location for example.
Integer, real, boolean, code, and string variables are the only variables in Jass that are NOT handles.

Strings are not handles, but they can be nullified as well to prevent memory leakage.
I tested my opinion and it worked. If you create a string to display and nullify it, the nest time it displays, the text will be "null". This null text is obviously inside the game memory, thus there is no way to remove it, but it proves my point, it is better then a memory text we insert on it.

About locals
PurplePoot said:
Well, i think locals are faster
I strongly remmember this setence, and it can be found at my 8 pages thread where i ask for help about my reward system. Just don't make me read it all again please. This is also 1 of the main reasons why i use locals.
Ofc that is PurplePoot's opinion changed, well ... then i want to know why lol.

Also agai as i say, if ALL our JASS tutorials advice the using of locals ... why use globals !? blarg, i feel like i am the bad guy here ... i do exactly what you guys teach us and still i feel i am defending a wrong (very wrong) concept.
Perhaps you should change those tutorials ...
 
Last edited:
Level 20
Joined
Apr 22, 2007
Messages
1,960
Strings... don't need to be nulled... Any variable type can be null. Strings (I think) can't be removed and are permanent in memory, but they don't leak alot anyway.

I asked some people if local triggers were better to use than global trigger, and everyone said globals were better -.- I just don't get WHY create a local trigger when the global trigger is automatically generated FOR you..? You would just be using up more memory by making a local trigger.

Regions leak as much as every other handle. Regions are not permanent... where did you hear that?

Instead of doing this:
JASS:
call IssuePointOrder(My_Unit, "move", GetRectCenterX(end_point), GetRectCenterY(end_point))
Just do something like this:
JASS:
call IssuePointOrder(My_Unit, "move", SomeXCoordinate, SomeYCoordinate)
And these coordinates would be the center of the moving rects. Instead of calling GetRectCenterX/Y each time, it would be more efficient (if it's a 'permanent' rect) to simply get the coordinates.

Locals ARE faster than globals, but I don't think that local triggers RUN faster than global triggers. More like, assigning values to locals and using locals generally (not running on local triggers or local code vars) are faster than globals... I don't know if you understand.

Globals are still very useful. They are alot faster than gamecache, and can be 'carried' throughout multiple functions. So in the end, if you REALLY want to use locals all the time, you'd have to pass by either globals or gamecache (for carrying locals throughout functions).
 
Strings can be nulled, as i already demonstrated .. Also, in conclusion, you and PurlplePoot say global triggers are better rit ?? i guess i will have to change all my map's triggers again lol ...

Also, regions ARE permanent !! If you create a region with WE in the map, that region will be permanent in game, unless you destroy it. Regions are some kind of globals in a 3d plan.
Also, if regions leak, they probably leak like locations, because that is what they are, one way or another (but not sure).

Also, yes i understood your lcoals and globals point. Still, Globals are evil !! lol, that is why i avoid them so much !! You can use globals, but they get over runned all the time. That is why i believe locals are way much better. In GUI, you can only use globals, and it sux (lol, that is why we all are in JASS rit ?) because is it too much limited.

ALso, in conclusion, you say that this code doesn't leak, rit?
JASS:
call IssuePointOrder(My_Unit, "move", 138.546282, 164.754756)

If that is so, it also means that you can use
JASS:
CreateUnit( Player(0), 'hprt', 152.87879, 169.98617, 270.0)
to create a unit instead of
JASS:
CreateUnit( P6, 'hprt', GetRectCenterX(g), GetRectCenterY(g), 270.0)
because it won't leak and because it is faster rit ????
 
That is JASS. It is not GUI. People who don't know JASS will never use Custom script .... lol, as i said b4, we all learned JASS because GUi is too limited. You just prove my point. People use JASS in GUI because GUI sux (litterally, GUI is great, until 1 point).

Also, b_a_d, paste some of your code, so we can see your progress.
Also, remmeber to rep+ me and hyndi !! =P lool
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Well technically that isn't GUI anymore...

FP, ALL variables can be nulled. There is just no point in nulling strings. If you can null a variable, doesn't mean it removes the leak.
Also, regions ARE permanent !! If you create a region with WE in the map, that region will be permanent in game, unless you destroy it.
Umm... you just ownt yourself? The rects you create with the world editor region editor are stored in globals. You can remove those globals, which is technically removing the rect.. so yes, rects can be removed and no, they are not permanent.

Regions and rects are both handles, like locations. All handles leak (what don't you understand?!) if not destroyed and nulled.

Globals are not evil... just look at vJass' structs. They are completely based on global arrays, and I haven't had those structs bug yet. They work perfectly fine, and do loads of stuff you couldn't accomplish with gamecache/locals (mostly because of efficiency/complicatedness...?).

Ugh, you just don't understand the leaking. Only handles leak. It's not the function call that will make the rect leak, it's the rect that will leak if you don't remove and null it. Using the direct coordinates (when you can) will just make the script more efficient and faster. It's always better to avoid useless function calls.
 
Level 6
Joined
Sep 4, 2007
Messages
157
ok i converted my gui trigger for when a unit reachs the end i havnt changed anything on it yet so its a big mess but i cant figure out how to fix it
JASS:
function Trig_Redend_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetEnteringUnit()) != 'u001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Redend_Func006001 takes nothing returns boolean
    return ( udg_Lives[1] >= 1 )
endfunction

function Trig_Redend_Func007001 takes nothing returns boolean
    return ( udg_Lives[1] == 0 )
endfunction

function Trig_Redend_Func008001 takes nothing returns boolean
    return ( udg_Lives[1] == 0 )
endfunction

function Trig_Redend_Func009Func009A takes nothing returns nothing
    call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Units\\Demon\\Infernal\\InfernalBirth.mdl" )
    call ExplodeUnitBJ( GetEnumUnit() )
endfunction

function Trig_Redend_Func009C takes nothing returns boolean
    if ( not ( udg_Lives[1] == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Redend_Actions takes nothing returns nothing
    call ExplodeUnitBJ( GetTriggerUnit() )
    call PlaySoundBJ( gg_snd_GoodJob )
    call DisplayTextToForce( GetForceOfPlayer(ConvertedPlayer(GetUnitUserData(GetEnteringUnit()))), ( "|cffffcc00 You have taken a life from |r" + GetPlayerName(ConvertedPlayer(1)) ) )
    set udg_Lives[1] = ( udg_Lives[1] - 1 )
    if ( Trig_Redend_Func006001() ) then
        call DisplayTextToForce( bj_FORCE_PLAYER[0], ( I2S(udg_Lives[1]) + " lives left!" ) )
    else
        call DoNothing(  )
    endif
    if ( Trig_Redend_Func007001() ) then
        call DisplayTextToForce( GetPlayersAll(), ( GetPlayerName(ConvertedPlayer(GetUnitUserData(GetEnteringUnit()))) + ( " has defeated " + GetPlayerName(ConvertedPlayer(1)) ) ) )
    else
        call DoNothing(  )
    endif
    if ( Trig_Redend_Func008001() ) then
        call TriggerExecute( gg_trg_Player_Defeated )
    else
        call DoNothing(  )
    endif
    if ( Trig_Redend_Func009C() ) then
        call ForceRemovePlayerSimple( Player(0), udg_Players )
        call CinematicModeBJ( true, bj_FORCE_PLAYER[0] )
        call PanCameraToTimedLocWithZForPlayer( Player(0), GetRectCenter(udg_PlayerLane[1]), 1000.00, 1.00 )
        call TriggerSleepAction( 1.00 )
        call SetCameraBoundsToRectForPlayerBJ( Player(0), udg_PlayerLane[1] )
        call CameraSetEQNoiseForPlayer( Player(0), 45.00 )
        call TriggerSleepAction( 2 )
        call ForGroupBJ( GetUnitsOfPlayerAll(Player(0)), function Trig_Redend_Func009Func009A )
        call TriggerSleepAction( 2 )
        call CameraClearNoiseForPlayer( Player(0) )
        call SetCameraBoundsToRectForPlayerBJ( Player(0), GetCameraBoundsMapRect() )
        call CinematicModeBJ( false, bj_FORCE_PLAYER[0] )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Redend takes nothing returns nothing
    set gg_trg_Redend = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Redend, gg_rct_Red_end )
    call TriggerAddCondition( gg_trg_Redend, Condition( function Trig_Redend_Conditions ) )
    call TriggerAddAction( gg_trg_Redend, function Trig_Redend_Actions )
endfunction

any help would be nice to help fix this big pile of junk
 
Well, there is another away which is much simplier:
1 - Create 1 integer global with 20 as value (20 lifes)
2 -
Events:A Unit Enters a region
Conditions: Region is bla bla bla
Actions: Set MyVar to MyVar -1
//This is the GUI Trigger you will have to do in order to take 1 life

Then you create another trigger that ends the game when My Var is equal to 0. Very easy to do. You don'ty need half of that stuuf you have in your script.

Also Hyndi, you didn't explained us my question:
me said:
in conclusion, you and PurlplePoot say global triggers are better rit ?? i guess i will have to change all my map's triggers again lol ...

Also, regions ARE permanent !! If you create a region with WE in the map, that region will be permanent in game, unless you destroy it. Regions are some kind of globals in a 3d plan.
Also, if regions leak, they probably leak like locations, because that is what they are, one way or another (but not sure).

Also, yes i understood your lcoals and globals point. Still, Globals are evil !! lol, that is why i avoid them so much !! You can use globals, but they get over runned all the time. That is why i believe locals are way much better. In GUI, you can only use globals, and it sux (lol, that is why we all are in JASS rit ?) because is it too much limited.

ALso, in conclusion, you say that this code doesn't leak, rit?
JASS:
call IssuePointOrder(My_Unit, "move", 138.546282, 164.754756)

If that is so, it also means that you can use
JASS:
CreateUnit( Player(0), 'hprt', 152.87879, 169.98617, 270.0)
to create a unit instead of
JASS:
CreateUnit( P6, 'hprt', GetRectCenterX(g), GetRectCenterY(g), 270.0)
because it won't leak and because it is faster rit ????
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
It might leak, depending on if you remove the g region and created units.

Yes I did answer.
Ugh, you just don't understand the leaking. Only handles leak. It's not the function call that will make the rect leak, it's the rect that will leak if you don't remove and null it. Using the direct coordinates (when you can) will just make the script more efficient and faster. It's always better to avoid useless function calls.
 
mmm lol. So, it seems that my script is ok. Good =) Thx just teached me something i really needed to know =) Now i will apply it on my map =).

Also, About my mehtod of regions, what can i say, is the only way of doing such a trigger, because the event fires when the units enters the bla bla bla region.
If you have a better way, please show it .


Also, have a look on my recently appoved tutorial !!! ALL about icons by me !!!! looool (sry for advertising, i am 2 happy =p)
 
Level 6
Joined
Sep 4, 2007
Messages
157
well i took out most of the code for sending units but its still making the game crash and i have no idea why
JASS:
function Trig_IncomeSends_Actions takes nothing returns nothing
            call CreateUnitAtLoc(Player(11), GetUnitTypeId(GetSoldUnit()), GetRectCenter(udg_PlayerSpawnPoint[GetForLoopIndexA()]), 180.00 )
            call SetUnitUserData( GetLastCreatedUnit(), GetConvertedPlayerId(GetOwningPlayer(GetLastCreatedUnit())) )
            call SetUnitPathing( GetSoldUnit(), false )
    call RemoveUnit( GetSoldUnit() )
endfunction

//===========================================================================
function InitTrig_IncomeSends takes nothing returns nothing
    set gg_trg_IncomeSends = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(0), EVENT_PLAYER_UNIT_SELL )
    call TriggerAddAction( gg_trg_IncomeSends, function Trig_IncomeSends_Actions )
endfunction
 
Sometimes fixing a spell or a system is not a great idea ... Imagine a boat that is fixed ... it's quality is lower because the rem-mended pieces of wood can dis-attach from the boat, thus destroying. It is the same with triggers. I suggest you post your script for optimization, as you have here great professionals ready to help you, like hyndi and PurplePoot.
 
Level 6
Joined
Sep 4, 2007
Messages
157
JASS:
function Trig_IncomeSends_Actions takes nothing returns nothing
            call SetUnitPositionLoc( GetSoldUnit(), GetRectCenter(udg_PlayerSpawnPoint[2]) )
            call SetUnitPathing( GetSoldUnit(), false )
            call SetUnitUserData( GetSoldUnit(), GetConvertedPlayerId(GetOwningPlayer(GetSoldUnit())) )
endfunction

//===========================================================================
function InitTrig_IncomeSends takes nothing returns nothing
    set gg_trg_IncomeSends = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_IncomeSends, Player(0), EVENT_PLAYER_UNIT_SELL )
    call TriggerAddAction( gg_trg_IncomeSends, function Trig_IncomeSends_Actions )
endfunction
the problem i found was the custom value i was giving the unit wasnt give the right unit the value.
 
JASS:
function Trig_IncomeSends_Actions takes nothing returns nothing
    local unit sold = GetSoldUnit() //This var lock the sold unit
    local player P = GetOwningPlayer(sold) //This var locks teh buying player
    call CreateUnit(P, 'h000', 123.444, 567.888, 270.00) //This call creates your unit, 
    // at X(123.444), Y(567.888) and facing 270 degrees
    // according the the trigonometric circle. I suggest you use coordinates instead of regions, as regions leak
    call SetUnitPathing(sold, false) // This call turns off the colision size              
    call SetUnitUserData(sold, GetConvertedPlayerId(P))//This call is stupid, why get the buying player
    //if your trigger only is fired by player 1 ?? Np, i made this trigger work for all players.
    set sold = null //Now i set all vars to null
    set P = null
endfunction
//==========================================================
function InitTrig_IncomeSends takes nothing returns nothing  
    local integer index = 0
    set gg_trg_IncomeSends = CreateTrigger( )  
    loop 
        exitwhen index == 16
        call TriggerRegisterPlayerUnitEvent(gg_trg_IncomeSends, Player(index), EVENT_PLAYER_UNIT_SELL, null)
        set index = index +1
    endloop  //Now this will check ALL players, instead of player 1 only
    call TriggerAddAction( gg_trg_IncomeSends, function Trig_IncomeSends_Actions ) 
endfunction

Here is a version of what i think you want to do.
You SHOULD explain bettef your idea before asking for our help, because we will NOT help you if we don't know what you want.
I think this is what you want, i fixed some stuff and made it faster.
It also works for all player now.
 
mmm no problemo. I can do that.

JASS:
function Units_Conds takes nothing returns boolean
     return GetUnitTypeId(GetSoldUnit()) == 'h000'
endfunction
//============================================================================
function Units takes nothing returns nothing
    local unit S = GetSoldUnit()
    local unit C
    local player P = GetOwningPlayer(S)
    if S == Player(0) then
        call RemoveUnit(S)
        call CreateUnit(Player(0), 'h000', 123.444, 567.888, 270)
        call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + 25)
        set C = GetLastCreatedUnit()
        call IssuePointOrder(C, "move", 111.222, 333.444)
    elseif S == Player(1)then      
        call RemoveUnit(S)
        call CreateUnit(Player(1), 'h000', 222.333, 444.555, 270)
        call SetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD) + 25)
        set C = GetLastCreatedUnit()
        call IssuePointOrder(C, "move", 666.777, 888.999)
    endif
    set S = null
    set C = null 
    set P = null
endfunction
//================================================
function InitTrig_MyTrigger takes nothing returns nothing
    local integer index = 0
    set gg_trg_MyTrigger = CreateTrigger( )
    loop 
        exitwhen index == 16
        call TriggerRegisterPlayerUnitEvent(gg_trg_MyTrigger, Player(index), EVENT_PLAYER_UNIT_SELL, null)
        set index = index + 1
    endloop
    call TriggerAddCondition( gg_trg_MyTrigger, Condition( function Units_Conds ) )
    call TriggerAddAction( gg_trg_MyTrigger, function Units )
endfunction

Well, its done. This time id ecided not to explain everything to you. I wanna know what you are capable of =).

This triggers works for Player 1 and Player 2.
I think it is easy to understand how it works.
Aso you see, i used coordinates to solve your problem. Long live to leak free !!! lol
 
Last edited:
Status
Not open for further replies.
Top