• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Make a house capturable, without switching units.

Status
Not open for further replies.
Level 6
Joined
May 31, 2008
Messages
218
I need help with a trigger that makes a house capturable, and so that it's the exact same house that you destroy/damage alot as the one you get. At the moment i have a working trigger:
  • Change owner gold
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to (==) Gold Income
    • Actions
      • Set Income_point = (Position of (Dying unit))
      • Unit - Create 1 Gold Income for (Owner of (Killing unit)) at Income_point facing Default building facing (270.0) degrees
      • Custom script: call RemoveLocation (udg_Income_point)
But this trigger changes the unit to another unit, so how can i solve this? Since i need to check who the owner of the unit is, and it's hard if the unit changes all the time.
 
Level 6
Joined
Jul 25, 2005
Messages
221
I'm assuming you want to make an income system based on the units you own?
It's not really that hard, and there are many ways to approach this. For example, instead of killing the unit, dont create it at all... Create a trigger that adds gold to the player owning the house, and count how many houses he owns.

  • IncomeSystem
  • Events
    • Periodic Event - Every 1.00 seconds of in-game time
  • Conditions
  • Actions
    • Loop 1 to 12
      • Unit Group - Pick all units in (Playable Map Area) matching condition (Owning player of Matching unit equal to Player(integerA) and (Matching Unit) equal to IncomeHouse)
        • Game - Add gold to Player(integerA) 12 (or something)
As for switching houses or whatever you were reffering to, there is a command in the trigger editor that lets you change owner of a unit.
  • Unit - Change owner of (House) to Player(1)
 
Level 6
Joined
May 31, 2008
Messages
218
The bad part is each income point will spawn a unit(caravan thingy) that will travel to a regional hub, so maybe each regional hub will have 2 gold income points, 1 wood, 1 food. BUT if the player don't control the regional hub he wont spawn any caravans, so it's a slight problem here.
 
Level 6
Joined
Jul 25, 2005
Messages
221
So basically, what you're saying is that, if the player owns an income point, a unit that delivers resources to another location will be spawned. Sounds like a Market from Age of Empires II.
Again, it shouldn't be too difficult.
I don't wanna do the work for you, but I can give you the idea.

Create a similar trigger I wrote earlier, that checks if the player still owns the income point, and if he does, then spawn a "caravan". Then you will need a unit array that keeps track of all your caravans so that if the player loses a control point, the caravan belonging to that income point will be removed.
Additionally, you should create a boolean array that checks if there is a caravan moving to the hub, then change its values to tell when the caravan has delivered it's goods. This should be used in conjuction with whether or not a caravan should be spawned
like,
  • If (incomepoint belongs to Player(Loop Index IntegerA) and caravanactive[Loop Index IntegerA] equal to false)
    • Then
      • Unit - Create caravan at Position of (incomepoint) facing default degrees
      • Set - Caravan[Loop Index IntegerA] = Last Created Unit
      • Set - caravanactive[Loop Index IntegerA] equal to True
    • Else
And if the caravan dies for some reason along the way, just make another trigger checking all caravans and then make the caravanactive[thatunit] false
 
Level 6
Joined
May 31, 2008
Messages
218
And then i just have to check that the same player owns the control point which is the regional hub. But i still think this might not work. Since the map is divided into... maybe 20 small areas, each containing one regional control point(the hub) 2 gold income 1 food and 1 wood. But i could aslo solve this by naming each income point differently so i just check globaly for that unit. But that is a pain in the ass.

And i still don't get it how to make a trigger for a unit so it's the same unit, since that would make things alot easier.
 
Level 6
Joined
Jul 25, 2005
Messages
221
Again, I don't really wanna do your work. However I can enlighten you about the changing of ownership.
This is the EXACT code that just changes unit owner.
  • Changing ownership
    • Unit - Change ownership of (Picked Unit) to Player 1 (Red) and Change color
 
Level 6
Joined
May 31, 2008
Messages
218
Again, I don't really wanna do your work. However I can enlighten you about the changing of ownership.
This is the EXACT code that just changes unit owner.
  • Changing ownership
    • Unit - Change ownership of (Picked Unit) to Player 1 (Red) and Change color

But if you try do that to a unit that is under condition and even dead/dying, nothing happens. That's why i need some more help.
 
Level 6
Joined
May 31, 2008
Messages
218
well already thought about that, but then i give the unit very much hp so it wont die or somthing due to receiving to much damage, which is unlikely but still
 
Status
Not open for further replies.
Top