HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

My Crazy Arrow Movement System Problems [Help]

01-26-2008, 09:24 PM#1
Salbrismind
Okay...

I've been working on this for a few weeks and I wanted to wait a bit longer until I showed the community but I've run into some crazy problems I can't fix.

The first problem is that after adding the ability for the unit to attack it started messing with the movement animations. My first though was to stop the unit, play the attack, then start him moving again, but this has not worked at all.

Second, there is a possible exploit for moving twice as fast if the player clicks a spot in front of the unit and also uses the keyboard. I've tried to stop the orders but I couldn't find out exactly how through searching either.

Third, the pathing for the unit gets ridiculous when you use "SetX/Y of unit" to move it around because it tends to be able to move anywhere now. To fix this I added a condition to each trigger to check for untravelable terrain in the direction of travel but the unit now gets stuck in cliffs and rocks.


Basically I need some help to solve these problems. Any help would be great. Please don't mind a few of the other minor bugs in the map. If you use the switch movement mode button and go to strafing there are a few there as well. Just understand this is a work in progress and even my code will likely be optimized for the full game, this version is just to work out all the systems.

Here's the Map:

Morphers Arena v0.1.w3x

Just so you know the game is not called Morphers Arena, that is an old map I am building my new one in.
Attached Files
File type: w3xMorphers Arena v0.1.w3x (89.9 KB)
01-29-2008, 03:50 PM#2
Salbrismind
Bump... Guys can anyone help plz? I still need hlep with this.
02-01-2008, 10:41 PM#3
Salbrismind
Bump yet again... Is anyone if looking at this thread?

If you are confused at all, just ask I'll clarify if needed. If it's too much then offer some suggestion, or just help with one. But please help if you can, this has put my map to a near stand still.
02-01-2008, 10:52 PM#4
TEC_Ghost
Ill check it out this weekend bud, don't have the time at this moment :)
02-01-2008, 11:00 PM#5
TaintedReality
The problem is, for most of those questions there isn't really a clear answer, you kind of just have to do it on your own and get it to fit with your own map.

Quote:
The first problem is that after adding the ability for the unit to attack it started messing with the movement animations. My first though was to stop the unit, play the attack, then start him moving again, but this has not worked at all.

What do you mean? How was it messing with the movement animations?

Quote:
Second, there is a possible exploit for moving twice as fast if the player clicks a spot in front of the unit and also uses the keyboard. I've tried to stop the orders but I couldn't find out exactly how through searching either.

We don't know how you're determining their speed. I know it's in the map, but most people (including me) would rather not open a map up and search through it to find the trigger :). But there are a couple possible methods you could use, shouldn't be a big deal.

Quote:
Third, the pathing for the unit gets ridiculous when you use "SetX/Y of unit" to move it around because it tends to be able to move anywhere now. To fix this I added a condition to each trigger to check for untravelable terrain in the direction of travel but the unit now gets stuck in cliffs and rocks.

If you're checking and acting correctly then the unit shouldn't get stuck. But again, we need to know more about how these units are moving. Maybe post some triggers from the movement system.
02-02-2008, 02:12 AM#6
Salbrismind
First off, thank you for posting I really need this help so thank you.

Well... I think the problem was I typed this late at night... hoping to get some posts by morning but I ended up writing a bad post...

1. Basically whats happening is very odd. I put a new triggered spell on my test unit that allows it to have a sorta of melee attack. It attacks units directly in front of it by checking all units in 200 or so range and picking the ones that are infront of it then playing blood effects on those units. The spell it self is supposed to play the attack animation. It does, but it also makes the walking stop. To prevent this I made the trigger check if the unit is walking (upcheck/downcheck) then to save that data and use it later to replay the walk animation so it looks natural.

