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

Problem viewing a model in game

Status
Not open for further replies.
Level 4
Joined
Apr 9, 2020
Messages
15
Hello! I am making a custom map and I have the following problem. I am using a custom model of a haunted gold mine for a demon race. It works fine in the editor as you can see here:

1675752136661.png


But then, when I test the map, it goes back to the same haunted gold mine of the undead.

1675752300687.png


This never happened to me with any model. I'm guessing this is an exception.

Any idea on how I can solve this?

Thanks a lot!
 
Level 29
Joined
Sep 26, 2009
Messages
2,596
This is the hardcoded behavior of 'Blighted gold mine' ability as far as I know.
At startup, any unit with this ability is converted into the default 'Haunted Gold Mine' unit.

A way to resolve this is to pick all these gold mines at map initialization and update them.
For whatever reason, replacing or removing gold mine seems to cause strange behavior, so it may be better to use the 'Change unit skin' and 'Set unit name' trigger actions (note that these actions are available on newer patches).

Something like this:
  • Untitled Trigger 001 Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Haunted Gold Mine)) and do (Actions)
        • Loop - Actions
          • Custom script: call BlzSetUnitSkin( GetEnumUnit(), 'u000' ) // replace u000 for unit-type ID of your custom gold mine
          • Unit - Set Name of (Picked unit) to Abc
 
Level 4
Joined
Apr 9, 2020
Messages
15
Thanks a lot! I saw a map where a guy made his own haunted gold mine and it worked but there is a different problem. I am making a demon race that have their own gold mine but in the same map I want normal undead to be playable with no problems. My idea is to add, not to replace anything. I am adding also naga, fel orc and blood elf but since they mine gold normally there is no problem there. A new race it's just a number of buildings and units if you don't count the UI and their music set and sounds because such a project would require a MOD. But I thought this would be far easier. I mean the haunted gold mine is just a unit, right? Apparently not.

Is there a way to make the new demon gold mine coexist with the undead gold mine?

1675830862650.png
1675830883588.png
 
Level 4
Joined
Apr 9, 2020
Messages
15
Ok. I solved it. But I had to do something different wich caused a different problem.

1675834655525.png


What I did was to instead use the Entangled Gold Mine base. It works perfectly in game. But... It cannot be used. I created a worker like the Wisp, instead naming him Servant (my idea is that the workers of the demons are souls delivered to them and enslaved) and changing his model a bit (custom models for workers would be appreciated if you know of them). Created the same abilities a wisp requires but for the servant. Everything is the same except when I go to the game, I cant "place" the servant in the demon gold mine as you normally do wisps. Also when the demon gold mine gets destroyed, it doesn't leave the normal gold mine in it's place, it just dissapears.

1675835553331.png

And the gold mine is gone too!

1675835594883.png


Any idea how can I solve this? Or indeed any idea for the use of a custom gold mine. It can be however you like as long as it works.

Thanks a lot everyone!
 
Last edited:
Level 29
Joined
Sep 26, 2009
Messages
2,596
Well, gathering resources is one of the things that lack any customization in WCIII. From what I understand, these aspects are hardcoded in the engine.
I tried to create a custom undead gold mine and encountered a bunch of issues.

