View Single Post
Old 03-30-2013, 09:36 PM   #14
Fair Strides 2
Junior Member
Fair Strides 2's Avatar
Join Date: Jan 2012
Location: Oregon, United States
Posts: 495
Current Game: Master of Orion 2
Originally Posted by arsenalforever View Post
Is the second parameter of ExecuteScript() always OBJECT_SELF?

What does the GetLastPerceived() function do?

And I get an error when I'm compiling the first script. The error has something to do with the compiler not being able to identify KOTOR_DEFAULT_EVENT_ON_HEARTBEAT. Also, why have you not used KOTOR_DEFAULT_EVENT_ON_HEARTBEAT parameter in the if condition?

Thanks for your reply
1. You don't have to, but the second parameter is the target that calls the script. The caller is used by a lot of functions, but an example is giving the parameter as:

object oAtton = GetObjectByTag("atton");
ExecuteScript("k_ai_master", oAtton, 1001);
This will make any instances of "OBJECT_SELF" be Atton.

2. The GetLastPercieved() function will return the last creature percieved through any means. It will return the most recent creature detected by hearing, seeing, or a combination of a lack of one or the other. If you want to be more specific, there are functions to get the last percieved thing by sight or hearing(GetLastPercievedHeard() and GetLastPercievedSeen()).

3. There is a code loop syntax called the switch statement. It will take an integer variable and execute a section of code based on that integer. Here's a sample of code from K_ai_master to show you:

        int KOTOR_DEFAULT_EVENT_ON_HEARTBEAT           = 1001;
        int KOTOR_DEFAULT_EVENT_ON_PERCEPTION          = 1002;
        int KOTOR_DEFAULT_EVENT_ON_ATTACKED            = 1005;
        int KOTOR_DEFAULT_EVENT_ON_DAMAGE              = 1006;
        int KOTOR_DEFAULT_EVENT_ON_DEATH               = 1007;
        int KOTOR_DEFAULT_EVENT_ON_DISTURBED           = 1008;
        int KOTOR_DEFAULT_EVENT_ON_BLOCKED             = 1009;
        int KOTOR_DEFAULT_EVENT_ON_PATH_BLOCKED        = 1012;
So, for your compile error, try replacing the "KOTOR_DEFAULT_EVENT_ON_HEARTBEAT" with "1001".

Also, I didn't use it in the if conditional because it wasn't needed. The script is the OnHeartbeat, so there's no point in calling the script your currently running.

4. And no problem. I'm happy to share my scripting knowledge.

Always remember modders: "Quality= Effort*Time"

Originally Posted by Jae Onasi
Hi! I messaged him on Facebook and got this answer: "Sure if he wants to release a new KSE, no problem. I'm surprised he was able to find all the perl modules. I released them a long time ago but they were buried somewhere in the KSE thread." So, go for it--please give him credit for the original work, though!
KSE 3.3.4 is LIVE!!! Check it out here.

12/13/13 -- Fixed KSE 3.3.4 bugs. Please check the above link.
Fair Strides 2 is offline   you may: quote & reply,