Skip to content

Is there a better way?

tgxtgx Member Posts: 40
So, let's say I have these kinds of scripts:

has_con_10
has_con_12
has_con_14
has_con_16

I call them mostly in conversations, and each of them is as basic as you can get, returning true or false.

Is there a way to pass parameters to scripts? Or are we limited to this kind of arrangement?

Comments

  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,085
    Yeah ofc ever since nwn came out it is possible :) Since it is in a conversation it means you are speaking to an npc and npcs can be assigned variables. So you make a variable on the npc called iCon int 10 or whatever value you think that npc should have for the pc to check against. Then your script uses GetLocalInt(OBJECT_SELF, iCon) and it checks against the con of the player to that of the int.

    int StartingConditional()

    {

    object oPC=GetPCSpeaker();

    int iDC = GetLocalInt(OBJECT_SELF, "iCon");

    int iPCcon = GetAbilityScore(oPC, ABILITY_CONSTITUTION, TRUE);

    if(!(iPCcon>=iDC))

    return FALSE;

    return TRUE;

    }

    Then you can give each unique npc that you want the pc to run a check against its own value but ofc you would still need multiple scripts for other abilityes like strength, dexterity etc.

    Another way is just to get the constitution of the NPC with OBJECT_SELF during a conversation and avoid creating variables.

    int iDC = GetAbilityScore(OBJECT_SELF, ABILITY_CONSTITUTION, TRUE);

    It is all in the toolset just open the script editor and look for the command and it will give you information on how to use it. Voila!

    // Get the ability score of type nAbility for a creature (otherwise 0)
    // - oCreature: the creature whose ability score we wish to find out
    // - nAbilityType: ABILITY_*
    // - nBaseAbilityScore: if set to true will return the base ability score without
    // bonuses (e.g. ability bonuses granted from equipped items).
    // Return value on error: 0
  • tgxtgx Member Posts: 40
    Nice! I get it. I'm glad you responded, since I've been using my initial way for all sorts of things. But, I'll play with this and see how I go. Thanks again!
Sign In or Register to comment.