• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[HELP] Create a unit at a unit's position in a unit group

Status
Not open for further replies.
Level 9
Joined
Aug 7, 2009
Messages
380
Well, hi
I need you guys again...
I'm making a trigger that create a unit at a position of a unit group i picked, but created units are somehow not at picked units position
Check out my trigger:
  • Trigger 1
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Mirror Image
  • Actions
    • Set Casters[1] = (Triggering unit)
    • Set POINTS[1] = (Position of Casters[1])
    • Set Integers[1] = (Level of Mirror Image for Casters[1])
    • Set Illusions_Groups[1] = (Units within 500.00 of POINTS[1] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of Player 1 (Red)) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))))
    • Unit Group - Pick every unit in Illusions_Groups[1] and do (Actions)
      • Loop - Actions
        • For each (Integer A) from 1 to (Number of units in Illusions_Groups[1]), do (Actions)
          • Loop - Actions
            • Set Effectedunits[(Integer A)] = (Picked unit)
            • Set Points[(Integer A)] = (Position of Effectedunits[(Integer A)])
            • Unit - Create 1 Illusion for (Owner of Casters[1]) at Points[(Integer A)] facing Default building facing degrees
            • Set Illusions[(Integer A)] = (Last created unit)
            • Unit Group - Add Illusions[(Integer A)] to Illusions_Groups[2]
            • Unit - Order Illusions[(Integer A)] to Attack Effectedunits[(Integer A)]
            • Unit - Add a (15.00 + (5.00 x (Real(Integers[1])))) second Generic expiration timer to Illusions[(Integer A)]
            • Animation - Change Illusions[(Integer A)]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 70.00% transparency
I know it leaks but i'll remove it after, why it's not working (the units created are not at the set position but it appears at my map's spawn point :goblin_jawdrop:
Edit: @GangSpear: I copied my trigger and edit it, so there were some mistakes :) checked my trigger and it's the same point as "POINTS[1]":ogre_haosis:
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
You do not need so many variables either, temporary references like Triggering unit or Picked unit are here for some case.

  • Trigger 1
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Mirror Image
  • Actions
    • Set POINTS[1] = (Position of (Triggering unit))
    • Set Integers[1] = (Level of Mirror Image for (Triggering unit))
    • Set Illusions_Groups[1] = (Units within 500.00 of POINTS[1] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of (Triggering player)) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))))
    • Unit Group - Pick every unit in Illusions_Groups[1] and do (Actions)
      • Loop - Actions
        • For each (Integer A) from 1 to (Number of units in Illusions_Groups[1]), do (Actions)
          • Loop - Actions
            • Set Points[(Integer A)] = (Position of (Picked unit))
            • Unit - Create 1 Illusion for (Triggering player) at Points[(Integer A)] facing Default building facing degrees
            • Unit Group - Add (Last created unit) to Illusions_Groups[2]
            • Unit - Order (Last created unit) to Attack (Picked unit)
            • Unit - Add a (15.00 + (5.00 x (Real(Integers[1])))) second Generic expiration timer to (Last created unit)
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 70.00% transparency
            • Custom script: call RemoveLocation(udg_Points[GetForLoopIndexA()])
    • Custom script: call RemoveLocation(udg_Points[1])
However, I'm not sure what you want to archieve, since if your temporary group has for egzample 6 units, you gonna create 36 illusion (6 illusion per each unit).
If you want to summon just 1 for each unit in group remove For each (...) actions.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
I told you already that you dont need that arrays and loop, coz picked unit is already a loop...
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mirror Image
    • Actions
      • Set Casters = (Triggering unit)
      • Set temploc = (Position of Casters)
      • Set Integers = (Level of (Ability being cast) for Casters)
      • Set Illusions_Group = (Units within 500.00 of temploc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of (Triggering player)) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))))
      • Unit Group - Pick every unit in Illusions_Group and do (Actions)
        • Loop - Actions
          • Set temploc = (Position of (Picked unit))
          • Unit - Create 1 Footman for (Triggering player) at temploc facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack (Picked unit)
          • Unit - Add a (15.00 + (15.00 + (Real(Integers)))) second Generic expiration timer to (Last created unit)
          • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 70.00% transparency
          • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call DestroyGroup(udg_Illusions_Group)
 
Status
Not open for further replies.
Top