Author Topic: new to local variables, Please Help!? =')  (Read 327 times)

Legacy_lol8362

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
new to local variables, Please Help!? =')
« on: October 19, 2012, 11:32:03 pm »


               First off, you reply to this i really appreciate it! thank you!

im building a single player module.
i use lilac soul's script generator for all my scripts.
im trying to make a simple side quest, kill 10 sewer rats in the sewer
so i thought, if i make the guy giving u the quest set the local integer "ratskilled" to 0 and then make a script for the sewer rats that basically checks the number for the integer "ratskilled" and moves it up one, the guy knows when you have killed 10 sewer rats and thats the end of that quest.

idk why it wont work because this is my first time ever using Local Variables! I would greatly appreciate if someone explained the steps to making this quest and pretty much using the variables, i guess!

THANK YOU SO MUCH, I REALLY APPRECIATE IT BECAUSE I GET THE MOST JOYOUS FEELING WHEN I GET SCRIPTS TO WORK!

let me know if u want me to post the scripts...
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
new to local variables, Please Help!? =')
« Reply #1 on: October 20, 2012, 01:54:54 am »


               Doing so requires to add a count to the variable for each rat that is killed.

void main()
{
int nNth = GetLocalInt(GetModule(), "ratkills");

nNth++;
SetLocalInt(GetModule(), "ratkills", nNth);

}


This would be placed on the rat's OnDeath script, so for each rat killed, the variable grows by +1.

Then you need to check the conversation of your NPC for the variable number. In this case, it's 10.

This would be placed on the TEXT APPEARS TAB of the conversation.

int StartingConditional()
{

   // Inspect local variables
   if(!(GetLocalInt(GetModule(), "ratkills") == 10))
       return FALSE;

   return TRUE;
}


FP!
               
               

               
            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
new to local variables, Please Help!? =')
« Reply #2 on: October 20, 2012, 07:57:49 pm »


               

Fester Pot wrote...

Doing so requires to add a count to the variable for each rat that is killed.

void main()
{
int nNth = GetLocalInt(GetModule(), "ratkills");

nNth++;
SetLocalInt(GetModule(), "ratkills", nNth);

}


This would be placed on the rat's OnDeath script, so for each rat killed, the variable grows by +1.

Then you need to check the conversation of your NPC for the variable number. In this case, it's 10.

This would be placed on the TEXT APPEARS TAB of the conversation.

int StartingConditional()
{

   // Inspect local variables
   if(!(GetLocalInt(GetModule(), "ratkills") == 10))
       return FALSE;

   return TRUE;
}


FP!


Try this for the ondeath

void main()
{
int nNth = GetLocalInt(GetModule(), "ratkills");
if(!(GetLocalInt(GetModule(), "ratkills") <= 9))
{
nNth++;SetLocalInt(GetModule(), "ratkills", nNth);
}
}

 
Doing it this way will only allow it to get to 10 kills. If a player more than 10 rats, it will still fire Fester's conditional script.
Or you could change fester's conditional to this:

int StartingConditional(){

// Inspect local variables
if(!(GetLocalInt(GetModule(), "ratkills") >= 10))
return FALSE;

return TRUE;

Either way will work. of course this is persuming you have more than 10 rats in your sewer. If only 10 rats in your sewer do it how fester wrote it.
               
               

               


                     Modifié par Pattycake1, 20 octobre 2012 - 07:07 .