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.

[TSL]Scripting help - Granting FPs dependent on class/alignment

Page: 1 of 1
 Darth InSidious
05-02-2007, 3:50 PM
#1
I've been trying to grant force powers from a holocron, dependant on which class and alignment for TSL. But even only taking into account the three basic Jedi classes, the script won't compile...could someone please help?
//di_give_fp.nss
// Gives the player the right force power by class. Based on a_give_form.nss

#include "k_inc_force"
#include "k_inc_debug"
#include "k_inc_utility"
#include "k_inc_generic"

void main()
{
int nClass = GetClassByPosition(1,GetFirstPC());
if(nClass == CLASS_TYPE_JEDIGUARDIAN)
{
int align = GetGoodEvilValue(GetPCSpeaker());

if(align >= 0 && align < 50)
{
GrantSpell(320, GetFirstPC());
return TRUE;
}
else
{
GrantSpell(324, GetFirstPC());
return FALSE;
}

else
{
if(nClass == CLASS_JEDICONSULAR)
{
int align = GetGoodEvilValue(GetPCSpeaker());

if(align >= 0 && align < 50)
{
GrantSpell(321, GetFirstPC());
return TRUE;
}
else
{
GrantSpell(322, GetFirstPC());
return FALSE;
}
}
}
else
{
if(nClass == CLASS_TYPE_JEDISENTINEL)
{
int align = GetGoodEvilValue(GetPCSpeaker());

if(align >= 0 && align < 50)
{
GrantSpell(323, GetFirstPC());
return TRUE;
}
else
{
GrantSpell(325, GetFirstPC());
return FALSE;
}
}
else
{}
}
 stoffe
05-02-2007, 4:34 PM
#2
I've been trying to grant force powers from a holocron, dependant on which class and alignment for TSL. But even only taking into account the three basic Jedi classes, the script won't compile...could someone please help?

You have several else statements without any preceeding if statement, and block delimiters ( { } ) missing or in the wrong places. You also try to return a value (TRUE/FALSE) from a function with no return value (void), and try to use an undefined variable/constant (CLASS_JEDICONSULAR).

(You also include a big bunch of include files that are not used for anything, increasing the size of the script needlessly, though that's not a compile error :))

Try this variant where I have fixed those syntax errors:

//di_give_fp.nss
// Gives the player the right force power by class. Based on a_give_form.nss

void main()
{
object oPC = GetFirstPC();
int nClass = GetClassByPosition(1, oPC);
int align = GetGoodEvilValue(oPC);

if(nClass == CLASS_TYPE_JEDIGUARDIAN) {
if (align >= 0 && align < 50) {
GrantSpell(320, GetFirstPC());
return;
}
else {
GrantSpell(324, GetFirstPC());
return;
}
}
else if (nClass == CLASS_TYPE_JEDICONSULAR) {
if (align >= 0 && align < 50) {
GrantSpell(321, GetFirstPC());
return;
}
else {
GrantSpell(322, GetFirstPC());
return;
}
}
else if (nClass == CLASS_TYPE_JEDISENTINEL) {
if (align >= 0 && align < 50) {
GrantSpell(323, GetFirstPC());
return;
}
else {
GrantSpell(325, GetFirstPC());
return;
}
}
}


...or this somewhat shorter variant that should do the same thing :)

//di_give_fp.nss
// Gives the player the right force power by class. Based on a_give_form.nss

void main() {
object oPC = GetFirstPC();
int nClass = GetClassByPosition(1, oPC);
int align = GetGoodEvilValue(oPC);

if ((align >= 0) && (align < 50)) {
switch (nClass) {
case CLASS_TYPE_JEDIGUARDIAN: GrantSpell(320, oPC); break;
case CLASS_TYPE_JEDICONSULAR: GrantSpell(321, oPC); break;
case CLASS_TYPE_JEDISENTINEL: GrantSpell(323, oPC); break;
}
}
else {
switch (nClass) {
case CLASS_TYPE_JEDIGUARDIAN: GrantSpell(324, oPC); break;
case CLASS_TYPE_JEDICONSULAR: GrantSpell(322, oPC); break;
case CLASS_TYPE_JEDISENTINEL: GrantSpell(325, oPC); break;
}
}
}
 Darth InSidious
05-02-2007, 4:48 PM
#3
Thank you so very much! As always, invaluably helpful :)
Page: 1 of 1