Page 1 of 1
JS Event onFall exists in code, but is not used by UOX3
Posted: Wed Jul 19, 2006 9:05 am
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?
Posted: Wed Jul 19, 2006 3:15 pm
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?
Posted: Wed Jul 19, 2006 8:13 pm
by Xuri
I'm not sure

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?
Posted: Wed Jul 02, 2008 2:27 am
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?
Posted: Wed Jul 02, 2008 2:24 pm
by Maarc
This would be the WalkZ func in CChar. Put the hook in here if (z-oldz) > MAX_Z_FALL.
Posted: Wed Jul 02, 2008 8:21 pm
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
Posted: Thu Jul 03, 2008 6:37 am
by Maarc
Nope, you fixed my variable ordering problem

Posted: Thu Jul 03, 2008 10:25 pm
by Xuri
Alrighty, it's up on the CVS then.
