Poll

Need some opinions about the descend key:

Crouch Key (useless without client)
2 (40%)
Light Key (Most of people nowadays use it for reload)
2 (40%)
Jet Key (out of the way, makes exiting vehicles a problem)
0 (0%)
Jump Key (Switch ascend to right click or other option)
1 (20%)
Other? (Post your ideas!)
0 (0%)

Total Members Voted: 5

Author Topic: Project Support_HeightControl [Code Questions]  (Read 4920 times)

The revival of HeightControl is finally near.
Greetings!
After another way too long time (i had to necrobump), i finally came around and finished the important part of the code.
What is currently left to do is add the client sided prediction code (for people playing with latency mostly, to make going up and down look smoother) and fix one small bit that will add the last bit of backwards compatibility (i had to edit this build to be backwards compatible).

BETA BUILD
!WARNING! Incompatible with the old client of HeightControl due to massive rewrite.
Please request people who join and want to use HeightControl properly to download this build as well.
This build's client will be compatible with every upcoming build from now on.
My apologies for this inconvenience.


What changed?
Players/Server Owners should not notice much except for every vehicle made to use HeightControl now going up in the direction of the vehicle's up.
I fixed that the helicopters no longer go statically up (so no more super tilted but still going straight up helicopters) by default.

This feature is still available for modders though.
This and the rewrite does make it easier to use the crouch key.
HeightControl is now an add-on of an internal script which i called Vehicle Trigger Functions v2 (VTFv2), which aimed to fix some issues i had with the onTrigger functions.
For example, every trigger that the driver presses in the driver seat of a vehicle (now also fixed so that every type of vehicle works) gets pushed to the vehicle's onTrigger function.
Previously this was limited to the jump key only, but now modders can use that onTrigger just like they would use a player's onTrigger function, for every trigger you have (jumping, crouching, jetting (the latter still dismounting you from the vehicle)).
All the triggers except jumping (which you could do via the vehicle's onTrigger function) and crouching (not detectable on drivers) were done by packaging the Armor::onTrigger function. While it worked, it should be easier and more understandable now it is under the vehicle's onTrigger function as well.
I also added a new function called onPassengerTrigger for vehicles to use when a passenger presses a trigger.
A client script was and still is needed to fix the crouching key (not for the jump key anymore though, that was a mistake on my part), i did a whole load of tests with different ways to detect if someone was pressing the crouch key in the driver seat, but nothing worked. Trust me.
But this also will be used (soon) to implement some velocity "prediction", which will make the heightcontrol look a bit smoother, especially if there is lag present.
A vague plan is to also add the movement keys to this system (under onMovementTrigger or something similar) to give modders the ability to use those for interesting things as well.
Though this might be a bit too much.

Tl;DR
Users should not notice much change except for the non-static going up now, modders will see an increase in how easy it is to use this mod for their own weird/cool experiments (like submarines... Never expected that....).

EDIT: Previous topic content.
After years of other random projects, procrastinating and low motivation i finally decided to just take some time to finish some stuff up.
I am very sorry for those that waited for this, though i doubt there are many.
This is also because i recently visited a server using helicopters (Stay Woke!) and i really, really feel ashamed that i never added the thing where you go up relative to the vehicle's rotation instead of a static height increase. :X

Either way, i am not here to gloat over this fact but to discuss matters. Code matters.
I will list my questions with a bit of text after it to explain my questions in context a bit.
Don't want the questions to get lost in the text either.
1. Does any of you think calling the player's vehicle onTrigger from Armor::onTrigger could cause trouble?
I already check if the player is the driver, though i also am working on an additional function called onPassengerTrigger to make it easier for vehicle makerrs to detect if a passenger is pressing a trigger.
2. Does anybody (not the forum user) know if there is a way to detect if the driver of a vehicle is pressing his crouch button without client script?
3. The Torque Quick Reference Guide or whatever speaks of a ShapeBaseData::onTrigger, yet when i package for example the FlyingVehicleData::onTrigger and Parent it, it gives a console error saying: "Unknown command onTrigger".
Is it safe to make a ShapeBaseData::onTrigger function or should i package it still?
What is the preferred/recommended way of doing this?
4 & 5 & 6. Back in the days, after the release of HeightControl on RTB, i got a tip of M (Clockturn... I think?)
Quote from: M
What you should do is when the client gets into a vehicle that uses this, send them a clientcmd telling it the velocities the vehicle uses, and use
Code:
ServerConnection.getControlOb ject().getObjectMount()
to get the vehicle clientside then apply the velocity clientside. This still works (for now - it wouldn't surprise me if Dadspot "idiot-proofed" this too later)

Anyway, essentially what this means is, if you replicate the serverside logic clientside, it'll be (theoretically) smooth at higher latencies (ie, above 300 or so, where it becomes noticeable, though in theory even all the way up)
Would this be much more efficient?
Does it even work still?
Can i use set and getVelocity on the vehicle's object clientsided?
Most of these questions are asked because it seems odd to me that i can get (and apparently set) all this information clientsided.

EDIT: After dumping some stuff about the clientsided things and finally actually trying it out, the effect should be good and as M said, on a higher latency, it will help those people.
Especially for something like HeightControl.

Here's a bit of context for some of the questions:
Currently i am building it so that the onTrigger function of vehicles will also get called when the driver presses his crouch button, fire weapon/tool button and jet button.
The crouch button sadly can only get done through a client script, since none of the other onTrigger's gets called when you crouch as the driver.
So sadly i have to report, only the jump button client part has been removed ever since.
Back in the days i made a mistake in my tests and thought the onTrigger did not get called with a triggerValue..
So i made a client script to fix that... Yeah that wasn't needed either.
But after a lot of testing and checking things i am 100% convinced that only the crouch button is something i need a client script for.
But i just want to really know for sure.
Though i have gotten a tip on another way to handle descending, the light key, i prefer to give modders a way to use what they can use normally in other onTrigger functions.

That is basically my goal here as well, to "fix" the onTrigger function of vehicles for drivers.
It only gets called when pressing the jump key, which is... weird.
On top of that, the crouch key doesn't even get detected serverside if you are a driver of a vehicle...
This all binds into the heightControl mod, the "fix" to the onTrigger function has now basically become the base on which HeightControl will work.

Sorry for the wall of text and lot of questions, i just want to do this right, hopefully in one shot so that i do not have to change too much after the rerelease.
Especially on the client side, i want to avoid everyone running different versions of the client script specifically.
This rerelease will work perfectly fine with vehicles created with the old heightControl in mind.
Well most of them, i think the submarines will suffer because they overwritten some of the old functions that i have changed the function, name and pretty much everything of. :X

If you have any suggestions, questions or anything related to HeightControl, feel free to put them here as well!
This topic is basically gonna be my main development topic for project HeightControl.
« Last Edit: July 02, 2017, 08:25:03 AM by lordician »

wowe i completley forgot you made this

wowe i completley forgot you made this
Many people do not know this, but i am fine with it.
Though it would help in case they needed help with it.
I did visit most of the help topics related to HeightControl, though the issues most people had were probably caused by conflicting mods, which i hope to kinda prevent/solve with the rerelease.

lordican:

its Armor/Observer::onTrigger(%this, %obj, %triggerValue, %triggerState)

%triggerValue is 0 for left click, 1 for jump, something else for crouch, 4 for right click.
%triggerState is either 0 or 1 - 1 for when the button is down, 0 when its released.
trace(1); and dump(); is your best friend :)

You can use this to figure out whether or not to keep raising the vehicle without a client side mod. you will have to package unmounting the vehicle to prevent it from going up continuously when the player exits while holding down the button.

I still think its best to keep it spacebar/crouch only, as some vehicles have drivers shoot in the first seat.

lordican:

its Armor/Observer::onTrigger(%this, %obj, %triggerValue, %triggerState) I know.

%triggerValue is 0 for left click, 1 for jump, something else for crouch, 4 for right click. Actually, 0 is left click, 1 is for i dunno what, 2 is jump, 3 is crouch, 4is jetting
%triggerState is either 0 or 1 - 1 for when the button is down, 0 when its released. I know
trace(1); and dump(); is your best friend :) Yep, using that.

