Author Topic: Need help with...  (Read 647 times)

Legacy_Foregone_Conclusion

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Need help with...
« Reply #15 on: January 20, 2012, 09:50:17 pm »


               Thanks for that bard!

And thanks for some more feed back and the help prior to now Wyld. I can understand it well enough. A lot of the functions by name alone are pretty self explanatory. I'll read the tutorials again now that I'm not running on so little sleep!  

I know how tag based scripting is supposed to work, but I didn't know that placing the code IN the script was a way to make it function as intended. Just little things I didn't know that make a difference. Also the script generator doesn't include things like this unless you go well out of the way to make sure its there, but like I said, still a lot of things I didn't know!

But thanks for the patient and very helpful replies so far! Learning experience I've been trying to get into for a long time!
               
               

               
            

Legacy_wyldhunt1

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +0/-0
Need help with...
« Reply #16 on: January 20, 2012, 10:00:35 pm »


               Glad we could help.
I apologize if my responses are way too basic. Since I don't know how much you know, I tend to start at 0 just to make sure. That, and someone else may find this thread later who may be at the very beginning.
               
               

               
            

Legacy_Foregone_Conclusion

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Need help with...
« Reply #17 on: January 23, 2012, 12:11:58 am »


               So I'm having a bit of trouble understanding the IF functions and just exactly what can be done with them. Right now I was trying to come up with a template for doing quests and journal entries, AND conversation options all at the same time.

But I don't even know where to start on something like this. Any advice? 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Need help with...
« Reply #18 on: January 23, 2012, 03:35:31 am »


               

Foregone_Conclusion wrote...

So I'm having a bit of trouble understanding the IF functions and just exactly what can be done with them. Right now I was trying to come up with a template for doing quests and journal entries, AND conversation options all at the same time.

But I don't even know where to start on something like this. Any advice? 


Just about everything can be done with the If statment.

The First part is Probably learning what Kinds of Events exsist in the game and where you can store data at.  Then writting your script often becomes as simple as saying what you want to happen.  and then writting out exactly that. 

example:
lets say you want a Quest that has three states.
  • getting the Quest.



  • fulfilling the Task. 



  • and Reporting back for Rewards.
 

that looks like you can just simply assign a number to each of the states to simply track them and place that number on the PC.   To make it more human readable we can give each State a Name (label) that will be constant, something like.  


const int QUEST_STARTED =1;
const int QUEST_TASK_DONE=2;
const int QUEST_FINISHED=3; 

when we start out with the PC having done nothing the Quest State will not yet be defined therefore its value will be 0.
So lets add that in there as well.

const int QUEST_NOT_STARTED=0;

Hmm,  we also need a name for the place we are going to Store the data, so we can find it again.  Lets just call it Quest1. We will use this name for the local  integer that we place on the PC to track the state of the quest. 

Now, what do we want to happen.   When the PC talks to the NPC we want him to Give him the Option to start the Quest. This sounds like we need a starting condition for the 'Text  appears When'  node for the concersation. So we know where.  Now when do we want this  to appear.  

if the quest has not yet started then Ask the PC if he want to do the quest,  If not Don't ask dont tell. 

if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE; 

hmm That look good to me we just need to fill in the stuff we missed, like fetching the Quest state from where we have it stored, and making it into a starting condition.   so we end up with.  

  
const  int QUEST_NOT_STARTED=0;
const  int QUEST_STARTED =1;
const  int QUEST_TASK_DONE=2;
const  int QUEST_FINISHED=3; 

int StartingConditional()
{
    //Define the PC, so we can get the state off of him.
    object oPC GetPCSpeaker();

    // Get the current quest state from the PC.
    int QuestState = GetLocalInt(oPC,"Quest1");

   //Do what we said we want to do.    
   if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE; 
   
}  

It would not hurt at this point to think ahead a little bit.  It looks like we are going to be using thies states quite a bit.  So we can move them off into an include file that we can just add to our scripts as we need them. we will call this file inc_queststates.  While we are at it, It also looks like we are gong to be retriving the quest state from the PC quite a bit.   So let add a function to our include to get the Quest State from the PC and make Our Script even more Human readable. with this we end up with.   

