Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Question about placing alignment related item on Harbinger

Page: 1 of 1
 Kainzorus Prime
08-23-2006, 2:21 PM
#1
I've made two robes, one for dark side, and one for light side PC. What I wanted to do is that correct robe would spawn in PC's locker on Harbinger, based on alignment, i.e if PC is darksider, dark side robe would spawn and vice versa. Is there a script that would allow such thing?
 stoffe
08-23-2006, 2:37 PM
#2
I've made two robes, one for dark side, and one for light side PC. What I wanted to do is that correct robe would spawn in PC's locker on Harbinger, based on alignment, i.e if PC is darksider, dark side robe would spawn and vice versa. Is there a script that would allow such thing?

Something like this might work:



void main() {
int iGood = GetGoodEvilValue(GetFirstPC());
string sResRef;

if (iGood < 40)
sResRef = "MyEvilItem";
else if (iGood > 60)
sResRef = "MyGoodItem";
else
sResRef = "MyNeutralItem";

object oLocker = GetItemPossessor(GetObjectByTag("a_band_c01"));

if (GetIsObjectValid(oLocker) && (GetObjectType(oLocker) == OBJECT_TYPE_PLACEABLE)) {
CreateItemOnObject(sResRef, oLocker);
}
}


The parts in Yellow should be the ResRefs of the item to spawn. This would spawn a different item depending on the player's alignment in the container that contains the player's unique armband.

The script may vary a bit depending on where you run it from. If you run the script on the locker itself (like from its OnOpen event) you can just use OBJECT_SELF instead of looking for the container holding the unique armband.
 Kainzorus Prime
08-23-2006, 2:38 PM
#3
Ah thank you. Ill try and get back with result.
 Kainzorus Prime
08-24-2006, 9:03 AM
#4
It seems something is wrong. I checked it 2 times in game, once on dark side and once light side. Neither robe spawned in locker. Here's how I filled yellow entries, maybe I made some mistake.

void main() {
int iGood = GetGoodEvilValue(GetFirstPC());
string sResRef;

if (iGood < 40)
sResRef = "a_hod_51";
else if (iGood > 60)
sResRef = "a_gol_50";
else
sResRef = "MyNeutralItem";

object oLocker = GetItemPossessor(GetObjectByTag("a_band_c01"));

if (GetIsObjectValid(oLocker) && (GetObjectType(oLocker) == OBJECT_TYPE_PLACEABLE)) {
CreateItemOnObject(sResRef, oLocker);
}
}
 Addlcove
08-24-2006, 9:07 AM
#5
did you pass the lightside/darkside points? I imagine if you are between 40 and 60 then it wont spawn anything

change the (iGood < 40) to 49, and the (iGood > 60) to 51. ?
 Kainzorus Prime
08-24-2006, 9:44 AM
#6
Tried, started new game, and still no effect.
 stoffe
08-24-2006, 9:52 AM
#7
It seems something is wrong. I checked it 2 times in game, once on dark side and once light side. Neither robe spawned in locker. Here's how I filled yellow entries, maybe I made some mistake.


Where do you run your script from?
 Kainzorus Prime
08-24-2006, 10:01 AM
#8
I honestly do not know. All I've done is copy script you generously provided me, added my entries, complied the script and placed it in override. I tought it would work.

So here comes the question - How to run the script, preferably at entering Harbinger Command Deck (First Harbinger area).
 stoffe
08-24-2006, 12:38 PM
#9
I honestly do not know. All I've done is copy script you generously provided me, added my entries, complied the script and placed it in override. I tought it would work.

So here comes the question - How to run the script, preferably at entering Harbinger Command Deck (First Harbinger area).

Then that is the problem. :) Scripts don't run on their own, they need an object in the game to run them (either via some event or through ExecuteScript()).

As for suitable things to run your script there are three main options I can think of. Either would be incompatible with other mods using the same method of doing it, but should otherwise produce identical results (item spawned in locker):
Assign the script to the OnOpen event of the locker itself. If you do this you can use OBJECT_SELF as the destination to spawn and won't have to look for the armband or mess with coordinates, and can trim the script down to something like below.

