1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Paying for the training of an Allied unit

Discussion in 'World Editor Help Zone' started by Drazhar, Mar 19, 2012.

  1. Drazhar

    Drazhar

    Joined:
    May 11, 2010
    Messages:
    213
    Resources:
    0
    Resources:
    0
    So pretty much, players on the map can train units from an allied npc's buildings, but the player's don't lose any resources and the npc has to pay for it even if the player is the one that selected to train the unit because the players have shared unit control with said npc. However, I don't want to change the the buildings' ability to 'trains a unit' to 'sells a unit' because it loses the build time for the unit.

    Is there anyway to to make players' pay for the training of a unit from a allied structure?
     
  2. helekiller

    helekiller

    Joined:
    Aug 5, 2011
    Messages:
    99
    Resources:
    0
    Resources:
    0
    make the building neutral passive once its created?
     
  3. Drazhar

    Drazhar

    Joined:
    May 11, 2010
    Messages:
    213
    Resources:
    0
    Resources:
    0
    That won't work, the players are not allied or share control with neutral passive.
     
  4. Hashjie

    Hashjie

    Joined:
    Apr 20, 2009
    Messages:
    1,515
    Resources:
    0
    Resources:
    0
    Create a very, very simple trigger like this?

    • Training
      • Events
        • Unit - A unit Finishes training a unit
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to (==) Altar of Kings
      • Actions
        • Player - Set (Owner of (Trained unit)) Current gold to (((Owner of (Trained unit)) Current gold) - 200)
        • Player - Set (Owner of (Trained unit)) Current lumber to (((Owner of (Trained unit)) Current lumber) - 200)
     
  5. Drazhar

    Drazhar

    Joined:
    May 11, 2010
    Messages:
    213
    Resources:
    0
    Resources:
    0
    No, the gold will be needed before the unit begins training, not after. And that also doesn't detect what player initialized the training. (Also, the trained unit belongs to the npc, it's just the players that begin the training.)
     
  6. Hashjie

    Hashjie

    Joined:
    Apr 20, 2009
    Messages:
    1,515
    Resources:
    0
    Resources:
    0
    My mistake, either ways you could ofcourse change the Gold cost and Lumber cost inside the Object editor for the units you want trained....
    If you really want to make sure that it's done for the corresponding player,
    you could use GetLocalPlayer() to see if the local player equals the player selecting the tavern and respectively change the ownership to that player locally.

    For example:
    • Unit Selection
      • Events
        • Player - Player 1 (Red) Selects a unit
        • Player - Player 2 (Blue) Selects a unit
        • Player - Player 3 (Teal) Selects a unit
        • Player - Player 4 (Purple) Selects a unit
        • Player - Player 5 (Yellow) Selects a unit
        • Player - Player 6 (Orange) Selects a unit
        • Player - Player 7 (Green) Selects a unit
        • Player - Player 8 (Pink) Selects a unit
        • Player - Player 9 (Gray) Selects a unit
        • Player - Player 10 (Light Blue) Selects a unit
        • Player - Player 11 (Dark Green) Selects a unit
        • Player - Player 12 (Brown) Selects a unit
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to (==) Tavern
      • Actions
        • Custom script: if (GetLocalPlayer() == Player(GetPlayerId(GetTriggerPlayer()))) then
        • Unit - Change ownership of (Triggering unit) to (Player((Player number of (Triggering player)))) and Retain color
        • Custom script: endif


    I tested this and it seems to work fine for me.
    If this somehow causes a desynchronization when several players select the building at once,
    you might want to use a invisible dummy unit for each player and make the players select the dummy unit for the corresponding player when selecting the original tavern.

    That should fix your issue.
     
  7. helekiller

    helekiller

    Joined:
    Aug 5, 2011
    Messages:
    99
    Resources:
    0
    Resources:
    0
    that will cause problems in multiplayer ^^ if 2 people select it at the same time, evrything is fucked, the player who first selected it could use up the gold from the second one. would need to clear selection for the first one if u do that.. and that wont look too good either :s
    maybe try to give the building to a player with fullshared unit control to evryone, when it starts training a unit, check whether the triggering player has enough gold, if not then cancel the training... make sure u give infinate resources to that player then ^^
     
  8. shadowvzs

    shadowvzs

    Joined:
    Nov 13, 2006
    Messages:
    1,803
    Resources:
    2
    Spells:
    2
    Resources:
    2
    why dont clear the selection for all player after change owner thing? :D
     
  9. Hashjie

    Hashjie

    Joined:
    Apr 20, 2009
    Messages:
    1,515
    Resources:
    0
    Resources:
    0
    First of all, you do know what GetLocalPlayer() does?

    It gets the local player.
    This way you can for example show multiboards to a local player instead of having to show it to all players.
    I was hoping that this would be possible for unit ownership.
    Causing the building to be owned by every local player selecting it.
    But you're probably right that it would cause a desynchronization.

    A desynchronization means that the server is sending incorrect information to the client.
    The server in this case would be the host and the client the player.
    When a desynchronization occurs, a player will see stuff on his screen that is not there or not see stuff that actually is there.
    Usually this causes the player to disconnect.

    I did however give an alternative... Dummy taverns ;)
    You can achieve a lot of cool stuff with dummy's alright :D
    Simply create invisible dummy units within the tavern.
    Then when a player selects the tavern you can change it's selection to select the dummy unit for the corresponding player.
    All that would need to be done then is set the gold and lumber cost for the units who are trained accordingly in the object editor.
    This would solve his issue.

    Then how can that player train a unit? :)
    I was hoping that it would be possible to change the owner locally, causing the unit to have multiple owners.