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.

How to spawn an item based on your alignment?

Page: 1 of 1
 SithRevan
07-21-2006, 5:49 PM
#1
I was wondering how to spawn an item bsed on my alignment or if it is even possible to do such a thing, if it is would somebody help me with the script to do it, thanks.
 stoffe
07-21-2006, 6:43 PM
#2
I was wondering how to spawn an item bsed on my alignment or if it is even possible to do such a thing, if it is would somebody help me with the script to do it, thanks.

It's possible, here's a quick example of how it could be done:

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

if (iGood > 60)
sResref = "gooditem";
else if (iGood < 40)
sResref = "evilitem";
else
sResref = "neutralitem";

CreateItemOnObject(sResref, GetObjectByTag("mybox"));
}


This would put one out of 3 possible items inside the container with the Tag "mybox", depending on the force alignment of the main character:
gooditem.uti for a lightsider, evilitem.uti for a darksider and neutralitem.uti for those in the gray zone in between.
 SithRevan
07-21-2006, 7:02 PM
#3
thanks, that explains a lot.
 SithRevan
07-21-2006, 7:20 PM
#4
I was wondering if that script could be used on placeables like containers, footlockers, bones, ect.
 stoffe
07-21-2006, 7:46 PM
#5
I was wondering if that script could be used on placeables like containers, footlockers, bones, ect.

Shouldn't be any problems, though if you assign the script to the placeable you can replace the GetObjectByTag("mybox") part with OBJECT_SELF instead. You probably want to make sure it only fires once as well if the player opens the container more than once.

The modified example script in this case could look like:


void main() {
if (!GetLocalBoolean(OBJECT_SELF, 57)) {
string sResref;
int iGood = GetGoodEvilValue(GetFirstPC());

if (iGood > 60)
sResref = "gooditem";
else if (iGood < 40)
sResref = "evilitem";
else
sResref = "neutralitem";

CreateItemOnObject(sResref, OBJECT_SELF);
SetLocalBoolean(OBJECT_SELF, 57, TRUE);
}
}


Save the script, compile it to NCS, put in the override folder along with the placeable UTP. Then assign it to the OnOpen event script slot of the placeable (in the UTP file) and it should fill the container with the proper item the first time it is opened. (You put the name of the script, minus the ".ncs" extension, in the OnOpen field in the UTP.)

Make sure all the other event script fields are empty if you used an existing container as a blueprint for your new container.
Page: 1 of 1