There are 3 problems with it though. First, for both back and forward it doesn't start the walking again. Second, the unit doesn't stop moving when it truly should. Third, when first walking backwards then attacking, it doesn't even play the attack animation. The movement works very simply, if the player presses the forward key then a boolean (upcheck) is turned on, for every 0.03 secs it is on the unit moves forward a little bit. In the trigger that makes the unit attack it sets upcheck to off thus it shouldn't move and yet it continues.

As you can see this is only the first problem and it by itself is perplexing, so i'll start with only it. Here's the code for this part becasue ur too lazy :P.

Trigger:
Basic Attack
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Casting unit) Equal to Heroes[1]
(Ability being cast) Equal to Attack
Collapse Actions
Sound - Play BristleBackMissileLaunch3 <gen> at 100.00% volume, attached to Heroes[1]
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
upcheck[1] Equal to True
Collapse Then - Actions
Game - Display to (All players) the text: works
Set upcheck[1] = False
Set uptemp[1] = True
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
downcheck[1] Equal to True
Collapse Then - Actions
Game - Display to (All players) the text: works2
Animation - Change Heroes[1]'s animation speed to 100.00% of its original speed
Custom script: call SetUnitAnimationByIndex(udg_Heroes[1], 1)
Set downcheck[1] = False
Set downtemp[1] = True
Else - Actions
Collapse Unit Group - Pick every unit in (Units within 250.00 of (Position of Heroes[1]) matching (((Owner of (Matching unit)) is an enemy of Player 1 (Red)) Equal to True)) and do (Actions)
Collapse Loop - Actions
Set x = ((X of (Position of (Picked unit))) - (X of (Position of Heroes[1])))
Set y = ((Y of (Position of (Picked unit))) - (Y of (Position of Heroes[1])))
Set AtkAng[1] = (Atan((y / x)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
x Greater than 0.00
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
y Greater than 0.00
Then - Actions
Collapse Else - Actions
Set AtkAng[1] = (360.00 + AtkAng[1])
Collapse Else - Actions
Set AtkAng[1] = (180.00 + AtkAng[1])
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
AtkAng[1] Greater than ((Facing of Heroes[1]) - 22.50)
AtkAng[1] Less than ((Facing of Heroes[1]) + 22.50)
Collapse Then - Actions
Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
Unit - Cause Heroes[1] to damage (Picked unit), dealing 80.00 damage of attack type Normal and damage type Normal
Set num = (Random integer number between 1 and 6)
Sound - Play sounds[num] at 100.00% volume, attached to Heroes[1]
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
uptemp[1] Equal to True
Collapse Then - Actions
Custom script: call SetUnitAnimationByIndex(udg_Heroes[1], 6)
Set upcheck[1] = True
Set uptemp[1] = False
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
downtemp[1] Equal to True
Collapse Then - Actions
Custom script: call SetUnitTimeScalePercent( udg_Heroes[1], -100)
Custom script: call SetUnitAnimationByIndex(udg_Heroes[1], 6)
Set downcheck[1] = True
Set downtemp[1] = False
Else - Actions
02-02-2008, 03:18 AM#7
TaintedReality
Hmm. Can I see the movement triggers? Both the periodic trigger that moves units and the triggers detecting key presses. And, the attack ability has the "attack" animation or something like that in the animation field?
02-02-2008, 03:36 AM#8
Salbrismind
Quote:
Originally Posted by TaintedReality
Hmm. Can I see the movement triggers? Both the periodic trigger that moves units and the triggers detecting key presses. And, the attack ability has the "attack" animation or something like that in the animation field?

All of the triggers are in the map. In total it takes about 12 triggers to make the movement work (including right and left keys). I'll show you the relevant part though. Here are the triggers to operate the up key and forward movement:

I encourage you to try the map out, this way you get a better understanding of the problems. The unit is supposed to attack, and as it does stay still then go back to moving with the animation.

Trigger:
ForwardOn
Collapse Events
Player - Player 1 (Red) Presses the Up Arrow key
Collapse Conditions
(Heroes[1] is selected by Player 1 (Red)) Equal to True
Collapse Actions
Set upcheck[1] = True
Animation - Change Heroes[1]'s animation speed to 100.00% of its original speed
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Strafe[1] Equal to True
leftcheck[1] Equal to True
Collapse Then - Actions
Unit - Make Heroes[1] face ((Facing of Heroes[1]) - 45.00) over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Strafe[1] Equal to True
rightcheck[1] Equal to True
Collapse Then - Actions
Unit - Make Heroes[1] face ((Facing of Heroes[1]) + 45.00) over 0.00 seconds
Collapse Else - Actions
Custom script: call SetUnitAnimationByIndex(udg_Heroes[1], 6)


Trigger:
Forward
Collapse Events
Time - Every 0.03 seconds of game time
Collapse Conditions
(Heroes[1] is selected by Player 1 (Red)) Equal to True
(Terrain pathing at ((Position of Heroes[1]) offset by ((Current movement speed of Heroes[1]) / 30.00) towards (Facing of Heroes[1]) degrees) of type Walkability is off) Equal to False
upcheck[1] Equal to True
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Strafe[1] Equal to True
(leftcheck[1] Equal to True) or (rightcheck[1] Equal to True)
Collapse Then - Actions
Custom script: call SetUnitX ( udg_Heroes[1], GetUnitX(udg_Heroes[1]) + GetUnitMoveSpeed(udg_Heroes[1])/52.5 * Cos( udg_TempFacing[1] * bj_DEGTORAD) )
Custom script: call SetUnitY ( udg_Heroes[1], GetUnitY(udg_Heroes[1]) + GetUnitMoveSpeed(udg_Heroes[1])/52.5 * Sin( udg_TempFacing[1] * bj_DEGTORAD) )
Collapse Else - Actions
Custom script: call SetUnitX ( udg_Heroes[1], GetUnitX(udg_Heroes[1]) + GetUnitMoveSpeed(udg_Heroes[1])/30 * Cos( GetUnitFacing(udg_Heroes[1])* bj_DEGTORAD) )
Custom script: call SetUnitY ( udg_Heroes[1], GetUnitY(udg_Heroes[1]) + GetUnitMoveSpeed(udg_Heroes[1])/30 * Sin( GetUnitFacing(udg_Heroes[1])* bj_DEGTORAD) )


Trigger:
ForwardOff
Collapse Events
Player - Player 1 (Red) Releases the Up Arrow key
Conditions
Collapse Actions
Set upcheck[1] = False
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Strafe[1] Equal to True
(leftcheck[1] Equal to True) or (rightcheck[1] Equal to True)
Collapse Then - Actions
Animation - Change Heroes[1]'s animation speed to 50.00% of its original speed
Collapse Else - Actions
Animation - Reset Heroes[1]'s animation
02-02-2008, 08:39 AM#9
Ant
I'm looking through it. Yeesh it's confusing. I find it easier to manage everything if you just use one trigger to detect press/release and use another to do all the rest of the movement.

I can't solve much since I (1) don't know customscript so I'm not sure what's the difference between the SetUnitX, SetUnitY and the GUI trigger for moving a unit, and (2) I can't really understand the use for all the actions that run during detection of keyboard press/release.

I'll see what I can replicate bugless though and post it.

Edit: Okay I don't have that much time today to understand what's going on. I can create a system based off this to do what this does, but I can't modify the existing system because I don't really get it.

Plus do you intend for the mouse control to do anything, or for the unit's movement speed to matter? If not you can disable selection for that unit or set the unit's movement speed to 0.
02-02-2008, 06:17 PM#10
Salbrismind
Quote:
Originally Posted by Ant
I'm looking through it. Yeesh it's confusing. I find it easier to manage everything if you just use one trigger to detect press/release and use another to do all the rest of the movement.

I can't solve much since I (1) don't know customscript so I'm not sure what's the difference between the SetUnitX, SetUnitY and the GUI trigger for moving a unit, and (2) I can't really understand the use for all the actions that run during detection of keyboard press/release.

I'll see what I can replicate bugless though and post it.

Edit: Okay I don't have that much time today to understand what's going on. I can create a system based off this to do what this does, but I can't modify the existing system because I don't really get it.

Plus do you intend for the mouse control to do anything, or for the unit's movement speed to matter? If not you can disable selection for that unit or set the unit's movement speed to 0.


Just so you know, these three tiggers only govern the forward movement.

The first is for detecting the up press: It checks if the unit is selected because this is the hero unit, I want the play to only control when it is selected.
In the first part of the actions it sets upcheck to on because that tells the next trigger if it should move forward or not. Next is the animation speed just in case of errors, then after that ifs to check for strafing. See a unit can choose to strafe or not, if selected it becomes difficult to match the movement it should have, so each set of triggers have these ifs in there. In the then part is the trigger to make the unit face diagonally down its path. The else at the bottom is incase no strafing, if it fires the custom script fires the walk animation.

The second trigger is used to do the actual walking. Inside it are the conditions for pathing and again if the unit is selected, also if upcheck is on which is the key to this trigger. Whenever the player presses up the upcheck goes on and the second trigger fires thus it moves, once the player stops pressing the upcheck is set to off by the third trigger thus the unit stops moving. Thus in this trigger are the custom scripts that move the unit. The top part of scripts is incase of strafing. If it is strafing then the unit moves diagonally and not just straight ahead of it. I need to use setx/sety because this script does not interfere with the animations like the gui version does.

The third trigger is to stop the unit when the up key is no longer pressed. It has no conditions and its first action turns upcheck to off in order to stop it moving. The next if asks again if it is strafing, if the player is still hold right or left I want them to still be moving that direction with the proper animation and animation speed, so to this I added an if. So if it is strafing when it stops moving forward then the animation speed is set to what it should be for strafing, otherwise the animation is reset to default standing animation.


The bugs are in the new attacking trigger (2 posts above my movement triggers). To see it all better just open the map...

But the problems like I already said are in the animations, for some reason the new attack spell and trigger mess up animations and even though I put it to stop moving it keeps going.
02-03-2008, 09:15 AM#11
Ant
I have no idea what's going on, so I re-did the entire thing with easier to debug triggers. Clumped all the movement into one trigger. Animation seems to work fine. The initial system was too buggy and cluttered for me to try to debug.

So, I didn't find out what's wrong with your system, but you can look at what I did and maybe see what you can do to improve yours. A few parts I'm not too sure about, like which direction to face when going back, to turn to, etc. but all are easily modifiable.

Pathing seems to work fine for me (unless you wanted it to not move through enemy units, in which case there's no detection for that). The unit moving at double speed thing I can't really solve cause I've not worked with SetUnitX and SetUnitY at all (using GUI triggers to move instantly has none of those problems, but has a new set of animation difficulties). If there's no need to select the unit that you're controlling with arrow keys, then just select another unit off the playing area to reflect the status of the unit.

There's a lot of other issues with the system, but since it's still WIP I'll leave them to you. Try to keep your triggers simpler though... otherwise it's a pain to debug.
Attached Files
File type: w3xMorphers Arena v0.1.w3x (94.9 KB)
02-03-2008, 08:07 PM#12
Salbrismind
I'm not complaining, because your version offered some ideas that could help me. However you version is not only ugly and confusing but is much to crowded, my version offers each part in it's own area. As well your version has many bugs with strafing.

And also it does not solve the problem of the unit to stop moving. When it attack it is supposed to stop moving, and in yours it does not. If your could offer an idea for that, it would be great.
02-04-2008, 02:03 AM#13
Anitarf
Quote:
Originally Posted by Salbrismind
The first problem is that after adding the ability for the unit to attack it started messing with the movement animations. My first though was to stop the unit, play the attack, then start him moving again, but this has not worked at all.

Second, there is a possible exploit for moving twice as fast if the player clicks a spot in front of the unit and also uses the keyboard. I've tried to stop the orders but I couldn't find out exactly how through searching either.
Simple solution: don't allow the players to select the unit. Give it locus or something. Make it so that players can only control the unit through arrow keys and not through the regular wc3 interface. If you want any abilities to be used via hotkeys, you can simply create another unit hidden somewhere and select it for the player.

Quote:
Third, the pathing for the unit gets ridiculous when you use "SetX/Y of unit" to move it around because it tends to be able to move anywhere now. To fix this I added a condition to each trigger to check for untravelable terrain in the direction of travel but the unit now gets stuck in cliffs and rocks.
If you're making a low-tech map then simply move the unit by issuing move orders instead of using SetUnitX; otherwise, the triggered pathability check should work fine, just remember that it only detects static pathing from cliffs and doodads, not dynamic pathing from destructibles.
02-04-2008, 11:47 PM#14
Salbrismind
Quote:
Originally Posted by Anitarf
Simple solution: don't allow the players to select the unit. Give it locus or something. Make it so that players can only control the unit through arrow keys and not through the regular wc3 interface. If you want any abilities to be used via hotkeys, you can simply create another unit hidden somewhere and select it for the player.


If you're making a low-tech map then simply move the unit by issuing move orders instead of using SetUnitX; otherwise, the triggered pathability check should work fine, just remember that it only detects static pathing from cliffs and doodads, not dynamic pathing from destructibles.


Your right that is a good idea. But could I remove and add locus? I expect I should be able to but you never know with W.E... I need to be able to switch between control modes, sometimes keyboard control and others with just normal control. No worries though players can't attack in this mode so it's not like you have players of key control fighting mouse control, just that I want people to have both for different reasons.


Problem is for pathing that my map isn't low tech. I tried the order idea but I thought that with all the turning and moving and such that it might over click onto a cliff or down a ramp which would not be good if it were a final order and the unit went running down the ramp or around to the cliff. The pathing I tried in my map ends up putting the unit stuck in walls.
02-05-2008, 05:46 AM#15
Ant
Oh. It's supposed to stop moving when you attack. I thought you just wanted an animation thing. What I did was detect whether the unit was attacking, moving, or doing both at the same time (which I guess now is not supposed to happen). Everytime the unit attacks I start a timer for 1 second and change IsbAttacking (a boolean, of some similar name) to true, and change it to false when the Timer runs out. This same timer is the animation timer set to reset the walk animation everytime it finishes. You already had an Animtimer variable so I guess this is similar to yours, just organised into one trigger.

Personal preference for trigger organisation differs I guess.

But the general idea is, if you detect when the attack starts, start a timer to say when the attack ends, and change a variable while the attack is going on (i.e. between the start and the end of the attack a boolean is true), then you should be able to easily detect at any point whether the unit is attacking and then stop it from moving.

Also, you might be overshooting the pathing detection by a little bit. Not sure if this is intentional but the point to move to and the point to check pathing is different. I changed this in my map and you don't go up cliffs, into solid rocks, or through rocks and get stuck etc. The only thing you DO go through which you're not supposed to is destructibles (trees and rock chunks), which I guess doesn't show up as unwalkable on the terrain map since they are well, destructible. I didn't add this condition in my map, and detecting whether a destructible appears in front of you can be quite hard because you have to find the destructible's center, but the destructible has a random size. If you're not planning for the destructibles to be destroyed, then replace them with another static doodad of the same model.

If the double movement speed thing is bugging you and you absolutely HAVE to select the unit that the arrow keys is controlling, then use the GUI Move Unit Instantly trigger. Walking animations still work, along with standing animations, but abilities don't get cast etc. which might be a pain to work around, much moreso than just selecting a replica of an offscreen unit and all orders issued to that offscreen unit are issued to the unit you see, EXCEPT those you want to filter out.