Best alternative?

Samael88

Evil always finds a way
Reaction score
182
Hello,
I was wondering if someone know wich are the most optimal for jassers to do between these:

Write the most functions in the map script thingy(where you can only write JASS) and then call them from triggers.

or

Let each trigger contain its necessary functions and write nothing in the map script.

Wich is best?
 
I feel like helpping someone :D

Use vJass libraries and scopes

If you need to use some functions in many places, place them in one library.

If you need some function in only one trigger, then have it in same scope with your trigger.

The key is to make easy for you to find right functions when you need to edit them.

I hope this helps. Im not suprised if it does not.
 
I never use custom map script.

So it is slower to use that.
For the vJASS, I am working on learning that, I have downloaded all the stuff I need, newgen and all that. I just never have had the time since then to use it.
Can you use librarys without vJASS?
What does scope make any difference in terms of effectivity?
 
If you have duplicates of functions embedded in triggers, you are making the functions hash fatter, and it will eventually make function calls in general slower. This is the only way in which picking where to put functions is related to performance.
 
actually... warcraft puts all your triggers in the map script when saving... the first script is the map script, then all your triggers and function calls to their initialization functions

"triggers" in jass are only handles which are hold in global variables

"triggers" in the trigger editor can help you organizing your scripts

theres no different in speed

(by the way, what do you need the speed for?)
just look through the functions and optimize them, or post a script to be optimized
 
If you have duplicates of functions embedded in triggers, you are making the functions hash fatter, and it will eventually make function calls in general slower. This is the only way in which picking where to put functions is related to performance.

Thank you vexorian:) You are actually the first one really trying to answer my question:D +rep to you:thup:
 
(by the way, what do you need the speed for?)

It came to my mind if it was possible to optimize the effectivity of my functions by putting them in a special place or something like that.

On the opimization part, is it not better to take numbers and return numbers in a function, else then letting th triggers work with units and points and other bigger stuff?
 
units and other "bigger stuff" are just integers poiting to some space in the memory, so i think there shouldnt be a big difference in speed

but again, what for? if your map is running fluently, everything is great^^ first steps to optimize your map would be to reduce the amount of units, reduce the amount of periodically running functions and their leaks and search for the triggers which are runned often, then try to remove useless function calls, BJs, locations, any other "bigger stuff" which is not really needed... then if you really need even more performance, do not create "bigger stuff" at all but have some of them in global variables so you can use them temporarly (recycling handles)
and of course, which is quite hard to do with a already written code, think about the structure in general
 
I try to think of the structure already when I'm writing the code, and the BJ:s I do not even use when I write.

I checked the blizzard.j file. A BJ to me seams like a function that only calls another function, is that correct?
If so it must mean that I just search blizzard.j to find the proper function and then call it myself. Am I wrong?

And the leaks you can also do pretty easy when you are writing the code to.

What are these handles you are talking about? I never really understood the handle things:confused:
 
BJ's are functions that call one or more natives, correct. If you use NewGen or Jasshelper, you dont need to find it in the Blizzard.j, you can look it up in the Native List. Much faster and easier ^^.
 
BJ's are functions that call one or more natives, correct. If you use NewGen or Jasshelper, you dont need to find it in the Blizzard.j, you can look it up in the Native List. Much faster and easier ^^.

Everything shall go fast today, what is wrong with the old fashion way of patience, it works better for me:D But do not think that I am old beacuse of that:eek:
 
a handle is a variable which holds more than one value... basically...^^

you can detect a handle this way:

JASS:
local location p = Location(0,0)
local location p2 = p
call RemoveLocation(p)
// p2 is a pointer to the same space in memory, it is removed, too!

local integer i = 100
local integer i2 = i
set i = 0
// i2 is still 100


so a handle works with a pointer to some space in the memory, and it uses its "value" just as a referrer, where integers just use the number to store the information

yes, everything is quite easy, but it takes time to learn, everything
and i assume that you did not write "perfect" code^^

if you want you can post a trigger executed very often and i will take a look ;) i bet i will find something to optimize^^
 
yes, everything is quite easy, but it takes time to learn, everything
and i assume that you did not write "perfect" code^^

if you want you can post a trigger executed very often and i will take a look ;) i bet i will find something to optimize^^

Thank you for you explanation:D Now i understand it a little better:thup:

I have not begun with the triggers yet, I have started to experiment with standard JASS just recently. I found it easier to start with just writing functions and call them with gui. I will post a function I made here, the first one actually:D

JASS:
globals
integer udg_Index
real udg_GravityForce
real array udg_Y_Velocity
boolean array udg_Up
real array udg_YA
real array udg_YB
unit array udg_Unit
endglobals           

function boolconvert takes integer udg_Index returns boolean
    if udg_Y_Velocity[udg_Index] <10 then
    return true
    else
    return false 
    endif
endfunction

