Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. //::///////////////////////////////////////////////
  2. //:: Name: x2_onrest
  3. //:: Copyright (c) 2001 Bioware Corp.
  4. //:://////////////////////////////////////////////
  5. /*
  6. The generic wandering monster system
  7. */
  8. //:://////////////////////////////////////////////
  9. //:: Created By: Georg Zoeller
  10. //:: Created On: June 9/03
  11. //:://////////////////////////////////////////////
  12. //:: Modified By: Deva Winblood
  13. //:: Modified Date: January 28th, 2008
  14. //:://////////////////////////////////////////////
  15.  
  16. #include "x2_inc_restsys"
  17. #include "x2_inc_switches"
  18. #include "x3_inc_horse"
  19.  
  20. void main()
  21. {
  22. object oPC = GetLastPCRested();
  23. object oMount;
  24.  
  25. if (!GetLocalInt(GetModule(),"X3_MOUNT_NO_REST_DISMOUNT"))
  26. { // make sure not mounted
  27. /* Deva, Jan 17, 2008
  28. Do not allow a mounted PC to rest
  29. */
  30. if (HorseGetIsMounted(oPC))
  31. { // cannot mount
  32. if (GetLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT"))
  33. { // cancel message already played
  34. DeleteLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT");
  35. } // cancel message already played
  36. else
  37. { // play cancel message
  38. FloatingTextStrRefOnCreature(112006,oPC,FALSE);
  39. SetLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT",TRUE); // sentinel
  40. // value to prevent message played a 2nd time on canceled rest
  41. } // play cancel message
  42. AssignCommand(oPC,ClearAllActions(TRUE));
  43. return;
  44. } // cannot mount
  45. } // make sure not mounted
  46.  
  47. if (!GetLocalInt(GetModule(),"X3_MOUNT_NO_REST_DESPAWN"))
  48. { // if there is a paladin mount despawn it
  49. oMount=HorseGetPaladinMount(oPC);
  50. if (!GetIsObjectValid(oMount)) oMount=GetLocalObject(oPC,"oX3PaladinMount");
  51. if (GetIsObjectValid(oMount))
  52. { // paladin mount exists
  53. if (oMount==oPC||!GetIsObjectValid(GetMaster(oMount))) AssignCommand(oPC,HorseUnsummonPaladinMount());
  54. else { AssignCommand(GetMaster(oMount),HorseUnsummonPaladinMount()); }
  55. } // paladin mount exists
  56. } // if there is a paladin mount despawn it
  57.  
  58. if (GetModuleSwitchValue(MODULE_SWITCH_USE_XP2_RESTSYSTEM) == TRUE)
  59. {
  60. /* Georg, August 11, 2003
  61. Added this code to allow the designer to specify a variable on the module
  62. Instead of using a OnAreaEnter script. Nice new toolset feature!
  63. Basically, the first time a player rests, the area is scanned for the
  64. encounter table string and will set it up.
  65. */
  66. object oArea = GetArea (oPC);
  67.  
  68. string sTable = GetLocalString(oArea,"X2_WM_ENCOUNTERTABLE") ;
  69. if (sTable != "" )
  70. {
  71. int nDoors = GetLocalInt(oArea,"X2_WM_AREA_USEDOORS");
  72. int nDC = GetLocalInt(oArea,"X2_WM_AREA_LISTENCHECK");
  73. WMSetAreaTable(oArea,sTable,nDoors,nDC);
  74.  
  75. //remove string to indicate we are set up
  76. DeleteLocalString(oArea,"X2_WM_ENCOUNTERTABLE");
  77. }
  78.  
  79.  
  80. /* Brent, July 2 2003
  81. - If you rest and are a low level character at the beginning of the module.
  82. You will trigger the first dream cutscene
  83. */
  84. if (GetLocalInt(GetModule(), "X2_G_LOWLEVELSTART") == 10)
  85. {
  86. AssignCommand(oPC, ClearAllActions());
  87. if (GetHitDice(oPC) >= 12)
  88. {
  89. ExecuteScript("bk_sleep", oPC);
  90. return;
  91. }
  92. else
  93. {
  94. FloatingTextStrRefOnCreature(84141 , oPC);
  95. return;
  96. }
  97. }
  98.  
  99. if (GetLastRestEventType()==REST_EVENTTYPE_REST_STARTED)
  100. {
  101. if (!WMStartPlayerRest(oPC))
  102. {
  103. // The resting system has objections against resting here and now
  104. // Probably because there is an ambush already in progress
  105. FloatingTextStrRefOnCreature(84142 ,oPC);
  106. AssignCommand(oPC,ClearAllActions());
  107. }
  108. if (WMCheckForWanderingMonster(oPC))
  109. {
  110. //This script MUST be run or the player won't be able to rest again ...
  111. ExecuteScript("x2_restsys_ambus",oPC);
  112. }
  113. }
  114. else if (GetLastRestEventType()==REST_EVENTTYPE_REST_CANCELLED)
  115. {
  116. // No longer used but left in for the community
  117. // WMFinishPlayerRest(oPC,TRUE); // removes sleep effect, etc
  118. }
  119. else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED)
  120. {
  121. // No longer used but left in for the community
  122. // WMFinishPlayerRest(oPC); // removes sleep effect, etc
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement