PDA

View Full Version : Tainted Jedi Robes


VarsityPuppet
07-11-2009, 12:18 AM
Some people like to have "dark" versions of jedi robes. It's a valid desire indeed, but too often people just adopt a black color scheme.

For one of my mods, I had the mind to make all white-themed items. Then I realized that "white" doesn't fulfill the dark-side robe requirement.

Then my brain exploded... with a groundbreaking idea!

and thus the tainted Jedi robes were born.


http://h.imagehost.org/0258/Tainted1.jpg

http://h.imagehost.org/0016/Tainted2.jpg

And of course, I can never be satisfied with anything simple.

What I wanted to do was make the tainted robes actually change your alignment when worn. Is this possible with scripting, or is this a 2da edit? Can it be done simply by equipping the item? If not.. well, it's not the end of the world, but it would be cool.

Also, would any of you want to see other tainted items?

TriggerGod
07-11-2009, 10:59 AM
You can easily make a new item using the Tainted robe's texture as the variation (you should know how to do this) and make it Dark Side only, making your white robes... Light Side. If you placed them, you should put your white robes on Dantooine, and the tainted on Korriban.

VarsityPuppet
07-11-2009, 02:06 PM
You can easily make a new item using the Tainted robe's texture as the variation (you should know how to do this) and make it Dark Side only, making your white robes... Light Side. If you placed them, you should put your white robes on Dantooine, and the tainted on Korriban.



Way ahead of ya... well, except until earlier today, I didn't know how to spawn/remove things in modules. But first, I wanted to see if there was a way to make the robes actually change your alignment when you equip them.

gsusfrk
07-11-2009, 03:15 PM
There may be a way. If it's possible to modify the script that runs when you equip an item, you can first check to see if the item in question is your tainted robe (a conditonal). If it is, change the PC's alignment and equip the item. If it isn't, equip the item and do nothing. Unfortunately I don't know what the script is called or where it's located, or even if you could modify it if you found it, as it may be in nss (compiled) form. This will involve editing the game's original files (the equip item script) and placing it in override, but if you set the conditional correctly, you shouldn't have a problem. I'll see if I can find the game's script in question and possibly write a new script. What game is this for, TSL or KotOR?

P.S. Nice texture job!

VarsityPuppet
07-11-2009, 07:58 PM
It's for TSL. What I want it to do is to alter the alignment to the dark side by 25-30 points, but only when equipped. Once they're removed, your alignment should return to normal.

I figured it would be something with scripting.. I just don't know enough about it to know what's possible.

gsusfrk
07-11-2009, 10:58 PM
I looked into this for you, and it will involve both 2da editing and scripting, but it's not as hard as it sounds. I'll walk you through it.

Use KOTOR Tool to open Bifs-> 2da.bif -> 2D Array -> globalcat.2da. Open globalcat, and the 2DA editor of KOTOR Tool will open up. Scroll all the way down until you see the last row. You can see that there is a empty line at the bottom. In the name column, type "taintedRobesOn" or something. It can really be anything. It could be "waffles", but the point is to name it to something you'll remember. After that, type in "999", or whatever the next row is in the row column, and Boolean in the type column. Next, type in "taintedRobesOff" into a new row, followed by a "1000" or whatever the next row is into the row column, and Boolean into the type column. Press Ctrl+S and save the file as "globalcat.2da" into your override folder.

