• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Harvest ability bug

Status
Not open for further replies.
Level 5
Joined
Dec 25, 2014
Messages
111
So, i planned to make the harvest ability to be able to use if only there is a specific unit exist. I tried to set the Techtree Requirements to the required unit. Yes it works that the ability is disabled until the specific unit exist BUT it is still clickable. It's very annoying. Any thoughts?
 
Level 5
Joined
Jun 12, 2018
Messages
146
If I'm right about the problem you're facing, I think you could achieve what you want with some simple triggers

This one enabled by default :

  • Make Harvest Available
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equals to Peasant
    • Actions
      • Trigger - Turn off (This trigger)
      • Player - Enable Harvest for (Owner of (Triggering unit))
      • Trigger - Turn on Make Harvest Unavailable <gen>
This one disabled by default (will trigger when your last specific unit dies) :

  • Make Harvest Unavailable
    • Events
      • Unit - A unit dies
    • Conditions
      • (Number of units in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equals to Peasant))) Equals to 1
    • Actions
      • Trigger - Turn off (This trigger)
      • Player - Disable Harvest for (Owner of (Triggering unit))
      • Trigger - Turn on Make Harvest Available <gen>
Disable the abilty at start :

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Player - Disable Harvest for (Picked player))
The code will work assuming you've got the Harvest ability on your specific unit
 
Level 5
Joined
Dec 25, 2014
Messages
111
Well yes those would disabled the ability but it wouldn't show the ui and it would disabled it for the whole units of the player. I tried it once with UnitEvent for the unit create and dies and using BlzUnitDisableAbility but it comes weird, it got disabled or enabled sometimes for each event runs.
 
Last edited:
Level 5
Joined
Jun 12, 2018
Messages
146
Nevermind I thought you wanted to hide the icon UI aswell. Could you post the triggers you've tried so far ?
 
Level 8
Joined
May 21, 2019
Messages
435
  • Make Harvest Unavailable
    • Events
      • Unit - A unit dies
    • Conditions
      • (Number of units in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equals to Peasant))) Equals to 1
    • Actions
      • Trigger - Turn off (This trigger)
      • Player - Disable Harvest for (Owner of (Triggering unit))
      • Trigger - Turn on Make Harvest Available <gen>
It is worth noting that this condition will return a false, if all units of type Peasant die within the time-frame between the unit dying and the unit being removed from the game's memory. I don't know how long that time-frame is, but I think it lasts as long as the entire death animation, so that's several seconds.
You need to count living units and check that their count is at 0.

Also, you are leaking a unit group here and a player group in your last trigger.
 
Level 12
Joined
Nov 3, 2013
Messages
989
You could replace the harvest ability with a dummy ability (that does nothing) that has the correct tech tree requirement, then when the requirement is met you remove the dummy ability and add the harvest ability again.


p.s. The easiest way would probably be to not actually remove the harvest ability (and re-add it) but rather to just temporarily disable it.
 
Level 8
Joined
May 21, 2019
Messages
435
Death animation + decay duration if the unit decays. Instantly after death animation if no decay or exploded.
Right, wasn't certain about the decay duration. Thanks for the input!
On a side-note, how do spells like Reanimate Dead and Revive work?
Do the corpse units have an attached unit-type to them?
 
Level 8
Joined
May 21, 2019
Messages
435
The corpses are the units... just dead.
I don't mean the corpse of the decaying unit, I mean the generic corpses left behind for use in abilities, like the ones unloaded by a meat wagon or generated at a graveyard, that's what some dying units turn into. Is this skeletal corpse part of the decaying cycle of a unit? If so, what are the generic corpses?
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
They're not generic corpses. Those skills all have a data field that allows you to choose which unit-type is created as a corpse; by default they are ghouls. Resurrection seems unable to target meat wagon exhumed corpses in my limited testing (yes I did change its targets allowed).
 
Level 8
Joined
May 21, 2019
Messages
435
They're not generic corpses. Those skills all have a data field that allows you to choose which unit-type is created as a corpse; by default they are ghouls. Resurrection seems unable to target meat wagon exhumed corpses in my limited testing (yes I did change its targets allowed).
Interesting, thanks for the insight.
 
Status
Not open for further replies.
Top