HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Stumped on this trigger..

01-13-2007, 11:38 PM#1
Gojhin
i'm making an rpg and i wanna make floating text for experience gained but apparently i went wrong somewhere and it will alwayse show up as 9 instead of the correct given...

Trigger:
Dark Forest Spider Ancient XP
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Unit-type of (Dying unit)) Equal to Dark Forest Spider Ancient
Collapse Actions
Set Loc = (Position of (Dying unit))
Set UnitGroup = (Units within 1000.00 of Loc matching ((((Matching unit) is A Hero) Equal to True) and (((Owner of (Matching unit)) Not equal to Neutral Hostile) and ((Owner of (Matching unit)) Not equal to Neutral Victim))))
Unit Group - Pick every unit in UnitGroup and do (Hero - Add (Random integer number between 36 and 55) experience to (Picked unit), Show level-up graphics)
Set Loc = (Position of (Random unit from UnitGroup))
Floating Text - Create floating text that reads (String((Integer A))) at Loc with Z offset 0.00, using font size 10.00, color (85.00%, 85.00%, 0.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 50.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
01-13-2007, 11:51 PM#2
Anopob
You are not using GUI loops, so your "reads (String((Integer A))) at Loc" should be the experience giving.

EDIT: Like make "integer = random int between X and X", then give the hero exp integer, and display integer.
01-14-2007, 12:02 AM#3
Pyrogasm
Here's the correct trigger, optimized with locals and no memory leaks:
Trigger:
Dark Forest Spider Ancient XP
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Unit-type of (Dying unit)) Equal to Dark Forest Spider Ancient
Collapse Actions
Custom Script: local integer udg_XP
Set Loc = (Position of (Dying unit))
Set UnitGroup = (Units within 1000.00 of Loc matching ((((Matching unit) is A Hero) Equal to True) and (((Owner of (Matching unit)) Not equal to Neutral Hostile) and ((Owner of (Matching unit)) Not equal to Neutral Victim))))
Set XP = (Random integer number between 36 and 55)
Unit Group - Pick every unit in UnitGroup and do (Hero - Add (XP) experience to (Picked unit), Show level-up graphics)
Set Loc = (Position of (Random unit from UnitGroup))
Floating Text - Create floating text that reads (String((XP))) at Loc with Z offset 0.00, using font size 10.00, color (85.00%, 85.00%, 0.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 50.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
Custom script: call RemoveLocation( udg_Loc )
Custom script: call DestroyGroup( udg_UnitGroup )
01-14-2007, 12:15 AM#4
Gojhin
k thanks man
01-14-2007, 02:16 AM#5
Anopob
Pyrogasm, does that actually work? Your custom script part says "local Integer XP".

1: Isn't it "integer" (JASS = case sensitive)?
2: Isn't it udg_varname?
01-14-2007, 02:20 AM#6
Gojhin
= ) yep. i just finished setting my trigger's, it works 100%
01-14-2007, 02:21 AM#7
Pyrogasm
Am I retarted? I thought maybe I did something wrong... integer should not be capitalized. Also, it does need the "udg_". I don't know why I didn't put it in! D'oh!

I've fixed the above trigger...
01-14-2007, 03:15 AM#8
Gojhin
is there something im missing about the variable or something? i've got the trigger right but when i kill them, the proper numbers show up but i dont actually get the exp
01-14-2007, 03:40 AM#9
Joker
The custom on the first line of actions in Pyro's is completely unnecesary. GUI cant read locals well, and you have a global there anyway, so no reason to use a local
01-14-2007, 03:59 AM#10
Rising_Dusk
Quote:
The custom on the first line of actions in Pyro's is completely unnecesary. GUI cant read locals well, and you have a global there anyway, so no reason to use a local
Pyro is using the local-global trick.
Which FYI, works perfectly.

Remember, GUI is nothing but jass in disguise.
Therefore everything that works in one can work in the other.
01-14-2007, 06:06 AM#11
Anopob
Quote:
Originally Posted by Gojhin
is there something im missing about the variable or something? i've got the trigger right but when i kill them, the proper numbers show up but i dont actually get the exp

Did you try the UPDATED version? I've correct Pyrogasm's mistakes and it should work now (I think).
01-15-2007, 05:53 AM#12
Pyrogasm
I used the local because it makes the trigger more reliable. When using a global for this, there is a very small chance (but a chance none-the-less) that the integers will get messed up.

Using a local avoids that possibility, and with a local integer, you don't even need to nullify it!
01-17-2007, 08:57 PM#13
Gojhin
i see.. ok cool.
01-17-2007, 11:36 PM#14
Ammorth
Quote:
Originally Posted by Pyrogasm
I used the local because it makes the trigger more reliable. When using a global for this, there is a very small chance (but a chance none-the-less) that the integers will get messed up.

Using a local avoids that possibility, and with a local integer, you don't even need to nullify it!

That is not the case. As long as you have no waits in between when you assign and use the variable, your variable will not be changed. Try it, if you don't believe me.

Also, about the local-global trick, it only works for one global variable. After that, there are wierd problems that occur. But in this case, no local is required.
01-17-2007, 11:56 PM#15
Pyrogasm
I know that it only works once per trigger, and that they can't be used in conditions. By "very small chance" I meant if the events occurred at the same time (which is VERY unlikely), in which case the XP could become 'confused' and get weirded out. It's just smarter to use a local... why would they exist if we shouldn't use them?

Ammorth has made a valid point, however, and if you keep getting errors, you can leave the local part out.