HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

(at least to me) Tricky thing

10-28-2004, 07:38 PM#1
n\/Cl34r
Yet another question from a desperate noobie

Now, i finally got an global-free, leak-free and easy to customize Knockback Spell, but oh well in its actual state it has been there before. Well maybe not because it features damage per tree hit, but anyway, a really cool feature would be a smooth stop (yeah like the one in tob n). Well now i'm sure this can be done easily with an global because i've done it. But now, i'm trying to keep globals out of the game.

So what i'm trying to do is a non-global way to reduce a real by multiplying it with 0.98 in a repeating function. I already tried to achieve this with the Handle Variables (did Lord Vexorian did those ??? ), but failed because they need a subject (a timer) for each transaction from a function to another. And this works, as far my experience goes, only in the direction of the function with the GetExpiredTimer call.

I also already tried SetUnitUserData but found it horribly laggy.

Thx for your help !
10-29-2004, 12:36 AM#2
curi
why not store the value on the unit being knocked back?
10-29-2004, 06:20 AM#3
n\/Cl34r
Quote:
Originally Posted by curi
why not store the value on the unit being knocked back?

Do you mean the custom Unit Value ? That's SetUnitUserData, i already tried that. It lags like hell when performed 100 times a second.
10-29-2004, 06:39 AM#4
Litany
Quote:
Originally Posted by curi
why not store the value on the unit being knocked back?

If you read his post again, you'll find he tried it and found it laggy.

You're not going to be able to make a knockback like ours without globals. Going to such lengths to avoid them is silly anyway. If performance is an issue for you at that level, you should be writing all data in .slks, all triggers in fully optimized jass (no wasted calls, i.e. return GetSpellAbilityId() == 109XXXXXXX instead of return GetSpellAbilityId() == 'AXxx'), etc.

I'm not sure who you've been listening to, but there's nothing wrong with globals as long as you know when you need them and when there are more efficient ways. Really they're only a problem if you're, say, Guinsoo, and use them for absolutely everything because you have no idea what a local is. In fact you can save a lot of efficiency by creating only the triggers you need in any given game as locals, rather than initializing and creating them all as globals whether you end up using them or not. Say for example you have an AoS with 50 heroes, average of 2 triggered abilities per hero. If you write all 100 of those triggers normally, they're all initialized and created at map init. But if you, say, only create the relevant triggers for a hero when it has been selected by a player, you end up playing with only 20-24 (given 10-12 players) active triggers instead of 100. Quite a difference, no?

Basically a global in a knockback spell is really the last thing you should worry about.
10-29-2004, 09:12 AM#5
n\/Cl34r
Well actually i MANAGED to do it without globals (besides, the reason why i wanted to keep them away is easy implentation & customization ;) ).

But now i'm stumped. I've done something somewhere what causes the target unit to disappear and to get moved to the center of playable map area. The Spell WAS working perfectly. Have a look:

I think it's something with the targetloc, but i can't find it.


EDITed out, Spell available at wc3sear.ch
10-29-2004, 12:36 PM#6
AIAndy
Use code tags, that will increase the readability. Your problem is that you use targetloc after removing it.

@Litany: 'A001' is actually resolved into an integer on compile time and not on run time so you will likely not get any improvement by writing 109xxxxx.
10-29-2004, 03:20 PM#7
n\/Cl34r
Ehrm .... "Code Tag" (Grabs English-German-Translator)

Do you mean something like:

call DoNothing() // This is a very important function. Yeah really.

Or those:

//========================================

:(

Anyway thanks a lot, the spell works GREAT now.
10-29-2004, 03:27 PM#8
Luzif3r
Code:
call bla()


its like

(code)insert your trigger code here(/code)

but with these [] instead of these ().
10-29-2004, 06:00 PM#9
curi
i meant with gamecache. sethandlereal.
10-29-2004, 10:08 PM#10
Litany
Quote:
Originally Posted by AIAndy
@Litany: 'A001' is actually resolved into an integer on compile time and not on run time so you will likely not get any improvement by writing 109xxxxx.

That's an interesting bit of information Andy. How did you arrive at it? And is this also true of order strings and other integer checks? When I was still working on ToB N I was actually writing all the triggers checking for integers wherever integers were, so unit codes, ability codes, order strings, etc. Of course it's a slight performance gain, even if resolved during load, but I did so mainly for the built-in obfuscation, although we did tend toward all natives.

n\/Cl34r, I guess the unit being knockedback doesn't knockback any other units it comes into contact with in your trigger then? The gliding to a halt is easy enough, but I was thinking more of the bowling pin aspect of our knockback.
10-29-2004, 11:43 PM#11
AIAndy
That is not the case for true strings, but 'A001' is no string but a special variant of specifying an integer. Internally it is then an integer and not a string. In the case of order strings you are actually dealing with strings and using order ids there is a bit more efficient.
10-30-2004, 01:17 AM#12
Litany
Quote:
Originally Posted by AIAndy
That is not the case for true strings, but 'A001' is no string but a special variant of specifying an integer. Internally it is then an integer and not a string.

'A001' as data is contained in the .w3a, so I'm not entirely sure how it's handled, but if you take say the AbilityData.slk or any of the several unit data .slk's, they all work from their 4-letter/-integer codes and have no hint of the longer integer value. That's why I find it strange. It seems as though the A/B/XXxx codes should serve at least some purpose other than being permanently converted to the longer integer codes on load.
10-30-2004, 12:24 PM#13
n\/Cl34r
Quote:
Originally Posted by Litany
n\/Cl34r, I guess the unit being knockedback doesn't knockback any other units it comes into contact with in your trigger then? The gliding to a halt is easy enough, but I was thinking more of the bowling pin aspect of our knockback.

What ? A Bowling Pin Effect ? I didn't know about that, haven't played the leaked version really. It should be pretty easy though. I gonna try that later today.

EDIT

While trying to do this (i think i found a possible way), i encountered a wierd bug kicking me back to the main menu when i try to start the map:

It looks like it's caused by the line
Code:
local rect knockedarea = RectFromCenterSizeBJ(returnlocation(targetloc), 100.00, 100.00)
and i have absolutely no idea why because i even wrote this in GUI first and just replaced the dummy globals with my locals after converting it... It's not giving me compile errors or anything but the map works when i comment it out....
10-30-2004, 03:28 PM#14
a thing
Post the function returnlocation
10-30-2004, 04:31 PM#15
n\/Cl34r
Quote:
Originally Posted by n\/Cl34r
... because i even wrote this in GUI first and just replaced the dummy globals with my locals after converting it...

I have no idea what that returnlocation is for. If i remove it, i still don't get any compile errors, but the map continues to crash me because of that line.