I'm implementing a function to allow one player to take over a disconnected player in my map. Fairly simplistic, just removes the units owned by the player taking over and transfers ownership of the disconnected players units.
The problem is that for all the obvious reasons the new owner doesn't have any of the upgrades purchased by the disconnected player (as upgrades are applied to players, not units). I'm trying to figure out a clean way to copy these upgrades across.
One way is by maintaining arrays for each player storing game links to the upgrades they have purchased, then looping through them when a player takes over another player. However there are 12 players, and one race has about 25 different upgrades, so the array size would be pretty large (12x25). Some races only have a couple of upgrades, so perhaps some cleverness could avoid bloat here.
There doesn't seem to be any function to iterate through upgrades purchased for a player, so the other alternative is to have a huge nested if then if then statement (if race A then: if upgrade A give upgrade A, if upgrade B give upgrade B) however there are around 150 total upgrades so this would be pretty bloated.
There is no way to do this. Upgrades don't just "go up" - they're all different and separate from each other. There is no way to "overwrite" an existing player's upgrades with someone else's.
There is no way to do this. Upgrades don't just "go up" - they're all different and separate from each other.
I'm not sure you properly read my post, and what you say is incorrect to begin with. Upgrades do "go up" - they have a level. Most are only level 0 (not researched) or level 1 (researched), however.
Quote:
There is no way to "overwrite" an existing player's upgrades with someone else's.
Yes, there is, and it is fairly trivial. For example:
Tech Tree - Set Changeling - Research Barbed Armor upgrade level to (Changeling - Research Barbed Armor count for player Source Player, counting Complete) for player Target Player
The problem is that there is no clean way to loop through all the upgrades without either overly large variables or massive amounts of code (that I can see, anyway).
Trying to offer simple answer =) How about creating 1 trigger called "Upgrades" and when player gains control of disconnected player's units make that rigger run trigger "Upgrades"?
Not a huge fan of massive arrays to hold the info, I think I'll just do it with a long section of triggers. A little more work but less overhead in the end. Once again I wish we had variable length arrays...
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm implementing a function to allow one player to take over a disconnected player in my map. Fairly simplistic, just removes the units owned by the player taking over and transfers ownership of the disconnected players units.
The problem is that for all the obvious reasons the new owner doesn't have any of the upgrades purchased by the disconnected player (as upgrades are applied to players, not units). I'm trying to figure out a clean way to copy these upgrades across.
One way is by maintaining arrays for each player storing game links to the upgrades they have purchased, then looping through them when a player takes over another player. However there are 12 players, and one race has about 25 different upgrades, so the array size would be pretty large (12x25). Some races only have a couple of upgrades, so perhaps some cleverness could avoid bloat here.
There doesn't seem to be any function to iterate through upgrades purchased for a player, so the other alternative is to have a huge nested if then if then statement (if race A then: if upgrade A give upgrade A, if upgrade B give upgrade B) however there are around 150 total upgrades so this would be pretty bloated.
Thoughts?
@AgoutiByte: Go
There is no way to do this. Upgrades don't just "go up" - they're all different and separate from each other. There is no way to "overwrite" an existing player's upgrades with someone else's.
I'm not sure you properly read my post, and what you say is incorrect to begin with. Upgrades do "go up" - they have a level. Most are only level 0 (not researched) or level 1 (researched), however.
Yes, there is, and it is fairly trivial. For example:
Tech Tree - Set Changeling - Research Barbed Armor upgrade level to (Changeling - Research Barbed Armor count for player Source Player, counting Complete) for player Target Player
The problem is that there is no clean way to loop through all the upgrades without either overly large variables or massive amounts of code (that I can see, anyway).
I don't know a better way as well, I would just maintain an array holding the upgrade ids.
Trying to offer simple answer =) How about creating 1 trigger called "Upgrades" and when player gains control of disconnected player's units make that rigger run trigger "Upgrades"?
Not a huge fan of massive arrays to hold the info, I think I'll just do it with a long section of triggers. A little more work but less overhead in the end. Once again I wish we had variable length arrays...