Author Topic: Need help with skill averaging script  (Read 344 times)

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
Need help with skill averaging script
« on: November 17, 2010, 04:33:44 am »


               Greetings all,

I'm trying to modify a script that averaged strength and dexterity for a check into one that makes a check against the skills Listen and Spot, averaged.  The relevant part of the script is below - it refuses to compile.  Any assistance would be most appreciated!
-----------------------------------------
const int DC = 22;
const int CAT_FAIL = 3;
void main()
{
    object oPC = GetPCSpeaker();
    object oTarget;
    // Get Listen
    int iLis = int GetSkillRank(int nSkill, object oTarget=OBJECT_SELF, int nBaseSkillRank=FALSE)
    // Get Spot
    int iSpo = int GetSkillRank(int nSpot, object oTarget=OBJECT_SELF, int nBaseSkillRank=FALSE);
    int iScore = (iLis + iSpo)/2;
    int iRoll = d20();
    if(iRoll <= CAT_FAIL)
        {
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Need help with skill averaging script
« Reply #1 on: November 17, 2010, 05:25:52 am »


               You're missing a semicolon after this line:

   int iLis = int GetSkillRank(int nSkill, object oTarget=OBJECT_SELF, int nBaseSkillRank=FALSE)
               
               

               
            

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
Need help with skill averaging script
« Reply #2 on: November 17, 2010, 05:53:00 am »


               D'oh!



Hmm.  After fixing that, I still get ERROR: UNKNOWN STATE IN COMPILER on that line.  



               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Need help with skill averaging script
« Reply #3 on: November 17, 2010, 07:47:23 am »


               Oh, yeah, sorry, I just pointed out the first problem I saw. You are putting the function declaration on the right side of the function, instead of just the function. Both lines should lose the 'int' in front of GetSkillRank, like so:



int iLis = GetSkillRank(int nSkill, object oTarget=OBJECT_SELF, int nBaseSkillRank=FALSE);



Then, you need to put the relevant information in that function. Assuming you want to check the SPOT skill, for example, you need to plug in the spot skill const (found in the const section of the script editor, as well as in the nwscript script), like so:  



int iLis = GetSkillRank(SKILL_SPOT, object oTarget=OBJECT_SELF, int nBaseSkillRank=FALSE);



That still won't work, though, because you need to specify the object whose spot skill you're checking - in this case, you presumably want to check oPC's, like so:



int iLis = GetSkillRank(SKILL_SPOT, oPC, int nBaseSkillRank=FALSE);



And that STILL won't work, because you still have one partial declaration left - the int telling it whether or not you want to get base or total skill rank. If you want to get base skill rank, you need to set it to TRUE, like so:



int iLis = GetSkillRank(SKILL_SPOT, oPC, TRUE);



If, on the other hand, you want to get the pc's fully modified spot score, you can leave out that function input altogether, since it defaults to FALSE, as you can see in the declaration you tried to use. It'd look like this:



int iLis = GetSkillRank(SKILL_SPOT, oPC);



Hopefully that clears a few things up for you. I'm guessing this is your first attempt to modify a script? Looking at a couple of scripting tutorials will probably save you quite a bit of time.



Let me know if yo have further questions, and please post the entire script if you have further difficulties in compiling.



Funky
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Need help with skill averaging script
« Reply #4 on: November 17, 2010, 01:26:46 pm »


               My tutorial might be useful to you, written for the beginning scripter. Link in sig below.
               
               

               
            

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
Need help with skill averaging script
« Reply #5 on: November 17, 2010, 07:34:47 pm »


               Thanks Funky & KM, I'll give that a read.  High time I graduated from "frankenscripting"!