The problem is that the container template for the locker, g_tresmillow007.utp, doesn't have a unique resref, files with that name are used in a lot of other modules and as such you can't put it in the override folder without breaking the game.

So, if you intend to share this mod with others you'll either need to ship the whole modified module .RIM (or repackaged .MOD) with your mod, which may cause incompatibility with other mods (and is overkill for such a minor change). Or you can use a mod installer (TSLPatcher can do this) to modify the OnOpen field in the g_tresmillow007.utp file inside the 152HAR_s.rim file to set the name of your script. This works fine, but is vulnerable to the same incompatibility issue with other mods doing the same thing (don't know of any, but that doesn't mean none exist since I don't try all mods released :))

The modified script for this:

void main() {
if (GetLocalBoolean(OBJECT_SELF, 140))
return;

string sResRef = ((GetGoodEvilValue(GetFirstPC()) < 40) ? "a_hod_51" : "a_gol_50");
CreateItemOnObject(sResRef, OBJECT_SELF);
CreateItemOnObject("st_aloband01", OBJECT_SELF);
SetLocalBoolean(OBJECT_SELF, 140, TRUE);
}



You can edit the script k_152area_enter, which is the OnEnter script of the Harbinger Crew Quarters area to spawn the items in the box. This is probably the most used method in other mods to add items to that container, since it only requires you to place the modified k_152area_enter.ncs file in the override folder to work. Thus it's most likely to conflict with other mods of that type. If you use this, I think it should work to modify the above named script to look something like:

void main() {
object oEnter = GetEnteringObject();
object oPC = GetFirstPC();

if (oEnter == oPC) {
PlayRoomAnimation("152Har36", ANIMATION_ROOM_SCRIPTLOOP03);

if (!GetLocalBoolean(OBJECT_SELF, 140)) {
int iGood = GetGoodEvilValue(oPC);
string sResRef;

if (iGood < 40)
sResRef = "a_hod_51";
else
sResRef = "a_gol_50";

object oLocker = GetItemPossessor(GetObjectByTag("a_band_c01"));
if (GetIsObjectValid(oLocker) && (GetObjectType(oLocker) == OBJECT_TYPE_PLACEABLE)) {
CreateItemOnObject(sResRef, oLocker);
SetLocalBoolean(OBJECT_SELF, 140, TRUE);
}
}
}
}



Another way might be to attach the script to the heartbeat event of another unique object in the area. The advantage of doing this is that you can modify the event of that objects UT* template directly to set the name of your script, and then put the modified UT* template in the override folder, since it only exists in that area. The disadvantage is incompatibility with other mods using the same technique, since at a quick glance I can only find one suitable object with an unique ResRef in that module, the 152lockeddoor.utd door. If you do this, the script variant may look something like:

void main() {
if (GetLocalBoolean(OBJECT_SELF, 140))
return;

int iGood = GetGoodEvilValue(GetFirstPC());
string sResRef;

if (iGood < 40)
sResRef = "a_hod_51";
else
sResRef = "a_gol_50";

object oLocker = GetItemPossessor(GetObjectByTag("a_band_c01"));

if (GetIsObjectValid(oLocker) && (GetObjectType(oLocker) == OBJECT_TYPE_PLACEABLE)) {
CreateItemOnObject(sResRef, oLocker);
SetLocalBoolean(OBJECT_SELF, 140, TRUE);
}
}
 Kainzorus Prime
08-24-2006, 1:36 PM
#10
Thanks again. Ill go trough this and come back with result.
 Kainzorus Prime
08-24-2006, 4:30 PM
#11
Haven't tried first method yet, Second method, I have trouble because DenCS script decomplier is not working so i cant edit .ncs, Third worked just fine when set on door template you mentioned, but it spawned 2 robes instead of one.

I found and fixed the 2 robes bug, eveyrthing works fine using 3rd method.
Page: 1 of 1