Some stuff I found out:
  • In order for a custom worker to mine gold from a custom gold mine based on 'Haunted Gold Mine' unit (with the 'Blighted Gold Mine ability'), the worker must have Race set to Undead in the Object Editor (this is irrespective of the race a player selected in the lobby) and have the 'Gather (Acolyte Gold)' ability, otherwise they just won't be able to use the gold mine.
  • Any gold mine with the 'Blighted Gold Mine' ability (including derivate abilities) will be replaced at map initialization with the default 'Haunted Gold Mine'
  • Removing the 'Haunted Gold Mine' in any way from the game (killing, replacing or even using 'Unit - Remove unit' action) will create at its place a normal Gold Mine
  • The created Gold Mine will not trigger any events (it's not set as (Last replaced unit) nor (last Created Unit) and it does not trigger the (Unit - Unit entered playable map area) event
  • Checking before hand if there is any hidden Gold Mine in the (Entire map) yielded no results

Considering the above, I made it work in my test map by doing the following:
  1. I created a custom gold mine based on Haunted Gold Mine
  2. At map initialization, I picked all Haunted Gold Mines in the map and replaced them with my custom gold mine
  3. Replacing Haunted Gold mines will sadly also create default gold mines at their locations (so essentially, there is my custom gold mine and default gold mine stacked on one another)
  4. I created a second trigger that picks all my custom gold mines and for each such unit it detects a nearby normal gold mine (the one stacked underneath) and removes it
  5. Finally I had to create a third trigger that detects when my custom gold mine has been destroyed and creates at its place the default gold mine (to mimic what happens to Undead when haunted gold mine has been destroyed)

The triggers below is what made it work for me, but I did not take care of any memory leaks (as I've spent enough time just trying to make it work :D ). You can try it in your map and if it works for you, then we can update the triggers to not leak.
  • GoldMine - unit
  • GoldMineLocation - point
  • GoldMineTimer - timer
  • GoldMineGoldAmount - integer

  • Start Replacement
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Haunted Gold Mine)) and do (Actions)
        • Loop - Actions
          • Unit - Replace (Picked unit) with a Custom Gold Mine using The new unit's max life and mana
      • Countdown Timer - Start GoldMineTimer as a One-shot timer that will expire in 0.00 seconds
  • Delayed Removal
    • Events
      • Time - GoldMineTimer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Custom Gold Mine)) and do (Actions)
        • Loop - Actions
          • Set VariableSet GoldMineLocation = (Position of (Picked unit))
          • Unit Group - Pick every unit in (Units within 100.00 of GoldMineLocation matching ((Unit-type of (Matching unit)) Equal to Gold Mine).) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
  • Custom Gold Mine Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Custom Gold Mine
    • Actions
      • Set VariableSet GoldMineGoldAmount = (Resource quantity contained in (Triggering unit))
      • Set VariableSet GoldMineLocation = (Position of (Triggering unit))
      • Unit - Create 1 Gold Mine for Neutral Passive at GoldMineLocation facing Default building facing degrees
      • Set VariableSet GoldMine = (Last created unit)
      • Neutral Building - Set GoldMine to GoldMineGoldAmount gold
      • Unit - Hide GoldMine
      • Custom script: call SetUnitX(udg_GoldMine, GetLocationX(udg_GoldMineLocation))
      • Custom script: call SetUnitY(udg_GoldMine, GetLocationY(udg_GoldMineLocation))
      • Unit - Unhide GoldMine
You also mentioned that you just want to do this for the 'Demon' race's haunted gold mines, but not touch the 'Undead' race's haunted gold mines.
For that you just need to change the condition in the first 'Pick every unit' action in the 'Start Replacement' trigger. In my version, I pick all such gold mines in playable map area. I don't know how your map works - especially what marks whether a player plays the Demon race or not.
For example if only a specific player slot can be demon, then you can update the condition in my first trigger to just pick Haunted Gold mines of that player.
 
