Staredit Network

Staredit Network -> UMS Assistance -> Divide 'X' by 2
Report, edit, etc...Posted by l)ark_13 on 2005-08-20 at 20:36:08
I've been thinking of a way to divide any number by two using triggers but I cant think of anything. Anybody else know or have any ideas? Is it even possible?

ADDITION:
Can someone explain to me the X and Y coordinates in uberation 2 (extended conditions)? I dont understand how you are suppose to set the coordinates between 0 and 65536 when the map sizes are different. (wouldn't the 65536 get bigger as the map would too?)
Report, edit, etc...Posted by PCFredZ on 2005-08-20 at 21:11:18
Yeah, it's pretty simple.

Do a binary death count transfer trigger set, and just change the Add actions so they add half the amounts each time.

Example map: my World of Starcraft 2 and 3 both use a KTC system where Kills and Razings gets transferred to Experience and Minerals at the same time, except Minerals is transferred by only half the amount.
Report, edit, etc...Posted by l)ark_13 on 2005-08-20 at 21:14:04
Okay, I sort of understand that. Could you show me an actuall equation or trigger so I can make sure I understand?
Report, edit, etc...Posted by PCFredZ on 2005-08-20 at 21:23:16
This example works up to 500 and rounds up, but can be easily changed to accomodate larger numbers or rounding down.


P: Force1
C: Cur. Player suffers at least 256 deaths for Dividend
A: Set Deaths for Cur. Player: subtract 256 deaths for Divident
A: Set Deaths for Cur. Player: add 128 deaths for Quotient
A: Preserve Trigger

P: Force1
C: Cur. Player suffers at least 128 deaths for Dividend
C: Cur. Player suffers at most 255 deaths for Dividend
A: Set Deaths for Cur. Player: subtract 128 deaths for Divident
A: Set Deaths for Cur. Player: add 64 deaths for Quotient
A: Preserve Trigger

P: Force1
C: Cur. Player suffers at least 64 deaths for Dividend
C: Cur. Player suffers at most 127 deaths for Dividend
A: Set Deaths for Cur. Player: subtract 64 deaths for Divident
A: Set Deaths for Cur. Player: add 32 deaths for Quotient
A: Preserve Trigger

...
...
...

P: Force1
C: Cur. Player suffers at least 2 deaths for Dividend
C: Cur. Player suffers at most 3 deaths for Dividend
A: Set Deaths for Cur. Player: subtract 2 deaths for Divident
A: Set Deaths for Cur. Player: add 1 deaths for Quotient
A: Preserve Trigger

P: Force1
C: Cur. Player suffers exactly 1 deaths for Dividend
A: Set Deaths for Cur. Player: subtract 1 deaths for Divident
A: Set Deaths for Cur. Player: add 1 deaths for Quotient
A: Preserve Trigger


NOTE: all the "At most" conditions are optional, assuming the order of the triggers are as shown, from large to small.
Report, edit, etc...Posted by l)ark_13 on 2005-08-20 at 21:58:12
So lets say I need to give half the units in a location to a different player. I would:
First give all the units (12 units in total) in the location to the other player, one at a time, while adding 1 "Dividend". Then, I would start the dividing process. I would make the max 64 (in your case it was 256). <---is that right?
How would that actually work? (If I know how the trigger works then I usually understand it a lot better).
Report, edit, etc...Posted by PCFredZ on 2005-08-20 at 22:04:08
QUOTE(l)ark_13 @ Aug 20 2005, 09:58 PM)
So lets say I need to give half the units in a location to a different player.  I would:
First give all the units (12 units in total) in the location to the other player, one at a time, while adding 1 "Dividend".  Then, I would start the dividing process.  I would make the max 64 (in your case it was 256).  <---is that right?

Say the units, Marines, belong to P8 and you want to give half to P1, and you want to round up. Note that this example is slightly different, or more specifically, simpler, compared to the Death counts. This is due to the fact that you can directly Give Units, but you cannot Give Deaths (so to speak).

P: P1
C: P8 commands at least 2 Marine
A: Give 1 Marine from P8 to P9
A: Give 1 Marine from P8 to P1
A: Preserve

P: P1
C: P8 commands exactly 1 Marine
A: Give 1 Marine from P8 to P1
A: Preserve

P: P1
C: P9 commands at least 1 Marine
C: P8 commands exactly 0 Marine
A: Give all Marines from P9 to P8
A: Preserve
QUOTE
How would that actually work? (If I know how the trigger works then I usually understand it a lot better).
[right][snapback]294429[/snapback][/right]

For the death counts: basically, you start with a group of things.

You mark these things off, 2 at a time, to keep track of which things you've checked through. Everytime you mark 2, you add 1 to a new group, the quotient. Obviously this can get slow with big numbers, so that's where binary comes in. Of course, if you're working with very few things, you don't have to use the other powers of 2.

FYI: Dividend / Divisor = Quotient


For the units: basically, it's one of those "1 for you, 1 for me" things that gives the units to a temporary player, and at the end of the transactions gives the units from teh temporary player back to the original player.
Report, edit, etc...Posted by l)ark_13 on 2005-08-20 at 22:10:34
QUOTE
FYI: Dividend / Divisor = Quotient

Lmao. I knew that, but thanks tongue.gif

Okay. So I how it works I just dont get where the the other stuff comes in.
So, would this way work?:
- I give one unit at a time and add one death at a time.
- When deaths equal two give one unit back and set deaths back to zero.
Report, edit, etc...Posted by PCFredZ on 2005-08-20 at 22:15:11
QUOTE(l)ark_13 @ Aug 20 2005, 10:10 PM)
Lmao.  I knew that, but thanks tongue.gif

Okay.  So I how it works I just dont get where the the other stuff comes in.
So, would this way work?:
- I give one unit at a time and add one death at a time.
- When deaths equal two give one unit back and set deaths back to zero.
[right][snapback]294444[/snapback][/right]

I modified my last post.

The trigger you described will not work because the unit that is "given back" will be counted in the next cycle of marking as well. See the modified post for a solution.[snapback]294434[/snapback]
Report, edit, etc...Posted by l)ark_13 on 2005-08-20 at 22:21:19
Okay! Thank you very much biggrin.gif
This will help a lot. kicking.gif
Next Page (1)