• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Units in units group problem

Status
Not open for further replies.
Level 10
Joined
Mar 17, 2012
Messages
579
Hi there! I need your help, guys!
  • Tihonova Dark loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
      • (Tihonova_Dark is alive) Equal to True
    • Actions
      • Set Tihonova_Dark_Point = (Position of Tihonova_Dark)
      • Set Tihonova_Dark_Group = (Units within 700.00 of Tihonova_Dark_Point matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an ally of Player 7 (Green)) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • Set Tihonova_Count_Dark = (Number of units in Tihonova_Dark_Group)
      • Unit - Set level of Tihonova Attack Speed for Tihonova_Dark to Tihonova_Count_Dark
      • Unit - Set level of Tihonova Move Speed for Tihonova_Dark to Tihonova_Count_Dark
      • Unit - Set level of Tihonova Regen for Tihonova_Dark to Tihonova_Count_Dark
      • Unit - Set level of Tihonova Armor 0 for Tihonova_Dark to Tihonova_Count_Dark
      • Unit - Set level of Tihonova Damage 0 for Tihonova_Dark to Tihonova_Count_Dark
      • Custom script: call RemoveLocation(udg_Tihonova_Dark_Point)
      • Custom script: call DestroyGroup(udg_Tihonova_Dark_Group)
Any idea howto make that trigger work???
(it doesn't count units in unit group)
 
Level 12
Joined
May 20, 2009
Messages
822
You're setting the level to the amount of units in the group, I dunno if this is intended but if the level the trigger is trying to set the ability to is higher than the ability actually has, it won't set it at all.

This should be an easy fix:

  • Set Tihonova_Dark_Group = (Units within 700.00 of Tihonova_Dark_Point matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an ally of Player 7 (Green)) Equal to True) and (((Matching unit) is alive) Equal to True))))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in (Units in (Tihonova_Dark_Group)) Greater than LevelOfAbility)
    • Then - Actions
      • Unit - Set level of Tihonova Attack Speed for Tihonova_Dark to LevelOfAbility
    • Else - Actions
      • Unit - Set level of Tihonova Attack Speed for Tihonova_Dark to Tihonova_Count_Dark
 
Level 10
Joined
Mar 17, 2012
Messages
579
This should be in Triggers & Scripts.

Your trigger looks fine. I can't see why this wouldn't work as it should. Are your filters properly filtering out the units you need? They might be causing the unit group to filter out everything, resulting in a count of 0. Also, can you show where you initialize Tihonova_Dark?

Sure. Here it is.
  • Tihonova Dark spawn
    • Events
      • Unit - A unit enters Tihonova Dark Spawn <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to РўРёС…РѕРЅРѕРІР°
    • Actions
      • Set Tihonova_Dark = (Triggering unit)
      • Unit - Order Tihonova_Dark to Attack-Move To (Center of Region 021 <gen>)
Trigger should work properly, it just doesn't coun units in units group. If I pick them it will aeefct them.

You're setting the level to the amount of units in the group, I dunno if this is intended but if the level the trigger is trying to set the ability to is higher than the ability actually has, it won't set it at all.

This should be an easy fix:

  • Set Tihonova_Dark_Group = (Units within 700.00 of Tihonova_Dark_Point matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an ally of Player 7 (Green)) Equal to True) and (((Matching unit) is alive) Equal to True))))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in (Units in (Tihonova_Dark_Group)) Greater than LevelOfAbility)
    • Then - Actions
      • Unit - Set level of Tihonova Attack Speed for Tihonova_Dark to LevelOfAbility
    • Else - Actions
      • Unit - Set level of Tihonova Attack Speed for Tihonova_Dark to Tihonova_Count_Dark

Ability has only 5 levels and there can be only 5 units available in unit group.

Does the Tihonova_Dark unit already have the abilities you're trying to increase the level of? If not, nothing will work.

And use a game message to display how many units there are.

Yes, it does have the abilities I'm trying to increase.

I remember having issues with this too, never solved it.

Here is a lame workaround.
Loop from 1-9999, pick random unit from group and remove it. Then set counter + 1
when group is empty exit loop.

