Push object system

Wratox1

Member
Reaction score
22
Hello, ive decided to do some wc3 map making again.

So, i have this knight/warrior(the captain/swordsman model) and i want him to be able to push boxes and other objects around, but only when his shield is raised(using the defend ability).
He should only be able to push the object north/south/east/west, and the objects should be pushed in the direction he is facing. Also the objects should only move if the knight is moving and should only move if the knight is right behind the object.

How would i make this? I dont know any Jass.

Ideas and tips are welcome.

thanks in advance
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
Well, to start off, If Defend doesn't apply a buff to your knight (which if I remember, it does),
then create a buff for it and apply it to your knight when he uses defend.

Secondly check that when your knight is within, lets say 100 units to your box or object, you check whether he has the defend buff or not, and then save the angle between your knight and the box as a variable

Lastly check what the angle is and move accordingly, so if the angle is between:
  • -pi/4 and pi/4 you move the box east
  • pi/4 and 3xpi/4 you move the box north
  • 3xpi/4 and 5xpi/4 you move the box west
  • 5xpi/4 and 7xpi/4 you move the box south
 

Wratox1

Member
Reaction score
22
Well, to start off, If Defend doesn't apply a buff to your knight (which if I remember, it does),
then create a buff for it and apply it to your knight when he uses defend.

I actually tried making a system myself before i posted this thread, but that system wasnt very good, but there i checked if a unit used the defend ability and set a boolean to true, and when it was turned off, i set it to false. I did that since the defend ability didnt give the knight the buff i added to the ability and i felt it was easier to just set a boolean than to make a dummy unit cast a ability to add the buff.

Secondly check that when your knight is within, lets say 100 units to your box or object, you check whether he has the defend buff or not, and then save the angle between your knight and the box as a variable

Thats almost what i did with my system, however, i also want it to check if the knight is moving or standing still, and i have no idea on how to do that. Got any ideas? Also, im not really sure about the best method about checking the distance, at the moment the box is a unit with a box model, whats best to use: (i am going to have alot of these boxes/objects) a unit comes within range event or a periodic event + pick all units in range?

Lastly check what the angle is and move accordingly, so if the angle is between:
  • -pi/4 and pi/4 you move the box east
  • pi/4 and 3xpi/4 you move the box north
  • 3xpi/4 and 5xpi/4 you move the box west
  • 5xpi/4 and 7xpi/4 you move the box south

Thats easy enough i guess, ill get back to you if get any problems.

Edit: when i check the angle, what should i use as the comparison operator? Like, Less
than or equal to, greater than or equal to, etc. Also, is there a pi variable in the editor?

Another thing, im not entirely sure if im going to use the mouse for movement or perhaps the arrowkeys, if i use the arrowkeys it would be easy to restrict the pushing to only north/south/east/west, but i would rather have "wasd" instead of the arrowkeys, and from what ive heard there is no way to do that :(
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
it was easier to just set a boolean
That would work too, I would just see it as a wasted global variable but thats not much of a problem if you don't have thousands of them.
i also want it to check if the knight is moving or standing still
Hmm, if your knight moves within the range of a box, the box will move, so unless it reaches the edge of the map, your knight should never actually catch up with the box, therefore if won't matter if your knight is standing still, he'll only ever get within range if he's moving
im not really sure about the best method about checking the distance
There is a distance between two units method, it should be under the math operations.
a unit comes within range event or a periodic event?
I think a unit comes with range would be a better event, because like you said, you'll have a lot of these units, therefore if you're picking all units, and doing checks on everyone of them its just wasted memory again. If you're not using waits, all the actions will finish on one specific box, so you don't have to worry about the trigger starting on one box and halfway switching to another box.
when i check the angle, what should i use as the comparison operator?
In my first example it would be greater than -pi/4 and smaller than then pi/4 and so forth
Also, is there a pi variable in the editor?
Yes, if I remember correctly when choosing your Real values, so when set your Smaller Than value, click on the preset drop down menu, and it's right at the bottom, Pi
Remember that your angle is a Real value
but i would rather have "wasd" instead of the arrowkeys, and from what ive heard there is no way to do that :(
If you wanted to use wasd, you'd have to have four abilities and it just gets messy after that, so unfortunately its arrow keys or the mouse
 

DrEvil

FCRI Associate!
Reaction score
111
  • -pi/4 and pi/4 you move the box east
  • pi/4 and 3xpi/4 you move the box north
  • 3xpi/4 and 5xpi/4 you move the box west
  • 5xpi/4 and 7xpi/4 you move the box south


If he is using GUI(Says he knows no Jass) the angles between (a) and (b) will be in degrees not radians:

-45 and 45 = east
45 and 135 = north
135 and 225 west
225 and 315 south
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
Hmm, I thought it returned real values and there was a function that converted
to degrees, but it could my programming brain at work
 

Wratox1

Member
Reaction score
22
That would work too, I would just see it as a wasted global variable but thats not much of a problem if you don't have thousands of them.
Hmm, if your knight moves within the range of a box, the box will move, so unless it reaches the edge of the map, your knight should never actually catch up with the box, therefore if won't matter if your knight is standing still, he'll only ever get within range if he's moving
thats not true, or well, it depends on how fast the box is moving, but if the knight is faster than the speed the box is moving, he can stand still for a second or so and the box is still moving, also if he approaches the box with his shield lowered and then brings up the shield, the box would get moved a bit..
There is a distance between two units method, it should be under the math operations.
i know that, but thats not what i meant, this was meant to be a part of the question about unit comes in range or periodic event, sorry for not being more clear..
I think a unit comes with range would be a better event, because like you said, you'll have a lot of these units, therefore if you're picking all units, and doing checks on everyone of them its just wasted memory again. If you're not using waits, all the actions will finish on one specific box, so you don't have to worry about the trigger starting on one box and halfway switching to another box.
i did not mean to check every box with the periodic but rather check the area around the knight..
In my first example it would be greater than -pi/4 and smaller than then pi/4 and so forth
ok
Yes, if I remember correctly when choosing your Real values, so when set your Smaller Than value, click on the preset drop down menu, and it's right at the bottom, Pi
Remember that your angle is a Real value
thanks, i found it
If you wanted to use wasd, you'd have to have four abilities and it just gets messy after that, so unfortunately its arrow keys or the mouse
yeah, thats what i thought:(
If he is using GUI(Says he knows no Jass) the angles between (a) and (b) will be in degrees not radians:

-45 and 45 = east
45 and 135 = north
135 and 225 west
225 and 315 south
thanks, but i displayed the angle after i calculated it, and when approaching the box from north(to move it south) it displayed -101 as the value..
 

Wratox1

Member
Reaction score
22
okay, so ive decided to change to arrowkey-movement, but i havent found any system that i liked yet, ive checked here, hive and wc3c.

Does anyone know of a arrowkey-movement system where you dont attack normal, but rather you press a to attack? I also need a good third person camera system, can someone suggest a good one, it can be written in Jass but there should be instructions on how to use it with gui.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top