Author Topic: Is it possible...?  (Read 479 times)

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« on: May 20, 2012, 04:04:46 pm »


               ...to check to see if a PC has a spell (I have Knock in mind) memorized in their spellbook and use it in a Text Appears When conditional?

EDIT: Forgot to ask, also is there a thread on the forums or a tutorial anywhere that would help me figure out how to use DC's in scripts that are designed to make skill or ability checks. I want specific control of these DC's, otherwise I'd be using the standard NWN difficulty checks.

Thank you in advance!
               
               

               


                     Modifié par NineCoronas2021, 20 mai 2012 - 03:06 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Is it possible...?
« Reply #1 on: May 20, 2012, 04:46:03 pm »


               Function - GetHasSpell
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #2 on: May 20, 2012, 06:46:02 pm »


               Thank you Lightfoot!
               
               

               


                     Modifié par NineCoronas2021, 20 mai 2012 - 05:50 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Is it possible...?
« Reply #3 on: May 20, 2012, 06:57:54 pm »


               In fact the starting condition for the knock spell is already a bioware standard script.

x0_d2_hasknock

EDIT:  In fact all of the scripts in the toolset that have  *_d2_*  in the middle of them are starting conditions.  A lot of the time you can find what you are looking for by looking through them.
               
               

               


                     Modifié par Lightfoot8, 20 mai 2012 - 06:00 .
                     
                  


            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #4 on: May 20, 2012, 07:03:53 pm »


               Okay, I am trying to write a Text Appears When script that would allow me to perform Ability checks while setting the DC's on local variable's stored on the object that begins the conversation. I've figured out a bit of it on my own, but now I'm at a loss.

int StartingConditional()
{
object oPC = GetPCSpeaker();

int iDexCheck = d20(1) + GetAbilityModifier(ABILITY_DEXTERITY, oPC);
int iStrCheck = d20(1) + GetAbilityModifier(ABILITY_STRENGTH, oPC);
int iConCheck = d20(1) + GetAbilityModifier(ABILITY_CONSTITUTION);
int iWisCheck = d20(1) + GetAbilityModifier(ABILITY_WISDOM);
int iIntCheck = d20(1) + GetAbilityModifier(ABILITY_INTELLIGENCE);
int iChaCheck = d20(1) + GetAbilityModifier(ABILITY_CHARISMA);

//Checks the object for local variables placed on it defining the DC of the ability roll
int iDexDC = GetLocalInt(OBJECT_SELF, "DexDC");
int iStrDC = GetLocalInt(OBJECT_SELF, "StrDC");
int iConDC = GetLocalInt(OBJECT_SELF, "ConDC");
int iWisDC = GetLocalInt(OBJECT_SELF, "WisDC");
int iIntDC = GetLocalInt(OBJECT_SELF, "IntDC");
int iChaDC = GetLocalInt(OBJECT_SELF, "ChaDC");

//Allows for a second of the same type of DC check
int iDexDCa = GetLocalInt(OBJECT_SELF, "DexDCa");
int iStrDCa = GetLocalInt(OBJECT_SELF, "StrDCa");
int iConDCa = GetLocalInt(OBJECT_SELF, "ConDCa");
int iWisDCa = GetLocalInt(OBJECT_SELF, "WisDCa");
int iIntDCa = GetLocalInt(OBJECT_SELF, "IntDCa");
int iChaDCa = GetLocalInt(OBJECT_SELF, "ChaDCa");

//Allows for a third of the same type of DC check
int iDexDCb = GetLocalInt(OBJECT_SELF, "DexDCb");
int iStrDCb = GetLocalInt(OBJECT_SELF, "StrDCb");
int iConDCb = GetLocalInt(OBJECT_SELF, "ConDCb");
int iWisDCb = GetLocalInt(OBJECT_SELF, "WisDCb");
int iIntDCb = GetLocalInt(OBJECT_SELF, "IntDCb");
int iChaDCb = GetLocalInt(OBJECT_SELF, "ChaDCb");

//TextAppearsWhen Conditionals:
if (iDexCheck =< iDexDC);
}


I honestly have no idea what I am doing now; does anyone know how I would go about achieving my goal from here? (Am currently getting an unknown compiler state from the 'if' line, not really surprising, expect more <.<)
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Is it possible...?
« Reply #5 on: May 20, 2012, 08:46:53 pm »


               In your "if" line, change "=<" to "<=". '<img'>

and you need the ", oPC" in your other GetAbilityModifier calls.


As far as the rest of the script, it just depends on what checks you want to make.  That'll determine what code you need.

Things to consider:
What checks do you want done?
Do you want PCs to see the mechanics (rolls, results, etc.)?
Do you want to make standard skill checks, but with the DC controlled by variables?
               
               

               


                     Modifié par The Amethyst Dragon, 20 mai 2012 - 07:50 .
                     
                  


            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #6 on: May 20, 2012, 10:18:13 pm »


               I blame sleep deprivation on those errors at the top of the script <.<

Well,
I want to make Ability Score checks, and later standard skill checks, with the DC controlled by variables stored on the placeable the conversation is attached too.
I want to be able to use one script for all of these checks so I don't have to clutter up my SP module.

Is this possible?
If the script ends up looking like this at the end:

if (iDexCheck <= iDexDC) return FALSE;
if (iDexCheck <= iDexDCa) return FALSE;
if (iDexCheck <= iDexDCb) return FALSE;

if (iStrCheck <= iStrDC) return FALSE;
if (iStrCheck <= iStrDCa) return FALSE;
if (iStrCheck <= iStrDCb) return FALSE;

