Just a quick question, is there any way to detect unit amounts and compare, i mean like, be able to detect if there are the same amount of units in 1 location?
Im not edxactly sure what you mean, but if you mean for your civilizations map,
if player brings at most 10 men to location,
if player brings at lease 2
farms to location
then they are happy
if player brings at least 11 men,
if polayer brings at most 2 farms
then they are sad
youd have to do one for 1 farm, 2 farms, 3 farms, etc
or whatever building you want
ya but i mean like instead of write all the code for that, is there something like:
if player brings same amount men as farms or something like that
i dont know about that, but i dont think so
There's no trigger that returns the amount of men and then lets you compare them. You have to use a system of triggers. First to get the amount of men, and then to compare.
Use binary countoffs. If you want to preserve the actual units, then give them away in a binary countoff storing the amount in a death counter, then give them all back. If not, you can just remove the units as you count them.
Once you have the amount of units for each player stored in a death counter, you can use another binary countoff which subtracts only if both players satisfy the current step in the countoff. If both are reduced to 0 by the end then they are equal. If one reaches 0 and the other doesn't, then the one with the remainder has more.
That was just a broad overall explanation of the process, but if you don't know what a binary countoff is, then I will go more indepth.
Well i don't exactly know what a binary count off is, but i know that once you have the numbers stored in death counts, you just subtract one from each until either one or both counters have reached 0, am i correct?
Correct, a binary countoff just makes the process much faster, because it's based on subtracting powers of 2.
An example of a binary countoff for comparison would look like this:
QUOTE
Condition:
Player 1 has suffered at least 32 death of marine
Player 2 has suffered at least 32 death of marine
Action:
Subtract 32 death of marine from p1
Subtract 32 death of marine from p2
Condition:
Player 1 has suffered at least 16 death of marine
Player 2 has suffered at least 16 death of marine
Action:
Subtract 16 death of marine from p1
Subtract 16 death of marine from p2
Condition:
Player 1 has suffered at least 8 death of marine
Player 2 has suffered at least 8 death of marine
Action:
Subtract 8 death of marine from p1
Subtract 8 death of marine from p2
Condition:
Player 1 has suffered at least 4 death of marine
Player 2 has suffered at least 4 death of marine
Action:
Subtract 4 death of marine from p1
Subtract 4 death of marine from p2
Condition:
Player 1 has suffered at least 2 death of marine
Player 2 has suffered at least 2 death of marine
Action:
Subtract 2 death of marine from p1
Subtract 2 death of marine from p2
Condition:
Player 1 has suffered at least 1 death of marine
Player 2 has suffered at least 1 death of marine
Action:
Subtract 1 death of marine from p1
Subtract 1 death of marine from p2
Then after those triggers you would have 3 triggers to check the results after the above binary countoff has ran. One would check if both are 0, if p1 is 0 and p2 isn't, and if p2 is 0 and p1 isn't.
alright..... well that kinda bombs my plan for a simple trigger system for my map... (look about 5 strings down, my Civilziation one...)
Well, once you are familiar with it the concept becomes relatively simple. If you're using SCMD2's trigedit, and notepad or a binary countoff duplicator, then creating the triggers also becomes extremely simple and fast.
wait... so how do i use these? scmdraft + notepad? i tried trigger editing on scmdraft but i couldn't figger out how, and whats a binary duplicator?
still trying to teach people about binary countoffs i see, even after you finished with me, how long did it take? like 3 pages, lol.
anyhow, a binary countoff is exactly like a counter(counting by 1s), except that it counts by much larger numbers due to a mathematical property. it is not technically a trigger system, so theres no complex triggering to learn. Binary countoffs just speed up addition and subtraction process. It is incredibly simple(after you understand the concept) and enormously beneficial.
ADDITION:
Oh, and is there any way to keep a running count of how many units i have in a location? like if i do the count, and have 2, but then i make another building, and now i have 3? is there anyway to do it w/o preserve trigger always taking the buildings away from player?
sigh, stupid bug, the first portion of the above post belongs to zeratul_101
ADDITION:
just set the triggers to run every half a minute of w/e
lol wow, ya i know the mathematics behind it, and i get it now, but what was he saying about binary countoff duplicator? or scmdraft, how are triggers done on that, i tried using it, but i guess i dont know the code well enough.... i've been sticking to SF ever since
ADDITION:
ya i figured i'll just use the countdown timer already set on, and it'll calculate it about 5 seconds before the time for money and tech and crap...
You could use the 'Command the Most At' condition to see what player has more units at whatever location.
hmm, they are owned by different players, but im trying to find the difference between 2 different units, i don't think that'd work
QUOTE(micro119 @ Sep 21 2006, 07:15 PM)
lol wow, ya i know the mathematics behind it, and i get it now, but what was he saying about binary countoff duplicator? or scmdraft, how are triggers done on that, i tried using it, but i guess i dont know the code well enough.... i've been sticking to SF ever since
[right][snapback]565663[/snapback][/right]
the binary countoff duplicator is a program made specifically for making binary countoffs. SCMD2 has an entirely text-based editor. which means that you can write text in any text program and simply copy and paste it onto SCMD2. while you are in the text program, you can take advantage of find+paste option - which is accessed by pressing CTRL+H
okay, is scmdrafts code any different from starforges code? whats the basic layout for text triggers in scmdraft?
quite different apparently, i've never used SCMD2's trigedit so i don't have firsthand knowledge. nor can i remember the syntaxes.
alright i'll just research in tutorials and stuff, now to bring attention back to my Need Suggestions post
You can use SCMD2's classic trigedit to create the first trigger, and then go into trigedit, take that trigger and copy paste it, changing the value of the death counter each time, since essentially the only difference from trigger to trigger in a binary countoff is the power of 2.
This is the duplicator I was referring to:
http://www.staredit.net/index.php?download=5857There's also MindArchon's trigger duplicator, it has more options, yet it's not specifically geared towards use with SCMD2 and for making binary countoffs, and the syntax is totally different than SF and SCMD2.
FYI, its quite a painful process to create binary countoffs by hand. My hand almost fell off after making a map almost entirely of BCs, so heed MoonlighTurtle's advice and go with TrigEdit, even if you're not used to it. it's much more efficient and less strenous/boring.
Okay, one last thing, what if i want a ratio of 10:1? or something other than equal amounts?
use the same binary values, just times them by 10.