////File Inc_QuestStates////////
const  int QUEST_NOT_STARTED=0;
const  int QUEST_STARTED =1;
const  int QUEST_TASK_DONE=2;
const  int QUEST_FINISHED=3; 

// This is just a wraper around the GetLocalInt To amke it more readable.  
int GetQuestStateFromPC(object oPC, string sQuest)
{
    return GetLocalInt(oPC, sQuest)
}
   
With all that moved into our new include our script can now look like this.

#include "inc_queststates"
int StartingConditional()
{
    //Define the PC, so we can get the state off of him.
    object oPC GetPCSpeaker();

    // Get the current quest state from the PC.
    int QuestState = GetQuestStateFromPC(oPC,"Quest1");

   //Do what we said we want to do.    
   if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE; 
   
}  



Ok so we have our script for when the text is to appear to give the PC to option to start the quest.   Now if he selects that option. What do we want to happen. Hmm Besides giving him more instructions in the Dialogue we just want to change the state of the quest.  hmm, It would be really nice if that include also had a function to change the quest states, Sounds like that is going to happen a lot also.   So lets add it to the include first.   

So now our include file looks like this: 

////File Inc_QuestStates////////
const  int QUEST_NOT_STARTED=0;
const  int QUEST_STARTED =1;
const  int QUEST_TASK_DONE=2;
const  int QUEST_FINISHED=3; 

// This is just a wraper around the GetLocalInt To amke it more readable.  
int GetQuestStateFromPC(object oPC, string sQuest)
{
    return GetLocalInt(oPC, sQuest)
}
   
//Update the Quest state on the PC; again Just a wrapper.
int SetQuestStateOnPC(object oPC, string sQuest, int sState )
{
   SetLocalInt(oPC,sQuest, sState);
}  

With That in Place your action taken Script looks like this.

#include "inc_queststates"

void main()
{
   object oPC = GetPCSpeaker();
   SetQuestStateOnPC( oPC, "Quest1", QUEST_STARTED);  
}

That is roughly what goes through my mind when i am building a quest.  Righ not I am running short on time.   Hope that helps to get you started.   
               
               

               


                     Modifié par Lightfoot8, 23 janvier 2012 - 03:37 .
                     
                  


            

Legacy_Foregone_Conclusion

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Need help with...
« Reply #19 on: January 23, 2012, 10:09:10 pm »


               Thanks for that light foot. Just one thing, it doesn't want to parse the return statement on the inc_queststates.
               
               

               
            

Legacy_wyldhunt1

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +0/-0
Need help with...
« Reply #20 on: January 23, 2012, 10:35:20 pm »


               Looks like Lightfoot wrote that more as a guide. It has a few minor typos.


if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE;

Should probably be

if (QuestState== QUEST_NOT_STARTED) return TRUE; else return FALSE;




return GetLocalInt(oPC, sQuest)

Should probably be:

return GetLocalInt(oPC, sQuest);


               
               

               


                     Modifié par wyldhunt1, 23 janvier 2012 - 11:10 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Need help with...
« Reply #21 on: January 23, 2012, 11:18:35 pm »


               

Foregone_Conclusion wrote...

Thanks for that light foot. Just one thing, it doesn't want to parse the return statement on the inc_queststates.


Sorry, Wyld Got it.    I was just typing the thought  process.   once you get the hang of it.  It is not that hard.   There is more to learn about how the objects intereact with there events and when they fire,  then there is to learn about base scripting.  
               
               

               
            

Legacy_Foregone_Conclusion

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Need help with...
« Reply #22 on: January 24, 2012, 03:52:45 am »


               That is really the thing about scripting isn't it? More about what it does and how it interacts with things than, just writing it.  I'm a pretty hands on type and some things are coming to me. Most of the functions make sense. It's just getting them in the right order to get them to -work- with what I'm doing.
               
               

               
            

Legacy_wyldhunt1

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +0/-0
Need help with...
« Reply #23 on: January 24, 2012, 04:47:36 am »


               I've spent a better part of the last few weeks going over a bunch of my old scripts from 5 or 6 years ago when I was just learning. They all work, but the amount of really bad, repetative, useless code keeps making me want to pull my hair out.
Trying to learn the order to put things in is what I had issues with too.
The only thing that really helped me was a lot of practice and a lot of studying other peoples code... and keeping the Lexicon close.

If you have any specific questions, feel free to ask them.