The upgrades might be a lot more complicated matter. I haven't done that sort of thing myself, but if I were trying to do it, I would start off with checking what sort of units entered the region, then check what ups the other player has based on the unit you had enter the region. Not sure what the syntax is for checking/giving upgrades though unless you had them recorded as variables somewhere in your triggers. A later response might know how to check exactly, that should give you some logic to work with at least.
It's a bit of a complicated process, but I'll try to explain it all for you.
First of all, you need to track the upgrades each player has. There's no way to just iterate through each upgrade, so you'll have to use a Unit Research Progress event to store the upgrades. You also need a place to store the upgrades, so create the following global variables:
StoredUpgrades: Type = "- Game Link", Link Type = "Upgrade", check Array, set the first size to 16 and the second size to a number big enough to hold all your upgrades (perhaps 100).
StoredUpgradeCount: Type = Integer, check Array, set the size to 16.
StoredUpgrades will be the variable that holds the actual upgrades, while StoredUpgradeCount will be used to tell the trigger which slot to should put the next upgrade in.
So in your trigger with the Unit Research Progress event (which, by the way, should be "Any Unit research progress is Completed"), make a Set Variable action. Set StoredUpgrades[Triggering Player][StoredUpgradeCount[Triggering Player]] = (Triggering Progress Upgrade). This will store the upgrade as the player completes it. Then add another Set Variable action, and Set StoredUpgradeCount[Triggering Player] = Arithmetic(StoredUpgradeCount[Triggering Player] + 1). This ensures you won't overwrite previous upgrades when a new upgrade is stored.
Now go to your Unit Entered Region trigger. Create a local Integer variable for a loop; let's call it "x" here, but you can use a more descriptive name. Add a For Each Integer loop, using that variable, from 0 to Arithmetic(StoredUpgradeCount[Triggering Player] - 1). This upper bound is because our first upgrade is in slot 0, but StoredUpgradeCount is 1 at that time. Leave the increment set to 1. In this loop, you need an Add Upgrade Level for Player action. Set the upgrade to StoredUpgrade[Triggering Player][x], and set the player to whatever player you give the units to. After the loop, set StoredUpgradeCount[Triggring Player] to 0 so that these upgrades won't be added again the next time a unit from that player enters the region.
Multiple upgrade levels: I don't think it'll cause any errors if you exceed the maximum level for an upgrade, but if it does, you might have to use Set Upgrade Level instead, so if that's the case and you have an upgrade with multiple levels, you would have to modify this trigger to get more than 1 level to transfer. Also, if one player has 3 levels of an upgrade and another player has 5 of the same upgrade and its maximum is 10, you'll end up with the target player having 8 levels.
Only giving upgrades that apply to the current unit: In order to determine if an upgrade applies to a specific unit type, make an If Then statement with a Unit Type Is Affected By Upgrade == True condition. Set the unit type to Unit Type Of Unit (Triggering Unit) and Upgrade Type to StoredUpgrade[Triggering Player][x]. Instead of setting StoredUpgradeCount to 0 after the loop, you need to remove that action and subtract 1 from StoredUpgradeCount inside the If Then statement, and immediately before that, you would also Set Variable: StoredUpgrade[Triggering Player][x] = StoredUpgrade[Triggering Player][StoredUpgradeCount[Triggering Player]]. This results in the last upgrade in the array being moved backwards so that it isn't forgotten due to the reduced StoredUpgradeCount.
So when i step into a region that unit ownership changes to an other player and the upgrades i have researched is transfered to the given player too.
i found out the ownership transfer pretty easy but cant figure out the upgrade part.
can someone plz help me?
sry for my bad english btw.
@EightLeggedJ: Go
The upgrades might be a lot more complicated matter. I haven't done that sort of thing myself, but if I were trying to do it, I would start off with checking what sort of units entered the region, then check what ups the other player has based on the unit you had enter the region. Not sure what the syntax is for checking/giving upgrades though unless you had them recorded as variables somewhere in your triggers. A later response might know how to check exactly, that should give you some logic to work with at least.
It's a bit of a complicated process, but I'll try to explain it all for you.
First of all, you need to track the upgrades each player has. There's no way to just iterate through each upgrade, so you'll have to use a Unit Research Progress event to store the upgrades. You also need a place to store the upgrades, so create the following global variables:
StoredUpgrades: Type = "- Game Link", Link Type = "Upgrade", check Array, set the first size to 16 and the second size to a number big enough to hold all your upgrades (perhaps 100).
StoredUpgradeCount: Type = Integer, check Array, set the size to 16.
StoredUpgrades will be the variable that holds the actual upgrades, while StoredUpgradeCount will be used to tell the trigger which slot to should put the next upgrade in.
So in your trigger with the Unit Research Progress event (which, by the way, should be "Any Unit research progress is Completed"), make a Set Variable action. Set StoredUpgrades[Triggering Player][StoredUpgradeCount[Triggering Player]] = (Triggering Progress Upgrade). This will store the upgrade as the player completes it. Then add another Set Variable action, and Set StoredUpgradeCount[Triggering Player] = Arithmetic(StoredUpgradeCount[Triggering Player] + 1). This ensures you won't overwrite previous upgrades when a new upgrade is stored.
Now go to your Unit Entered Region trigger. Create a local Integer variable for a loop; let's call it "x" here, but you can use a more descriptive name. Add a For Each Integer loop, using that variable, from 0 to Arithmetic(StoredUpgradeCount[Triggering Player] - 1). This upper bound is because our first upgrade is in slot 0, but StoredUpgradeCount is 1 at that time. Leave the increment set to 1. In this loop, you need an Add Upgrade Level for Player action. Set the upgrade to StoredUpgrade[Triggering Player][x], and set the player to whatever player you give the units to. After the loop, set StoredUpgradeCount[Triggring Player] to 0 so that these upgrades won't be added again the next time a unit from that player enters the region.
Multiple upgrade levels: I don't think it'll cause any errors if you exceed the maximum level for an upgrade, but if it does, you might have to use Set Upgrade Level instead, so if that's the case and you have an upgrade with multiple levels, you would have to modify this trigger to get more than 1 level to transfer. Also, if one player has 3 levels of an upgrade and another player has 5 of the same upgrade and its maximum is 10, you'll end up with the target player having 8 levels.
Only giving upgrades that apply to the current unit: In order to determine if an upgrade applies to a specific unit type, make an If Then statement with a Unit Type Is Affected By Upgrade == True condition. Set the unit type to Unit Type Of Unit (Triggering Unit) and Upgrade Type to StoredUpgrade[Triggering Player][x]. Instead of setting StoredUpgradeCount to 0 after the loop, you need to remove that action and subtract 1 from StoredUpgradeCount inside the If Then statement, and immediately before that, you would also Set Variable: StoredUpgrade[Triggering Player][x] = StoredUpgrade[Triggering Player][StoredUpgradeCount[Triggering Player]]. This results in the last upgrade in the array being moved backwards so that it isn't forgotten due to the reduced StoredUpgradeCount.
@DeProgrammer: Go
Thx alot... That rly helped me out.
Awesome very specific description. thx again for takin your time