function groundcheck takes integer udg_Index returns boolean
    if udg_YA[udg_Index] < 10 then
    set udg_Up[udg_Index] = true
    elseif ( GetBooleanAnd(boolconvert(udg_Index)==true, udg_Up[udg_Index]==true)) then
    set udg_Up[udg_Index] = false                           
    endif
    return udg_Up[udg_Index]
endfunction  

function MoveZ takes integer udg_Index returns real
    if udg_Up[udg_Index] == true then
    set udg_Y_Velocity[udg_Index] = (udg_Y_Velocity[udg_Index] - udg_GravityForce)
    set udg_YB[udg_Index] = udg_Y_Velocity[udg_Index] * 0.03
    set udg_YA[udg_Index] = udg_YA[udg_Index] + udg_YB[udg_Index]
    call groundcheck(udg_Index)
    call SetUnitFlyHeight(udg_Unit[udg_Index], udg_YA[udg_Index], 0)
    elseif udg_Up[udg_Index] == false then
    set udg_Y_Velocity[udg_Index] = (udg_Y_Velocity[udg_Index] + udg_GravityForce)
    set udg_YB[udg_Index] = udg_Y_Velocity[udg_Index] * 0.03
    set udg_YA[udg_Index] = udg_YA[udg_Index] - udg_YB[udg_Index]
    call groundcheck(udg_Index)
    call SetUnitFlyHeight(udg_Unit[udg_Index], udg_YA[udg_Index], 0)
    endif
    return udg_YA[udg_Index]
endfunction


It makes a ball bounce up and down and lose height for each bounce:) It is mui and works with about 70balls for now:) Think I can get it over a 150 if I make the trigger calling it in JASS to, or atleast I hope:)
You can please take a look at it if you want, I would really like to learn opimizing function atleast:) This one is written in directly into the map script, you know the place where you can only write. Hope you know what I mean:eek:

Edit: I mean more that 70 balls and it starts to lag, atleast on my computer:(
 
JASS:
globals
	integer udg_Index
	real udg_GravityForce
	real array udg_Y_Velocity
	boolean array udg_Up
	real array udg_YA
	real array udg_YB
	unit array udg_Unit
endglobals 

function MoveZ takes integer udg_Index returns real
	if udg_Up[udg_Index] then
		set udg_Y_Velocity[udg_Index] = (udg_Y_Velocity[udg_Index] - udg_GravityForce)
		set udg_YB[udg_Index] = udg_Y_Velocity[udg_Index] * 0.03
		set udg_YA[udg_Index] = udg_YA[udg_Index] + udg_YB[udg_Index]
	else
		set udg_Y_Velocity[udg_Index] = (udg_Y_Velocity[udg_Index] + udg_GravityForce)
		set udg_YB[udg_Index] = udg_Y_Velocity[udg_Index] * 0.03
		set udg_YA[udg_Index] = udg_YA[udg_Index] - udg_YB[udg_Index]
	endif
	if udg_YA[udg_Index] < 10 then
		set udg_Up[udg_Index] = true
	elseif udg_Y_Velocity[udg_Index]<10 and udg_Up[udg_Index] then
		set udg_Up[udg_Index] = false                       
	endif
	call SetUnitFlyHeight(udg_Unit[udg_Index], udg_YA[udg_Index], 0)
	return udg_YA[udg_Index]
endfunction


inlining helps improving the performance...

however, if you dont want to inline your functions, at least dont use GetBooleanAnd(), instead only "and", dont use == true

JASS:
function boolconvert takes integer udg_Index returns boolean
    return (udg_Y_Velocity[udg_Index] <10)
endfunction


create conditions in this way


by the way, i dont really understand why you use "up" there... just ALWAYS reduce the z speed by the gravity, and if the projectile hits the ground, set SpeedZ = -0.9*SpeedZ


thats how i would do it... and thats what i am calling "structure"^^
JASS:
globals
	integer udg_Index
	real udg_GravityForce
	real array udg_SpeedZ
	real array udg_Z
	unit array udg_Unit
endglobals 

function MoveZ takes integer udg_Index returns real
	set udg_SpeedZ=udg_SpeedZ-udg_GravityForce
	set udg_Z=udg_Z-udg_SpeedZ*0.03
	if udg_Z<=0 then
		set udg_Z = 0
		set udg_SpeedZ = -0.9*udg_SpeedZ
	endif
	call SetUnitFlyHeight(udg_Unit[udg_Index], udg_Z[udg_Index], 0)
	return udg_Z[udg_Index]
endfunction


and "takes integer udg_Index".... udg_Index is a global.... either you let the function take a parameter, or you set the global and make the function take nothing

and heres a slightly advanced system i made :D http://www.hiveworkshop.com/forums/resource.php?t=81933
 
Are you that N-a-z-g-u-l?
Dude, you are awesome, I have seen some screens on that map before and heard a lot about it, but never thought I would acctually write with the maker:rolleyes:

Thank you for teaching me this:) I will have all of this in mind when I work on my own physics engine:thup:
 