return TRUE;


If one of those "If" statements are met, will it show the text, or will the script be requiring all of those to "If" conditions to be met?
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Is it possible...?
« Reply #7 on: May 20, 2012, 10:46:57 pm »


               Something like this?


int AbilityCheck(object oPC,int iAbility, int iDC)
{
int iABResult =FALSE;
int iRoll = d20(1);
int iAb_mod =GetAbilityModifier(iAbility,oPC);
int iResult = iRoll+iAb_mod;
if(iResult>=iDC)iABResult=TRUE;

return iABResult;
}


/*
int    ABILITY_STRENGTH         = 0; // should be the same as in nwseffectlist.cpp
int    ABILITY_DEXTERITY        = 1;
int    ABILITY_CONSTITUTION     = 2;
int    ABILITY_INTELLIGENCE     = 3;
int    ABILITY_WISDOM           = 4;
int    ABILITY_CHARISMA         = 5;

Use these for variable type
*/

int StartingConditional()
{
   int iResult;
   int iAb_type = GetLocalInt(OBJECT_SELF,"AbilityCheckTyp");
   //Fix for 0
   if(iAb_type==-1)iAb_type=ABILITY_STRENGTH;
   int iDC = GetLocalInt(OBJECT_SELF,"AbilityCheck");
   iResult =  AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
   return iResult;
}
               
               

               


                     Modifié par ShadowM, 20 mai 2012 - 09:47 .
                     
                  


            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #8 on: May 20, 2012, 11:27:54 pm »


               Honestly, I don't quite understand how to use that just by looking at that. ':whistle:'
I get how the AbiltyCheck function works, but everything below that...
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #9 on: May 20, 2012, 11:32:39 pm »


               Why is "if(iAb_type==-1)" -1 and not 0 like up in the commented section?
Also, what do you mean by "Fix for 0"?

What variables would be on the placeable with this script?
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #10 on: May 20, 2012, 11:41:54 pm »


               Ahh, I think I understand your script. The thing is, I want to be able to account for more than one possible DC and more than one possible ability check using variables on the object.
               
               

               


                     Modifié par NineCoronas2021, 20 mai 2012 - 10:50 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Is it possible...?
« Reply #11 on: May 20, 2012, 11:46:48 pm »


               The -1 because when you do call of a variable it will always call a 0 if even if it does not have the variable on it. It more or less to make sure something does not go wrong. You can take it out if you want.  You would put
AbilityCheckTyp for the type of ability check.
AbilityCheck for the DC of the check.
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #12 on: May 20, 2012, 11:51:41 pm »


               This works well for a single check, but I have conversations that include multiple checks of varying difficulty and type :/ I think you're on to something, I just need to figure out a different method of implementation that allows for a wider scope.
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Is it possible...?
« Reply #13 on: May 20, 2012, 11:57:34 pm »


               Hmm, is it possible to get the name of an integer and define that name as a string?

EDIT:
Also, would this code theoritically work?

int AbilityCheck(object oPC,int iAbility, int iDC)
{
int iABResult =FALSE;
int iRoll = d20(1);
int iAb_mod =GetAbilityModifier(iAbility,oPC);
int iResult = iRoll+iAb_mod;
if(iResult>=iDC)iABResult=TRUE;

return iABResult;
}


/*
int ABILITY_STRENGTH = 1; // should be the same as in nwseffectlist.cpp
int ABILITY_DEXTERITY = 2;
int ABILITY_CONSTITUTION = 3;
int ABILITY_INTELLIGENCE = 4;
int ABILITY_WISDOM = 5;
int ABILITY_CHARISMA = 6;

Use these for variable type
*/

int StartingConditional()
{
int iResult;
int iAb_type = GetLocalInt(OBJECT_SELF,"AbilityCheckTyp");
int iDC = GetLocalInt(OBJECT_SELF,"DCCheck");

if(iAb_type==1)iAb_type=ABILITY_STRENGTH;
iResult = AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
return iResult;

if(iAb_type==2)iAb_type=ABILITY_DEXTERITY;
iResult = AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
return iResult;

if(iAb_type==3)iAb_type=ABILITY_CONSTITUTION;
iResult = AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
return iResult;

if(iAb_type==4)iAb_type=ABILITY_INTELLIGENCE;
iResult = AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
return iResult;

if(iAb_type==5)iAb_type=ABILITY_WISDOM;
iResult = AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
return iResult;

if(iAb_type==6)iAb_type=ABILITY_CHARISMA;
iResult = AbilityCheck(GetPCSpeaker(),iAb_type,iDC);
return iResult;
}

               
               

               


                     Modifié par NineCoronas2021, 20 mai 2012 - 11:06 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Is it possible...?
« Reply #14 on: May 21, 2012, 12:04:02 am »


               Hope you dont mind me jumping in ShodowM.  

 What you are asking for uses a lot of advanced scripting styles, with a good base understanding of how conversations work.  For what you are tring to do you may want to check out one of the dynamic conversation systems on the vault, Like zz_dialogue.   Or use a system like _guile has already ofered up in a post recently.  

My opinion is if yu are going to take the step towards dynamic dialouges you might as well give zz dialogue a try.  I can not comment on it much since I have never used it though.
 
As far as  _guiles scripts he posted them Here.. I also can not comment on them much since I have never used them. They can at least give you an Idea of what you are up against.
               
               

               


                     Modifié par Lightfoot8, 20 mai 2012 - 11:05 .