Author Topic: Heartbeat problem  (Read 509 times)

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Heartbeat problem
« on: April 19, 2015, 08:09:11 pm »


               

Hi all!


 


I made a script on a invisible placeable wich onheartbeat randomly creates a random "place". I placed several of this placeables on the map wich should work and each one be one of the random "places" i defined. Ok till now we are ok and it works!... the thing is that today testing the module i opened a placeable with his own tag and name, and even in other area, and suddenly one of the "places" appeared in the place of this placeable... WTF??


 


I really cant figure out what happened there... a strange bug. 


 


This is part of the code to the "places" creator:


 



 


#include "X0_I0_POSITION"


#include "x2_inc_switches"

void main()

{

 

 

 

  object oO = OBJECT_SELF;

  location oL =  GetLocation(oO);

  int nL = Random(24)+1;

 

 

  if(Random(3000) > 2830 && GetLocalInt(oO, "Lugar")== 0)         

  {

        if (nL == 1)  Creates the place number 1 etc.


 


 


 


I thought that maybe i need to add some event handler like this:


 


 int nEvent =GetUserDefinedItemEventNumber();

if(nEvent !=  EVENT_HEARTBEAT)return;

 

But this stops the script always and nothing happens. 

 

Im lost here and need help.

 

The script was working but that error keeps  happening. there is something i need to know about heartbeat on placeables/creatures etc?

               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Heartbeat problem
« Reply #1 on: April 19, 2015, 09:24:36 pm »


               

GetUserDefinedEventNumber() is for the user defined event which is signaled from another script (in this case the heart beat script).  In this case it looks like you have the same script for heartbeat as you do for another event.  Make sure you use different scripts for each event.



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Heartbeat problem
« Reply #2 on: April 20, 2015, 02:29:08 am »


               Cant really say i understood very well. Not used to work with userdefinedevents or events at all. Something i need to learn it seems. Thanksss !!!
               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Heartbeat problem
« Reply #3 on: April 20, 2015, 03:47:55 am »


               

If you look at the scripts tab of a creature there is one at the bottom called OnUserDefined.  That script runs when you Signal an Event.  GetUserDefinedEventNumber() figures out which event was signaled inside that script (among other places).


 


You use the following line to signal an event on at the end of a combat round.


 


        SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_END_COMBAT_ROUND));

 


 


Anyway, I think we're a little unclear what you're trying to do.  I could offer more help if you can give more details about what you want to do.



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Heartbeat problem
« Reply #4 on: April 20, 2015, 04:48:54 am »


               

Well its a little harder for me to explain in english cause its not my language but i do my best xD


 


Basically i have like 15 instances of a  placeable running a OnHeartbeat script wich will determine in a random time, what this placeable will become. Ex.(a goblin nest, a merchant etc). I put the script on the OnHeartbeat tab of the placeable and when random(3000>2800) this placeable destroy itself and in the same location creates the placeables and creatures depending on what it will become. 


 


My problem is that today, testing in-game, i was in another area and suddenly a chest transformed into a goblin nest somehow, and the chest was a simple chest with own and unique tag and no scripts. Sooo... why? 


 


Im also using onheartbeat tab in npcs wich suffers from hunger, they work, etc so i made a big script and placed on that tab. It works fine. 


 


Thanks for your response, i will try to learn that more deeply so i may find a better way to do all of this. (:


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Heartbeat problem
« Reply #5 on: April 20, 2015, 07:57:55 am »


               

My problem is that today, testing in-game, i was in another area and suddenly a chest transformed into a goblin nest somehow, and the chest was a simple chest with own and unique tag and no scripts. Sooo... why? 


 


I would like to know more about this chest.  Was it painted in the module or created by CreateObject() or CopyObject()?  Does it have no scripts whatsoever or does it just use the default scripts?  Are any variables set on the chest?


               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Heartbeat problem
« Reply #6 on: April 20, 2015, 03:04:15 pm »


               Its painted on the module and runs a conversation on opened... so i was mistaked it has the default nw placeable conv script. But does it. Causes the problem?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Heartbeat problem
« Reply #7 on: April 20, 2015, 05:46:58 pm »


               

The fact that the chest runs a conversation means that you have custom scripts on it.  Only creatures have default scripts to run the conversation assigned to them.



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Heartbeat problem
« Reply #8 on: April 21, 2015, 03:33:14 am »


               

Ok but the chest having a default script its related to my issue with heartbeat?



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Heartbeat problem
« Reply #9 on: April 21, 2015, 03:19:30 pm »


               


Ok but the chest having a default script its related to my issue with heartbeat?




 


Default scripts for placeables do not run conversations.  There is no conversation that is "assigned" via Toolset to a placeable that can be scripted to be used, so whatever conversation the placeable is running was created by your module.  What you have may be a modified OnOpen script.   It would bear the same name as an OnOpen core resource because the script itself is modified to add in the conversation.