You can use this to figure out whether or not to keep raising the vehicle without a client side mod. you will have to package unmounting the vehicle to prevent it from going up continuously when the player exits while holding down the button. Never thought of using jet actually, but then exiting becomes another issue...

I still think its best to keep it spacebar/crouch only, as some vehicles have drivers shoot in the first seat. Exactly but a client sided script is still needed to detect crouching of the driver of a vehicle.
But thanks for the tips. ^_^
I am mostly asking the questions for more in depth advice on how to tackle some of the problems.
Though i have never dumped the client sided stuff.
But i am really doubting if it is worth it.

EDIT:
Alright i finally did a bit of testing with it and it should be worth it, especially in the case of HeightControl.
Thanks for reminding me about dump(), i kinda forgot to check some things using that.
« Last Edit: January 24, 2017, 06:52:24 PM by lordician »

You could prevent people from dismounting (maybe double tap jet key to exit the vehicle)

You could prevent people from dismounting (maybe double tap jet key to exit the vehicle)
Not sure if i like the double tap for exiting...
The player could accidentally exit the vehicle by pressing descend rapidly.
It is a bit iffy.
But it is good to consider these alternatives right now.

Maybe a quick jet key press?

i dont understand - why would you need a client script to detect if a client is crouching? just package armor::onTrigger and have it change %player variables when the triggers are toggled?? how are you even doing the check for jump?

