home *** CD-ROM | disk | FTP | other *** search
/ PC Zone 125 / DPPCZ0203B.7z / DPPCZ0203B.ISO / Demos / Neverwinter / data1.cab / override / nw_i0_plot.nss < prev    next >
Text File  |  2002-09-10  |  34KB  |  1,056 lines

  1. //::///////////////////////////////////////////////
  2. //::
  3. //:: Designer Include File
  4. //::
  5. //:: NW_I0_PLOT.nss
  6. //::
  7. //:: Copyright (c) 2001 Bioware Corp.
  8. //::
  9. //::
  10. //:://////////////////////////////////////////////
  11. //::
  12. //::
  13. //:: This is a sample of design wrote
  14. //:: functions that may need inclusion in multiple
  15. //:: modules.
  16. //::
  17. //:://////////////////////////////////////////////
  18. //::
  19. //:: Created By: Brent Knowles
  20. //:: Created On: February 12, 2001
  21. //::
  22. //:://////////////////////////////////////////////
  23.  
  24. int DC_EASY = 0;
  25. int DC_MEDIUM = 1;
  26. int DC_HARD = 2;
  27. // * this is used by some of the template scripts
  28. // * 100 - this number is the chance of that dialog
  29. // * appearing
  30. int G_CLASSCHANCE = 70;
  31.  
  32.  
  33. // * FUNCTION DECLARATIONS
  34.  
  35. int GetCanCastHealingSpells(object oPC) ;
  36. int DoOnce();
  37. void DebugSpeak(string s);
  38. object GetMyMaster();
  39. int IsRecall();
  40. void DimensionHop(object oTarget);
  41. int CanSeePlayer();
  42. void EscapeArea(int bRun = TRUE, string sTag="NW_EXIT");
  43. int HasItem(object oCreature, string s);
  44. void TakeGold(int nAmount, object oGoldHolder, int bDestroy=TRUE);
  45. object GetNearestPC();
  46. void SetIsEnemy(object oTarget);
  47. int AutoDC(int DC, int nSkill, object oTarget);
  48. void AutoAlignG(int DC, object oTarget);
  49. void AutoAlignE(int DC, object oTarget);
  50. void DoGiveXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL);
  51. void RewardXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL, int bAllParty=TRUE);
  52. void RewardGP(int GP, object oTarget,int bAllParty=TRUE);
  53. int CheckCharismaMiddle();
  54. int CheckCharismaNormal();
  55. int CheckCharismaLow();
  56. int CheckCharismaHigh();
  57. int CheckIntelligenceLow();
  58. int CheckIntelligenceNormal();
  59. int CheckIntelligenceNormal();
  60. int CheckIntelligenceHigh();
  61. int CheckWisdomHigh();
  62. int GetWisdom(object oTarget);
  63. int GetIntelligence(object oTarget);
  64. int GetCharisma(object oTarget);
  65. int GetNumItems(object oTarget,string sItem);
  66. void GiveNumItems(object oTarget,string sItem,int nNumItems);
  67. void TakeNumItems(object oTarget,string sItem,int nNumItems);
  68. // * plays the correct character theme
  69. // * assumes OBJECT_SELF is in the area
  70. void PlayCharacterTheme(int nTheme);
  71. // * plays the old theme for the area
  72. // * assumes OBJECT_SELF is in the area
  73. void PlayOldTheme();
  74. int GetPLocalInt(object oPC,string sLocalName);
  75. void SetPLocalInt(object oPC,string sLocalName, int nValue);
  76. // * removes all negative effects
  77. void RemoveEffects(object oDead);
  78.  
  79. // * plays the correct character theme
  80. // * assumes OBJECT_SELF is in the area
  81. void PlayCharacterTheme(int nTheme)
  82. {
  83.     object oArea =GetArea(OBJECT_SELF);
  84.     int nMusicNight = MusicBackgroundGetNightTrack(oArea);
  85.     int nMusicDay = MusicBackgroundGetDayTrack(oArea);
  86.    // AssignCommand(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC), SpeakString(IntToString(nMusic)));
  87.     //* stores the last music track
  88.     SetLocalInt(oArea, "NW_L_MYLASTTRACKNight", nMusicNight);
  89.     SetLocalInt(oArea, "NW_L_MYLASTTRACKDay", nMusicDay);
  90.     MusicBackgroundStop(oArea);
  91.     MusicBackgroundChangeNight(oArea, nTheme);
  92.     MusicBackgroundChangeDay(oArea, nTheme);
  93.     MusicBackgroundPlay(oArea);
  94.  
  95. }
  96.  
  97. // * plays the old theme for the area
  98. // * assumes OBJECT_SELF is in the area
  99. void PlayOldTheme()
  100. {
  101.     object oArea =GetArea(OBJECT_SELF);
  102.     //* stores the last music track
  103.     int nMusicNight = GetLocalInt(oArea, "NW_L_MYLASTTRACKNight");
  104.     int nMusicDay = GetLocalInt(oArea, "NW_L_MYLASTTRACKDay");
  105.     MusicBackgroundStop(oArea);
  106.     MusicBackgroundChangeNight(oArea, nMusicNight);
  107.     MusicBackgroundChangeDay(oArea, nMusicDay);
  108.     MusicBackgroundPlay(oArea);
  109.  
  110. }
  111.  
  112.  
  113. //  Returns the adjusted Reaction for the purposes of store pricing.
  114. float GetReactionAdjustment(object oTarget);
  115. /*
  116.     Adjusts all faction member's reputation visa via
  117.     another faction.  Pass in a member from each
  118.     faction.
  119. */
  120. void AdjustFactionReputation(object oTargetCreature, object oMemberOfSourceFaction, int nAdjustment);
  121. /*
  122.     Makes the person teleport away and look like
  123.     they are casting a spell.
  124. */
  125. void EscapeViaTeleport(object oFleeing);
  126.  
  127. // * FUNCTION DEFINITIONS
  128.  
  129.  
  130. int GetCanCastHealingSpells(object oPC)
  131. {
  132.     talent tTalent = GetCreatureTalentBest(TALENT_CATEGORY_BENEFICIAL_HEALING_TOUCH, 20, oPC);
  133.     if (GetIsTalentValid(tTalent) == TRUE)
  134.     {
  135.       return TRUE;
  136.     }
  137.       return FALSE;
  138. }
  139.  
  140.  
  141. int DoOnce()
  142. {
  143.     int bResult = FALSE;
  144.  
  145.     if (GetLocalInt(OBJECT_SELF,"NW_L_DOONCE999") == 0)
  146.     {
  147.         SetLocalInt(OBJECT_SELF,"NW_L_DOONCE999",1);
  148.         bResult = TRUE;
  149.     }
  150.     return bResult;
  151. }
  152.  
  153. void DebugSpeak(string s)
  154. {
  155.     SpeakString(s);
  156. }
  157. object GetMyMaster()
  158. {
  159.     return GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
  160. }
  161.  
  162.  
  163.  
  164. //::///////////////////////////////////////////////
  165. //:: IsRecall
  166. //:: Copyright (c) 2001 Bioware Corp.
  167. //:://////////////////////////////////////////////
  168. /*
  169.     Attempts  to transport the player
  170.     back to closest Temple of Tyr using
  171.     a Recall Stone.
  172. */
  173. //:://////////////////////////////////////////////
  174. //:: Created By:
  175. //:: Created On:
  176. //:://////////////////////////////////////////////
  177. int IsRecall()
  178. {
  179.     if (GetTag(GetItemActivated()) == "NW_IT_RECALL")
  180.     {
  181.        string sAreaTag = GetTag(GetArea(GetItemActivator()));
  182.        if (/*Chapter 1 Areas*/
  183.            sAreaTag == "MAP_M1S3B" ||
  184.            sAreaTag == "Map_M1S4C" ||
  185.            sAreaTag == "MAP_M1Q6F4" || // Fenthick area in Chapter1e
  186.            sAreaTag == "Map_M1S4D" ||
  187.            sAreaTag == "Map_M1S4E" ||
  188.            sAreaTag == "Map_M1S4F" ||
  189.  
  190.            /* Chapter 3 and 4 Areas*/
  191.            sAreaTag == "MAP_M1Q6A" || /*Castle Never*/
  192.            sAreaTag == "M4Q1D2" /*Final Source Stone level*/ ||
  193.            sAreaTag == "M4FinalArea" || /*Haedralines area*/
  194.            sAreaTag == "M3Q1A10" || /*Aarin Gend's Lodge*/
  195.            sAreaTag == "M3Q3C" || sAreaTag == "M3Q3Ca" ||  sAreaTag == "M3Q2G" ||  sAreaTag == "M3Q2I" ||
  196.            sAreaTag == "Map_M2Q2E2" || sAreaTag == "Map_M2Q2G" || sAreaTag == "Map_M2Q3GA" || sAreaTag == "Map_M2Q3GB")
  197.        {
  198.         AssignCommand(GetItemActivator(), ActionSpeakStringByStrRef(10611));
  199.         return TRUE;
  200.        }
  201.        else
  202. /*       if (CanAffordIt() == FALSE)
  203.        {
  204.         AssignCommand(GetItemActivator(), ActionSpeakStringByStrRef(66200));
  205.         return TRUE;
  206.  
  207.        }
  208.        else */
  209.        // * May 2002: Checking a global to see if Haedraline is around as well
  210.        if (        GetLocalInt(GetModule(),"NW_G_RECALL_HAED") == 10
  211.        || GetIsObjectValid(GetNearestObjectByTag("Haedraline3Q11", GetItemActivator())) == TRUE)
  212.        {
  213.         AssignCommand(GetItemActivator(), ActionSpeakStringByStrRef(10612));
  214.         return TRUE;
  215.        }
  216.        else
  217.        {
  218.            object oPortal = GetObjectByTag("NW_RECALL_PORTAL");
  219.            if (GetIsObjectValid(oPortal) == TRUE)
  220.            {
  221.              SetLocalInt(GetItemActivator(), "NW_L_USED_RECALL", 1);
  222.              SetLocalLocation(GetItemActivator(), "NW_L_LOC_RECALL", GetLocation(GetItemActivator()));
  223.              string sTag =  "NW_RECALL_PORTAL";
  224.               object oClicker = GetItemActivator();
  225.               object oTarget = GetObjectByTag(sTag);
  226.              // AssignCommand(GetItemActivator(), SpeakString(sTag));
  227.                 // * if I don't do this, gets stuck in a loop
  228.                 // * of casting.
  229.               AssignCommand(oClicker, ClearAllActions());
  230.               
  231.               AssignCommand(oClicker, PlaySound("as_mg_telepout1"));
  232.               
  233.               
  234.               //SetAreaTransitionBMP(AREA_TRANSITION_RANDOM);
  235. //              AssignCommand(oClicker, PlaySound("as_mg_telepout1"));
  236.               AssignCommand(oClicker,JumpToObject(oTarget));
  237. //              AssignCommand(oClicker, DelayCommand(1.0,PlaySound("as_mg_telepout1")));
  238.               AssignCommand(oClicker, ActionDoCommand(ClearAllActions()));
  239.               return TRUE;
  240.            }
  241.            // * this module does not have a temple of tyr
  242.            else
  243.            {
  244.                 AssignCommand(GetItemActivator(), ActionSpeakStringByStrRef(10614));
  245.                 return TRUE;
  246.            }
  247.        }
  248.     }
  249.     return FALSE;
  250.  
  251. }
  252.  
  253. //::///////////////////////////////////////////////
  254. //:: DimensionHop
  255. //:: Copyright (c) 2001 Bioware Corp.
  256. //:://////////////////////////////////////////////
  257. /*
  258.      Will move the character from one point to oTarget
  259.      with a flashy graphic.
  260.      Original Use: Dryads in M3Q3, SnowGlobe
  261. */
  262. //:://////////////////////////////////////////////
  263. //:: Created By: Brent
  264. //:: Created On: January 10, 2002
  265. //:://////////////////////////////////////////////
  266.  
  267. void DimensionHop(object oTarget)
  268. {
  269.     if (GetDistanceToObject(oTarget) > 2.5)
  270.     {
  271.         effect eVis = EffectVisualEffect(VFX_IMP_UNSUMMON);
  272.         ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
  273.         ActionJumpToObject(oTarget);
  274.     }
  275. }
  276.  
  277.  
  278.  
  279. //::///////////////////////////////////////////////
  280. //:: CanSeePlayer
  281. //:: Copyright (c) 2001 Bioware Corp.
  282. //:://////////////////////////////////////////////
  283. /*
  284.    Returns true if OBJECT_SELF can see the player
  285. */
  286. //:://////////////////////////////////////////////
  287. //:: Created By:
  288. //:: Created On:
  289. //:://////////////////////////////////////////////
  290.  
  291. int CanSeePlayer()
  292. {
  293.     return GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN));
  294. }
  295. //::///////////////////////////////////////////////
  296. //:: EscapeArea()
  297. //:: Copyright (c) 2001 Bioware Corp.
  298. //:://////////////////////////////////////////////
  299. /*
  300.   Runs object to nearest waypoint with tag
  301.   "NW_EXIT".  This tag can be overridden.
  302.   You can also specify whether to run or not.
  303. */
  304. //:://////////////////////////////////////////////
  305. //:: Created By: Brent
  306. //:: Created On: December 2001
  307. //:://////////////////////////////////////////////
  308. void EscapeArea(int bRun = TRUE, string sTag="NW_EXIT")
  309. {
  310.     object oWay = GetNearestObjectByTag(sTag);
  311.     if (GetIsObjectValid(oWay))
  312.     {
  313.         ActionMoveToObject(oWay, bRun);
  314.         ActionDoCommand(DestroyObject(OBJECT_SELF));
  315.         SetCommandable(FALSE); // * this prevents them from being interrupted
  316.     }
  317.     else
  318.     SpeakString("invalid exit waypoint");
  319. }
  320.  
  321. //::///////////////////////////////////////////////
  322. //:: HasItem
  323. //:: Copyright (c) 2001 Bioware Corp.
  324. //:://////////////////////////////////////////////
  325. /*
  326.       A wrapper to simplify checking for an item.
  327. */
  328. //:://////////////////////////////////////////////
  329. //:: Created By:        Brent
  330. //:: Created On:        November 2001
  331. //:://////////////////////////////////////////////
  332.  
  333. int HasItem(object oCreature, string s)
  334. {
  335.     return  GetIsObjectValid(GetItemPossessedBy(oCreature, s));
  336. }
  337.  
  338. //::///////////////////////////////////////////////
  339. //:: Take Gold
  340. //:: Copyright (c) 2001 Bioware Corp.
  341. //:://////////////////////////////////////////////
  342. /*
  343.     Takes nAmount of gold from the object speaking.
  344.     By default, the gold is destroyed.
  345. */
  346. //:://////////////////////////////////////////////
  347. //:: Created By: Brent
  348. //:: Created On: November 2001
  349. //:://////////////////////////////////////////////
  350. void TakeGold(int nAmount, object oGoldHolder, int bDestroy=TRUE)
  351. {
  352.     TakeGoldFromCreature(nAmount, oGoldHolder, bDestroy);
  353. }
  354.  
  355.  
  356. //::///////////////////////////////////////////////
  357. //:: HasGold
  358. //:: Copyright (c) 2001 Bioware Corp.
  359. //:://////////////////////////////////////////////
  360. /*
  361.     Checks to see if the player has nAmount of gold
  362. */
  363. //:://////////////////////////////////////////////
  364. //:: Created By:
  365. //:: Created On:
  366. //:://////////////////////////////////////////////
  367. int HasGold(int nAmount, object oGoldHolder)
  368. {
  369.     return GetGold(oGoldHolder) >= nAmount;
  370. }
  371.  
  372. //:: GetNearestPC
  373. //////////////////////////////////////////////////
  374. //
  375. //  GetNearestPC
  376. //
  377. //////////////////////////////////////////////////
  378. //
  379. //
  380. // Returns the PC closes to the object calling
  381. // the function.
  382. //
  383. //////////////////////////////////////////////////
  384. //
  385. //  Created By: Brent
  386. //  Created On: May 16, 2001
  387. //
  388. //////////////////////////////////////////////////
  389. object GetNearestPC()
  390. {
  391.    return GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC);
  392. }
  393.  
  394.  
  395. //:: SetIsEnemy
  396. //////////////////////////////////////////////////
  397. //
  398. //  [Function Name]
  399. //
  400. //////////////////////////////////////////////////
  401. //
  402. //
  403. // [A description of the function.  This should contain any
  404. // special ranges on input values]
  405. //
  406. //////////////////////////////////////////////////
  407. //
  408. //  Created By:
  409. //  Created On:
  410. //
  411. //////////////////////////////////////////////////
  412. void SetIsEnemy(object oTarget)
  413. {
  414.     AdjustReputation(oTarget, OBJECT_SELF,-100);
  415.     ActionAttack(oTarget);
  416. }
  417.  
  418.  
  419. ///////////////////////////////////////////////////////////////////////////////
  420. //
  421. //  AutoDC
  422. //
  423. ///////////////////////////////////////////////////////////////////////////////
  424. //  Returns a pass value based on the object's level and the suggested DC
  425. // December 20 2001: Changed so that the difficulty is determined by the
  426. // NPC's Hit Dice
  427. ///////////////////////////////////////////////////////////////////////////////
  428. //  Created By: Brent, September 13 2001
  429. ///////////////////////////////////////////////////////////////////////////////
  430. int AutoDC(int DC, int nSkill, object oTarget)
  431. {
  432.     /*
  433.     Easy = Lvl/4 ...rounded up
  434.     Moderate = 3/Lvl + Lvl ...rounded up
  435.     Difficult = Lvl * 1.5 + 6 ...rounded up
  436.     */
  437.     int nLevel = GetHitDice(OBJECT_SELF);
  438.     int nTest = 0;
  439.  
  440.     // * July 2
  441.     // * If nLevel is less than 0 or 0 then set it to 1
  442.     if (nLevel <= 0)
  443.     {
  444.         nLevel = 1;
  445.     }
  446.     
  447.     switch (DC)
  448.     {
  449.     case 0: nTest = nLevel / 4 + 1; break;
  450.         // * minor tweak to lower the values a little
  451.     case 1: nTest = (3 / nLevel + nLevel) - abs( (nLevel/2) -2); break;
  452.     case 2: nTest = FloatToInt(nLevel * 1.5 + 6) - abs( ( FloatToInt(nLevel/1.5) -2));   break;
  453.     }
  454.     //SpeakString(IntToString(nTest));
  455.     
  456.     // * Roll d20 + skill rank vs. DC + 10
  457.     if (GetSkillRank(nSkill, oTarget) + d20() >= nTest + 10)
  458.     {
  459.        return TRUE;
  460.     }
  461.        return FALSE;
  462. }
  463.  
  464. ///////////////////////////////////////////////////////////////////////////////
  465. //
  466. //  AutoAlignG(int DC, object oTarget)
  467. //
  468. ///////////////////////////////////////////////////////////////////////////////
  469. //  Adjusts the alignment of the object towards good, relative to the
  470. //  degree indicated.
  471. ///////////////////////////////////////////////////////////////////////////////
  472. //  Created By: Brent, September 13, 2001
  473. ///////////////////////////////////////////////////////////////////////////////
  474. void AutoAlignG(int DC, object oTarget)
  475. {
  476.     int nShift = 0;
  477.     switch (DC)
  478.     {
  479.         case 0: nShift = 3;  break;
  480.         case 1: nShift = 7; break;
  481.         case 2: nShift = 10; break;
  482.     }
  483.     AdjustAlignment(oTarget, ALIGNMENT_GOOD, nShift);
  484. }
  485. ///////////////////////////////////////////////////////////////////////////////
  486. //
  487. //  AutoAlignE
  488. //
  489. ///////////////////////////////////////////////////////////////////////////////
  490. //  Adjusts the alignment of the object towards evil, relative to the
  491. //  degree indicated.
  492. ///////////////////////////////////////////////////////////////////////////////
  493. //  Created By: Brent, September 13, 2001
  494. ///////////////////////////////////////////////////////////////////////////////
  495. void AutoAlignE(int DC, object oTarget)
  496. {
  497.     int nShift = 0;
  498.     switch (DC)
  499.     {
  500.         case 0: nShift = 3;   break;
  501.         case 1: nShift = 7;  break;
  502.         case 2: nShift = 10;  break;
  503.     }
  504.     AdjustAlignment(oTarget, ALIGNMENT_EVIL, nShift);
  505. }
  506.  
  507.  
  508. //::///////////////////////////////////////////////
  509. //:: DoGiveXP
  510. //:: Copyright (c) 2001 Bioware Corp.
  511. //:://////////////////////////////////////////////
  512. /*
  513.       Gives the designated XP to the object
  514.       using the design rules for XP
  515.       distribution.
  516. */
  517. //:://////////////////////////////////////////////
  518. //:: Created By:
  519. //:: Created On:
  520. //:://////////////////////////////////////////////
  521.  
  522. void DoGiveXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL)
  523. {
  524.  
  525.     float nRewardMod = 1.0;
  526.     // * error handling
  527.     if ((nPercentage < 0) || (nPercentage > 100))
  528.     {
  529.         nPercentage = 100;
  530.     }
  531.     float nXP = GetJournalQuestExperience(sJournalTag) * (nPercentage * 0.01);
  532.  
  533.     // * for each party member
  534.     // * cycle through them and
  535.     // * and give them the appropriate reward
  536.     // * HACK FOR NOW
  537.     if ((GetAlignmentGoodEvil(oTarget) == ALIGNMENT_NEUTRAL) || (QuestAlignment ==ALIGNMENT_NEUTRAL) )
  538.     {
  539.         nRewardMod = 1.0;
  540.     }
  541.     else
  542.     if (GetAlignmentGoodEvil(oTarget) == QuestAlignment)
  543.     {
  544.         nRewardMod = 1.25;
  545.     }
  546.     else
  547.     if (GetAlignmentGoodEvil(oTarget) != QuestAlignment)
  548.     {
  549.         nRewardMod = 0.75;
  550.     }
  551. //    AssignCommand(oTarget,SpeakString("My XP reward is: " + FloatToString(nRewardMod * nXP)));
  552.     GiveXPToCreature(oTarget, FloatToInt(nRewardMod * nXP));
  553.     
  554. }
  555. ///////////////////////////////////////////////////////////////////////////////
  556. //
  557. //  RewardXP
  558. //
  559. ///////////////////////////////////////////////////////////////////////////////
  560. //  Gives each player the reward, scaled 1.25 times if of the correct alignment
  561. //  and 0.75 times if of the wrong alignment.  Neutral always get the
  562. //  1.0 times reward.
  563. ///////////////////////////////////////////////////////////////////////////////
  564. //  Created By: Brent, September 13, 2001
  565. ///////////////////////////////////////////////////////////////////////////////
  566. void RewardXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL, int bAllParty=TRUE)
  567. {
  568.  
  569. //   AssignCommand(oTarget, SpeakString("in rewardxp funtion"));
  570.     if (bAllParty == TRUE)
  571.     {
  572.         object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
  573.         while (GetIsObjectValid(oPartyMember) == TRUE)
  574.         {
  575.             DoGiveXP(sJournalTag, nPercentage, oPartyMember, QuestAlignment);
  576.             oPartyMember = GetNextFactionMember(oTarget, TRUE);
  577. //            AssignCommand(oTarget,SpeakString("here your xp sir"));
  578.         }
  579.     }
  580.     else
  581.     {
  582.      DoGiveXP(sJournalTag, nPercentage, oTarget, QuestAlignment);
  583.     }
  584.  
  585.  
  586. }
  587.  
  588.  
  589. ///////////////////////////////////////////////////////////////////////////////
  590. //
  591. //  RewardGP
  592. //
  593. ///////////////////////////////////////////////////////////////////////////////
  594. //  Gives the GP to (if bAllParty = TRUE) all party members.
  595. //  Each players gets the GP value amount.
  596. ///////////////////////////////////////////////////////////////////////////////
  597. //  Created By: Brent, September 13, 2001
  598. ///////////////////////////////////////////////////////////////////////////////
  599.  
  600. void RewardGP(int GP, object oTarget,int bAllParty=TRUE)
  601. {
  602.     // * for each party member
  603.     // * cycle through them and
  604.     // * and give them the appropriate reward
  605.     // * HACK FOR NOW
  606.     if (bAllParty == TRUE)
  607.     {
  608.         object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
  609.         while (GetIsObjectValid(oPartyMember) == TRUE)
  610.         {
  611.             //AssignCommand(oPartyMember, SpeakString("MY GP reward is: " + IntToString(GP)));
  612.             GiveGoldToCreature(oPartyMember, GP);
  613.             oPartyMember = GetNextFactionMember(oTarget, TRUE);
  614.         }
  615.     }
  616.     else
  617.     {
  618.      GiveGoldToCreature(oTarget, GP);
  619.     }
  620. }
  621.  
  622.  
  623. // *
  624. // * Conversation Functions
  625. // *
  626.  
  627. ///////////////////////////////////////////////////////////////////////////////
  628. //
  629. //  CheckCharismaMiddle
  630. //
  631. ///////////////////////////////////////////////////////////////////////////////
  632. //  Returns TRUE if charisma is in the normal range.
  633. ///////////////////////////////////////////////////////////////////////////////
  634. //  Created By: Brent, September 13, 2001
  635. ///////////////////////////////////////////////////////////////////////////////
  636. int CheckCharismaMiddle()
  637. {
  638.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_CHARISMA) >= 10 && GetAbilityScore(GetPCSpeaker(),ABILITY_CHARISMA) < 15)
  639.  {
  640.    return TRUE;
  641.  }
  642.  return FALSE;
  643. }
  644.  
  645. ///////////////////////////////////////////////////////////////////////////////
  646. //
  647. //  CheckCharismaNormal
  648. //
  649. ///////////////////////////////////////////////////////////////////////////////
  650. //  Returns TRUE if charisma is in the normal range.
  651. ///////////////////////////////////////////////////////////////////////////////
  652. //  Created By: Brent, September 13, 2001
  653. ///////////////////////////////////////////////////////////////////////////////
  654. int CheckCharismaNormal()
  655. {
  656.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_CHARISMA) >= 10)
  657.  {
  658.    return TRUE;
  659.  }
  660.  return FALSE;
  661. }
  662.  
  663. ///////////////////////////////////////////////////////////////////////////////
  664. //
  665. //  CheckCharismaLow
  666. //
  667. ///////////////////////////////////////////////////////////////////////////////
  668. //  Returns TRUE if charisma is in the low range.
  669. ///////////////////////////////////////////////////////////////////////////////
  670. //  Created By: Brent, September 13, 2001
  671. ///////////////////////////////////////////////////////////////////////////////
  672. int CheckCharismaLow()
  673. {
  674.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_CHARISMA) < 10)
  675.  {
  676.   return TRUE;
  677.  }
  678.  return FALSE;
  679. }
  680. ///////////////////////////////////////////////////////////////////////////////
  681. //
  682. //  CheckCharismaHigh
  683. //
  684. ///////////////////////////////////////////////////////////////////////////////
  685. //  Returns TRUE if charisma is in the high range.
  686. ///////////////////////////////////////////////////////////////////////////////
  687. //  Created By: Brent, September 13, 2001
  688. ///////////////////////////////////////////////////////////////////////////////
  689. int CheckCharismaHigh()
  690. {
  691.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_CHARISMA) >= 15)
  692.  {
  693.   return TRUE;
  694.  }
  695.  return FALSE;
  696. }
  697. ///////////////////////////////////////////////////////////////////////////////
  698. //
  699. //  CheckIntelligenceLow
  700. //
  701. ///////////////////////////////////////////////////////////////////////////////
  702. //  Returns TRUE if intelligence is in the low range
  703. ///////////////////////////////////////////////////////////////////////////////
  704. //  Created By: Brent, September 13, 2001
  705. ///////////////////////////////////////////////////////////////////////////////
  706.  
  707. int CheckIntelligenceLow()
  708. {
  709.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_INTELLIGENCE) < 9)
  710.    return TRUE;
  711.  return FALSE;
  712. }
  713.  
  714. ///////////////////////////////////////////////////////////////////////////////
  715. //
  716. //  CheckIntelligenceNormal
  717. //
  718. ///////////////////////////////////////////////////////////////////////////////
  719. //  Returns TRUE if intelligence is in the normal range
  720. ///////////////////////////////////////////////////////////////////////////////
  721. //  Created By: Brent, September 13, 2001
  722. ///////////////////////////////////////////////////////////////////////////////
  723. int CheckIntelligenceNormal()
  724. {
  725.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_INTELLIGENCE) >= 9)
  726.    return TRUE;
  727.  return FALSE;
  728. }
  729.  
  730. //::///////////////////////////////////////////////
  731. //:: CheckIntelligenceHigh
  732. //:: Copyright (c) 2001 Bioware Corp.
  733. //:://////////////////////////////////////////////
  734. /*
  735.  
  736. */
  737. //:://////////////////////////////////////////////
  738. //:: Created By:
  739. //:: Created On:
  740. //:://////////////////////////////////////////////
  741.  
  742. int CheckIntelligenceHigh()
  743. {
  744.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_INTELLIGENCE) >= 15)
  745.    return TRUE;
  746.  return FALSE;
  747. }
  748. ///////////////////////////////////////////////////////////////////////////////
  749. //
  750. //  CheckWisdomHigh
  751. //
  752. ///////////////////////////////////////////////////////////////////////////////
  753. //  Returns TRUE if wisdom is in the High range
  754. ///////////////////////////////////////////////////////////////////////////////
  755. //  Created By: Brent, September 13, 2001
  756. ///////////////////////////////////////////////////////////////////////////////
  757. int CheckWisdomHigh()
  758. {
  759.  if (GetAbilityScore(GetPCSpeaker(),ABILITY_WISDOM) > 13)
  760.    return TRUE;
  761.  return FALSE;
  762. }
  763.  
  764. int GetWisdom(object oTarget)
  765. {
  766.     return GetAbilityScore(oTarget, ABILITY_WISDOM);
  767. }
  768. int GetIntelligence(object oTarget)
  769. {
  770.     return GetAbilityScore(oTarget, ABILITY_WISDOM);
  771. }
  772. int GetCharisma(object oTarget)
  773. {
  774.     return GetAbilityScore(oTarget, ABILITY_CHARISMA);
  775. }
  776.  
  777. //:: GetNumItems
  778. //////////////////////////////////////////////////
  779. //
  780. //  GetNumItems
  781. //
  782. //////////////////////////////////////////////////
  783. //
  784. //
  785. // Returns the number of specified item in the
  786. // target's inventory.
  787. //
  788. //////////////////////////////////////////////////
  789. //
  790. //  Created By: John
  791. //  Created On: September 19, 2001
  792. //
  793. //////////////////////////////////////////////////
  794. int GetNumItems(object oTarget,string sItem)
  795. {
  796.     int nNumItems = 0;
  797.     object oItem = GetFirstItemInInventory(oTarget);
  798.  
  799.     while (GetIsObjectValid(oItem) == TRUE)
  800.     {
  801.         if (GetTag(oItem) == sItem)
  802.         {
  803.             nNumItems = nNumItems + GetNumStackedItems(oItem);
  804.         }
  805.         oItem = GetNextItemInInventory(oTarget);
  806.     }
  807.  
  808.    return nNumItems;
  809. }
  810.  
  811. //:: GiveNumItems
  812. //////////////////////////////////////////////////
  813. //
  814. //  GiveNumItems
  815. //
  816. //////////////////////////////////////////////////
  817. //
  818. //
  819. // Gives the target the number of items specified.
  820. //
  821. //////////////////////////////////////////////////
  822. //
  823. //  Created By: John
  824. //  Created On: September 19, 2001
  825. //
  826. //////////////////////////////////////////////////
  827. void GiveNumItems(object oTarget,string sItem,int nNumItems)
  828. {
  829.     int nCount = 0;
  830.     object oItem = GetFirstItemInInventory(OBJECT_SELF);
  831.  
  832.     while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)
  833.     {
  834.         if (GetTag(oItem) == sItem)
  835.         {
  836.             ActionGiveItem(oItem,oTarget);
  837.             nCount++;
  838.         }
  839.         oItem = GetNextItemInInventory(OBJECT_SELF);
  840.     }
  841.  
  842.    return;
  843. }
  844.  
  845. //:: TakeNumItems
  846. //////////////////////////////////////////////////
  847. //
  848. //  TakeNumItems
  849. //
  850. //////////////////////////////////////////////////
  851. //
  852. //
  853. // Takes the number of items specified from the target.
  854. //
  855. //////////////////////////////////////////////////
  856. //
  857. //  Created By: John
  858. //  Created On: September 19, 2001
  859. //
  860. //////////////////////////////////////////////////
  861. void TakeNumItems(object oTarget,string sItem,int nNumItems)
  862. {
  863.     int nCount = 0;
  864.     object oItem = GetFirstItemInInventory(oTarget);
  865.  
  866.     while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)
  867.     {
  868.         if (GetTag(oItem) == sItem)
  869.         {
  870.             ActionTakeItem(oItem,oTarget);
  871.             nCount++;
  872.         }
  873.         oItem = GetNextItemInInventory(oTarget);
  874.     }
  875.  
  876.    return;
  877. }
  878.  
  879.  
  880. ///////////////////////////////////////////////////////////////////////////////
  881. //
  882. //  GetReactionAdjustment
  883. //
  884. ///////////////////////////////////////////////////////////////////////////////
  885. //  Returns the adjusted Reaction for the purposes of store pricing.
  886. ///////////////////////////////////////////////////////////////////////////////
  887. //  Created By: Brent, September 25, 2001
  888. ///////////////////////////////////////////////////////////////////////////////
  889.  float GetReactionAdjustment(object oTarget)
  890. {
  891.     float nFactionAdjustment = 2.0;
  892.     // (i)
  893.     if (GetIsFriend(oTarget) == TRUE)
  894.     {
  895.         nFactionAdjustment = 1.0;
  896.     }
  897.  
  898.     // (ii)
  899.     int oTargetLawChaos = GetLawChaosValue(oTarget);
  900.     int oTargetGoodEvil = GetGoodEvilValue(oTarget);
  901.     int oSourceLawChaos = GetLawChaosValue(OBJECT_SELF);
  902.     int oSourceGoodEvil = GetGoodEvilValue(OBJECT_SELF);
  903.     int APB = abs(oSourceLawChaos - oTargetLawChaos)  + abs(oSourceGoodEvil - oTargetGoodEvil);
  904.     int nTargetCharismaMod = GetAbilityModifier(ABILITY_CHARISMA, oTarget);
  905.     return abs(10 + APB - (nTargetCharismaMod * 10)) * nFactionAdjustment;
  906.  
  907. }
  908.  
  909. //::///////////////////////////////////////////////
  910. //:: AdjustFactionReputation
  911. //:: Copyright (c) 2001 Bioware Corp.
  912. //:://////////////////////////////////////////////
  913. /*
  914.     Adjusts all faction member's reputation visa via
  915.     another faction.  Pass in a member from each
  916.     faction.
  917. */
  918. //:://////////////////////////////////////////////
  919. //:: Created By: Presotn Watamaniuk
  920. //:: Created On: Nov 15, 2001
  921. //:://////////////////////////////////////////////
  922. void AdjustFactionReputation(object oTargetCreature, object oMemberOfSourceFaction, int nAdjustment)
  923. {
  924.     object oFaction = GetFirstFactionMember(oTargetCreature);
  925.     while(GetIsObjectValid(oFaction))
  926.     {
  927.         AdjustReputation(oTargetCreature, oMemberOfSourceFaction, nAdjustment);
  928.         oFaction = GetNextFactionMember(oTargetCreature);
  929.     }
  930.     AdjustReputation(oTargetCreature, oMemberOfSourceFaction, nAdjustment);
  931. }
  932.  
  933. //::///////////////////////////////////////////////
  934. //:: Escape Via Teleport
  935. //:: Copyright (c) 2001 Bioware Corp.
  936. //:://////////////////////////////////////////////
  937. /*
  938.     Makes the person teleport away and look like
  939.     they are casting a spell.
  940. */
  941. //:://////////////////////////////////////////////
  942. //:: Created By: Preston Watamaniuk
  943. //:: Created On: March 12, 2002
  944. //:://////////////////////////////////////////////
  945.  
  946. void EscapeViaTeleport(object oFleeing)
  947. {
  948.     effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
  949.     ActionCastFakeSpellAtObject(SPELL_MINOR_GLOBE_OF_INVULNERABILITY, oFleeing);
  950.     DelayCommand(1.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oFleeing)));
  951.     DestroyObject(oFleeing, 2.5);
  952. }
  953.  
  954.  
  955. //::///////////////////////////////////////////////
  956. //:: GetP(arty)LocalInt
  957. //:: Copyright (c) 2001 Bioware Corp.
  958. //:://////////////////////////////////////////////
  959. /*
  960.     Scans through all players in the party, to
  961.     treat them all as 'one person' for the purposes
  962.     of most plots. Makes our plots more multiplayer friendly.
  963. */
  964. //:://////////////////////////////////////////////
  965. //:: Created By: John
  966. //:: Created On:
  967. //:://////////////////////////////////////////////
  968. int GetPLocalInt(object oPC,string sLocalName)
  969. {
  970.     int nValue = 0;
  971.     object oMember;
  972.  
  973.     oMember = GetFirstFactionMember(oPC);
  974.  
  975.     while (GetIsObjectValid(oMember))
  976.     {
  977.         if (GetLocalInt(oPC,sLocalName) > nValue)
  978.         {
  979.             nValue = GetLocalInt(oMember,sLocalName);
  980.         }
  981.         oMember = GetNextFactionMember(oPC);
  982.     }
  983.  
  984.     return nValue;
  985. }
  986. //::///////////////////////////////////////////////
  987. //:: SetP(arty)LocalInt
  988. //:: Copyright (c) 2001 Bioware Corp.
  989. //:://////////////////////////////////////////////
  990. /*
  991.  
  992. */
  993. //:://////////////////////////////////////////////
  994. //:: Created By: John
  995. //:: Created On:
  996. //:://////////////////////////////////////////////
  997. void SetPLocalInt(object oPC,string sLocalName, int nValue)
  998. {
  999.     object oMember;
  1000.  
  1001.     oMember = GetFirstFactionMember(oPC);
  1002.  
  1003.     while (GetIsObjectValid(oMember))
  1004.     {
  1005.         SetLocalInt(oMember,sLocalName,nValue);
  1006.          oMember = GetNextFactionMember(oPC);
  1007.     }
  1008.  
  1009.     return;
  1010. }
  1011. // * removes all negative effects
  1012. void RemoveEffects(object oDead)
  1013. {
  1014.     //Declare major variables
  1015.     object oTarget = oDead;
  1016.     effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
  1017.     int bValid;
  1018.  
  1019.     effect eBad = GetFirstEffect(oTarget);
  1020.     //Search for negative effects
  1021.     while(GetIsEffectValid(eBad))
  1022.     {
  1023.         if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
  1024.             GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
  1025.             GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
  1026.             GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
  1027.             GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
  1028.             GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
  1029.             GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
  1030.             GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
  1031.             GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
  1032.             GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
  1033.             GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
  1034.             GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL ||
  1035.             GetEffectType(eBad) == EFFECT_TYPE_FRIGHTENED ||
  1036.             GetEffectType(eBad) == EFFECT_TYPE_DAZED ||
  1037.             GetEffectType(eBad) == EFFECT_TYPE_CONFUSED ||
  1038.             GetEffectType(eBad) == EFFECT_TYPE_POISON ||
  1039.             GetEffectType(eBad) == EFFECT_TYPE_DISEASE
  1040.                 )
  1041.             {
  1042.                 //Remove effect if it is negative.
  1043.                 RemoveEffect(oTarget, eBad);
  1044.             }
  1045.         eBad = GetNextEffect(oTarget);
  1046.     }
  1047.     //Fire cast spell at event for the specified target
  1048.     SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
  1049.  
  1050.     ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);
  1051.  
  1052.     // * May 2002: Removed this because ActionRest is no longer an instant.
  1053.     // * rest the player
  1054.     //AssignCommand(oDead, ActionRest());
  1055. }
  1056.