I am confused. Still learning. :)

Simbob

New Member
Reaction score
0
Hi guys. I'm so sick of the clickity click of GUI. So i decided to learn JASS.

I made this trigger (Not my first JASS trigger). I Have no idea why WE won't let it work... So uh, here it is:

JASS:
function Trig_Infernals_Conditions takes nothing returns boolean
    return true
endfunction

function Trig_Infernals_Actions takes nothing returns nothing
    local integer Random = GetRandomInt(1, 3)
    local location array meteor
    set meteor[1] = GetRandomLocInRect ( gg_rct_meteor1 )
    set meteor[2] = GetRandomLocInRect ( gg_rct_meteor2 )
    set meteor[3] = GetRandomLocInRect ( gg_rct_meteor3 ) 
    call CreateUnitAtLoc ( Player(PLAYER_NEUTRAL_AGGRESSIVE), h00E, meteor[Random], 0.00 )
    call UnitAddAbility ( GetLastCreatedUnit(), A001 )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "dreadlordinferno", GetUnitLoc(GetLastCreatedUnit()) )     
endfunction

function InitTrig_Infernals takes nothing returns nothing
    set gg_trg_Infernals = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Infernals, 60.00 )
    call TriggerAddCondition( gg_trg_Infernals, Condition( Trig_Infernals_Conditions ) ) 
    call TriggerAddAction( gg_trg_Infernals, function Trig_Infernals_Actions )
endfunction



It's supposed to make a dummy unit in a random position in 1 of 3 regions. Then cast Infernal at its own position. Probably not the most effective way to do it, but i wanna do it this way.

Anyone know why it won't work? I'm stumped. I would've liked to figure it out myself, but i sadly can't... :(
 

Komaqtion

You can change this now in User CP.
Reaction score
469

themean

Active Member
Reaction score
7
:)

komaqtion is right
you need destroy location
location cause leak or use globals and movelocation
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Though, it's better to start using x and y instead of locations right from the start :D
And also, to remove all the BJ's you can ;)
 

Simbob

New Member
Reaction score
0
Ah ok. so whenever i have to type in a string i gotta put 'these' around it?

And what do you mean x and y? Like coordinates? I could see how that would be simpler.

And is destroying a location like this?
JASS:
call RemoveLocation <location name>


EDIT: also now at this line here
JASS:
call TriggerAddCondition( gg_trg_Infernals, Condition( Trig_Infernals_Conditions ) )

it says " Expected '(' "

Now that is confuesed me :eek:

Whoop. Nevermind i fixed it my self *pats own back*
JASS:
call TriggerAddCondition( gg_trg_Infernals, Condition( function Trig_Infernals_Conditions ) )


You said Remove BJ's... Why?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
> Ah ok. so whenever i have to type in a string i gotta put 'these' around it?

Strings use "", while rawcodes use ' ' as indicators.

> And what do you mean x and y? Like coordinates? I could see how that would be simpler.

Yup coordinates. it removes all the hazzle of having to deal with location leaks to begin with since they only use real values.

> You said Remove BJ's... Why?

Most BJs are basically useless functions that does nothing but calling some natives. For the sake of speed it's better to call these natives directly, rather than using the BJs.
 

saw792

Is known to say things. That is all.
Reaction score
280
May I just point out that your code won't work right now since GetLastCreatedUnit() will not return the correct unit/any unit. The CreateUnit/CreateUnitAtLoc() natives don't set bj_lastCreatedUnit, the global variable that GetLastCreatedUnit() returns. A solution:
JASS:
function Test takes nothing returns nothing
local unit u
//some stuff
set u = CreateUnit(...)
call UnitAddAbility(u, 'A001')
endfunction
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
>Most BJs are basically useless functions that does nothing but calling some natives. For the sake of speed it's better to call these natives directly, rather than using the BJs.

That said, there are some BJs that I choose not to remove especially if they are called in low frequency. An example is the CustomDefeatBJ. It calls tons of other functions, but only is called once per player so I just go the easy route :).

If you have NewGen, all the BJs show up in red, if you control+click the function name, you can see what the BJ does.
 

Rainther

I guess I should write something of value here...
Reaction score
61
Don't know what the space after "Loc" does for ya, but that works yeah.