then within the vehicle loop check the driver's trigger states? or check once when a player enters, and have it loop check until the player is not holding down the button. Have the trigger when pressed call the loop check function on %pl.getObjectMount()?

also im fairly sure isCrouched() is a default function, though it probably doesnt check the actual trigger pressed down or not.

Lordican thank you for doing this and I'm proud to be the insperation. STAY WOKE

i dont understand - why would you need a client script to detect if a client is crouching? just package armor::onTrigger and have it change %player variables when the triggers are toggled?? how are you even doing the check for jump?

then within the vehicle loop check the driver's trigger states? or check once when a player enters, and have it loop check until the player is not holding down the button. Have the trigger when pressed call the loop check function on %pl.getObjectMount()?

also im fairly sure isCrouched() is a default function, though it probably doesnt check the actual trigger pressed down or not.
EDIT:
Oh hold on, i see where you are going now, sorry, just woke up.
So you are saying a constant loop on a vehicle and then checking the trigger.
First of all, the HeightControl loop only goes when one of the triggers is active, want to keep it as responsive as possible.
Second of all, see below for another reason, the crouch trigger cannot even be used as a trigger of some sort when the player is the driver.
I just tested the isCrouched thing and it works just like the onTrigger function (does not detect it properly when you are the driver).
Funny thing with that is that if you keep crouch active and switch seat you actually keep your crouching in the other seats, but when you are in the driver seat, it is all of sudden inactive.
So yeah in the end, looping and checking is not quite possible as nothing tells me serverside if the driver of a vehicle is crouching.
Sadly.
Nice suggestion though.

ORIGINAL RESPONSE:
Armor onTrigger is only called on left click when you are the driver of a vehicle, jump is only detectable via the vehicle's onTrigger and crouch is not detectable at all.
Here have an example of one of my tests.
Relevant code:
Code: [Select]
function Armor::onTrigger(%data, %player, %slot, %io)
{
echo("Armor::onTrigger");
echo("Information: DATABLOCK" SPC %data SPC "| PLAYER" SPC %player SPC "| TRIGGERNUM" SPC %slot SPC "| TRIGGERVALUE" SPC %io);
Parent::onTrigger(%data, %player, %slot, %io);
}

