[FIXED] JS Event onFall exists in code, but is not used by UOX3

Here we stuff all the bugs we've managed to squash/squish/squelch.
Post Reply
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

JS Event onFall exists in code, but is not used by UOX3

Post by Xuri »

I noticed that the JS Event onFall (for when a character falls) exists in the UOX3 source, but it is not referenced anywhere, and thus can't be used in JavaScripts.

I also noted that my character said "ouch!" when falling down, even though this word is not present in UOX3, in neither source nor dictionary files. In other words - a client feature?
Last edited by Xuri on Sun Jan 18, 2009 7:49 pm, edited 3 times in total.
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

What is considered a fall? Easy enough to do if it's known. Is it just the change of height from high to low rapidly?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

I'm not sure :P I guess there would have to be a certain minimum change in altitude required for it to trigger, or it would perhaps trigger every time someone walked down stairs or down steep terrain?
-= Ho Eyo He Hum =-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

The client triggers an automatic "Ouch!" message and sound-effect when falling from heights taller than 22, so I reckon we could use the same as basis to trigger the onFall JS event?
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

This would be the WalkZ func in CChar. Put the hook in here if (z-oldz) > MAX_Z_FALL.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hm. Okay, I managed to get it working ingame using the following:

Code: Select all

void CChar::WalkZ( SI08 newZ )
{
	bool JSEventUsed = false;

	oldLocZ = z;
	z		= newZ;
	UI08 fallDistance = oldLocZ - z;

	if( fallDistance > MAX_Z_FALL )
	{
		const UI16 FallTrig = GetScriptTrigger();
		cScript *toExecute = JSMapping->GetScript( FallTrig );
		if( toExecute != NULL )
			JSEventUsed = toExecute->OnFall( (this), fallDistance );
		
//		return JSEventUsed;
	}
}
See anything glaring errors? =P
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Nope, you fixed my variable ordering problem :)
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Alrighty, it's up on the CVS then. :)
-= Ho Eyo He Hum =-
Post Reply