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

[Trigger] Returning unit to original position

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
I've got 4 units in a turn-based battle. When it's the turn of a unit to perform an action, that unit it marked as the unit variable 'ActiveCharacter'.

Now when a unit attacks, I want the unit to:
-Move to the targeted unit
-Play 1 attack animation
-Move back to the region it came from (yes, it's a region)
-Turn around

I need to know how I can check from which region ActiveCharacter came. Checking the unit itself is going to be hard, since I need the same trigger for enemy units too, which are of random type, can contain double of the same unit-type, and are placed at any of the 4 enemy regions. So checking all that will be a LOT of work. That's why I'm looking for an easier and faster way to do this.
 
Level 9
Joined
May 27, 2006
Messages
498
  • Blah
    • Actions:
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in your reg <gen> and do Set BattleCharacterPlayer[1] = (Picked unit)
Do it this way. Repeat it for every region in your battle area, whatever. To make it shorter use the godly Integer A loop. (D:)

  • Actions:
    • For each (Integer A) from 1 to 4 do (Actions):
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in Your_Reg_PlayerCharacters[(Integer A)] and do Set BattleCharacterPlayer[(Integer A)] = (Picked unit)
    • For each (Integer A) from 1 to 4 do (Actions):
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in Your_Reg_EnemyCharacters[(Integer A)] and do Set BattleCharacterEnemy[(Integer A)] = (Picked unit)
Just move the characters to the center of the corresponding rect, and store them to a variable before the battle begins and the units act.
 
Level 9
Joined
May 27, 2006
Messages
498
  • For each (Integer A) from 1 to 4 do (Actions):
    • If (ActiveCharacter Equal to BattleCharacterEnemy[(Integer A)]) then do:
      • Set TempPoint = (Center of(YourReg_EnemyCharacters[(Integer A)]))
      • Unit - Order ActiveCharacter to move to TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
    • If (ActiveCharacter Equal to BattleCharacterPlayer[(Integer A)]) then do:
      • Set TempPoint = (Center of(YourReg_PlayerCharacters[(Integer A)]))
      • Unit - Order ActiveCharacter to move to TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
Integer A loop for president.

Anyway you could just store the region the unit comes from at the beggining of the action trigger, as i think its more like a cinematic sequence then nothing other will happen during it, meaning the variable wont change during it. After the unit performs its attack, order it to move back to the rect stored at the beggining.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Today I've officially announced my battle demo. All info can be found here. For remaining information, I refer you to my new forum where all my projects will be displayed with their progress, announced information and places to discuss and download the projects.

Screenshots will be posted as soon as I've got something to make a screenshot of! xD
I don't have any terrain terrained and I'm only working on the triggers, which will take a long, long time. To give you an idea of how long a long, long time is: I still need to create GUI triggers for every single ability of my characters (which are about 100-150 abilities). Also I need to create a multiboard Inventory system for the Item command within the battles (not to mention the item visual and data effects). So I think I got quite some work to do before releasing either the demo or any screenshots. Unless you'd like a screenshot of some GUI triggers xD
 
Level 11
Joined
Dec 31, 2007
Messages
780
Sry for reviving this and i know that it is already solved but i feel i gotta tell you this


DONT USE INTEGER A A LOT

it will screw your spells after a while, then you will start using INTEGER B. But after a while they will screw also.

You can replace integer a and b by using any integer variable you want
for Ie. Integer "I"

Set TempPoint = (Center of(YourReg_EnemyCharacters[(Integer A)]))

would be

Set TempPoint = (Center of(YourReg_EnemyCharacters[udg_I]))

Integer "MY_INTEGER_VAR" would be

Set TempPoint = (Center of(YourReg_EnemyCharacters[udg_MY_INTEGER_VAR]))

etc etc

im trying to prevent you to have the same problem i had long ago :p

also you will need to replace the integer A in the loop for your variable (it is the third option :p)
 
Level 9
Joined
May 27, 2006
Messages
498
Integer A and B were created to make it possible to create such loops:
  • For each (Integer A) from 1 to 5 do (Actions)
    • For each (Integer B) from 1 to 10 do (Actions)
      • Unit - Create (Integer A) Footman for (Player(Integer B)) at blah
At least its my interpretation, i've never experienced problems with a massive use of Integer A loops.
 
Level 11
Joined
Dec 31, 2007
Messages
780
then you have never used them for spells in games with 10 guys playing and casting those spells at the same time... try it and later tell me your results :p

what i said also includes using the same integer variable (any variable used a lot might be given a new value at a time you might not want)
 
Level 9
Joined
May 27, 2006
Messages
498
You're right, i've never used integer A for many players, just because i can't host.
Anyway, i always thought that Integer A is assigned as local for each trigger. Like, you can't refer to Integer A from another trigger, but it gets overwritten in the trigger you're using it in.
Like something between a local and a global.
 
Level 18
Joined
Oct 18, 2007
Messages
930
SUPERMEGAGIANTBLASTASTIC-SOLUTION!!!

  • Bleh
    • Events
    • Conditions
    • Actions
      • Index is an INTEGER VARIABLE
      • For each (Integer Index) from 1 to 12, do (Actions)
        • Loop - Actions
          • If you just need the number do this :
          • Player - Set (Player(Index)) Current gold to 1000000000000...
          • Else for array do this:
          • Set YourVariable[Index] = (YourVariableStuff)
 
Status
Not open for further replies.
Top