WorldScript Jump Countdown Events

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

WorldScript Jump Countdown Events

Post by Thargoid »

Can someone with access to the code confirm what the world script events for beginning and cancelling a witchspace jump should be?

In the wiki they're listed as this.playerStartedJumpCountdown = function(type) and this.playerCancelledJumpCountdown = function() respectively, but neither of those work.

I've also looked in Ahruman's old Javascript example OXP which has this.didBeginJumpCountDown = function(type) and this.didCancelJumpCountDown but they don't work either.

Can anyone shed light on what does work for 1.72.1, and also for 1.72 and 1.71.2 if possible? I want the events for the start of and for the cancellation of a jump (standard or galactic), not when one is completed (the start of the countdown, not the end of it).
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Its a large Function, since this is the flight control function, however
it does seem to send of the script events that should trigger those respective events...

Here is the code snippet...

Code: Select all

					if (status == STATUS_WITCHSPACE_COUNTDOWN)
					{
						// abort!
						jumpOK = NO;
						galactic_witchjump = NO;
						status = STATUS_IN_FLIGHT;
						[self playHyperspaceAborted];
						// say it!
						[UNIVERSE clearPreviousMessage];
						[UNIVERSE addMessage:DESC(@"witch-user-abort") forCount:3.0];
						
						[self doScriptEvent:@"playerCancelledJumpCountdown"];
					}
					
					if (jumpOK)
					{
						galactic_witchjump = NO;
						witchspaceCountdown = 15.0;
						status = STATUS_WITCHSPACE_COUNTDOWN;
						[self playStandardHyperspace];
						// say it!
						[UNIVERSE clearPreviousMessage];
						[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-to-@-in-f-seconds]"), [UNIVERSE getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
						
						[self doScriptEvent:@"didBeginJumpCountDown" withArgument:@"standard"];
					}
				}
				hyperspace_pressed = YES;
			}
			else
				hyperspace_pressed = NO;
			
			// Galactic hyperspace 'g'
			if (([gameView isDown:key_galactic_hyperspace] || joyButtonState[BUTTON_GALACTICDRIVE]) &&
				([self hasEquipmentItem:@"EQ_GAL_DRIVE"]))// look for the 'g' key
			{
				if (!galhyperspace_pressed)
				{
					BOOL	jumpOK = YES;
					
					if (status == STATUS_WITCHSPACE_COUNTDOWN)
					{
						// abort!
						jumpOK = NO;
						galactic_witchjump = NO;
						status = STATUS_IN_FLIGHT;
						[self playHyperspaceAborted];
						// say it!
						[UNIVERSE clearPreviousMessage];
						[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[witch-user-abort]") forCount:3.0];
						
						[self doScriptEvent:@"playerCancelledJumpCountdown"];
					}
					
					if (jumpOK)
					{
						galactic_witchjump = YES;
						witchspaceCountdown = 15.0;
						status = STATUS_WITCHSPACE_COUNTDOWN;
						[self playGalacticHyperspace];
						// say it!
						[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-galactic-in-f-seconds]"), witchspaceCountdown] forCount:1.0];
						
						[self doScriptEvent:@"playerStartedJumpCountdown" withArgument:@"galactic"];
					}
				}
				galhyperspace_pressed = YES;
			}
I´ll make a quick script, to confirm your results, if not, there is something else wrong...
Bounty Scanner
Number 935
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

This is how I'm trying to use them in my code (a Javascript script.js):

Code: Select all

this.playerStartedJumpCountDown = function(type)
	{
	player.consoleMessage("Hey, why are we going to witchspace?", 6);
	missionVariables.planetFallTaxiOffer = "Worried";
	}

this.playerCancelledJumpCountDown = function()
	{
	if(missionVariables.planetFallTaxiOffer == "Worried")
		{
		player.consoleMessage("Thanks, I only wanted to go locally!", 6);
		missionVariables.planetFallTaxiOffer = "Hired";
		}
	}
Quite simple as you can see, but if I start a jump I don't get the consoleMessage for example. It's for the little intra-system taxi script I was mentioning for PlanetFall.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

It seems

Code: Select all

this.playerStartedJumpCountdown = function()
{
	log("this.playerStartedJumpCountdown triggerd")
}

Only works for galactic hyperspace

while

Code: Select all


this.didBeginJumpCountDown = function()
{
	log("this.didBeginJumpCountDown triggerd")
}

this.playerCancelledJumpCountdown =function()
{
	log("this.playerCancelledJumpCountdown triggerd")
}
only this.playerCancelledJumpCountdown =function()

works for both normal witchspace jump and galactic hyperspace

so this.didBeginJumpCountDown is broken
Bounty Scanner
Number 935
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

It is broken because in PlayerEntityControls.m, the gal hyper event is triggered as playerStartedJumpCountdown (correct as per wiki), but the standard jump one is triggered as playerStartedJumpCountDown (wrong, has capital D in countdown). It will still work if you make a handler this.playerStartedJumpCountDown, but it certainly needs fixing to conform to both wiki and logic.

The code posted by Frame must be from an older version, the 1.72.1 code does not have the didBeginJumpCountDown anywhere.

Will be commiting the fix shortly. I wish all bugs could be so simple....
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

hmmm gotta delete that code... sry :oops:

Forgot to change paths in Ultra edit...so it searched in the old 1.71.2 code,,,

But I can confirm it works with the capital D for normal witch space
Bounty Scanner
Number 935
Post Reply