You see, I need to change levels of those abilities dependant on how many heroes are around that unit.
Take a look:
  • Tihonova Dark loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
      • (Tihonova_Dark is alive) Equal to True
    • Actions
      • Set Tihonova_Dark_Point = (Position of Tihonova_Dark)
      • Set Tihonova_Dark_Group = (Units within 700.00 of Tihonova_Dark_Point matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an ally of Player 7 (Green)) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Random 1 units from Tihonova_Dark_Group) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Tihonova_Dark_Group is empty) Not equal to True
                • Then - Actions
                  • Set Tihonova_Count_Dark = (Tihonova_Count_Dark + 1)
                  • Unit Group - Remove (Picked unit) from Tihonova_Dark_Group
                  • Unit - Set level of Tihonova Armor 0 for Tihonova_Dark to (Tihonova_Count_Dark + 1)
                  • Unit - Set level of Tihonova Attack Speed for Tihonova_Dark to (Tihonova_Count_Dark + 1)
                  • Unit - Set level of Tihonova Damage 0 for Tihonova_Dark to (Tihonova_Count_Dark + 1)
                  • Unit - Set level of Tihonova Move Speed for Tihonova_Dark to (Tihonova_Count_Dark + 1)
                  • Unit - Set level of Tihonova Regen for Tihonova_Dark to (Tihonova_Count_Dark + 1)
                • Else - Actions
      • Custom script: call RemoveLocation(udg_Tihonova_Dark_Point)
      • Custom script: call DestroyGroup(udg_Tihonova_Dark_Group)
Actually I also need to reduce the level of ability to 1 if nobody's around :)
 
Level 10
Joined
Mar 17, 2012
Messages
579
And you are certain that the filters are not removing the units you need? I really don't see anything wrong with the triggers. Do you mind sending the map so I can take a look at it? There might be a conflicting trigger.

Actually trigger works and gives level of the ablilty, but it doesn't reduc it when number of units becomes less. (works the last trigger that I've sent)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Your first trigger is a correct approach... it would be a shame to change that to how that last trigger is made.

You can try to do a "Game - Display text to all players" where text is a convertion from an integer to a string which shows the number of units in the group.

Also, setting an ability to level 0 does not really remove the ability.
It either does nothing or sets it to 1, but I havent tested it out.
 
do not use this
  • Conditions
  • (Tihonova_Dark is alive) Equal to True
use this instead
JASS:
function IsUnitAlive takes unit u returns boolean
    return not (GetUnitTypeId(u) == 0 or IsUnitType(u, UNIT_TYPE_DEAD))
endfunction

here you have:
  • set
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set YourUnit = Sylvanas Windrunner 0001 <gen>
      • Set YourAbility = Devotion Aura1
      • Unit - Add YourAbility to YourUnit
      • Unit - Set level of YourAbility for YourUnit to 1
and:
  • Untitled Trigger 001
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set udg_YourBoolean = IsUnitAlive(udg_YourUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • YourBoolean Equal to True
        • Then - Actions
          • Set YourPoint = (Position of YourUnit)
          • Set YourGroup = (Units within 700.00 of YourPoint)
          • -------- --- --------
          • Set YourInteger = 0
          • Unit Group - Pick every unit in YourGroup and do (Actions)
            • Loop - Actions
              • Custom script: set udg_YourBoolean = IsUnitAlive(GetEnumUnit())
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • YourBoolean Equal to True
                  • ((Picked unit) is A Hero) Equal to True
                  • ((Picked unit) belongs to an ally of Player 1 (Red)) Equal to True
                • Then - Actions
                  • Set YourInteger = (YourInteger + 1)
                • Else - Actions
          • -------- --- --------
          • Game - Display to (All players) for 1.00 seconds the text: (Debug: unit group count is: + (String(YourInteger)))
          • -------- --- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • YourInteger Not equal to (Level of YourAbility for YourUnit)
            • Then - Actions
              • Unit - Set level of YourAbility for YourUnit to YourInteger
            • Else - Actions
          • -------- --- --------
          • Custom script: call RemoveLocation(udg_YourPoint)
          • Custom script: call DestroyGroup(udg_YourGroup)
          • -------- --- --------
        • Else - Actions
zibi
 
Status
Not open for further replies.
Top