• 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.

Conquer a castle

Status
Not open for further replies.
Level 2
Joined
Jan 22, 2021
Messages
10
Hi guys, I'm a fresh begginer. I have this idea: all gold mines have alredy a city hall near it, that town hall is passive neutral at start, and if in a range of it there is only units of an specified team, then that town hall change its owner to that player. How could I make it happen?
This does not sound too much original, I guess, but I don't know how to find it here.
Thanks in advance and sorry if this was alredy discussed.

Ps: sorry my awful english, I play an spanish version of it, maybe there is not even such "city hall", but you know what I mean :v
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
(I will answer in spanish and english)

Para esto tienes que aprender sobre variables y regiones y hacer un detonador para cada vez que una unidad se acerca a ese edificio, haz una region que cubra dicho edificio o usa el evento de "Unit comes within a Range", si tu plan es que el que más unidades tenga cerca sea el dueño, lo mejor es usar una tabla de líderes.
For this you have to learn about variables and regions and make a detonator for each time a unit approaches that building, make a region that covers that building or use the "Unit comes within a Range" event, if your plan is that the one with the most units nearby is the owner, it is best to use a leaderboard.
  • Trigger1
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Leaderboard - Create a leaderboard for (All players) titled "Your name"
      • Set Board = (Last created leaderboard)
      • Leaderboard - Sort Board by Valor in Descendant order
      • Set TempForce = (All players controlled by a User player)
      • Player group - Pick every player in TempForce and do (Actions)
        • Loop - Actions
          • Leaderboard - Add (Picked player) to (Last created leaderboard) with label Unit and value 0
      • Custom script: call DestroyForce(udg_TempForce)
  • Trigger2
    • Events
      • Unit - A unit enters in "Your Region"
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Triggering player)
      • Set UnitNumber[TempInt] = (UnitNumber[TempInt] + 1)
      • Leaderboard - Change the value for (Triggering player) in Board to UnitNumber[TempInt]
      • Leaderboard - Sort Board by Valor in Descendant order No sé si es necesario esto / I don't know if this is necessary
      • Unit - Change ownership of "That building" to (Player in position 1 of Board) and Change color
  • Trigger3
    • Events
      • Unit - A unit leaves "Your Region"
    • Conditions
      • ((Triggering unit) is dead) Equal to False Esto es para no contar a las unidades muertas (desaparecer cuenta como abandonar región) / This is to avoid counting dead units (disappearing counts as leaving region)
    • Actions
      • Set TempInt = (Player number of (Triggering player)
      • Set UnitNumber[TempInt] = (UnitNumber[TempInt] - 1)
      • Leaderboard - Change the value for (Triggering player) in Board to UnitNumber[TempInt]
      • Leaderboard - Sort Board by Valor in Descendant order
      • Unit - Change ownership of "That building" to (Player in position 1 of Board) and Change color
  • Trigger4
    • Events
      • Unit - A unit dies
    • Conditions
      • ("Your Region" contains (Dying unit)) Equal to True
    • Actions
      • Set TempInt = (Player number of (Triggering player)
      • Set UnitNumber[TempInt] = (UnitNumber[TempInt] - 1)
      • Leaderboard - Change the value for (Triggering player) in Board to UnitNumber[TempInt]
      • Leaderboard - Sort Board by Valor in Descendant order
      • Unit - Change ownership of "That building" to (Player in position 1 of Board) and Change color
 
Status
Not open for further replies.
Top