Hey guys, I'm starting to learn jass. I do know some programming language so the whole logic/variable system for the most part makes sense to me although I am somewhat out of practice. What I don't know exactly is how to relate my data to warcraft. For instance:
I was able to make this after reading a couple tutorials for jass. There might be a way to do what I did in about 5 lines, but whatever. Anyway, ultimaetly what this does is makes the 'local integer array position_numbers' full of numbers 1-11, however, there are no repeats, and in a random order.
What I want to know is how to "attach" one of the array variables to a player. For instance 'position_numbers[1] be reds' and 'position_numbers[2] be blues'. This is probably fairly simple but as I said, I don't really know how to relate the data to warcraft 3 too well. From there depending on the value of the integer array, I'd like to assign them a position. For instance, whoever has number 11 gets to be leader, and whoever gets number 1 is a douche, you get the idea. I know it's hard to understand what exactly I want so yeah, but please try your best.
Figured this out for the most part, but please keep on reading
My second question is why exacly do we need parameters (the words after take and return). I understand what they are, but from reviewing tutorials and looking at scripts, I don't exactly see the point. From what I can tell (this is probably wrong so correct me) you can just get by them by having local variables and setting variables within the function.
Also, the call function can kind of act as an event right? As in it can call what time of day it is etc. to see if the function should proceed?
Lastly, I am currently on a project that is definently out of ability level at the moment, and although I am a fast learner when it comes to this these types of things I probably will be asking for a lot of help in the next couple weeks, so please bear with me. Thank you.
JASS:
globals
trigger gg_trg_random_positions
endglobals
function IntTrig_position_numbers takes nothing returns nothing
local integer counter_1=1
local integer counter_2=2
local integer counter_3=3
local integer counter_4=1
local integer array position_numbers
local real array random_numbers
loop
exitwhen random_numbers[11] >= .01
set random_numbers[counter_1] = GetRandomReal(0.01,10000.00)
set counter_1 = counter_1+1
endloop
set counter_1=1
loop
exitwhen counter_4==12
loop
exitwhen counter_3==14
if random_numbers[counter_1] > random_numbers[counter_2]then
set counter_2=counter_3
set counter_3=counter_3+1
else
set counter_1=counter_3
set counter_3=counter_3+1
endif
endloop
if random_numbers[counter_1] >= random_numbers[counter_2]then
set random_numbers[counter_1]=0
set position_numbers[counter_1] = counter_4
else
set random_numbers[counter_2]=0
set position_numbers[counter_2] = counter_4
endif
set counter_3=3
set counter_1=1
set counter_2=2
set counter_4=counter_4+1
endloop
set counter_1=1
loop
exitwhen counter_1==12
call BJDebugMsg (I2S(position_numbers[counter_1]))
set counter_1=counter_1+1
endloop
endfunction
function InitTrig_random_positions takes nothing returns nothing
set gg_trg_random_positions = CreateTrigger()
call TriggerAddAction( gg_trg_random_positions, function IntTrig_position_numbers )
endfunction
I was able to make this after reading a couple tutorials for jass. There might be a way to do what I did in about 5 lines, but whatever. Anyway, ultimaetly what this does is makes the 'local integer array position_numbers' full of numbers 1-11, however, there are no repeats, and in a random order.
What I want to know is how to "attach" one of the array variables to a player. For instance 'position_numbers[1] be reds' and 'position_numbers[2] be blues'. This is probably fairly simple but as I said, I don't really know how to relate the data to warcraft 3 too well. From there depending on the value of the integer array, I'd like to assign them a position. For instance, whoever has number 11 gets to be leader, and whoever gets number 1 is a douche, you get the idea. I know it's hard to understand what exactly I want so yeah, but please try your best.
Figured this out for the most part, but please keep on reading
My second question is why exacly do we need parameters (the words after take and return). I understand what they are, but from reviewing tutorials and looking at scripts, I don't exactly see the point. From what I can tell (this is probably wrong so correct me) you can just get by them by having local variables and setting variables within the function.
Also, the call function can kind of act as an event right? As in it can call what time of day it is etc. to see if the function should proceed?
Lastly, I am currently on a project that is definently out of ability level at the moment, and although I am a fast learner when it comes to this these types of things I probably will be asking for a lot of help in the next couple weeks, so please bear with me. Thank you.
Last edited: