RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

A note on overriding the Target class

Zippy

Razor Creator
A note on overriding the Target class

I notice a lot of these scripts are using targets, and are checking CanSee, and I wanted to let everyone know that the Target base class checks this before calling OnTarget....

The target base class will call OnCantSeeTarget( Mobile from, object targeted ) if the target is out of range (or in the future if there is no line of sight)

The fucntions default behavor is to display the "Target cannot be seen" message, and thus there is no need to ever override this function if that's all you want to do...

Also there's an OnTargetOutOfRange( Mobile from, object targeted ) which is called by the base class when the target is out of range, it's default behavoir is to send message 500446 (That is too far away.)

This isn't a big issue now because we don't have line of sight yet, but when line of sight is implimented we aren't going to want to have extra calls to CanSee that will slow down the server.


These function prototypes are also available in the docs at : http://www.runuo.com/docs/Types/type_8.html
 

krrios

Administrator
Relating to spells, CanSee() was included in a spell's Target() function when Target classes were only available to NetStates (not NPC-AIs). Eventually (probably come LoS), we'll remove the redundant checks.
 
Top