Jump to content

Home

Backup Module Files


Recommended Posts

I need help desperately. This is the part of modding that I fear I may have messed up. I used triggers which means I had to replace a module file, but apparently my backup got overwrote by my modded one. So now I can't fix what I was going to. Can anyone please PM so I can give you my email so you can email me danm14ab.Rim and danm14ab_s.rim?

Link to comment
Share on other sites

Ugh.

 

This is the precise reason why I used script injection and NPC perception rather than a trigger in the Sith Stalker spawning for jonathan7.

 

I can send you the files, if you have not got them yet. I am off tomorrow, thank the maker, so drop me a line and I can 7zip them for you and send them your way :)

Link to comment
Share on other sites

Your need for a trigger may have been different than what I needed for my "trigger". There are definitely circumstances where a real trigger is superior to what I did, but here is the gist of what I did.

 

I will cover these bases a little more in-depth when I have my little scripting tutorial polished up - right now it doesn't add much to the tut's that stoffe and tk102 have done, so I am trying to add some in-game examples of ideas their tut's bring up.

 

Anywho, back to my "trigger".

 

All "things" in the KotOR world have UserDefined fields that are built into the item/NPC/placeable, yet they are all commented out when starting from a scratch template. These commented out scripts reside in the generic OnSpawn script. The field I un-commented was the OnPerception field.

 

Basically, when the PC enters the field of perception of said thing, which is a radius that is undefined as far as I know but seems to be about 8-10 meters around the thing, the OnPerception flag is raised. You can then use this to run your UserDefined script.

 

You will probably recall my Holowan thread about Spawning a cloaked NPC and then "uncloak". That thread contains my UserDefined script. Sadly, when LF's database crashed, half of the posts in that thread were destroyed, including the happy conclusion!

 

What needs to happen: A declared integer that corresponds to the OnPerception event is created, and is used in a conditional that sets off the rest of the action - in other words, this is a script-built trigger, sparing us from needing to repack the module....

 

You can search for my thread, the name of it is exactly what is underlined. The following pieces of code are what was needed to make all of this work.

 

This is the area OnEnter, which is how Script Injection works:

void main()
{
  effect eI1 = EffectInvisibility(INVISIBILITY_TYPE_NORMAL);
  effect eI2 = EffectVisualEffect(8000);
  effect eInvis = EffectLinkEffects(eI1, eI2);

  if  (!GetIsObjectValid(GetObjectByTag("qg_sithstalker")))
  {
     CreateObject(OBJECT_TYPE_CREATURE, "qg_sithstalker", Location(Vector(76.90,84.12,0.00), 0.0));
     object oStalker=GetObjectByTag("qg_sithstalker");
     ApplyEffectToObject(3, eInvis, oStalker, -1.0);
     }
 ExecuteScript("qg_pnd_1b_area", OBJECT_SELF);
}

 

This is the custom OnSpawn script:

//:: 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 ) ****************************************************************************
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_CIRCULAR);
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_ONCE);
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_PATH);
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_RANDOM);
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_RUN);
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_STOP);         //Causes the creature to pause for 1 - 3 seconds at a waypoint
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_STOP_LONG);    //Causes the creature to pause for 6 - 12 seconds at a waypoint
    //GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_STOP_RANDOM);  //Causes the creature to pause for 1 - 12 seconds at a waypoint
    //GN_SetWalkWayPointsSeries(1); //If this function is uncommented a number from 1 to 99 must be passed. This number represents
                                    //a waypoint series that uses the string "01" through "99" instead of the creature's tag.
                                    // eg. WP_22_01 through WP_22_05.  22 is the series number set with this function.

    //GN_SetSpawnInCondition(SW_FLAG_COMMONER_BEHAVIOR);
    //GN_SetSpawnInCondition(SW_FLAG_FAST_BUFF);
    //GN_SetSpawnInCondition(SW_FLAG_AMBIENT_ANIMATIONS);
    //GN_SetSpawnInCondition(SW_FLAG_AMBIENT_ANIMATIONS_MOBILE);
               //This will play Ambient Animations until the NPC sees an enemy or is cleared.
               //NOTE that these animations will play automatically for Encounter Creatures.

    //GN_SetSpawnInCondition(SW_FLAG_ON_DIALOGUE_COMPUTER);
               //When a creature with this flag is talked to a computer dialogue will come up instead of the usual screens.
