HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

NEW! JASS function pack, please contribute

08-02-2003, 09:23 PM#31
Peppar
Well, I think that the reason for the functions not messing with
each other is simply that they never run at the same time. From
what I have leared, a trigger is allowed to run to the end
without interruption if not:

The trigger uses too much time, where Warcraft III decides to
terminate the trigger even if it was working perfectly.

The trigger executes a TriggerSleepAction(), where other triggers
are allowed to run and mess with global variables all they want.

I believe that the Blizzard.j globals are treated much the same
way as the user-defined ones, and that you don't have to fear the
variables getting dirty.

EDIT: ColorToStringFraction was bugged, I realized that the
function would cause a variable-type error. How typical. The only
one I didn't test :P.
08-03-2003, 12:22 AM#32
Peppar
I couldn't upload an updated version of the file in my first post for
some reason.

Anyway, here it is.
08-03-2003, 01:05 AM#33
piRo-piOn
i dont think you will acually need to manually decode the function pack... all you would have to do is keep certain values in a table form, so it technically wont be a text file but a DB file. i don't see the reason to put it in a text file scince copy/pasting functions is alot easier when you have a title, body and explanation for each function, seperated by horizontal rules and any other doo-hikkys you want to throw in. Not only that but instead of having to make a new text file each time you update the file pack you just type the specifics into an HTML form. (btw, i didn't know that sourceforge acually decoded the .j file... i always thought that the guy that made is simply typed everything out.)

AND YOU WONT HAVE THESE MILLIONS OF ANNOYING COPIES!!! Please stop uploading your own files, i think it would be alot easier (and less reminiscient of wintermaul) if you simply posted all your code and data would have the newest version up each time.

and btw, that GetSubString function is called "String Tokenizer" in programmer's terms and basically what it does is "cuts" a string where a certain string is found.

and bj_ variables are trigger-specific variables and are "tagged" onto a trigger (forLoops are a perfect example)
08-03-2003, 01:32 AM#34
weaaddar
Actually they are tagged for every instance of the trigger as well. You can have the same trigger running 5 times with slight intervals all using bj variables.

A good example is my respawn trigger in my map which uses the bj_LastDyingUnit variable (orwhatever its called). It checks to see if the unit is dead and no one is around after 10 seconds and keeps running until the conditions are finally met. However it doesn't have a problem where the wrong unit respawns if you kill unit X.

In short Bj variables are like "global" local variables/
08-03-2003, 01:44 AM#35
piRo-piOn
ya, thats what i meant... sorry if it caused confution.

data, im not sre whether this is what you meant, but you can try looking at functions like GetForLoopIndexA() which take local variables (well, bj_ variables are technically locals) from "parent" functions and use them in called functions.
08-03-2003, 02:07 AM#36
Peppar
If the bj_-variables weren't really global then the trigger queue
wouldn't be possible, it keeps a count of the number of triggers
in the queue in a variable named bj_queuedExecTotal. There are
many other functions that rely on the fact that the variables are
global.

Yes pion, I am aware of the programming term Tokenize :P. Still
I find it undescriptive and the common programmer may find a
more descriptive name helpful.
08-03-2003, 05:08 AM#37
dataangel
Quote:
Originally posted by weaaddar
Actually they are tagged for every instance of the trigger as well. You can have the same trigger running 5 times with slight intervals all using bj variables.

A good example is my respawn trigger in my map which uses the bj_LastDyingUnit variable (orwhatever its called). It checks to see if the unit is dead and no one is around after 10 seconds and keeps running until the conditions are finally met. However it doesn't have a problem where the wrong unit respawns if you kill unit X.

In short Bj variables are like "global" local variables/


That sounds exactly like what I need. Now I just need to figure out what bj vars are used least frequently =)
08-03-2003, 05:09 AM#38
dataangel
Quote:
Originally posted by Peppar
Well, I think that the reason for the functions not messing with
each other is simply that they never run at the same time. From
what I have leared, a trigger is allowed to run to the end
without interruption if not:

The trigger uses too much time, where Warcraft III decides to
terminate the trigger even if it was working perfectly.

The trigger executes a TriggerSleepAction(), where other triggers
are allowed to run and mess with global variables all they want.

