• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Risk Triggers - Need help to a few of them

Status
Not open for further replies.
Level 2
Joined
Jul 20, 2004
Messages
27
Hey everyone

God its been a while since I was last here. Anyway I have been playing to make a risk game, cause, well, I don't like any of the ones currently out.

However there are a few things i don't know how to do, and I imagine can only be done with JASS which I simply can't comprehend. Well at least I can't find a tutorial thats not making quatum leaps all of the sudden, assuming that I know stuff that I don't.

So I need help making these triggers, I know how to copy/paste a JASS and also how to alter one already made (but making one from scratch I simply can't get my head around, nor do I see how it could ever be easier to do).

I need a Trigger that picks alls the units on the map owned by neutral (that'll be the circles), and random divide it between the present players.

Actually thats it for now, I'll be toying a little more with the rest before I start calling for help on those.

Oh and can someone PLEASE tell me what "local variables" are? There seem to be a lot it being the main reason for going JASS.,


EDIT: This Tutorial for example: http://www.hiveworkshop.com/forums/...s-280/beginning-jass-tutorial-series-30765/#3

It tells you how to make an action, but gives no clue as to how to make a the event which triggers the action. Its just irritating that people make such a long detailed guide, and doesn't even give the basics required. Any help in understanding this would be a great help
 
Level 2
Joined
Jul 20, 2004
Messages
27
That sounds extremely useful. I figured out from trial and error that the guide is either flawed or I was ahead of it. In any case, I have made my first trigger with jass only that works.

It displays: Some text. To everyone when red clicks left arrow key.

However to do this I start out by making a GUI trigger, add the even, convert it to custom text, and add the action copied from the tutorial, and modified it with the knowledge from another tutorial.

function Trig_HelloWorld_Actions takes nothing returns nothing
call DisplayTextToForce( GetPlayersAll(), "This is a message" )
endfunction
//===========================================================================
function InitTrig_HelloWorld takes nothing returns nothing
set gg_trg_HelloWorld = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_HelloWorld, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction( gg_trg_HelloWorld, function Trig_HelloWorld_Actions )
endfunction

I gotta tell you, I have no idea how this will ever be more efficient in terms of time used to make the trigger.
 
Last edited:
Level 6
Joined
Oct 4, 2008
Messages
263
ill assume never was a typo for ever.
how? because when you get used to it, you dont copy the things from a trigger made with GUI. you just type.
and, that is a very very simple function. when you're randomly running through 2d arrays to generate dungeons(like me), youll find jass a whole lot better. heck, 2d arrays isnt even possible without vJASS, which in turn isnt possible without jass.
edit: you got there before me. rats.
 
Level 2
Joined
Jul 20, 2004
Messages
27
Now I have made this trigger totally on own, by using logic, and some coverting of events and actions.
function Trig_VariableTest_Actions takes nothing returns nothing
local unit u = GetEnteringUnit ()
call SetUnitPositionLoc (u, GetRectCenter(gg_rct_circle2))
set u = null
endfunction
//===========================================================================
function InitTrig_VariableTest takes nothing returns nothing
set gg_trg_VariableTest = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_VariableTest, gg_rct_circle )
call TriggerAddAction( gg_trg_VariableTest, function Trig_VariableTest_Actions )
endfunction

For some reason I can't seem get the rabs/spaces in there, you'll have to assume I have made those right. Anyway I read about memory leaks, and thats why I added that "set u = null". Is that used right, is it just filling up?
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
JASS:
 tags, not [quote] tags...

The trigger leaks a location: GetRectCenter(gg_rct_circle2), so you either have to store the location locally or better even: use X / Y coordinates:

[code=jass]
function Trig_VariableTest_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    call SetUnitX(u, GetRectCenterX(gg_rct_circle2))
    call SetUnitY(u, GetRectCenterY(gg_rct_circle2))
    set u = null
endfunction
 
Level 2
Joined
Jul 20, 2004
Messages
27
Well the trigger is working fine? Besides why is coordinates required, when all I want is to have the unit moved to the center of the named region?

And this isn't logical for me
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Because GetRectCenter(gg_rct_circle2) returns a location. locations leak. Leaks are a cause of lag.

If you insist on using locations, you must use following function:
JASS:
function Trig_VariableTest_Actions takes nothing returns nothing
    local location loc = GetRectCenter(gg_rct_circle2)
    call SetUnitPositionLoc(GetTriggerUnit(), loc)
    call RemoveLocation(loc)
    set loc = null
endfunction

Because locations leak, they generally are useless and if you're using jass, you better get used to using X/Y coordinates instead of locations.
 
Level 6
Joined
Jun 7, 2006
Messages
23
Status
Not open for further replies.
Top