Jump to content

Home

Need help with mod


wasa7

Recommended Posts

Right now, what I'm trying to do is to spawn some Sith Troopers and some Battle Droids in the Sith Base, right after you kill the Sith Governor so the party can't scape so easily from the Sith Base. I compiled this code without errors but I can't make it trigger because I can't figure what's the correct entering .ncs file of the area. Any ideas?

 

As far as I can tell the Sith Base area has no standard OnEnter event script assigned, so if you want to use one you will have to create your own and then assign it to the area's OnEnter event slot in the m09aa.are file.

 

 

This would be found in the file tar_m09aa.rim, extract it, open it with k-gff and put the name of your script (without the .ncs extension) in the OnEnter field. Save the m09aa.are file and put it back into the tar_m09aa.rim file.

 

(If you want to release your mod to others though it might be better to use a mod installer to handle modifying the ARE and RIM file if you are concerned about compatibility with other mods modifying the same area. If you don't care about that you'll have to ship the modified tar_m09aa.rim file with your mod instead.)

 

I'd also suggest you add a condition check to the script to ensure that it only runs once, otherwise a new batch of droids and troopers would be spawned every time you re-enter the area (either by area transition or by loading a savegame inside the area). Something like this should work:

 

int HasShieldCodes();
object SpawnNPCAtLocation(string sResRef, float x, float y, float r);

void main()  {
   //If PC enters the area and if Sith Codes are available, then spawn creatures
   if ((GetEnteringObject() == GetFirstPC()) 
       && !GetLocalBoolean(OBJECT_SELF, 40)
       && (HasShieldCodes())) 
   {
       SpawnNPCAtLocation("x_sith_1",          35.36,       12.84,     0.0);
       SpawnNPCAtLocation("x_sith_2",          34.38,       10.69,     0.0);
       SpawnNPCAtLocation("x_battle_droid",    37.08,       11.28,     0.0);

       SpawnNPCAtLocation("x_sith_1",           6.20,       33.59,     0.0);
       SpawnNPCAtLocation("x_sith_2",           1.37,       33.23,     0.0);
       SpawnNPCAtLocation("x_battle_droid",     4.15,       31.15,     0.0);
       SpawnNPCAtLocation("x_battle_droid",     2.77,       36.19,     0.0);

       SpawnNPCAtLocation("x_sith_1",          -3.50,      -14.25,     0.0);
       SpawnNPCAtLocation("x_sith_1",          -3.22,      -15.40,     0.0);
       SpawnNPCAtLocation("x_sith_2",           6.44,      -15.26,     0.0);
       SpawnNPCAtLocation("x_battle_droid",    -5.69,      -14.66,     0.0);

       SetLocalBoolean(OBJECT_SELF, 40, TRUE);
   }
}

//Used for easy creature spawning (ResRef, x-coord, y-coord, facing)
object SpawnNPCAtLocation(string sResRef, float x, float y, float r) {
   return CreateObject(OBJECT_TYPE_CREATURE, sResRef, Location(Vector(x, y, 0.0), r));
}

//Used to check is Sith Codes are available
int HasShieldCodes() {
  return GetIsObjectValid( GetItemPossessedBy(GetFirstPC(), "ptar_shieldcodes") );
}

Link to comment
Share on other sites

Hello Stoffe, as usual, thank you for answering.

 

As far as I can tell the Sith Base area has no standard OnEnter event script assigned, so if you want to use one you will have to create your own and then assign it to the area's OnEnter event slot in the m09aa.are file.

 

The code above can be used as an OnEnter script or should I create one that calls the script you just gave me?

 

This would be found in the file tar_m09aa.rim, extract it, open it with k-gff and put the name of your script (without the .ncs extension) in the OnEnter field. Save the m09aa.are file and put it back into the tar_m09aa.rim file.

 

Found it, found the OnEnter field. When I save that file, where should I put it back? I believe it's not into the Override Folder. Back into the tar_m09aa.rim? How should I do that?

 

When I have this running, I'll think how to use the ModInstaller instead of just draging all the file into the Override Folder. Thank you again Stoffe!

Link to comment
Share on other sites

The code above can be used as an OnEnter script or should I create one that calls the script you just gave me?

 

That posted script can be used as an OnEnter event script, no need or point to call it from other scripts.

 

 

