| 02-18-2004, 02:17 AM | #1 |
Ok, I have a rouge spell called steal, it starts out stealing 10-50 gold, adding 10-20 every level, at least it is saposed to. For some reason I am getting obsceen amounts of gold stolen(around 3-10 times what its saposed to be). Here is the trigger: Code:
Actions
Set TempInt1[(Player number of (Triggering player))] = (10 x ((Level of Steal for (Triggering unit)) - 10))
Set TempInt2[(Player number of (Triggering player))] = (20 x ((Level of Steal for (Triggering unit)) + 30))
Set TempInt3[(Player number of (Triggering player))] = (Random integer number between TempInt1[(Player number of (Triggering player))] and TempInt2[(Player number of (Triggering player))])
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Owner of (Target unit of ability being cast)) Current gold) Less than TempInt3[(Player number of (Triggering player))]
Then - Actions
Floating Text - Create floating text that reads (String(((Owner of (Target unit of ability being cast)) Current gold))) at (Position of (Casting unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Set FloatingText[(Player number of (Triggering player))] = (Last created floating text)
Player - Add ((Owner of (Target unit of ability being cast)) Current gold) to (Owner of (Casting unit)) Current gold
Player - Set (Owner of (Target unit of ability being cast)) Current gold to 0
Else - Actions
Floating Text - Create floating text that reads (String(TempInt3[(Player number of (Triggering player))])) at (Position of (Casting unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Set FloatingText[(Player number of (Triggering player))] = (Last created floating text)
Player - Add TempInt3[(Player number of (Triggering player))] to (Owner of (Casting unit)) Current gold
Player - Set (Owner of (Target unit of ability being cast)) Current gold to (((Owner of (Target unit of ability being cast)) Current gold) - TempInt3[(Player number of (Triggering player))])
Wait 5.00 seconds
Floating Text - Destroy FloatingText[(Player number of (Triggering player))] |
| 02-18-2004, 05:05 AM | #2 |
Please include the full trigger so we know where Triggering Player and Triggering Unit are coming from. |
| 02-18-2004, 05:12 AM | #3 |
Code:
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Steal I really dont see why you need them, but here they are. The problem is with the random geneated numbers, not where they are going. |
| 02-18-2004, 05:17 AM | #4 |
Well, you have no action referring to a player, so there really is no triggering player in this. Also, I'd suggest using Casting Unit instead of Triggering Unit -- always be as specific as possible. To find the player, use "Owner of (Casting unit)" If you're using red, and only red, to test this -- it may very well be defaulting to him since there's no Triggering Player to get. Try printing a game message of the name of the "Triggering Player" to find out. Also, a word of advice: whenever coding, and especially when you expect other people to read your code, try to use descriptive variable names and comment the code so we can follow your thought process in all this. |
| 02-18-2004, 05:24 AM | #5 |
my god, you are just DEAF That is NOT the problem. Triggering player works just fine for me. it is the amount of gold being stolen that is off. how many times do I have to say it? |
| 02-18-2004, 05:30 AM | #6 |
Technically, I wouldn't need to hear you to help you. And if you're in need of help, I'd suggest you shut your hole -- it might get you further. If you look at this formula: Set TempInt1[(Player number of (Triggering player))] = (10 x ((Level of Steal for (Triggering unit)) - 10)) and break it down into it's steps, you might get a clue as to your problem. According to the placement of the parenthesis, it would be issued as thus (assuming that Steal is on level 1): Level of Steal for (Triggering unit) = 1 1 - 10 = -9 10 x -9 = -90 I don't see how you could be led to believe that the problem is in the random number generator -- computers don't make mistakes, you do. |
| 02-18-2004, 08:47 AM | #7 |
oops, maybe i should look at an entire thread before posting |
| 02-18-2004, 02:32 PM | #8 |
Triggering Player Works fine? It is weird, probably blizzard made something to make Triggering Player reffer the owner of triggering unit, I will need to make some testings. Or probably your trigger won't work when a player that isn't player 1 uses it. Anyways the problem is at the start of the trigger: Code:
Set TempInt1[(Player number of (Triggering player))] = (10 x ((Level of Steal for (Triggering unit)) - 10))
Set TempInt2[(Player number of (Triggering player))] = (20 x ((Level of Steal for (Triggering unit)) + 30))
Set TempInt3[(Player number of (Triggering player))] = (Random integer number between TempInt1[(Player number of (Triggering player))] and TempInt2[(Player number of (Triggering player))])Check the brackets, the first arithmethic operation you need to make is the addition/substraction, then inside that arithmetic operation place the multiplication: and since there aren't waits in the trigger you don't need an array |
| 02-18-2004, 02:44 PM | #9 | ||
Quote:
Yeah... I just tested it, and it does seem to work -- strangely enough. I guess they were feeling generous when they added that functionality, but I almost wish they hadn't -- hehe. It doesn't make any sense to me. Quote:
I alreaedy told him his problem. And I'd actually support the array because. It's not as effective as a local variable, but more so than a global one. Near as I can figure the WC3 engine runs multi-threaded, so waits aren't strictly needed for multiple triggers to be goin simultaneously and over-writing each other global variables -- or the same trigger running multiple times, as this case may be. Anyhoo -- you're welcome, Hunter0000 |
| 02-18-2004, 02:58 PM | #10 | |
Quote:
Well, yes but no, when there are no waits in the trigger there is no way to make it run at the same time as other triggers run. |
| 02-18-2004, 03:30 PM | #11 |
Set TempInt1[(Player number of (Triggering player))] = (10 x ((Level of Steal for (Triggering unit)) - 10)) RaeVanMorlock -- Check your math skills bro. That actually equals 0. Code:
If - Conditions
((Owner of (Target unit of ability being cast)) Current gold) Less than TempInt3[(Player number of (Triggering player))]Try less than or equal to. -- Other than that, I really have no clue why it's not working. All I know is at the first level, it's really doing 0-50, second is 10-70. But that's about it. |
| 02-18-2004, 04:12 PM | #12 |
Lord Vexorian, the very nature of multi-threading allows for more than one operation to be ran simultaneously. I don't know how WC3 is programmed, and I could be wrong, but it seems to be the case from what I've observed during creation of my Bloody Mess map. And if WC3 isn't truly multi-threaded, it could still simulate it by runnning operations side-by-side from each function. For instance, if it's on line 5 of 10 for function 1, and function 2 is called... after line 5, function 1 -- it could run line 1, function 2 -- then line 6, function 1 -- line 2, function 2 ----- and so forth until they are all finished. Since WC3 does have a "Trigger Queue" I'd like to imagine that it does, indeed, run triggers consecutively on a single-thread. But again, from what I've seen, that may not be the case -- better to be safe than sorry, right? MysticGeneral, check the parenthesis.. I already detailed this. Start from the center and work your way out, I'll even color-code it... (Triggering unit) = uhmm... ? no number here (Level of Steal for (Triggering unit)) = 1 [we'll assume for this calculation so we can get an idea of how the trigger will start out] ((Level of Steal for (Triggering unit)) - 10) = 1 - 10 = -9 (10 x ((Level of Steal for (Triggering unit)) - 10)) = 10 x (1 - 10) = -90 There, can I possibly make that any more clear? The very fact that you stated "I really have no clue why it's not working" should tell you that you're wrong. As I've said, computers don't make mistakes. Sorry if I seem rude, but Hunter0000 already got me annoyed in this thread by calling my blind -- and I thought I already explained this. The thread should be dead by now =P |
| 02-18-2004, 04:57 PM | #13 |
Guys, you arnt getting the problem, I see the 0-50 thing, but thats not the problem. A level one steal is getting me over 200, sometimes over 300 gold. It is way outa proportion. I realise now I don't need that -10 there now, but that isnt the issue. Just noticed the post above. sorry I missed it. If I am getting negativr values, then why is it giveing me 200+ stolen? besides, I ran some tests some time ago, and I though arithmatic did not follow the order of operations. Was I wrong? |
| 02-18-2004, 05:06 PM | #14 |
Ummmm.. if it didn't follow the order of operations, then nobody would be able to predict the results of their equations. Any programming language, at the least, has to follow the order of the parenthesis. And if you'd pay attention to what I described as the problem in the first equation, you'd see that the second is the same way. The actual range, as you have the formulae stated, is -90 to 620. |
| 02-18-2004, 10:26 PM | #15 |
Warcraft III follows the order of operations, but each Arithmetic operation in gui creates its brackets so you have to be careful with that. Warcraft 3 allows threads, but if you think about it is impossible for warcraft 3 to run 2 calls at the same time, it always runs one before the other, that is why I say that the array is only needed if there was a wait in the trigger. |