I believe that the Blizzard.j globals are treated much the same
way as the user-defined ones, and that you don't have to fear the
variables getting dirty.

EDIT: ColorToStringFraction was bugged, I realized that the
function would cause a variable-type error. How typical. The only
one I didn't test :P.


This is WAYYYYYYYYY wrong. War3 uses threads. The only time triggers DONT run at the same time is if you use the trigger queue. RodOfNod had to recode his entire map once he realized this ;p

I hope you don't have to do any recoding now... :P
08-03-2003, 05:36 AM#39
Panto
Mm, care to let me know how the queueing system works? I had rather assumed that it ran the way I expected it to.

Since I don't know enough jass to use local variables, I think I'm going to need to do queuing.

And, I'm hungry. Time for a snack.
08-03-2003, 05:38 AM#40
piRo-piOn
Quote:
Originally posted by dataangel
That sounds exactly like what I need. Now I just need to figure out what bj vars are used least frequently =)


i don't think this will be that great of an idea... i'm sure there is a simple way to declare new ones (ill get to work on it once i'm back)

@peppar: how about GetStringFragment(String targetStr, integer sectionNum, String cutPoint)

data, you have a nasty knack of quoting everything... it makes for really lon, hard to look at posts... you might want to try any of the methods listed above (i.e. "@piOn", "piOn,", or
Quote:
SMALL quotes
) and if your doing it because we are too lazy to scroll up pls dont spoil us like that. <== OCP, Obssessive Compulsive Poster
08-03-2003, 05:38 AM#41
piRo-piOn
btw, here is a function that i'm working on... i won't be around PCs for a week so if someone would be kind enough as to finish it:

//=============================================
//
// Created By : nTiev Prerequisites : NONE
//
// How To Use : Add "call function CreatePlayerLeavesEvent()"
// to your Map Initialization trigger via
// action -> custom script.
//
// Description : Whenever a player leaves it will display
// "Player's Name has left the game.
// Transferring unit control to allies..."
//
//=============================================

function CreatePlayerLeavesEvent takes nothing returns nothing
local integer IndexVar = 1
local trigger trig
loop
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, Player(IndexVar), EVENT_PLAYER_LEAVES)
call TriggerAddAction(trig, DisplayTextToForce(GetPlayersAll(), "|cffffcc00" + GetPlayerName(Player(IndexVar)) + "|r has left the game.|n |cffff0000Transfering unit control to allies...|r"))
call TriggerAddAction(trig, //JASS function to give adv. unit control to allies
set IndexVar = IndexVar + 1
exitwhen IndexVar = 12
endloop
endfunction

//=============================================
08-03-2003, 08:22 AM#42
SuperIKI
Quote:
Originally posted by dataangel
This is WAYYYYYYYYY wrong. War3 uses threads. The only time triggers DONT run at the same time is if you use the trigger queue.


My experience shows that Peppar is right and dataangel is wrong.
If WC3 would use threads, Blizzard's functions that use global vars would be completely messed up.
08-03-2003, 10:08 AM#43
AIAndy
War3 does use a kind of pseudo thread system but the currently executed thread is only changed when the conditions written by Peppar are met.

@dataangel: The least significant bit is the bit that changes the value of the integer the least when changed. So depending on in which direction you write your bits that would be the left or the right side and the division by 2 would be a left shift or a right shift.
08-03-2003, 03:39 PM#44
Aiursrage2k
here is something that should work, untested...

Code:
function TransferControl takes integer index returns nothing
    local player thePlayer = GetTriggerPlayer()
    call ShareEverythingWithTeam(thePlayer)
    call MeleeDoLeave(thePlayer)
endfunction


function CreatePlayerLeavesEvent takes nothing returns nothing
   local integer i = 0
   local trigger trig = CreateTrigger()
   local playerevent E = EVENT_PLAYER_LEAVE
   loop
     exitwhen i > 11
       call TriggerRegisterPlayerEvent(trig, Player(i), E)
       call TriggerAddAction(trig,function TransferControl)
     set i = i + 1
   endloop
endfunction
08-03-2003, 04:42 PM#45
Panto
I'll just drop requests as I see them appropriate.

Are there functions available that deal with Forces directly? I'm not talking playergroups, I'm talking about the Force settings as you can set them in the Player Properties area.