Found it, found the OnEnter field. When I save that file, where should I put it back? I believe it's not into the Override Folder. Back into the tar_m09aa.rim? How should I do that?

 

There are three ways to go about it that I can think of:

  1. Put the modified ARE file back into the tar_m09aa.rim file you extracted it from. Then you'll need to ship this modified RIM file with your mod files at all. You can use the simple ERF/RIM Editor I made a while ago for this, there might be other tools as well that escapes my mind at the moment. I don't know if the latest version of KotorTool allows you to edit RIM files, the one I have (a few versions old) does not, AFAIK.
     
     
  2. Use a mod installer to modify the ARE file in place inside the RIM file that already exists in the end mod user's game, then you don't need include the RIM file at all. TSLPatcher can do this. I don't remember if KISS can since I only looked at that one briefly a number of months ago.
     
     
  3. Extract all data from both tar_m09aa.rim and tar_m09aa_s.rim and repackage it all (your modified ARE file included) into a tar_m09aa.mod file instead, and ship that one with your mod files. You can do this with KotorTool.

 

It can be risky to put ARE files in the override folder so I wouldn't recommend doing that. (On the same note, never put any .GIT files or a module.ifo file in the override folder, or bad things will happen.)

Link to comment
Share on other sites

Hello Stoffe, how are you?

I've been bussy this week and I didn't have the time to work on the mods as I usually do. I found a little too complicated to put the OnEnter script into the Sith Base area so I decided to drop it, meaning that the Sith Base will remaing empty as the PC runs out from it.

 

What I decided is to spaw some Sith Troppers and a new character I'm making just outside the Sith Base. I'm working on a Dark Jedi Quarren (who will be the master of the Sith Governor) for wich I have modified the already existing skinn n_alien02_low. When renaming the skinn, how do I do to put it on a character? I've checked the .utc file in the appearance section but I'm not really sure if that what I'm looking for.

Link to comment
Share on other sites

I'm working on a Dark Jedi Quarren (who will be the master of the Sith Governor) for wich I have modified the already existing skinn n_alien02_low. When renaming the skinn, how do I do to put it on a character? I've checked the .utc file in the appearance section but I'm not really sure if that what I'm looking for.

 

While I'm not 100% sure, I believe you will need to add a new line to the appearance.2da for your modified Quarren. Copy the existing line for the quarren and paste it at the end. Then change the name in the racetex column to use your modified texture instead. Save the modified appearance.2da in your override folder, and modify the UTC file for your quarren to point to the line number of your new row in the Appearance_Type field.

 

When testing, make sure you use a savegame made before the NPC was spawned, otherwise your changes will not take effect.

Link to comment
Share on other sites

Hello Stoffe, so far I'm doing good with the project. I have spawned the Sith Soldiers and the Quarren Dark Jedi, I've made the dialog between the PC and the quarren and I just have to put the scripts to make it all work.

 

I have one question: Is there a function that make a NPC flourish his weapon wich can be triggered from a dialog? My idea is, while they are talking, the Dark Jedi flourish his lightsaber right before the last line, and before battle begins. Can it be done?

Link to comment
Share on other sites

I have one question: Is there a function that make a NPC flourish his weapon wich can be triggered from a dialog? My idea is, while they are talking, the Dark Jedi flourish his lightsaber right before the last line, and before battle begins. Can it be done?

 

Not in KotOR1, as far as I am aware. In KotOR2:TSL there is a function called CreatureFlourishWeapon() that does what you want, but that function is new to the scripting language in the second game and doesn't exist in the first, AFAIK.

 

You might be able to do it "the hard way" though with the PlayAnimation() and SetLightsaberPowered() functions, if you can figure out the animation number for the Flourish animation.

Link to comment
Share on other sites

  • 2 weeks later...

Hello again Stoffe, sorry to bother you again. I've been off for a few days but now I'm retaking the work I left unfinished. I've succesfully achieved to trigger scripts once the player party leaves the Sith Base with the Sith Codes. I've spawned some Sith Soldiers here and there, they are aready hostile when spawned, and turned the Lower City Elevator Sith Guard also hostile. The thing is that when PC enters the area, all enemies just stand there, and do nothing. They attack only if I attack first. What should I do to correct this? Also, is there a script to fully heal all party members that I could trigger when I enter an area? Thanks in advance!

 

