(Keeps Hive Alive)
The Hive Workshop
 Remember Me?
 Register FAQ Members List Calendar Mark Forums Read

 Triggers & Scripts In this forum you may ask for help on fixing a trigger or script. But if you need help getting started with a trigger, this is not the right place — use the World Editor Help Zone.

 08-06-2012, 02:41 PM #1 (permalink) Lysho User   Join Date: Jul 2012 Posts: 85 [Solved] Another Looping Problem EDIT: Nevermind!! I guess after toying around a bit I managed to figure out how to do it. Thanks to those who helped! Heres what it is now, so its solved. count civ happiness Events Conditions Actions For each (Integer A) from 1 to 102, do (Actions) Loop - Actions Player Group - Pick every player in playingplayers and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Owner of village[(Integer A)]) Equal to (Picked player) (village[(Integer A)] is alive) Equal to True Then - Actions Set stockhappiness[(Player number of (Picked player))] = ((stockhappiness[(Player number of (Picked player))] + villagehappiness[(Integer A)]) + 0) Else - Actions Do nothing Set civhappiness[(Player number of (Picked player))] = stockhappiness[(Player number of (Picked player))] Multiboard - Set the text for (Last created multiboard) item in column 2, row (Player number of (Picked player)) to ((String(cities[(Player number of (Picked player))])) + Villages) Multiboard - Set the text for (Last created multiboard) item in column 4, row (Player number of (Picked player)) to (String(civhappiness[(Player number of (Picked player))])) For each (Integer A) from 1 to 16, do (Actions) Loop - Actions Set stockhappiness[(Integer A)] = 0 Last edited by Lysho; 08-08-2012 at 02:49 AM.
 08-06-2012, 04:58 PM #2 (permalink) Marsal Tsubaki :)     Join Date: Jun 2009 Posts: 1,409 Why don't you just store the value of increase instead of these 2 calculations? __________________ People should learn how to say "Thanks" and how to give rep to those who helped them.....
 08-06-2012, 06:10 PM #3 (permalink) Lysho User   Join Date: Jul 2012 Posts: 85 [Solved] EDIT:Nevermind!! I managed to figure it out on my own after toying with it enough.Theres what it is now.. but anyway this trigger is solved. Thanks to those who helped Last edited by Lysho; 08-08-2012 at 02:49 AM.
 08-07-2012, 07:06 AM #4 (permalink) Marsal Tsubaki :)     Join Date: Jun 2009 Posts: 1,409 Yeah it must be the computer's fault ~.~ What do you even want to do and what is this 102 loop? __________________ People should learn how to say "Thanks" and how to give rep to those who helped them.....
 08-07-2012, 07:11 AM #5 (permalink) Lysho User   Join Date: Jul 2012 Posts: 85 There are a total of 102 lands, and therefore 102 villages can exist. When a village is settled, it is labeled onto these lands in a unit array. What i want this trigger to do, is keep the Multiboard accurate in displaying how much total happiness a player has. His total happiness would be calculated by combining all of his cities' individual happinesses together. So if I had 3 cities, one with 72 Happiness, one with 25 Happiness, and one with 13 Happiness, my total happiness would be 72+25+13= 110 Happiness. So thats supposed to represent Civilization Happiness, and I want that to be displayed for each player in the multiboard. But I'm having trouble calculating this...
 08-07-2012, 07:51 AM #6 (permalink) Marsal Tsubaki :)     Join Date: Jun 2009 Posts: 1,409 Why don't you just make a variable of the starter number of villages and increase it by one when a village is settled? It's much more efficient. You could do this much easier with Hashtables(don't ask me how, I only know 2D variables from Pascal and C ~.~). __________________ People should learn how to say "Thanks" and how to give rep to those who helped them.....
Lysho
User

Join Date: Jul 2012
Posts: 85
Quote:
 Originally Posted by Marsal Why don't you just make a variable of the starter number of villages and increase it by one when a village is settled? It's much more efficient. You could do this much easier with Hashtables(don't ask me how, I only know 2D variables from Pascal and C ~.~).
Not sure I understand what youre saying? Just count the number of villages and then multiply by a constant number to get civilization happiness?

Unfortunately I cannot do that, because that would be assuming each village had the same Happiness, which they dont. Each one is unique. However, what I did do below may be what you are saying, but I'm not sure.

In my trigger I counted the old happiness of each village, then the new happiness, to calculate the difference. Then I add that difference to another integer called the total difference. Then it loops to count all other villages' differences, and adds them to this. Then afterwards, it adds this total difference to civilization happiness, plus the number of cities owned. So i counted civilization happiness by multiplying the number of cities by its initial happiness(either 15 or 35, depending on game mode), then added the difference(which may or may not be positive).

To me, that method seems to make sense, but maybe I'm missing a piece of logic in there that makes the trigger count wrong. That, or, I had set up the arithmetic wrong, since it involves both addition and multiplication. But I haven't found where it might be miscalculated.

 08-07-2012, 06:04 PM #8 (permalink) Marsal Tsubaki :)     Join Date: Jun 2009 Posts: 1,409 No. I mean, I guess there wont be 102 settled villages at the start, will be? Erm... Why don't you just set the civ happiness to the sum of the new village happinesses? __________________ People should learn how to say "Thanks" and how to give rep to those who helped them.....
Lysho
User

Join Date: Jul 2012
Posts: 85
Quote:
 Originally Posted by Marsal No. I mean, I guess there wont be 102 settled villages at the start, will be? Erm... Why don't you just set the civ happiness to the sum of the new village happinesses?
No, not 102 villages at start.

And because I dont know how to do that. Like how to add up all villages belonging to player's happinesses??

EDIT: OK i guess after fiddling around a bit I fixed it on my own. Thanks for helping though :D

Last edited by Lysho; 08-08-2012 at 02:47 AM.

 08-08-2012, 06:51 AM #10 (permalink) Marsal Tsubaki :)     Join Date: Jun 2009 Posts: 1,409 Hehe :) I was about to make example triggers. Anyways, you should modify this part to that. For each (Integer A) from 1 to Villages, do (Actions)Set the variable "Villages" to the number of starting villages and add this little trigger. Untitled Trigger 001 Events (Event that starts the trigger[When a village settles]) Conditions Actions Set Villages=Villages+1That's more efficient than starting with 102 already when there are only a few villages. __________________ People should learn how to say "Thanks" and how to give rep to those who helped them.....

 Bookmarks

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are Off Pingbacks are Off Refbacks are Off Forum Rules

All times are GMT. The time now is 11:31 PM.

 -- Low Graphics ---- Night Elf ---- Terran (Beta) Contact Us - The Hive Workshop - The Warcraft 3 Modding Site - Archive - Top