Skip to content

Commit

Permalink
door unlock xp script
Browse files Browse the repository at this point in the history
  • Loading branch information
b5635 committed Sep 23, 2023
1 parent 2d1721e commit 4926ca6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/nss/area_init.nss
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void main()
//if (bInstance == 1)
//{
// every area is instanced now!
SetEventScript(oObject, EVENT_SCRIPT_DOOR_ON_UNLOCK, "unlock");
SetEventScript(oObject, EVENT_SCRIPT_DOOR_ON_UNLOCK, "door_unlock");
SetEventScript(oObject, EVENT_SCRIPT_DOOR_ON_MELEE_ATTACKED, "bash_lock");
nDoors = nDoors + 1;

Expand Down
18 changes: 18 additions & 0 deletions src/nss/door_unlock.nss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "inc_xp"

void main()
{
object oUnlocker = GetLastUnlocked();

if (GetObjectType(oUnlocker) == OBJECT_TYPE_CREATURE) PlaySound("gui_picklockopen");

// check if unlocked by a possessed pixie
if (!GetIsPC(oUnlocker)) oUnlocker = GetMaster(oUnlocker);

// do nothing if not a PC still
if (!GetIsPC(oUnlocker)) return;

GiveUnlockXP(oUnlocker, GetLockUnlockDC(OBJECT_SELF));
IncrementPlayerStatistic(oUnlocker, "locks_unlocked");
}

10 changes: 9 additions & 1 deletion src/nss/inc_xp.nss
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void UpdateXPBarUI(object oPC)

void GiveDialogueSkillXP(object oPC, int nDC, int nSkill)
{
float fXP = 2.0 + IntToFloat((nDC - 10) / 2);
float fXP = IntToFloat(nDC) / 2.5;

if (fXP > 16.0) fXP = 16.0;
if (fXP < 3.0) fXP = 3.0;
Expand All @@ -548,5 +548,13 @@ void GiveDialogueSkillXP(object oPC, int nDC, int nSkill)
GiveXPToPC(oPC, fXP, FALSE, sSkill);
}

void GiveUnlockXP(object oPC, int nDC)
{
float fXP = IntToFloat(nDC) / 3.0;

// cap
if (fXP > 14.0) fXP = 14.0;

GiveXPToPC(oPC, fXP, FALSE, "Unlocking");
}
//void main(){}
2 changes: 2 additions & 0 deletions src/nss/treas_unlock.nss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// this script is called when a treasure container is unlocked
#include "inc_general"
#include "inc_xp"

void main()
{
Expand All @@ -18,5 +19,6 @@ void main()
// do nothing if not a PC still
if (!GetIsPC(oUnlocker)) return;

GiveUnlockXP(oUnlocker, GetLockUnlockDC(OBJECT_SELF));
IncrementPlayerStatistic(oUnlocker, "locks_unlocked");
}
6 changes: 0 additions & 6 deletions src/nss/unlock.nss

This file was deleted.

0 comments on commit 4926ca6

Please sign in to comment.