Level 18
Joined
Dec 20, 2012
Messages
269
I also encountered the same thing when making my custom demon (undead) race. Here you go, you should be able to open it. I'm on patch 1.27. It create a new demon gold mine at game start. If it is destroyed, a new gold mine will spawn with the previous amounts of gold remaining. It should also be leakless.
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Create starting units (for all players)
      • Melee Game - Run melee AI scripts (for computer players)
      • Melee Game - Enforce victory/defeat conditions (for all players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Picked player)) Equal to Undead
              • ((Picked player) handicap) Equal to 90.00
            • Then - Actions
              • Set TempOwner = (Picked player)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Matching unit) is A peon-type unit) Equal to True)) and do (Unit - Replace (Picked unit) with a New Acolyte using The new unit's max life and mana)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) of type Haunted Gold Mine) and do (Set TempLoc = (Position of (Picked unit)))
              • Unit Group - Pick every unit in (Units owned by (Picked player) of type Haunted Gold Mine) and do (Set TempInitialDemonGoldMinesGold[(Player number of (Picked player))] = (Resource quantity contained in (Picked unit)))
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) of type Haunted Gold Mine) and do (Unit - Remove (Picked unit) from the game)
              • Unit Group - Pick every unit in (Units of type Gold Mine) and do (If ((Distance between (Position of (Picked unit)) and TempLoc) Equal to 0.00) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing))
              • Unit - Create 1 Demon Gold Mine for (Picked player) at TempLoc facing Default building facing degrees
              • Unit - Move (Last created unit) instantly to TempLoc
              • Set TempInitialDemonGoldMines[(Player number of (Picked player))] = (Last created unit)
              • Set TempInitialDemonGoldMinesLoc[(Player number of (Owner of (Last created unit)))] = TempLoc
              • Neutral Building - Set (Last created unit) to TempInitialDemonGoldMinesGold[(Player number of (Picked player))] gold
              • Custom script: call RemoveLocation(udg_TempLoc)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Matching unit) is A town-hall-type unit) Equal to True)) and do (Unit - Replace (Picked unit) with a Demon Gate using The new unit's max life and mana)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) of type Ghoul) and do (Unit - Replace (Picked unit) with a Zombie using The new unit's max life and mana)
            • Else - Actions
  • Demon Goldmines
    • Events
      • Unit - A unit Dies
    • Conditions
      • TempInitialDemonGoldMines[(Player number of (Owner of (Dying unit)))] Not equal to No unit
      • (Unit-type of (Dying unit)) Equal to Demon Gold Mine
    • Actions
      • Set TempNum2 = (Player number of (Owner of (Dying unit)))
      • Set TempInitialDemonGoldMinesGold[TempNum2] = (Resource quantity contained in TempInitialDemonGoldMines[TempNum2])
      • Set TempInitialDemonGoldMinesLoc[TempNum2] = (Position of TempInitialDemonGoldMines[TempNum2])
      • Set TempInitialDemonGoldMines[TempNum2] = No unit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInitialDemonGoldMinesGold[TempNum2] Not equal to 0
        • Then - Actions
          • Unit - Create 1 Gold Mine for Neutral Passive at TempInitialDemonGoldMinesLoc[TempNum2] facing Default building facing degrees
          • Set TempDummyUnit = (Last created unit)
          • Unit - Hide TempDummyUnit
          • Neutral Building - Set TempDummyUnit to TempInitialDemonGoldMinesGold[TempNum2] gold
          • Unit - Turn collision for TempDummyUnit Off
          • Custom script: call SetUnitY(udg_TempDummyUnit, GetLocationY(udg_TempInitialDemonGoldMinesLoc[udg_TempNum2]))
          • Custom script: call SetUnitX(udg_TempDummyUnit, GetLocationX(udg_TempInitialDemonGoldMinesLoc[udg_TempNum2]))
          • Unit - Unhide TempDummyUnit
          • Custom script: call RemoveLocation(udg_TempInitialDemonGoldMinesLoc[udg_TempNum2])
        • Else - Actions
          • Custom script: call RemoveLocation(udg_TempInitialDemonGoldMinesLoc[udg_TempNum2])
 

Attachments

  • (6)GnollWoodMineTest.w3x
    522.1 KB · Views: 2
Level 4
Joined
Apr 9, 2020
Messages
15
Guys I cannot stress how thankful I am! Thanks a lot! I've decided, for simplicity reasons, to just summon the gold mine at the start of the map. Since the map will have a cutscene, by the time it ends it will be finished.
BUT - will definitely try your solutions and then see what comes up. Then I come here and post the results.

For Nichilus, your solution might work as indeed only one player will be demon (player 6 - yellow).

Again, thanks a lot!
 
Status
Not open for further replies.
Top