EDIT: I discovered that the reason for they to stand and do nothing is a script you came up some time ago, that I used for Agent Xim's Operation Kill Bastila Mod. If I remove those OnPerceit script, bad guys attack me perfectly. What I will try to make that scrip to work only when need it and then to turn off. I hope that is possible.

Link to comment
Share on other sites

Also, is there a script to fully heal all party members that I could trigger when I enter an area?

 

If you want to fully heal all party members, you can do that with a script like:


void ST_HealActor(object oTarget);


[color=PaleGreen]
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ST: Main function...
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[/color]
void main() {
   int i;

   for (i = 0; i < GetPartyMemberCount(); i++) {
       ST_HealActor(GetPartyMemberByIndex(i));
   }
}

[color=PaleGreen]
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ST: Support function - remove harmful effects from character
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[/color]
void ST_RemoveBadEffects(object oTarget) {
   effect eEff = GetFirstEffect(oTarget);
   while (GetIsEffectValid(eEff)) {
       int iType = GetEffectType(eEff);
       if ((iType == EFFECT_TYPE_POISON)   
           || (iType == EFFECT_TYPE_PARALYZE)
           || (iType == EFFECT_TYPE_STUNNED)
           || (iType == EFFECT_TYPE_FRIGHTENED)
           || (iType == EFFECT_TYPE_SLEEP)
           || (iType == EFFECT_TYPE_ABILITY_DECREASE)
           || (iType == EFFECT_TYPE_ATTACK_DECREASE)
           || (iType == EFFECT_TYPE_AC_DECREASE)
           || (iType == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE)
           || (iType == EFFECT_TYPE_SAVING_THROW_DECREASE)
           || (iType == EFFECT_TYPE_DAMAGE_DECREASE)
           || (iType == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE)
           || (iType == EFFECT_TYPE_FORCE_RESISTANCE_DECREASE)
           || (iType == EFFECT_TYPE_SKILL_DECREASE)
           || (iType == EFFECT_TYPE_BLINDNESS)
           || (iType == EFFECT_TYPE_ENTANGLE)
           || (iType == EFFECT_TYPE_CONFUSED))
       {
           DelayCommand(0.1, RemoveEffect(oTarget, eEff));
       }
       eEff = GetNextEffect(oTarget);
   }   
}

[color=PaleGreen]
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ST: Heal character of injuries and afflictions
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[/color]
void ST_HealActor(object oTarget) {
   [color=PaleGreen]// ST: Revive if dead[/color]
   if (GetIsDead(oTarget)) 
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oTarget);

   [color=PaleGreen]// ST: Restore Health[/color]
   int iHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget);
   if (iHeal > 0)
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(iHeal), oTarget);

   [color=PaleGreen]// ST: Restore force points[/color]
   iHeal = GetMaxForcePoints(oTarget) - GetCurrentForcePoints(oTarget);
   if (iHeal > 0)
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHealForcePoints(iHeal), oTarget);  

   [color=PaleGreen]// ST: Remove harmful effects[/color]
   ST_RemoveBadEffects(oTarget);

   [color=PaleGreen]// ST: Show heal visual on target.[/color]
   ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEAL), oTarget);
}

 

I discovered that the reason for they to stand and do nothing is a script you came up some time ago, that I used for Agent Xim's Operation Kill Bastila Mod.

 

Is your custom script always running ExecuteScript("k_ai_master", OBJECT_SELF, 1002); no matter what else happens? Make sure that even if this line exists that it's always reachable (i.e. the script doesn't return before reaching it in some circimstances.

 

By your description it sounds like the standard OnPerception AI doesn't run, which is what makes an NPC attack when they spot an enemy. The above mentioned line runs the standard OnPerception AI and should always be called in any custom OnPerception AI scripts you use, either before or after your new script code.

Link to comment
Share on other sites

Thanks again Stoffe, I think I would have quit modding if it wasn't for you. I plan moving from this thread to another one I just created yesterday. It's called scripting help. I hope to see you there when I ask for help hahaha.

 

I will test the healing script above and tell you if it worked. About the script always running, you might be right about the original OnPerception AI script not always running. The thing is that the conditionals that trigger custom script are the same than when PC comes out the Taris Sith Base. I plan of using some custom boolean as you thaugh me to make a difference between the time before and after entering Sith Base. I would check if k_ai_master is running or not. Thank you again!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...