//"Missing" onTrigger function
//These originally do not exist, i add these to give a bit more freedom and make it easier for modders to change onTrigger behaviour of vehicles.
//These can be overwritten by modders to add functionalities if so desired...
function ShapeBaseData::onTrigger(%data, %obj, %val, %io)
{
//This exists and is used since we CREATED it and parent from (Flying/Wheeled)VehicleData -> VehicleData -> ShapeBaseData
//If you want to overwrite the behaviour of all types of vehicles (Playertype & FlyingVehicle & WheeledVehicle) i recommend packaging this function.
//We do not need to Parent this since this was originally not even there to begin with.
echo("ShapeBaseData::onTrigger");
echo("Information: DATABLOCK" SPC %data SPC "| PLAYER" SPC %obj SPC "| TRIGGERNUM" SPC %val SPC "| TRIGGERVALUE" SPC %io);
}
These two functions are packaged and i use shapeBaseData in this case to catch the vehicle's onTrigger. Could have used JeepVehicle::onTrigger or any of his parents, but you know, whatever.
Relevant console:
Quote
Jeep entered
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 0 | TRIGGERVALUE 1
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 0 | TRIGGERVALUE 0
ShapeBaseData::onTrigger
Information: DATABLOCK 975 | PLAYER 24153 | TRIGGERNUM 2 | TRIGGERVALUE 1
ShapeBaseData::onTrigger
Information: DATABLOCK 975 | PLAYER 24153 | TRIGGERNUM 2 | TRIGGERVALUE 0
Here i pressed crouch... Neither function catches the crouch.
Entered passenger seat of the Jeep
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 0 | TRIGGERVALUE 1
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 0 | TRIGGERVALUE 0
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 2 | TRIGGERVALUE 1
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 2 | TRIGGERVALUE 0
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 3 | TRIGGERVALUE 1
Armor::onTrigger
Information: DATABLOCK 38 | PLAYER 23842 | TRIGGERNUM 3 | TRIGGERVALUE 0
Everything works as passenger but not as driver.
I even ran something with just the default Jeep enabled and ran a trace for you.
I attached it to this post, forgive me, it is a bit long.
The first trace is of when i am in the driver seat and the second of when i am in a passenger seat.
I must say that not even the vehicle's onTrigger is showing up in the first trace because it is a virtual script normally i think (like an abstract function/method).
Suppose that is why i initially thought i should fix that. :P
However, sadly the crouch is still not detected when you have an actual filled in onTrigger function on the vehicle or one of his parents as you can see in the example above.

I hope i am clear here.
I did a lot of testing, tracing and stuff to make sure about the client script being needed, i would rather avoid it, but at the same time, if it is broken and using a client script for HeightControl itself (applying the velocity client sided to make it smoother for higher latency people) might be a good thing anyway, might as well fix that then.
« Last Edit: January 25, 2017, 06:48:49 AM by lordician »

thanks for clarifying. i didnt realize onTrigger for crouch fails to register when the player is a driver. Odd given that (iirc) for observer::ontrigger crouch still works.

right click may work well then. or maybe have people use building controls (shift up/down bricks), but that's admittedly a bit odd.
if you do do left click check if they have a weapon out before doing anything i guess
« Last Edit: January 25, 2017, 01:28:55 PM by Conan »

thanks for clarifying. i didnt realize onTrigger for crouch fails to register when the player is a driver. Odd given that (iirc) for observer::ontrigger crouch still works.

right click may work well then. or maybe have people use building controls (shift up/down bricks), but that's admittedly a bit odd.
if you do do left click check if they have a weapon out before doing anything i guess
I was thinking of build controls and i was like that's it!
But then i realised, for helicopters and stuff that will be very very awkward.
You would need like 3 hands to control a helicopter then.

would it be possible to use the walk key (default is C) for descent

nope
not without client mod
and at that point you might as well just use crouch