• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[General] How to make tiny castle item for a custom race

Status
Not open for further replies.
Level 24
Joined
Sep 26, 2009
Messages
2,352
I don't think it's really possible to do it. If I understand that ability correctly, you just supply list of Town Hall-type buildings and it chooses one depending on your player's selected Race - which ultimately is only Human, Orc, Undead or Night Elf.

I could think of the option to use the original/default ability and then detect when the building has been finished and replace it with the town hall of your custom race.
For example this works for me:

This detects when unit casts the original "Build Tiny Great Hall" ability.
  • Hero Builds TownHall Via Item Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Build Tiny Great Hall
    • Actions
      • Set VariableSet IsTownHallFromItem = True
      • Set VariableSet HeroUnitInitiatingConstruction = (Triggering unit)

This trigger will detect when the building begins construction. It performs some additional checks (mainly that the building belongs to the Hero using the item and that the Hero unit is close enough to the building. It is also the place to determine the unit type (target town hall) it should morph into.

  • TownHall Begins Construction
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • IsTownHallFromItem Equal to True
      • (Owner of (Triggering unit)) Equal to (Owner of HeroUnitInitiatingConstruction)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Town Hall
          • (Unit-type of (Triggering unit)) Equal to Great Hall
          • (Unit-type of (Triggering unit)) Equal to Necropolis
          • (Unit-type of (Triggering unit)) Equal to Tree of Life
    • Actions
      • Set VariableSet HeroLocation = (Position of HeroUnitInitiatingConstruction)
      • Set VariableSet BuildingLocation = (Position of (Triggering unit))
      • -------- The 110 range is 100 range from Cast Range of the item ability + 10 range as buffer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between HeroLocation and BuildingLocation) Less than or equal to 110.00
        • Then - Actions
          • Set VariableSet BuildingToChange = (Triggering unit)
          • Set VariableSet UnitTypeToChangeTo = Temple of Tides
          • Set VariableSet HeroUnitInitiatingConstruction = No unit
          • Set VariableSet IsTownHallFromItem = False
        • Else - Actions
      • Custom script: call RemoveLocation(udg_HeroLocation)
      • Custom script: call RemoveLocation(udg_BuildingLocation)

This trigger detects when the building from previous trigger has finished construction.
It replaces the original structure with the one from your custom race.
Since replacing structures can move them from their original position, the Move Unit action is used to move the structure back to its original position

  • TownHall Finishes Construction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Triggering unit) Equal to BuildingToChange
    • Actions
      • Set VariableSet BuildingLocation = (Position of (Triggering unit))
      • Unit - Replace (Triggering unit) with a UnitTypeToChangeTo using The new unit's default life and mana
      • Unit - Move (Last created unit) instantly to BuildingLocation
      • Set VariableSet BuildingToChange = No unit
      • Custom script: call RemoveLocation(udg_BuildingLocation)


Note, that these triggers are not MUI, so the whole thing will break once multiple tiny town halls are being built at the same time.
Even if the triggers were changed to support MUI, the approach has its drawbacks:
  • When you are placing the town hall and when it is being constructed you see the original building instead of the final building from your custom race
  • When construction is finished, you get a message notification saying "Completed: <original building's name>"

Another approach to this could be to trigger the whole thing yourself - for example when you select location an invisible dummy unit would build the structure for you - this would solve the drawbacks from the previous approach, but it has its own issues:
  • How to make the building free when it is built by the dummy unit
  • No preview of where you can build it when placing the structure (i.e. the green or red ground when placing structures)
  • How to change building's construction time to 20 seconds
 
Last edited:
Status
Not open for further replies.
Top