In this map I am currently working on I am giving control of units from a player to a computer. However, in the process of doing this I would like the unit to still count against the players supply so that the player cannot make too many units (and as a quick count of how many units the player has for reference).
Here is the problem: using modify player supplies used: - food requires that food be an integer. The obvious problem with this is zerglings (-0.5 food). I then tried keeping my own supply count in an array of real values, but that became a nightmare quite quickly (trying to catch all created, cancelled, and zerg egg/larva deaths was surprisingly difficult). Another option might be to simply double the cost of everything and give the player 400 supply, but it doesn't seem quite elegant enough of a solution. Lastly I thought to have a boolean array to denote the half, and do the adding/subtracting based on that. It might work (haven't had a good chance to work out the current problems).
I was wondering if anyone tried something like this, and if there were some simpler solution? (Like setting allied with shared supply, lol) It seems silly to me that I can't edit the real version of the supplies used before it is converted to an integer and displayed on the UI.
I may be over thinking or under thinking this here.
there is a command, a button, an event of some sort which gives a unit from the player to the computer.
When this "button" is pressed, set the custom value 1 of the unit to the owner of the player it is leaving (so you know which player owned it initially) and set the custom value 2= catalog field value get (Supply used on switched unit)
then you can modify a real variable which will represent the players supply used; and set player supply used equal to that variable; converted to an integer.
The .5 will automatically round (as it does with zerglings normally) however, 2 zerglings will still=1 supply
this should allow you to manage the system without having to alter data on every unit in the game. It will record who owned what unit initially, and their supply cost; and your supply used.
then when a unit owned by computer dies; if custom value of 1 of unit=player number of (whatever player, you may need to run a loop if multiplayer)
then modify player supply used based on custom value 2 of unit.
This will give the supply back to the player after their unit is killed.
so instead of trying to keep track of the supply of both the player and computer, just keep track of the modification I made to the player supply. Then when a player dies, change the modification value, get the difference as an integer, and apply that to the player supplies. I'm guessing at most I could be off by 1 supply (both player and computer has 0.5 rounded), but perhaps I could live wit that.
I like it, let's see if I can do it without too many bugs (perhaps after my 1 yr old son stops trying to use my computer...lol).
That seems to do pretty well. Here is what I now have:
Global variable:
supplies = -0.1 <Real[9]>
Triggers:
Give Unit:
Local Variables
supply = (Real((Value of Units (Unit type of (Triggering unit)) Food for player Any Player))) <Real>
owner = (Owner of (Triggering unit)) <Integer>
Actions
Unit - Change ownership of (Triggering unit) to player {owner+8} and Retain Color
General - If (Conditions) then do (Actions) else do (Actions)
If
supply <= 0
Then
Player - Modify player owner Supplies Used: Subtract {(Integer({supplies[owner]-supply}))-(Integer(supplies[owner]))}
Variable - Modify supplies[owner]: + supply
Else
Player - Modify player owner Supplies Made: Add (Integer(supply))
Unit Dies:
Local Variables
supply = (Real((Value of Units (Unit type of (Triggering unit)) Food for player Any Player))) <Real>
owner = {(Owner of (Triggering unit))-8} <Integer>
Conditions
(Owner of (Triggering unit)) >= 9
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
supply <= 0
Then
Player - Modify player owner Supplies Used: Add {(Integer({supplies[owner]+supply}))-(Integer(supplies[owner]))}
Variable - Modify supplies[owner]: - supply
Else
Player - Modify player owner Supplies Made: Subtract (Integer(supply))
The only problem I've run into with this is if the player kills a zergling before giving it away (loses 0.5 supply, but number does not go down), then gives away the other zergling, it goes from 0.5 on the user to 0.4 on the computer, allowing the player to get out one more supply worth of units. Ultimately, the max pop is then 200+1 computer zergling. The alternative is if the player just tributes one zergling, then the player has 0.5 rounded to 1 and the computer has 0.5 rounded to 1, the player has one fewer supply. This will also be more apparent, especially if they give units one at a time, the supply with switch between correct and +1. I think I can live with this.
If a protoss unit is generated in the region where the control is given to the computer (triggering region), the warping unit no longer has power and the warp in is cancelled. This wouldn't be a big deal, except the death of the warping in unit happens before the supply is added to the protoss player. This means that the cost of the dying unit is subtracted from the players supply count without being added, allowing the player to effectively reset their supply to 0. Will need to figure out how to either allow the warp in to finish before giving control over, or not allow warp in in that region...
Edit: looks like the best option for now is to not allow building in that region and disable warp prisms. Hopefully a better option can be found...
The campaign dependencies have invisible pylons you can add to a map (or perhaps make your own). Or you could add the behavior that gives power to some unit of the computer.
In this map I am currently working on I am giving control of units from a player to a computer. However, in the process of doing this I would like the unit to still count against the players supply so that the player cannot make too many units (and as a quick count of how many units the player has for reference).
Here is the problem: using modify player supplies used: - food requires that food be an integer. The obvious problem with this is zerglings (-0.5 food). I then tried keeping my own supply count in an array of real values, but that became a nightmare quite quickly (trying to catch all created, cancelled, and zerg egg/larva deaths was surprisingly difficult). Another option might be to simply double the cost of everything and give the player 400 supply, but it doesn't seem quite elegant enough of a solution. Lastly I thought to have a boolean array to denote the half, and do the adding/subtracting based on that. It might work (haven't had a good chance to work out the current problems).
I was wondering if anyone tried something like this, and if there were some simpler solution? (Like setting allied with shared supply, lol) It seems silly to me that I can't edit the real version of the supplies used before it is converted to an integer and displayed on the UI.
I may be over thinking or under thinking this here.
there is a command, a button, an event of some sort which gives a unit from the player to the computer.
When this "button" is pressed, set the custom value 1 of the unit to the owner of the player it is leaving (so you know which player owned it initially) and set the custom value 2= catalog field value get (Supply used on switched unit)
then you can modify a real variable which will represent the players supply used; and set player supply used equal to that variable; converted to an integer.
The .5 will automatically round (as it does with zerglings normally) however, 2 zerglings will still=1 supply
this should allow you to manage the system without having to alter data on every unit in the game. It will record who owned what unit initially, and their supply cost; and your supply used.
then when a unit owned by computer dies; if custom value of 1 of unit=player number of (whatever player, you may need to run a loop if multiplayer)
then modify player supply used based on custom value 2 of unit.
This will give the supply back to the player after their unit is killed.
Skype: [email protected] Current Project: Custom Hero Arena! US: battlenet:://starcraft/map/1/263274 EU: battlenet:://starcraft/map/2/186418
so instead of trying to keep track of the supply of both the player and computer, just keep track of the modification I made to the player supply. Then when a player dies, change the modification value, get the difference as an integer, and apply that to the player supplies. I'm guessing at most I could be off by 1 supply (both player and computer has 0.5 rounded), but perhaps I could live wit that.
I like it, let's see if I can do it without too many bugs (perhaps after my 1 yr old son stops trying to use my computer...lol).
That seems to do pretty well. Here is what I now have:
Global variable:
supplies = -0.1 <Real[9]>
Triggers:
Give Unit:
Local Variables
supply = (Real((Value of Units (Unit type of (Triggering unit)) Food for player Any Player))) <Real>
owner = (Owner of (Triggering unit)) <Integer>
Actions
Unit - Change ownership of (Triggering unit) to player {owner+8} and Retain Color
General - If (Conditions) then do (Actions) else do (Actions)
If
supply <= 0
Then
Player - Modify player owner Supplies Used: Subtract {(Integer({supplies[owner]-supply}))-(Integer(supplies[owner]))}
Variable - Modify supplies[owner]: + supply
Else
Player - Modify player owner Supplies Made: Add (Integer(supply))
Unit Dies:
Local Variables
supply = (Real((Value of Units (Unit type of (Triggering unit)) Food for player Any Player))) <Real>
owner = {(Owner of (Triggering unit))-8} <Integer>
Conditions
(Owner of (Triggering unit)) >= 9
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
supply <= 0
Then
Player - Modify player owner Supplies Used: Add {(Integer({supplies[owner]+supply}))-(Integer(supplies[owner]))}
Variable - Modify supplies[owner]: - supply
Else
Player - Modify player owner Supplies Made: Subtract (Integer(supply))
The only problem I've run into with this is if the player kills a zergling before giving it away (loses 0.5 supply, but number does not go down), then gives away the other zergling, it goes from 0.5 on the user to 0.4 on the computer, allowing the player to get out one more supply worth of units. Ultimately, the max pop is then 200+1 computer zergling. The alternative is if the player just tributes one zergling, then the player has 0.5 rounded to 1 and the computer has 0.5 rounded to 1, the player has one fewer supply. This will also be more apparent, especially if they give units one at a time, the supply with switch between correct and +1. I think I can live with this.
Another problem...
If a protoss unit is generated in the region where the control is given to the computer (triggering region), the warping unit no longer has power and the warp in is cancelled. This wouldn't be a big deal, except the death of the warping in unit happens before the supply is added to the protoss player. This means that the cost of the dying unit is subtracted from the players supply count without being added, allowing the player to effectively reset their supply to 0. Will need to figure out how to either allow the warp in to finish before giving control over, or not allow warp in in that region...
Edit: looks like the best option for now is to not allow building in that region and disable warp prisms. Hopefully a better option can be found...
@LuciusSilanus: Go
The campaign dependencies have invisible pylons you can add to a map (or perhaps make your own). Or you could add the behavior that gives power to some unit of the computer.
@MaskedImposter:
Now that I need to look in to! Thanks!