• 🏆 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!

Question about Picked Units

Status
Not open for further replies.
Level 9
Joined
Jun 25, 2009
Messages
427
Hey guys i have one problem, if i use

  • Set Split_Mana_Amount = (Mana of (Picked unit))
  • Game - Display to (All players) the text: (String(Split_Mana_Amount))
It writes let's say 100,50,50,50, i want them to be 250. How to make it in GUI, thanks. This thing is effing my mind all day guys help!:sad:

Tiche3
 
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Group = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set Mana = (Mana of (Picked unit))
      • Game - Display to (All players) the text: (String(((Integer(Mana)) x (Number of units in Group))))
      • Custom script: call DestroyGroup (udg_Group)
 
Level 9
Joined
Jun 25, 2009
Messages
427
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Group = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set Mana = (Mana of (Picked unit))
      • Game - Display to (All players) the text: (String(((Integer(Mana)) x (Number of units in Group))))
      • Custom script: call DestroyGroup (udg_Group)

Nah it is close but i'll write the whole trigger so you could understand what i want to do :)
  • Split Mana
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set Split_Mana_Caster = (Triggering unit)
      • Set Split_Mana_Pos = (Position of Split_Mana_Caster)
      • Set Split_Mana_Group = (Units within 512.00 of Split_Mana_Pos matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of (Owner of Split_Mana_Caster)) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • Unit Group - Pick every unit in Split_Mana_Group and do (Actions)
        • Loop - Actions
          • Set Split_Mana_Amount = (Mana of (Picked unit))
          • Game - Display to (All players) the text: (String(Split_Mana_Amount))
          • Set Split_Mana_Divided = (Split_Mana_Amount / (Real((Number of units in Split_Mana_Group))))
          • Unit - Set mana of (Picked unit) to Split_Mana_Divided
          • Set Split_Mana_Group_Pos = (Position of (Picked unit))
          • Special Effect - Create a special effect at Split_Mana_Group_Pos using Abilities\Spells\Items\AIma\AImaTarget.mdl
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_Split_Mana_Pos)
      • Custom script: call DestroyGroup(udg_Split_Mana_Group)
      • Custom script: call RemoveLocation(udg_Split_Mana_Group_Pos)
And for more deeper explanation: Picks units in 500 area, adds their mana to one place, then splits the mana and sets everybodys in the area mana to the split mana for example.

Caster casts, has 200 mana, other guys (4) has 100 mana. 200+100+100+100+100/5 and set to that mana.
 
Level 1
Joined
Jun 5, 2010
Messages
2
Is this perhaps what you want?
  • Split Mana
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Split Mana
    • Actions
      • Set Split_Mana_Caster = (Triggering unit)
      • Set Split_Mana_Pos = (Position of Split_Mana_Caster)
      • Set Split_Mana_Group = (Units within 512.00 of Split_Mana_Pos matching ((((Matching unit) is A structure) Equal to False) and ((((Owner of (Matching unit)) is an ally of (Owner of Split_Mana_Caster)) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • Set Split_Mana_Group_Amount = (Number of units in Split_Mana_Group)
      • For each (Integer A) from 1 to Split_Mana_Group_Amount, do (Actions)
        • Loop - Actions
          • Set Split_Mana_Group_Unit = (Random unit from Split_Mana_Group)
          • Set Split_Mana_Amount = (Split_Mana_Amount + (Mana of Split_Mana_Group_Unit))
          • Unit Group - Add Split_Mana_Group_Unit to Split_Mana_Group_2
          • Unit Group - Remove Split_Mana_Group_Unit from Split_Mana_Group
      • Set Split_Mana_Group_Amount = (Number of units in Split_Mana_Group_2)
      • Game - Display to (All players) the text: (String(Split_Mana_Amount))
      • For each (Integer B) from 1 to Split_Mana_Group_Amount, do (Actions)
        • Loop - Actions
          • Set Split_Mana_Divided = (Split_Mana_Amount / (Real(Split_Mana_Group_Amount)))
          • Set Split_Mana_Group_Unit = (Random unit from Split_Mana_Group_2)
          • Unit - Set mana of Split_Mana_Group_Unit to Split_Mana_Divided
          • Set Split_Mana_Group_Pos = (Position of Split_Mana_Group_Unit)
          • Special Effect - Create a special effect at Split_Mana_Group_Pos using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit Group - Remove Split_Mana_Group_Unit from Split_Mana_Group_2
          • Custom script: call RemoveLocation(udg_Split_Mana_Group_Pos)
      • Set Split_Mana_Amount = 0.00
      • Custom script: call DestroyGroup(udg_Split_Mana_Group)
      • Custom script: call DestroyGroup(udg_Split_Mana_Group_2)
      • Custom script: call RemoveLocation(udg_Split_Mana_Pos)
Edit: Wrote wrong ability name
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
You'll probably need to enum the group twice; the first will use a variable to get the total mana from the group and another variable to count how many units there are in the group and the second that will set each of the units' mana to the total mana/count.

You could use
  • (Number of units in YourGroup)
instead of having a second variable in the first enumeration but that's pretty much a waste since it'll just do another group enum.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Something like this?
  • Split Mana
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set ManaSum = 0.00
      • Set Loc = (Position of (Triggering unit))
      • Set Group = (Units within 600.00 of Loc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True))))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set ManaSum = (ManaSum + (Mana of (Picked unit)))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Unit - Set mana of (Picked unit) to (ManaSum / (Real((Number of units in Group))))
      • Custom script: call RemoveLocation(udg_Loc)
      • Custom script: call DestroyGroup(udg_Group)
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
1,084
Something like this?
  • Split Mana
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set Loc = (Position of (Triggering unit))
      • Set Group = (Units within 600.00 of Loc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True))))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set ManaSum = (ManaSum + (Mana of (Picked unit)))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Unit - Set mana of (Picked unit) to (ManaSum / (Real((Number of units in Group))))
      • Custom script: call RemoveLocation(udg_Loc)
      • Custom script: call DestroyGroup(udg_Group)
Yes, except ManaSum must be set to 0 before the first group enum. (Forgot to mention that)
 
Status
Not open for further replies.
Top