Author Topic: Silly quick question.  (Read 452 times)

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Silly quick question.
« on: June 11, 2013, 08:38:37 am »


               Sorry for posting it here, but I believe this is the place most people visit '<img'> and I have a better chance of someone answering! Besides... errr... it's sort of kind of maybe possibly mayhaps related to custom content!

I have tampered with the original campaign so much! Like... it was the first module I started editing, the one I learned lots of stuff from. However, as I was about doing even more changes, I realized during a test run that Open Lock and Disarm Trap don't give any XP gains. Since many custom modules do so, and many others don't, I assume such is implemented by the builder, and not necessarily activated automatically. However, I don't quite remember if those skills provided experience gains in the original campaign and expansions, or I clumsily deleted such script or something while going at them so many years ago.

So, I'm hoping some of you guys may refresh my memory on this subject.  Also, going at it again brought back some nice memories... Long live NWN!! ':wizard:'
               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Silly quick question.
« Reply #1 on: June 11, 2013, 10:28:44 am »


               It's done via scripting. For specifics (can't remember off the top of my head) ask in the scripting forum where they really know what they're talking about (unlike me('^_^')).

TR
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Silly quick question.
« Reply #2 on: June 12, 2013, 07:06:29 am »


               Well yes, I know it is done via scripting, but what I don't remember is if such is present in the Original campaign and expansions! ^__^
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Silly quick question.
« Reply #3 on: June 12, 2013, 05:03:55 pm »


               <opening...>

Those skills did not give xp in the OC or expansions.
As a rogueish wizard, I have always felt the lack.
IMO, every class skill should give xp when successfully used. :-P

<...his trap>
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Silly quick question.
« Reply #4 on: June 12, 2013, 08:22:53 pm »


               If you wanna add it yourself, here's a simple way to do it. Put the following on the OnUnLock event:


void main()
{
    object oUnlocked = OBJECT_SELF;
    object oPC       = GetLastUnlocked();
    string sName     = GetName(oPC);

    // If this isn't a PC or he's already unlocked this object, abort.
    if (!GetIsPC(oPC) || GetLocalInt(oUnlocked, "Unlocked: " + sName))
        return;

    // Our XP is just going to be the DC. Could modify this with some math to
    // fine-tune it, though.
    int nXP = GetLockUnlockDC(oUnlocked);
    GiveXPToCreature(oPC, nXP);

    // Mark the PC as having unlocked this object so he can't get infinite XP.
    SetLocalInt(oUnlocked, "Unlocked: " + sName, TRUE);
}

And this on the OnDisarm event:


void main()
{
    object oDisarmed = OBJECT_SELF;
    object oCreator  = GetTrapCreator(oDisarmed);
    object oPC       = GetLastDisarmed();
    string sName     = GetName(oPC);

    // If this isn't a PC, he set the trap, or he's disarmed this object's trap
    // before, abort.
    if (!GetIsPC(oPC) || oCreator == oPC || GetLocalInt(oDisarmed, "Disarmed: " + sName))
        return;

    // Our XP is just going to be the DC. Could modify this with some math to
    // fine-tune it, though.
    int nXP = GetTrapDisarmDC(oDisarmed);
    GiveXPToCreature(oPC, nXP);

    // Mark the PC as having disarmed this object so he can't get infinite XP.
    SetLocalInt(oDisarmed, "Disarmed: " + sName, TRUE);
}

               
               

               


                     Modifié par Squatting Monk, 13 juin 2013 - 02:06 .
                     
                  


            

Legacy_Killmonger

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +0/-0
Silly quick question.
« Reply #5 on: June 12, 2013, 10:19:17 pm »


               Nice...!!

Thank you for sharing ...
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Silly quick question.
« Reply #6 on: June 13, 2013, 06:35:46 am »


               WOW! 0__0 Thanks for clarifying Rolo, and even more thanks to you Monk! You sharing this is awesome!! I will try it out immediately!!
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Silly quick question.
« Reply #7 on: June 13, 2013, 02:33:16 pm »


               <getting...>

For the math portion, my thought is to compare DC against base skill. Subtract skill from DC, if >0 the XP = difference squared.
At the low end, this means no XP for a trap/lock that you can pick in your sleep.
At the high end, this makes the skill rewarding for challenging targets in similar manner to the scaled XP fighters get with variable opponents.

<...tricky>
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Silly quick question.
« Reply #8 on: June 13, 2013, 05:31:29 pm »


               

Rolo Kipp wrote...

<getting...>

For the math portion, my thought is to compare DC against base skill. Subtract skill from DC, if >0 the XP = difference squared.
At the low end, this means no XP for a trap/lock that you can pick in your sleep.
At the high end, this makes the skill rewarding for challenging targets in similar manner to the scaled XP fighters get with variable opponents.

<...tricky>


I do similar to what Rolo suggests, though its based on your overall levels vs the DC of the lock or trap and there's a minimum reward of 2xp ... even for the ones you can "do in your sleep".

XP for Locks:

void RewardPartyXP(int XP, object oTarget,int bAllParty=TRUE)
{
    if (bAllParty == TRUE)
    {
        object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            if( GetArea( oPartyMember) == GetArea( oTarget)) GiveXPToCreature( oPartyMember, XP);
            oPartyMember = GetNextFactionMember(oTarget, TRUE);
        }
    }
    else
    {
     GiveXPToCreature(oTarget, XP);
    }
}
object oPC=GetLastUnlocked();
int iXPaward = 0;
int iXPawarddc = 0;
void main()
{if(GetLocalInt(OBJECT_SELF,"unlock") == 1)
{return;}
iXPawarddc = (GetLockUnlockDC(OBJECT_SELF));
iXPaward = (iXPawarddc -((GetHitDice(oPC)+5)));
SetLocalInt(OBJECT_SELF,"unlock",1);
SendMessageToPC( (oPC ),"Unlocked");
if (iXPaward >= 2)
RewardPartyXP(iXPaward, oPC, TRUE);
else
RewardPartyXP(2, oPC, TRUE);
DelayCommand(600.0, SetLocalInt(OBJECT_SELF,"unlock",0));
}


XP for Traps:

void RewardPartyXP(int XP, object oTarget,int bAllParty=TRUE)
{
    if (bAllParty == TRUE)
    {
        object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            if( GetArea( oPartyMember) == GetArea( oTarget)) GiveXPToCreature( oPartyMember, XP);
            oPartyMember = GetNextFactionMember(oTarget, TRUE);
        }
    }
    else
    {
     GiveXPToCreature(oTarget, XP);
    }
}
object oPC=GetLastDisarmed();
int iXPaward = 0;
int iXPawarddc = 0;
void main()
{if(GetLocalInt(OBJECT_SELF,"disarm") == 1)
{return;}
iXPawarddc = (GetTrapDisarmDC(OBJECT_SELF));
iXPaward = (iXPawarddc -((GetHitDice(oPC)+5)));
SetLocalInt(OBJECT_SELF,"disarm",1);
SendMessageToPC( (oPC ),"Trap disarmed");
if (iXPaward >= 2)
RewardPartyXP(iXPaward, oPC, TRUE);
else
RewardPartyXP(2, oPC, TRUE);
DelayCommand(600.0, SetLocalInt(OBJECT_SELF,"disarm",0));
}


Both versions use a delayed command to allow a second, third, etc... attempt. This I think works better as if limited to once per PC, PCs can still relock or even retrap things and let others in their Party double dip.
               
               

               


                     Modifié par kalbaern, 13 juin 2013 - 04:33 .
                     
                  


            

Legacy_DA_Bhaall

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Silly quick question.
« Reply #9 on: June 03, 2014, 08:09:17 am »


               

Hi guys, i just wondering if is possible to attach these script to ALL doors/traps without doing it individually? Thx for answers.



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Silly quick question.
« Reply #10 on: June 03, 2014, 06:02:51 pm »


               


Hi guys, i just wondering if is possible to attach these script to ALL doors/traps without doing it individually? Thx for answers.




Unfortunately not. You'll have to edit each door, chest, etc... individually. If you're editting the OC or other premade modules, this would be quite the pain. If you're making your own custom module, then just premake doors, chests, etc... on your pallettes


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Silly quick question.
« Reply #11 on: June 03, 2014, 07:14:04 pm »


               


Hi guys, i just wondering if is possible to attach these script to ALL doors/traps without doing it individually? Thx for answers.




it is by using a letoscript macro, read more here


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Silly quick question.
« Reply #12 on: June 03, 2014, 11:37:01 pm »


               Yes, letoscript is your friend - well worth the learning curve, otherwise good ideas like this just get filed under "too difficult" in my experience.