Long Jump Module Help [SOLVED]

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Long Jump Module Help [SOLVED]

Post by Exosphere »

Hi there,

One of the items for my mod is going to be a module that functions as close to the Long Jump Module from Half Life as possible.
(for those unfamiliar) http://half-life.wikia.com/wiki/Long_Jump_Module

So, I decided to write an experimental ACS script to try an emulate the action but as I somewhat expected, it did not work (since I'm still not very familiar with ACS). What am I doing wrong? Here is the ACS code I came up with.

Code: Select all


#library "LJM"
#include "zcommon.acs"

//I created another script, code below, that sets the player's TID to 0. The code is directly from the Zdoom wiki.
/*

SetPlayerTID.acs
#library "SetPlayerTID"
#include "zcommon.acs"

script 1 ENTER
{
	Thing_ChangeTID(0, 100+PlayerNumber());
}

*/

script 101 (void)
{
	int bttns = GetPlayerInput(100, INPUT_BUTTONS); 
	
	if (CheckInventory("LongJump") == 1)
	{
		if (bttns & BT_SPEED && bttns & BT_JUMP)
		{
			ThrustThing(GetActorAngle(100)*256/360, 20, 0, 100);
			ThrustThingZ(100, 10, 0, 1);
			print(s:"Boost Activated"); //Used for testing purposes just to see if it even worked
		}
	}
	else
	{ print(s: "Long Jump Extension Not Found."); }
}

Thank you for any help given.
Last edited by Exosphere on Sat Aug 05, 2017 7:42 pm, edited 2 times in total.
User avatar
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory
Contact:

Re: Long Jump Module Code

Post by KeksDose »

GetPlayerInput uses player indices, not tids. Pass -1 to get the activator's inputs.

And GetActorAngle returns an angle in the range 0 to 65535, which is 0 to 1.0 (a bit less than that actually) in fixed point (which is a common pitfall: 1.0 is not 1 in ACS). You can convert a fixed point angle like that to a byte angle with angle >> 8 .

Looks good otherwise.
User avatar
Rachael
Posts: 13954
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Long Jump Module Code

Post by Rachael »

You need a delay(1); and restart; at the end of your script 101 to loop the script.

[wiki]Restart[/wiki]
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Code

Post by Exosphere »

KeksDose wrote:GetPlayerInput uses player indices, not tids. Pass -1 to get the activator's inputs.
Cool. Thanks for the important bit.
KeksDose wrote:And GetActorAngle returns an angle in the range 0 to 65535, which is 0 to 1.0 (a bit less than that actually) in fixed point (which is a common pitfall: 1.0 is not 1 in ACS). You can convert a fixed point angle like that to a byte angle with angle >> 8 .
Looks good otherwise.
Ok, so how would I code this? Would I still need to have GetActorAngle? Also, it seems as though its not receiving my input. I created a little function that would print out a message when I would wear the module and press E, but nothing would happen. It is located with in the inventory check.

Code of said function

Code: Select all

if (bttns == BT_USE)
		{
			print(s:"Script Is Receiving Input");
		}
Any thoughts. Also, thank you Rachael for that tidbit.
User avatar
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory
Contact:

Re: Long Jump Module Code

Post by KeksDose »

Yup, you still use GetActorAngle. Just write GetActorAngle(0) >> 8 instead of GetActorAngle(0) * 256 / 360.

If absolutely nothing happens, and even with the script looping there is no message on the screen, you can check if the script is running at all by typing scriptstat in the console. It prints which scripts are running.

I would say change the type of your script to enter, like the one commented out. It's then guaranteed to run for every player as soon as the map starts.
User avatar
Reactor
Posts: 2091
Joined: Thu Feb 03, 2011 6:39 pm
Location: Island's Beauty, Hungary

Re: Long Jump Module Code

Post by Reactor »

Excellent work!!! :o I am impressed!
I do have one question though - I would much prefer if this long jump module could be activated-deactivated like an inventory item (Holoduke or Nightvision Goggles for instance). Is it possible to alter the mechanics of said module so?

To be honest, the "crouch and then quickly jump" scheme was a damn mess...
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Code

Post by Exosphere »

Reactor wrote:Excellent work!!! :o I am impressed!
I do have one question though - I would much prefer if this long jump module could be activated-deactivated like an inventory item (Holoduke or Nightvision Goggles for instance). Is it possible to alter the mechanics of said module so?

To be honest, the "crouch and then quickly jump" scheme was a damn mess...
Certainly, I was actually experimenting with having the jump bound to just one button. Thank you for the compliment also.
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Help

Post by Exosphere »

UPDATE: So I was able to integrate the jump module in and it does work, sort of, but the player does not move when I press the new button. This is my new code.

Code: Select all

script 101 (void) //Did experiment with having "ENTER" there, but the "LONG JUMP NOT FOUND" message was always displayed until I got the LJM.
{
	int bttns = GetPlayerInput(-1, INPUT_BUTTONS); 
	
	if (CheckInventory("LongJump") == 1)
	{
		if (bttns == BT_USE)
		{
			print(s:"Script Is Receiving Input");
		}
		
		if (bttns & BT_USER1)
		{
			ThrustThing(GetActorAngle(0) >> 8, 20, 0, 0);
			ThrustThingZ(0, 10, 0, 1);
			print(s:"Boost Activated"); //Used for testing purposes
		}
	}
	else
	{ print(s: "Long Jump Extension Not Found."); }
	
	delay(10);
	restart;
}
Any Ideas?
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Help

Post by Exosphere »

See above post. I would really like some help on this.
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Help

Post by Exosphere »

Why did all the help I was getting earlier for this suddenly evaporate and people are avoiding this post? I am still at a loss why the jump module isnt working and would really like to find a solution for this soon.
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: Long Jump Module Help

Post by Blue Shadow »

People aren't obligated to help. They will if they feel like it. This means help comes when it comes.
User avatar
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory
Contact:

Re: Long Jump Module Help

Post by KeksDose »

If you want something to happen on the press of a custom button, you don't have to use a looping script or even GetPlayerInput. Unless for some reason you didn't state it absolutely had to be this way.

Just have an acs that does the long jump item check and Thrust* stuff. Look up [wiki=KEYCONF]keyconf[/wiki] and write an alias to execute that script on a press instead. Also append net to your script header so you can use this in multiplayer.

And I suspect your "not moving" problem lies elsewhere.
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Help

Post by Exosphere »

KeksDose wrote:If you want something to happen on the press of a custom button, you don't have to use a looping script or even GetPlayerInput. Unless for some reason you didn't state it absolutely had to be this way.

Just have an acs that does the long jump item check and Thrust* stuff. Look up [wiki=KEYCONF]keyconf[/wiki] and write an alias to execute that script on a press instead. Also append net to your script header so you can use this in multiplayer.

And I suspect your "not moving" problem lies elsewhere.
I did actually bind the script to a key, just to make it easier to activate.

Code: Select all

addmenukey "Use Long Jump" LJM
defaultbind "LJM" c
alias LJM "puke 101"
I have been testing it out some more and I did find out by using "scriptstat", it says that the script is delayed; however, I think that might just be the script waiting for the button press. Could it be something wrong with the actor identifier? Could I be identifying an actor that doesn't exist and not the player?
Blue Shadow wrote:People aren't obligated to help. They will if they feel like it. This means help comes when it comes.
Sorry about that. I didnt mean to come off as sounding people were obligated to me. I just found it unusual that my question wasnt answered for longer than a week. My experience on this forum for getting responses has usually been much shorter, around a day or two.
User avatar
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory
Contact:

Re: Long Jump Module Help

Post by KeksDose »

Ye, if it says delayed, then it is basically polling input. As previously mentioned, when your key executes the script, you don't need to loop it or even check for an input, since it is already pressed. It should then work as intended. Just keep the check for the item.

The activator is definitely the player if you press the button. If you're unsure, you can add a line like SetActorAngle(0, Random(0, 1.0)); to your script. If every time you hit the button you look into a random direction, then you're definitely the activator.

By the way, in the future, if you ever have to check for inputs in a script anyway, use a delay of 1 instead of 10. Otherwise, you would check for an input once every 0.3 seconds, which is unresponsive as heck (and you would basically force the player to hold the key). That's because you can only get the inputs on this current tic and the previous one.
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Long Jump Module Help

Post by Exosphere »

KeksDose wrote:Ye, if it says delayed, then it is basically polling input. As previously mentioned, when your key executes the script, you don't need to loop it or even check for an input, since it is already pressed. It should then work as intended. Just keep the check for the item.

The activator is definitely the player if you press the button. If you're unsure, you can add a line like SetActorAngle(0, Random(0, 1.0)); to your script. If every time you hit the button you look into a random direction, then you're definitely the activator.

By the way, in the future, if you ever have to check for inputs in a script anyway, use a delay of 1 instead of 10. Otherwise, you would check for an input once every 0.3 seconds, which is unresponsive as heck (and you would basically force the player to hold the key). That's because you can only get the inputs on this current tic and the previous one.
So after a lot of tinkering, I finally got it working. The main problem that was obsturcting the script from running was the USER2 button assignment. The setactorangle was very helpful in determining whether or not the script was working.
Locked

Return to “Editing (Archive)”