Are you that N-a-z-g-u-l?
Dude, you are awesome, I have seen some screens on that map before and heard a lot about it, but never thought I would acctually write with the maker:rolleyes:

Thank you for teaching me this:) I will have all of this in mind when I work on my own physics engine:thup:

Yup, that's him. Creator of BTanks.

:p

Muahaha... I did your job for you! Now you don't feel as much pride. :rolleyes:
 
And by the way N-a-z-g-u-l.
This function you made, it does not really work like mine did:S
JASS:
globals
	integer udg_Index
	real udg_GravityForce
	real array udg_SpeedZ
	real array udg_Z
	unit array udg_Unit
endglobals 

function MoveZ takes integer udg_Index returns real
	set udg_SpeedZ=udg_SpeedZ-udg_GravityForce
	set udg_Z=udg_Z-udg_SpeedZ*0.03
	if udg_Z<=0 then
		set udg_Z = 0
		set udg_SpeedZ = -0.9*udg_SpeedZ
	endif
	call SetUnitFlyHeight(udg_Unit[udg_Index], udg_Z[udg_Index], 0)
	return udg_Z[udg_Index]
endfunction

You forget to check if they are going up or down, this function as it is written here makes the balls go up continuesly;)
That is why I had the up boolean, If i did not have that, they would had gone in only one direction, and either bounced nor come down depending on the formula:shades:
 
And by the way N-a-z-g-u-l.
This function you made, it does not really work like mine did:S
JASS:
globals
	integer udg_Index
	real udg_GravityForce
	real array udg_SpeedZ
	real array udg_Z
	unit array udg_Unit
endglobals 

function MoveZ takes integer udg_Index returns real
	set udg_SpeedZ=udg_SpeedZ-udg_GravityForce
	set udg_Z=udg_Z-udg_SpeedZ*0.03
	if udg_Z<=0 then
		set udg_Z = 0
		set udg_SpeedZ = -0.9*udg_SpeedZ
	endif
	call SetUnitFlyHeight(udg_Unit[udg_Index], udg_Z[udg_Index], 0)
	return udg_Z[udg_Index]
endfunction

You forget to check if they are going up or down, this function as it is written here makes the balls go up continuesly;)
That is why I had the up boolean, If i did not have that, they would had gone in only one direction, and either bounced nor come down depending on the formula:shades:


ah yes, my mistake... i am substracting the speed...

this way is right:

JASS:
globals
	integer udg_Index
	real udg_GravityForce
	real array udg_SpeedZ
	real array udg_Z
	unit array udg_Unit
endglobals 

function MoveZ takes integer udg_Index returns real
	set udg_SpeedZ[udg_Index]=udg_SpeedZ[udg_Index]-udg_GravityForce
	set udg_Z[udg_Index]=udg_Z+udg_SpeedZ[udg_Index]*0.03
	if udg_Z[udg_Index]<=0 then
		set udg_Z[udg_Index] = 0
		set udg_SpeedZ[udg_Index] = -0.9*udg_SpeedZ[udg_Index]
	endif
	call SetUnitFlyHeight(udg_Unit[udg_Index], udg_Z[udg_Index], 0)
	return udg_Z[udg_Index]
endfunction


moving down = SpeedZ<0, by the way
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)
    +1
  • The Helper The Helper:
    It will only be on internal network
  • jonas jonas:
    Man the AI is good about gaslighting about security though. I've had several times where I pointed out security problems and it tried to convince me that with a tiny tweak it suddenly becomes secure
  • jonas jonas:
    Like using a distrobox as a "secure" container, and when I point out that's not secure at all, it claimed that specifying home will make it secure
  • The Helper The Helper:
    Yeah I finished the app today and it is bad ass. Like ChatGPT codes way better and faster than me that is for sure. The app is unsecure AF though and I would never put it anywhere it was obvious. I did not even show it today, the boss never made it in, but I showed the office and they liked it and frankly, I do software for a living and I am qualified to judge this kind of stuff and... Holy Shit this is a game changer. It took me around 4 hours to finish the app from design to end and that is much faster than I could have done it in the outdated MS Access the thing it replaced was in. Good Stuff! Had tons of fun doing it too! Work has not been fun in a while - today was fun!
  • The Helper The Helper:
    And really, I did not do it, chat wrote all the code I just pasted it in, tested it, acted like Chats eyes on it and just learned. I learned VS Code, how to use the Terminal and a bunch of Powershell and Command stuff, I used Git for the first time and learned how to save, search, start my server, stop it, run the tests, do some debugging - all the freaking fun stuff - chat wrote all the code
  • The Helper The Helper:
    I think the key was the 40 minutes of that 4 hours that went into the design of it. The thing was fully specced out before we started and the only reason it took so long was I had never done any of it and had to get used to the navigation and workflow.
  • The Helper The Helper:
    React, JS and AG Grid are the tools that I know i used along with git. I learned alot but it will be a minute before I fully understand everything I am doing in these environments because I am really just following instructions.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top