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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top