ScriptUO

Scripting Resources & Utilities => Stealth Client => Topic started by: playforfun on September 03, 2016, 01:14:49 PM

Title: CheckLOS function broken?
Post by: playforfun on September 03, 2016, 01:14:49 PM
Hello, I'm trying to use the function CheckLOS. But it seems not to work, anybody else having this issue?

It's always returning False, even if I'm clearly in LOS.

Code: [Select]
if checkLOS(GetX(self), GetY(self), GetZ(self), GetX(test), GetY(test), GetZ(test), WorldNum) then
  AddToSystemJournal('Target is in sight!');
Title: Re: CheckLOS function broken?
Post by: Crome969 on September 04, 2016, 12:04:50 AM
As far i remember, los calculation on stealth is based on runuo code. Not sure if this is still acurate & its not SDK but stealth framework part..
Title: Re: CheckLOS function broken?
Post by: playforfun on September 04, 2016, 06:50:22 PM
hmm I'm playing on a RunUO server.

I guess I will have to create my own LOS Function, I'm guessing the function is determining if it's in sight based off range and the tile between the two targets?
Title: Re: CheckLOS function broken?
Post by: Crome969 on September 05, 2016, 01:50:24 AM
hmm I'm playing on a RunUO server.

I guess I will have to create my own LOS Function, I'm guessing the function is determining if it's in sight based off range and the tile between the two targets?

Best idea is download runuo\servuo source and check that source, then adapt it.. Thats how i wrote SDK and XScript Framework. The structure is pretty good and it allows to design stuff on a good oop level.
Title: Re: CheckLOS function broken?
Post by: TrailMyx on September 05, 2016, 09:18:41 AM
Best idea is download runuo\servuo source and check that source, then adapt it.. Thats how i wrote SDK and XScript Framework. The structure is pretty good and it allows to design stuff on a good oop level.

Translation: Good Roswell-launching platform!  ;)

#littlegreymencode
Title: Re: CheckLOS function broken?
Post by: Boydon on September 11, 2016, 08:55:51 AM
In standard Pascal script you have to choose the type of emulator your are working with.

Code: [Select]
TLOSCheckType = (losSphere = 1, losSphereAdv = 2, losPOL = 3, losRunUO = 4);
TLOSCheckOption = (losSphereCheckCorners, losPolUseNoShoot, losPolLOSThroughWindow);
TLOSCheckOptions = set of TLOSCheckOption;

Not sure this is exported to external script though...

Modification post edit

I've checked and this seems to be related on the way ScriptSDK is exporting the CheckLOS function. If you look at the stealth_script.pas that is packed with the standard Stelath distro you'll see that the function is exported as following:

Code: [Select]
function Script_CheckLOS(xf, yf : Word; zf : ShortInt; xt, yt : Word; zt : ShortInt; WorldNum : Byte; LOSCheckType : Byte; LOSOptions : Cardinal) : Boolean; stdcall; external ConstScriptDLL name 'Script_CheckLOS';

and the used like this:

Code: [Select]
function TMover.CheckLOS(xf, yf : Word; zf : ShortInt; xt, yt : Word; zt : ShortInt; WorldNum : Byte; LOSCheckType : TLOSCheckType; LOSCheckOptions : TLOSCheckOptions) : Boolean;
var LOSOptions : Cardinal;
begin
LOSOptions := 0;
if losSphereCheckCorners in LOSCheckOptions then
  LOSOptions := $100;
if losPolUseNoShoot in LOSCheckOptions then
  LOSOptions := LOSOptions OR $200;
if losPolLOSThroughWindow in LOSCheckOptions then
  LOSOptions := LOSOptions OR $400;
  Result := Script_CheckLOS(xf, yf, zf, xt, yt, zt, WorldNum,Byte(LOSCheckType),LOSOptions);
end;

@Chrome969
Maybe you should review the ScriptSDK source on this: last two parameters (LOSCheckType and LOSOptions) are missing ;)
Title: Re: CheckLOS function broken?
Post by: playforfun on September 17, 2016, 12:23:37 AM
Nice find, I tried to add the missing parameters but stealth doesn't recognize them and says I have too many =(