Let me explain what you just did. Globalcat.2da is a file listing a bunch of what are called global variables that the game uses. These change throughout the game, but remain active during the entire course of the game (they're never unavailable or lost as local variables are). As you may have guessed, you have just created your own two global variables, taintedRobesOn and Off. These will be used by our own script to determine if you've equipped your tainted robes or not.

Open up KOTOR Tool's text editor (the TXT button) and copy the following into it:


//:: k_def_heartbt01
/*
Default heartbeat script
*/
//:: Created By: Preston Watamaniuk
//:: Copyright (c) 2002 Bioware Corp.

#include "k_inc_switch"
#include "k_inc_debug"

void main()
{
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_HEARTBEAT);
/*
object oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF,1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);

if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF))
{
if(GN_GetSpawnInCondition(SW_FLAG_AMBIENT_ANIMATIO NS) || GN_GetSpawnInCondition(SW_FLAG_AMBIENT_ANIMATIONS_ MOBILE))
{
string sWay = "WP_" + GetTag(OBJECT_SELF) + "_01";
int nSeries = GetLocalNumber(OBJECT_SELF, WALKWAYS_SERIES_NUMBER);
if(!GetIsObjectValid(GetObjectByTag(sWay)) && nSeries <= 0)
{
if(GetCurrentAction(OBJECT_SELF) != ACTION_MOVETOPOINT)
{
if(!GN_GetIsFighting(OBJECT_SELF) && !GetIsObjectValid(oEnemy))
{
GN_PlayAmbientAnimation();
}
}
}
}
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBE AT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}
*/

//Checks if tainted robes are equipped
if(GetTag(GetItemInSlot(INVENTORY_SLOT_BODY)) == "tainted robes tag")//Replace "tainted robes tag" with your tainted robes' item tag.
{
//tainted robes are equipped. Let's set the globals to reflect that:
SetGlobalBoolean("taintedRobesOn", TRUE);
//Now we need to check if the item was just equipped
if(GetGlobalBoolean("taintedRobesOff") == TRUE)
{
AdjustAlignment(GetFirstPC(), ALIGNMENT_DARK_SIDE, 0, FALSE);
//Replace 0 with how much you want the PC to shift to the dark side, and change FALSE to TRUE if you want this shift to affect party members.
SetGlobalBoolean("taintedRobesOff", FALSE); //this makes sure the dark side shift happens only once.
}
}
else if(GetGlobalBoolean("taintedRobesOn") == TRUE) //robes aren't equipped; this checks if the robes were just taken off.
{
//tainted robes are unequipped. Let's set the globals to reflect that:
SetGlobalBoolean("taintedRobesOff", TRUE);
AdjustAlignment(GetFirstPC(), ALIGNMENT_LIGHT_SIDE, 0, FALSE);
//Replace 0 with how much you want the PC to shift to the light side, and change FALSE to TRUE if you want this shift to affect party members.
SetGlobalBoolean("taintedRobesOn", FALSE); //this makes sure the light side shift happens only once.
}
}
When it's copied in, save it into your override folder as "k_def_heartbt01.nss". Make the necessary changes as indicated in the code above. Then, in the text editor, check the option "Script is for KOTOR II" under the Script menu and press F5 to compile the script.

Next, open a new file in KOTOR Tool's text editor. Copy the following into it:
//:: k_hen_heartbt01
/*
Heartbeat for the non-active party members.
*/
//:: Created By:
//:: Copyright (c) 2002 Bioware Corp.

#include "k_inc_debug"
#include "k_inc_switch"

void main()
{
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_HENCH_EVENT_ON_HEARTBEAT);
/*
object oEnemy = GetNearestCreature(CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, OBJECT_SELF, 1, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
//GN_SetSpawnInCondition(SW_FLAG_SHOUTED_AT, FALSE);

if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF) && !GetSoloMode())
{
if(GetPartyMemberByIndex(0) != OBJECT_SELF)
{
if(IsObjectPartyMember(OBJECT_SELF) && //Note that this check replaces GetIsObjectValid(oMaster)
//GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOW &&
GetCurrentAction(OBJECT_SELF) != ACTION_MOVETOPOINT &&
//GetCurrentAction(OBJECT_SELF) != ACTION_WAIT &&
GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOWLEADER &&
!GetIsConversationActive() &&
//GetDistanceBetween(OBJECT_SELF, GetPartyMemberByIndex(0)) > 4.5 &&
!GN_GetSpawnInCondition(SW_FLAG_SPECTATOR_STATE) &&
GetCommandable())
{
//Db_PostString(GetTag(OBJECT_SELF) + " HEARTBEAT CHECK 1 PASS", 4, 10, 2.0);
if(!GN_GetIsFighting(OBJECT_SELF) && !GetIsObjectValid(oEnemy))
{
//Db_PostString(GetTag(OBJECT_SELF) + " HEARTBEAT CHECK 2 PASS", 4, 12, 2.0);
//The distance checking is now down in the script fired from AI Action Update - Leave 5m Radius of party leader.
ClearAllActions();
ActionFollowLeader();
}
}
}
}
else if(GetSoloMode() && GetCurrentAction(OBJECT_SELF) == ACTION_FOLLOWLEADER)
{
ClearAllActions();
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBE AT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}
*/

