HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Where is the bug?!?!?!?

02-21-2008, 12:43 PM#1
A Dreamer
[[[[[Trigger1]]]]]]
Trigger:
Attack dmg calculator
Collapse Events
Unit - A unit Is issued an order targeting an object
Collapse Conditions
((Triggering unit) is A Hero) Equal to True
(Issued order) Equal to (Order(attack))
Collapse Actions
Set Dmg_physical[(Player number of (Owner of (Triggering unit)))] = (Life of (Target unit of issued order))



[[[[[[Trigger2]]]]]]]
Trigger:
Attack dmg calculator 2
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
((Attacking unit) is A Hero) Equal to True
Collapse Actions
Set Dmg_taken[(Player number of (Owner of (Attacking unit)))] = (Dmg_physical[(Player number of (Owner of (Attacking unit)))] - (Life of (Triggering unit)))
Floating Text - Create floating text that reads (Player_color[(Player number of (Owner of (Attacking unit)))] + ((String(Dmg_taken[(Player number of (Owner of (Attacking unit)))])) + |r)) at (Position of (Triggering unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
Set Dmg_physical[(Player number of (Owner of (Attacking unit)))] = (Life of (Triggering unit))




Now based on the actions that i made in my mind in order to get this trigger (which is supposed to calculate and show with a floating text the dmg a unit gets when it is hit) it should work... But when i tested it it always fails in the first attack (the rest of the attacks work fine). It actually gives me a number below zero.... like -300.569 and not it is only below zero it's also very huge number... usually the units that i tested it do about 50-60 dmg...

So what i'm asking form you is obviusly if you see any problem in the algorithm that might explain why the trigger fails in the first attack and if you do then tell me if you have any way to fix it..

NOTE: i don't work with JASS (i know it's i'm a bit noob to work with GUI) so any sujestions you make plz be in GUI or can be performed by GUI


Thnx for reading and helping me with this problem i hope i can help you too in the future with any problem you might have :)
02-21-2008, 05:56 PM#2
TaintedReality
First, use trigger tags next time and it will be easier to read ^^.

Next, there's a much better way to do this, but here's how to fix your current problem:

You need to also allow for "smart" orders on enemies (right clicking) in the first trigger. It's probably not firing, so not setting the Dmg_physical variable, so the other trigger doesn't work properly. The next time, if you use right-click again, it still won't work right, but it will at least display something reasonable because you set the Dmg_physical variable at the end of the 2nd trigger.

Now...unfortunately "a unit is attacked" will fire before the unit actually takes damage. You instead need to use the Specific Unit Event "Unit Takes Damage". You'll need to create a trigger with your actions but no events, and then add a "Unit Takes Damage" event to it for each hero on the map at startup, and also for each hero that enters the map (with another trigger). You'll also then be able to use the real Damage Taken so you won't have to do any messing around.
02-21-2008, 06:49 PM#3
Strilanc
TaintedReality is correct, you have two problems:
- The first trigger won't fire when the hero is order by right-clicking (as opposed to specifically using attack) or when the hero acquires a new target by itself.
- The second trigger will fire as a unit is hit, but before the damage is deducted from its life.

You will want to look for damage detection systems, which will give you easy access to the kind of information you want. Most of them are written in JASS, but don't let that scare you off, since using them is usually not very hard and can be done mostly in GUI.

(and yes, I know it's ridiculous blizzard didn't allow "unit takes damage" as an every-unit type event, but you have to work with what you get)
02-22-2008, 10:12 PM#4
A Dreamer
thnx both of you guys you helped me a lot still haven't fixed it totaly but i'm working on it with a diferent base now and having more progress which is much more inspiring than the situation before. :D As for the damage taken real var (which allready exist by blizzard) the problem is that i don't know from the begining of the game which are going to be the 8 heros players will be controling they buy them from some taverns and i have a trigger that actually sets in a var the units that are sold form these taverns but still it doesn't accept a unit variable in a specific unit event :(... But anyway i got help from some other friends and from you and i have some progress THNX A LOT!!!!!!