// CUSTOM USER DEFINED EVENTS
/*
   The following settings will allow the user to fire one of the blank user defined events in the NW_D2_DefaultD.  Like the
   On Spawn In script this script is meant to be customized by the end user to allow for unique behaviors.  The user defined
   events user 1000 - 1010
*/
   //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBEAT);        //OPTIONAL BEHAVIOR - Fire User Defined Event 1001
   [color=darkorange]GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_PERCEPTION);       //OPTIONAL BEHAVIOR - Fire User Defined Event 1002[/color]
   //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_SetDayNightPresence(AMBIENT_PRESENCE_ALWAYS_PRESENT);

   GN_SetListeningPatterns();  //This function although poorly named sets up the listening patterns and other important data for the
                               //creature it should never be removed.
   GN_WalkWayPoints();
}

The beauty of this is that all of that code and functionality is built and written by Bioware... just had to delete two backslashes in the line I colored dark orange.

 

This, finally, is the script I used for the event that the Stalker has perceived something entering her perception:

// * qg_stalkpercp.nss
// * Jan 06 2011 
// * This is for the UserDefinedEvent slot, or can be broken up from here
//    into several smaller dialog slot scripts 

void main()
{
 int nEvent = GetUserDefinedEventNumber();   // OnPerception
 effect eUncloak = EffectVisualEffect(8001); // VFX_DUR_CLOAK_REMOVAL, is FNF 

 if (nEvent == 1002)       
 {
    object oPC=GetFirstPC();
    object oStalker=GetObjectByTag("qg_sithstalker");
    effect eCurrent = GetFirstEffect(oStalker);

    while (GetIsEffectValid(eCurrent))       
    {
       if (GetEffectType(eCurrent) == EFFECT_TYPE_INVISIBILITY)    
       {
          DelayCommand(1.5, RemoveEffect(oStalker,eCurrent));
       }
       eCurrent = GetNextEffect(oStalker);
    }

    DelayCommand(0.5, AssignCommand(oStalker, ActionMoveToObject(oPC)));
    DelayCommand(2.0, ApplyEffectToObject(0, eUncloak, oStalker));
    DelayCommand(4.0, AssignCommand(oStalker,ActionStartConversation(oPC,"sithstalking",CONVERSATION_TYPE_CINEMATIC))); 
 }
}

 

So, there is an example of how this can be achieved. Hopefully this will provide some hints for you. tk102 has a little tutorial, actually mostly just a link to David Gaider's explanation of User Defined Events, that got me started in this direction.

 

I will now check my pm's, and hopefully pack up the module files you need and send them your way :)

EDIT: Files sent, happy modding!

 

EDIT2: In this case, the OnPerception event was used to make the Sith Stalker approach the PC, uncloak, and initiate a dialog. You could do this with a placeable, an invisible one even, if you only needed something to "happen" when crossing said perception zone/trigger. A quest could be updated, a new music could be triggered to play, a forcefield could be spawned, etc. The key difference between this approach and a trigger are these: The area OnEnter must be replaced with your custom one, which will then link to the original OnEnter. This spawns your thing, putting it into the module by "injecting" it into the area. This way, no .utt is necessary, and no editing or replacing of module files is necessary.

Link to comment
Share on other sites

Generally, it's safer to compile your modules as .mod files. This way, you don't erase the original file, and can still access your module in-game. As an added bonus, there appears to be no in-game difference between using a .rim and a .mod (except that, for some reason, you need two .rim files where you only need one .mod).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...