View Single Post
Old 09-21-2011, 06:28 AM   #3
Qui-Gon Glenn
Royal Nonesuch
Qui-Gon Glenn's Avatar
Join Date: May 2007
Location: Irune
Posts: 1,472
Current Game: KotOR awww yeah
Folder extraordinaire Helpful! Forum Veteran Veteran Modder 
The current script I am working on is related to an earlier script I did for j7 when we first were spawning his fantastic Sith Stalker skin. We had fun making a baby mini-mod out of it, with some basic cinematics.

The gist - this script will make folks "appear from nowhere" just uncloaking in your face... and I mean IN YOUR FACE, as they will attack you immediately.

The script will not do it all alone - your NPC would need to be spawned in however you chose and given the effect of invisibility (real easy, just add in EffectInvisibility(oYourNPC) to the spawn script), and then s/he or they (plural FTW ) would need a custom OnSpawn script allowing for perception to be opened. It is a simple cut&paste of the script k_def_spawn but with the "//" removed in front of the line for OnPerception events. Finally my handy script goes into the OnPerception slot of your .utc.

I post this script, for two reasons. One, I know it works and can be used to do several different jobs with just minor alteration. Two, I hope that someone that has used TimBob12's Populate Function will go ahead and use this custom UserDefined script for a .utc of your choice and populate the hell out of 'em. Then go ahead and warp into that area and it's a total free-for-all, but enemies will only appear as you near them.

The obvious test room would be the Rakatan Prison module.... Combining the two makes stealthy angry Mandalorians or Sith A.... Sneaky sith people appear wherever you go!

Custom OnSpawn:
//:: k_def_spawn01
//:: v1.0, Default On Spawn In
//:: Created By: Preston Watamaniuk, Copyright (c) 2002 Bioware Corp.

#include "k_inc_generic"
#include "k_inc_debug"

void main()
// WALK WAYPOINT BEHAVIORS (Comment In or Out to Activate ) ****************************************************************************
/* I cut this section out as in this use of the script it is not necessary.
   If you need to have these behaviors in for a spawn, simply use the original
   provided in scripts.bif. As it is, this script will compile and work
   just fine for this purpose, just not all purposes  */


    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBEAT);        //OPTIONAL BEHAVIOR - Fire User Defined Event 1001
    GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_PERCEPTION); //BEHAVIOR WE NEED - Fire User Defined Event 1002
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_ATTACKED);         //OPTIONAL BEHAVIOR - Fire User Defined Event 1005
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED);          //OPTIONAL BEHAVIOR - Fire User Defined Event 1006
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DISTURBED);        //OPTIONAL BEHAVIOR - Fire User Defined Event 1008
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_COMBAT_ROUND_END); //OPTIONAL BEHAVIOR - Fire User Defined Event 1003
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DIALOGUE);         //OPTIONAL BEHAVIOR - Fire User Defined Event 1004
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DEATH);            //OPTIONAL BEHAVIOR - Fire User Defined Event 1007
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DISTURBED);        //OPTIONAL BEHAVIOR - Fire User Defined Event 1008
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_BLOCKED);          //OPTIONAL BEHAVIOR - Fire User Defined Event 1009
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_FORCE_AFFECTED);   //OPTIONAL BEHAVIOR - Fire User Defined Event 1010
    //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DIALOGUE_END);     //OPTIONAL BEHAVIOR - Fire User Defined Event 1011

// DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) *****************************************************************************************


    GN_SetListeningPatterns();  //This function although poorly named sets up the listening patterns and other important data for the
                                //creature it should never be removed.
Custom UserDefined:
// qg_ambush.nss
// 9-21-2011 

void main()
   object oSelf = OBJECT_SELF;
   effect eUncloak = EffectVisualEffect(8001);
   effect eCurrent = GetFirstEffect(oSelf);
   int nEvent = GetUserDefinedEventNumber();   // OnPerception
   if (nEvent == 1002)
      while (GetIsEffectValid(eCurrent))       
         if (GetEffectType(eCurrent) == EFFECT_TYPE_INVISIBILITY)    
            DelayCommand(1.5, RemoveEffect(oSelf, eCurrent));
         eCurrent = GetNextEffect(oSelf);
      DelayCommand(2.0, ApplyEffectToObject(0, eUncloak, oSelf)); 
      ChangeToStandardFaction(oSelf, 1);
      ExecuteScript("k_ai_master", oSelf, 1005);

Want to play a game of ME3MP?

Last edited by Qui-Gon Glenn; 09-22-2011 at 12:50 AM.
Qui-Gon Glenn is offline   you may: quote & reply,