Staredit Network

Staredit Network -> UMS Assistance -> Comparing unit amounts
Report, edit, etc...Posted by micro119 on 2006-09-21 at 18:51:55
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?
Report, edit, etc...Posted by qw3rty on 2006-09-21 at 19:00:57
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
Report, edit, etc...Posted by micro119 on 2006-09-21 at 19:05:39
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
Report, edit, etc...Posted by qw3rty on 2006-09-21 at 19:10:28
i dont know about that, but i dont think so
Report, edit, etc...Posted by MoonlighTurtle on 2006-09-21 at 19:18:24
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.
Report, edit, etc...Posted by micro119 on 2006-09-21 at 19:31:02
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?
Report, edit, etc...Posted by MoonlighTurtle on 2006-09-21 at 19:32:42
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.
Report, edit, etc...Posted by micro119 on 2006-09-21 at 19:47:10
alright..... well that kinda bombs my plan for a simple trigger system for my map... (look about 5 strings down, my Civilziation one...)
Report, edit, etc...Posted by MoonlighTurtle on 2006-09-21 at 19:49:21
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.
Report, edit, etc...Posted by micro119 on 2006-09-21 at 21:05:52
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?
Report, edit, etc...Posted by micro119 on 2006-09-21 at 21:12:04
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?
Report, edit, etc...Posted by Zeratul_101 on 2006-09-21 at 21:13:54
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
Report, edit, etc...Posted by micro119 on 2006-09-21 at 21:16:21
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...
Report, edit, etc...Posted by Kenoli on 2006-09-21 at 21:19:01
You could use the 'Command the Most At' condition to see what player has more units at whatever location.
Report, edit, etc...Posted by micro119 on 2006-09-21 at 21:22:31
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
Report, edit, etc...Posted by Zeratul_101 on 2006-09-21 at 21:23:24
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
Report, edit, etc...Posted by micro119 on 2006-09-21 at 21:33:33
okay, is scmdrafts code any different from starforges code? whats the basic layout for text triggers in scmdraft?
Report, edit, etc...Posted by Zeratul_101 on 2006-09-21 at 21:37:03
quite different apparently, i've never used SCMD2's trigedit so i don't have firsthand knowledge. nor can i remember the syntaxes.
Report, edit, etc...Posted by micro119 on 2006-09-21 at 21:40:59
alright i'll just research in tutorials and stuff, now to bring attention back to my Need Suggestions post cool1.gif
Report, edit, etc...Posted by ClearWater on 2006-09-22 at 15:55:04
You can find the syntax of all of SCMDraft2's triggers here:
http://www.staredit.net/index.php?act=Atta...pe=post&id=8351

It's in logical order if you think about it. SF just seems weird now.
Report, edit, etc...Posted by MoonlighTurtle on 2006-09-22 at 17:20:35
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=5857

There'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.
Report, edit, etc...Posted by Zeratul_101 on 2006-09-22 at 17:24:03
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.
Report, edit, etc...Posted by micro119 on 2006-09-23 at 02:24:31
Okay, one last thing, what if i want a ratio of 10:1? or something other than equal amounts?
Report, edit, etc...Posted by Zeratul_101 on 2006-09-23 at 02:27:11
use the same binary values, just times them by 10.
Next Page (1)