| 07-11-2005, 08:58 PM | #1 |
So, as Vex explained to me some time ago, you can write an integer in JASS in two ways, as a regular number (like 215347) or the way object IDs are written (like 'AsdF'). Now, I was making a bonus mod and I didn't feel like initializing an array of abilities, so I just created them in the correct order, so their names were 'A000' (+1), 'A001'(+2), 'A002'(+4), 'A003'(+8)... This way, I could translate the power of two I wanted to have directly into the abilityID ('A000' + a). It worked like a charm. Now on to my problem. I have one last ability which is a big negative (-1024), so I can make negative bonuses as well. It's ID is 'A00A', and I am not able to get this through arithmethics. ('A000' + 'A') didn't work, neither did ('A000' + 10). So, how do I get 'A00A'? |
| 07-11-2005, 10:37 PM | #2 |
I don't know your answer straight off, but I'd suggest using a test bit of code to display I2S( 'A009' ) and I2S( 'A00A' ). Comparing the resulting normal integers might tell you something. |
| 07-11-2005, 11:34 PM | #3 |
A00A doesn't follow A009 , get an ascii table and you will note that the number that follows 'A009' is 'A00:' It uses Ascii to determine the values |
| 07-12-2005, 09:22 AM | #4 | |
Quote:
I'll test it and see how far 'A' is from '0'. (although, as it turns out, I maybe won't need the bonus mod for anything other than damage in my map, but it's always useful to make it a generic system that works with armor and hp too, for other maps) Thanks. |
| 07-12-2005, 04:41 PM | #5 |
why is it so difficult to have a global array of integers? If you really hate the idea, you can just make a vector in gamecache, of course then you need a global gamecache. |
| 07-12-2005, 06:26 PM | #6 | |
Quote:
|
| 07-13-2005, 03:03 AM | #7 |
great, your sounding like the childish idiots who go into warcraft III trying to make every map without variables. Trust me man, you love variables when you try to do instancible work. I miss the old day when I could have used globals, (and refused because I was an idiot) today most of my functions have a local section thats about as big as thier code body. BonusMod like systems are perfectly viable excuse to use global int array. If not you can be like EdwardSwolen toes terrible implementation where he basically cheats and has a function which acts as a global array, by using a local array. |
| 07-13-2005, 09:15 AM | #8 |
Oh, my mistake, I do have a bunch of local variables, just no global ones yet. I guess as I learn JASS I'm just excited about the ability to make code that you can just copy to another map and it works, no trouble with remaking all the variables first... Kind of stupid, seeing as how every map has a unique concept and I always end up making triggers for each project from scratch. I have a question regarding globals and game cache, though. Obviously, globals are faster, if you know what you want (in the case of the bonus mod, you know exactly which array index you want). But when you don't know and need to search, you have to loop through an array, while game cache has more intelligent search algorithms. At what point does this better architecture of game cache beat the speed of variable arrays, among how many items do you need to be searching? |
| 07-13-2005, 10:03 AM | #9 | |
Quote:
OMG~!! lol you're just jealous that my system is better. Why bother going global when you can have it local baby. |
| 07-13-2005, 10:15 AM | #10 |
I sense growing animosity between those two. LET THEM FIGHT IN THE ARENA OF FLAMES!!!!!!!!!!!!! THE WINNER WILL BE CROWNED QUEEN OF CODING!!!!!!!!!!!!!!!!! |
| 07-13-2005, 10:57 AM | #11 |
LLAMA SLAUGHTER TIME!! |
| 07-13-2005, 03:21 PM | #12 |
Depends on what you want. For instance if you were to make a queue, an array or vector is generally the worst possible way to do it. But a circular doubly linked list is an excellent implementation. However, to overcome the native speed advantage of an array you need to have a very large queue. I'm not sure how large but I'd say about 100 elements and it'd be worthwhile. And EdwardSwolenToe, a global array is faster then creating a local array everytime you need it. |
| 07-13-2005, 05:08 PM | #13 |
Given that estimate, as long as I had less than 100 units in my map at a time, it would be more efficient to have an array in which all units were stored and loop through it rather than storing their data to game-cache via their handle index. But unless on very fast periodic events, this really doesn't matter and the choice between global variables and game cache is more a matter of coding style. I just had another thought (concerning game cache vs global variables), but I suppose my question will be unclear if I don't give an exact example. I am wondering, how big a difference does it make, storing and geting about five real values, between storing them to a global variable and storing them to game cache. If this is used in a periodic event together with some math functions (sin, cos stuff mostly, plus the usual arithmetics) and a move-unit-instantly action, how big a difference would using game-cache or global variables make for the whole bundle? I know, it depends on how many math functions there are, and what else the periodic trigger does that I'm forgetting, but just a general estimate, would the difference matter, lag-wise? |
| 07-13-2005, 10:24 PM | #14 |
Not always, remember that as a direct access (knowing the string) gamecache is only three times slower than an array. Having to concantanate ("this"+"that") and using I2S are aditional penalties of speed. AiAndy said that it was about ten times slower to concantanate and use I2S. A global variable is faster than a global array which is faster than gamecache. Almost all math functions that are native or blizzard.j implemented should run damn near instaneously. In real life you can not notice the difference between a global or gamecache. Only when writing extremely complicated algorithms will this difference be noticable. |
| 07-13-2005, 11:29 PM | #15 |
Weaaddar, you always talk about speed speed! The probable 0.04 of a second gained by using globals doesnt outshine using locals. |