That function creates a unit and also returns the value of the unit, which you receive as "u".
 

ZugZugZealot

New Member
Reaction score
33
There are a lot of useless BJ functions, with DoNothing() being the most useless of them all. But some of them exist for simplicity, such as "create at loc," or most specifically PolledWait() and natives that require the usage of GetLocalPlayer().

If you're new to Jass, I wouldn't let the map making elitism get to you yet. Basically right now, just apply this rule, "destroy and remove whatever can be destroyed and removed, when they're no longer needed", and you should be fine for the most part. I know that there are map makers who later down the line that wish "I wish I could have coded it different from the start," and having to recode it is a pain in the ass. Sure, you don't want to be that kind of map maker... However, you could be the map maker that's early on stressing about every little thing constantly doing over and doing over, and never have a map made in the end.

Just enjoy making the map, when you gain the skill, use the skill, there's no need to force the skill.

ANYWAYS!
Here's some cheater functions...
JASS:
//CREATE UNIT AT CENTER OF RECT//
//This function will take a region/rectangle instead of a location
//and will not use locations to do so.

//Explaining the parameters/arguments:
//-'player p' is who will own the created unit
//-'integer utID' is the type of unit via Raw Code
//-'rect r' is where the unit will be made via rect
//-'real face' is the direction the unit will initially face
function CreateUnitAtRCenter takes player p, integer utID, rect r, real face returns unit
    return CreateUnit( p, utID, GetRectCenterX(r), GetRectCenterY(r), face )
endfunction
//END OF FUNCTION//

//CREATE UNIT PROJECTED FROM CENTER OF RECT//
//This function will take a region/rectangle instead of a location
//off set it by distance and direction, and will not use locations
//to do so.

//Explaining the parameters/arguments:
//-'player p' is who will own the created unit
//-'integer utID' is the type of unit via Raw Code
//-'rect r' is where the polar offset will be based from.
//-'real dist' is how far away from the rect the unit will be created from.
//-'real angle' is the angle from base which the unit will be projected from.
//-'real face' is the direction the unit will initially face.
function CreateUnitAtRCenterPOffset takes player p, integer utID, rect r, real dist, real angle, real face returns unit
    return CreateUnit( p, utID, GetRectCenterX(r) + (dist * Cos(angle * bj_DEGTORAD)), GetRectCenterY(r) + (dist * Sin(angle * bj_DEGTORAD)), face )
endfunction
//END OF FUNCTION//

//CREATE UNIT AT CENTER OF UNIT//
//This function will take a unit instead of a location
//and will not use locations to do so.

//Explaining the parameters/arguments:
//-'player p' is who will own the created unit
//-'integer utID' is the type of unit via Raw Code
//-'unit u' is where the unit will be made via unit
//-'real face' is the direction the unit will initially face
function CreatUnitAtUnit takes player p, integer utID, unit u, real face returns unit
    return CreateUnit( p, utID, GetUnitX(u), GetUnitY(u), face )
endfunction
//END OF FUNCTION//

//CREATE UNIT PROJECTED FROM CENTER OF UNIT
//This function will take a unit instead of a location
//off set it by distance and direction, and will not use locations
//to do so.

//Explaining the parameters/arguments:
//-'player p' is who will own the created unit
//-'integer utID' is the type of unit via Raw Code
//-'unit u' is where the polar offset will be based from.
//-'real dist' is how far away from the unit the unit will be created from.
//-'real angle' is the angle from base which the unit will be projected from.
//-'real face' is the direction the unit will initially face.
function CreatUnitAtUnitPOffset takes player p, integer utID, unit u, real face returns unit
    return CreateUnit( p, utID, GetUnitX(u) + (dist * Cos(angle * bj_DEGTORAD)), GetUnitY(u) + (dist * Sin(angle * bj_DEGTORAD)), face )
endfunction
//END OF FUNCTION//
If there's any other functions you'd find to be nice, I'll try to make them! I'm slowly developing a library of newbie cheater functions, these are ones I made for your case. Even if simple, it's good JASS practice for me to do so.
 

Rainther

I guess I should write something of value here...
Reaction score
61
There are more worthless functions then DoNothing() :D This beuti can reuse the return bugs "fixed" in 1.24.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top