Keyconf + Puke

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
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Keyconf + Puke

Post by Risen »

I should really just go try this, but I can't until I get back home...

PUKE is considered a cheat. Servers not running SV_Cheats will not puke scripts. If I set up keys and such with KEYCONF to run scripts via puke, does this mean that using my map in multiplayer can only be done if sv_Cheats is on? Or are pukes defined in KEYCONF considered an exception?

I really need to be able to do this without having to turn on cheats in multiplayer, so any workaround suggestions are welcome.
User avatar
Cutmanmike
Posts: 11353
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Post by Cutmanmike »

I too have this problem, though I have not messed with keyconf yet
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

You can define a script as netplay-safe by adding the net keyword to it. Such scripts may be puked even when sv_cheats is FALSE. I believe the format is as follows:

Code: Select all

script 10 (int x, int y) net {
But you may want to experiment, as I've never used them.
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

Works wonderfully. I remember seeing the NET identifier before, but I never associated it with this behavior.

Heh... come to think of it, I don't have any idea what I used to think it did.

I know I keep a lot of the things I'm working on under pretty tight wraps, but I think I'll share this one and hope someone else finds it useful, too. Note that I plan many improvements to this, this is just a base to see if I could get it to do what I wanted. It's a fully functional jetpack.

Code: Select all

// Functional Jetpack
// by Risen
// 2004-04-12

#include "zcommon.acs"

int jeton[8];
int jettime[8];
global int 63: jetfuel[];

script 991 OPEN { // Initialize the arrays
     int i;
     for (i=0;i<8;i++) jeton[i] = 0;
     for (i=0;i<8;i++) jettime[i] = 0;
} 

script 994 ENTER { // No jetpacks turned on when you start a level
	jeton[PlayerNumber()] = 0;
}

script 995 DEATH { // No more fuel if you're dead!
	jetfuel[PlayerNumber()] = 0;
}

script 996 (void) net // fuel display
{
	hudmessage (s:"Jet Fuel: ", d:jetfuel[PlayerNumber()]; 1, 1, CR_GRAY, 1.0, 0.1, 3.0, 1.0);
}

script 997 (int amount) // fuel addition
{
	jetfuel[PlayerNumber()] = jetfuel[PlayerNumber()] + amount;
	if (jetfuel[PlayerNumber()] > 1500) {
	 	jetfuel[PlayerNumber()] = 1500;
	}
	ACS_ExecuteAlways(996, 0, 0, 0, 0);
}

script 998 (void) // Jetpack!!
{
	if (jetfuel[PlayerNumber()]) {
		if (jettime[PlayerNumber()] > 70) {
			ThrustThingZ(0, 12, 0, 0);
			ActivatorSound("vile/firecrkl", 127);
		} else {
			ThrustThingZ(0, 8, 0, 0);
			ActivatorSound("vile/firecrkl", 127);
			jettime[PlayerNumber()]++;
		}
		ACS_ExecuteAlways(996, 0, 0, 0, 0);
		jetfuel[PlayerNumber()]--;
		Delay(1);
		if (jeton[PlayerNumber()]) {
			Restart;
		}
	} else {
		jeton[PlayerNumber()] = 0;
		hudmessage (s:"Out of Fuel"; 0, 1, CR_RED, 1.0, 0.1, 3.0);
		delay(5);
		hudmessage (s:""; 0, 1, CR_RED, 1.0, 0.1, 3.0);
		delay(5);
		hudmessage (s:"Out of Fuel"; 0, 1, CR_RED, 1.0, 0.1, 3.0);
		delay(5);
		hudmessage (s:""; 0, 1, CR_RED, 1.0, 0.1, 3.0);
		delay(5);
		hudmessage (s:"Out of Fuel"; 0, 1, CR_RED, 1.0, 0.1, 3.0);
		delay(5);
		hudmessage (s:""; 0, 1, CR_RED, 1.0, 0.1, 3.0);
		delay(5);
		hudmessage (s:"Out of Fuel"; 1, 1, CR_RED, 1.0, 0.1, 1.0, 1.0);
	}
}

script 999 (void) net // Jetpack activation
{
	jeton[PlayerNumber()]++;
	jeton[PlayerNumber()] = jeton[PlayerNumber()] % 2;
	if (jeton[PlayerNumber()]) {
		jettime[PlayerNumber()] = 0;
		ACS_ExecuteAlways(998, 0, 0, 0, 0);
	}
}
Bind your keys as follows:
"puke 999" to activate the jetpack
"puke 996" to view current amount of fuel remaining

You can bind "puke 997 250" to test the jetpack with sv_cheats enabled. If you want to use this in a project, (and I fully encourage it, but please leave a nice credit in the documentation for me,) then you need to give the player fuel by some other means.

Please, let me know what you think.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

It appears that script 999 is a toggle script, so you'd use a button to activate and hit the button again to deactivate. Just to add my two cents, you could also do this (as the script is now) to make a button that you hold down to use the jetpack, and release to stop using it:

alias +jetpack "puke 999"
alias -jetpack "puke 999"
bind X +jetpack
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

HotWax wrote:It appears that script 999 is a toggle script, so you'd use a button to activate and hit the button again to deactivate.
That's right. I don't know if it's possible to make a script only run when you have the button held, but your suggestion is probably a better way to handle it anyway.

Edit: Though if you want to do that, you should remove the auto-shutoff when you run out of fuel, as it would effectively reverse your button action...

Did you try it? What do you think?
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

A simple check for 0 fuel at the beginning of the 999 script would avoid screwing up the bind.

Alternatively, just to be sure the right action is being performed, the 999 script could be split into two; one for on and one for off. The bind would then become:

alias +jetpack "puke 999"
alias -jetpack "puke 1000"
bind X jetpack

Or you could even give 999 one arg that determines whether the key is being pressed or released.

alias +jetpack "puke 999 1"
alias -jetpack "puke 999 0"
bind X jetpack

And no, I haven't had a chance to try it out yet.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Post by Xaser »

I know of another way to make a jetpack that replaaces a weapon. I discovered it completely by accident, and I'm not gonna tell you what it is. It's my secret. Wait For HELLDOOM. :P
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

That's all well and good, but one of the whole points of doing it this way is allowing mid-air fighting. Even though you have to use your imagination for how the jetpack is actually activated since a lot of the weapons are 2-handed, I can forgive that because it is a whole lot of fun.
Locked

Return to “Editing (Archive)”