//Checks if tainted robes are equipped
if(GetTag(GetItemInSlot(INVENTORY_SLOT_BODY)) == "tainted robes tag")//Replace "tainted robes tag" with your tainted robes' item tag.
{
//tainted robes are equipped. Let's set the globals to reflect that:
SetGlobalBoolean("taintedRobesOn", TRUE);
//Now we need to check if the item was just equipped
if(GetGlobalBoolean("taintedRobesOff") == TRUE)
{
AdjustAlignment(GetFirstPC(), ALIGNMENT_DARK_SIDE, 0, FALSE);
//Replace 0 with how much you want the PC to shift to the dark side, and change FALSE to TRUE if you want this shift to affect party members.
SetGlobalBoolean("taintedRobesOff", FALSE); //this makes sure the dark side shift happens only once.
}
}
else if(GetGlobalBoolean("taintedRobesOn") == TRUE) //robes aren't equipped; this checks if the robes were just taken off.
{
//tainted robes are unequipped. Let's set the globals to reflect that:
SetGlobalBoolean("taintedRobesOff", TRUE);
AdjustAlignment(GetFirstPC(), ALIGNMENT_LIGHT_SIDE, 0, FALSE);
//Replace 0 with how much you want the PC to shift to the light side, and change FALSE to TRUE if you want this shift to affect party members.
SetGlobalBoolean("taintedRobesOn", FALSE); //this makes sure the light side shift happens only once.
}
}
Save the file as "k_hen_hearbt01.nss" in your override folder. Make the necessary changes as described in the code and compile the script as earlier.

Make sure the two scripts are in your override folder, and try out your robes in the game. If all goes well, your character should grow evil when the robes are applied, and back to normal when they are unequipped (assuming the two values in the AdjustAlignment method you replaced are the same). I hope this helps!

VarsityPuppet
07-12-2009, 06:52 PM
Holy nuts! I owe you a bunch gsusfrk! I'm going to see if I can get this all to work.

Do you mind if I consult you on further scripting in the future? There's at least one other script I'm trying to make for this mod, but besides that I could really use someone to show me the ins and outs of scripting.

gsusfrk
07-12-2009, 11:30 PM
Thanks a lot, and feel free to ask anything (well, almost anything). You can either start a new thread or PM me, whichever you prefer.

As a sidenote, be cautious when you equip the robes on your party members. At best, they will be affected leaving you alone, or they might affect you as well, or nothing will happen, or at worst, they may conflict with the global variables. I'm not sure how to script it to fix that possibility, but for now, just have The Exile wear the robes.

Additionally, for anyone else reading this who wants to have the same effect as the above (certain items affecting lightside/darkside points), simply follow the same procedure as above, except make fitting global variables, and edit the scripts so that the following is accomplished:


The "GetGlobalBoolean" and "SetGlobalBoolean" have the correct parameters (your global variable names).
The tag for the item to check if equipped is set correctly for your item.
The "INVENTORY_SLOT_BODY" is changed to match your item (consult nwscript.nss in your override for the correct variables to use).
The lightside/darkside shift is done in the correct order for the desired item (for example, if you want some gloves to make you more light side, the lightside adjustment should come first in the script).
The parameters are correct for the lightside/darkside adjustment.
Repeat the above for any additional items that you wish to have affect lightside/darkside balance. They all MUST be in the two scripts.
Speaking of two scripts, make sure your adjustments to one script are copied into the other.
Make sure all relevant files are in the override folder; this includes the modified versions of globalcat.2da, k_def_heartbt01.nss, k_def_heartbt01.ncs, k_hen_heartbt01.nss, and k_hen_heartbt01.ncs.


Lastly, VarsityPuppet, if you find that the scripts and 2da editing work as intended, try removing both k_hen_heartbt01 files from the override folder (move them, don't delete them just yet). If you find the game still works as intended, feel free to delete them. I included them in my little tutorial because I wasn't sure if they were necessary or not. I could easily tell if they were if I could find the default utc for The Exile, but I couldn't find it. Let me know how this works out.

Enjoy!

Trench
07-13-2009, 04:25 PM
You're right VP, that idea is groundbreaking! Can't wait to see how this turns out.:D

VarsityPuppet
07-27-2009, 09:58 AM
UPDATE: Mwahahaha!

I have scripted the robes to change your alignment gradually over time. Any alignment can wear them, but doing so will slowly change your alignment.


Here're the specifics:

Alignment = 100 - Your alignment is unaffected
99> Alignment >1 - Your alignment shifts downward (without message screens) 1 point every 30 seconds.
Alignment > 1 - Nothing happens


There are a couple of reasons why it's set up like this.

1. The way I scripted this doesn't remove the Alignment Mastery Bonuses. I didn't want to go through the trouble of doing it anyways.

2. Would someone with Lightside Mastery likely fall victim to some mildly tainted robes? I don't think so. Plus, it makes it a bit more interesting.

This is oh so close to being released... except for there seems to be a problem with KScriptEditor, not to mention I can't get the conditionals to work correctly.

Ah well, I shall keep on keeping on.