Author Topic: Random encounter on inventory  (Read 276 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Random encounter on inventory
« on: September 17, 2015, 01:06:24 pm »


               Hello everyone!


I wondered if this is possible to have a script written for an item that does the following:


- checks if the time is day or night

-if night then makes a random roll for an encounter to attack pc that holds the item in his inventory.


So far my own attempts have failed, well failed at the start.


So if anyone knows how to do this than that yay! (And also help me with this script '<img'>)


So thanks in advance!
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Random encounter on inventory
« Reply #1 on: September 17, 2015, 11:03:12 pm »


               in brief:


If this can happen anywhere, you'd put it in the module heartbeat script.


GetIsNight will tell you when it's nightfall. If you want some random time during the night, GetTimeHour is better.


Loop through PCs (or instances of the item, if there aren't many) to find PCs who have the item.


CreateObject at the location of the PC is a simple way to spawn an encounter, using switch/case to choose a random monster resref.


Set a variable on the PC to stop further encounters for this night.


GetIsDay will tell you when to delete that variable, so that encounters can happen on night #2.