Author Topic: default script caution  (Read 1963 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
default script caution
« on: July 14, 2010, 04:55:01 pm »


               Rumours spread this script fires only for PC heartbeat, but lately I decided to use it, PC heartbeat was great opportnity to save persistent info about PC. But when I looked into database, I saw strange values so I made few debugs and guess what, any trap made via scripting, fires default script every 6seconds...

Yes you can add [nwscript] if(!GetIsPC(OBJECT_SELF))return;[/nwscript] but I think pseudoheartbeat will be much "clean" way to do this afterall...
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
default script caution
« Reply #1 on: July 14, 2010, 10:25:13 pm »


               Traps fire the script titled "default"? Intresting, you could do the if not pc return OR use that to do specials with trap IE:



if not a PC(assume is trap) and do this

if is PC do this other thing
               
               

               
            

Legacy_ElgarL

  • Full Member
  • ***
  • Posts: 128
  • Karma: +0/-0
default script caution
« Reply #2 on: July 15, 2010, 02:13:43 pm »


               I wonder if the trap was named 'default' and it triggered the script through 'tag based scripting'.



Just an idea. I'll give this a test when I get time.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
default script caution
« Reply #3 on: July 15, 2010, 03:01:51 pm »


               

ElgarL wrote...

I wonder if the trap was named 'default' and it triggered the script through 'tag based scripting'.

Just an idea. I'll give this a test when I get time.

First I dont use tag based scripting.
Second, traps cant trigger tag based scripts, because tag based script are in OnPlayer events - (un)equip,(un)acquire,activate.
Third those traps created via CreateTrapAtLocation (guess those on object dont do that) had tag = "" (null).
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
default script caution
« Reply #4 on: July 16, 2010, 02:26:54 am »


               I have alway been afraid something like that would happen. Ever since I heard about people useing the defualt script I have wondered about what strange things could happen or what other places bioware my have placed 'default' as the name of a script not filled in. Axe seemed to clear the use of the script for PC heart beat. But if it is running on some other objects also I think I would advoid it for sure. I agree the use of the pseudo heart beat of a known overhead value. Is better then an unknown overhead value checking to make sure it is a PC and a script running on other objects.

just my 2 cents again.


Edit:  oh If you did happen to put a script in the HB of the traps, even if it was a blank script, Then it would no longer run the Default script as its HB.  another messy solution to the problem.   lol
               
               

               


                     Modifié par Lightfoot8, 16 juillet 2010 - 01:29 .
                     
                  


            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
default script caution
« Reply #5 on: July 19, 2010, 02:41:54 am »


               Those traps were 1.69 additions and it isn't surprising they implemented it that way. Wish they would have used a different script name than default so it wouldn't interfere, but oh well. This isn't a problem at all tho because for one thing there is no default script. So the standard behavior is to do nothing. Therefore all you have to do is have the "default" script verify OBJECT_SELF is a PC and you can ignore the trap bit. Of course if you want to hook into the trap or clones too, then you can do something like this in your "default" script:

[dascript]// default Script - player heartbeat, player clone events, scripted traps
void main()
{ if( GetIsPC( OBJECT_SELF ) ) ExecuteScript( "player_heartbeat", OBJECT_SELF );
   else if( GetObjectType( OBJECT_SELF ) == OBJECT_TYPE_CREATURE )
            ExecuteScript( "pc_clone_event", OBJECT_SELF );
   else ExecuteScript( "trap_event", OBJECT_SELF );
}
[/dascript]

Once you create three scripts for default "player_heartbeat", player clone events "pc_clone_event", and "trap_event" you can use them to hook into all types of objects separately. And of course if you don't create one of these scripts you'll simply get the standard behavior for that.
               
               

               


                     Modifié par Axe_Murderer, 19 juillet 2010 - 01:56 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
default script caution
« Reply #6 on: July 19, 2010, 04:33:03 am »


               Question is, if its efficient anymore. When I believed it runs only for PC, it was OK, I assume my module could have max 15 players at once, so default script will fire in average rate of 7times per 6secons, but since it runs for traps as well, atm I have 6dungeons which spawns about 10 traps, now thats 60times per 6seconds. And thats only start, I will have more dungeons and more random traps. No matter if the default script will handle it with simple conditional, the script is fired hence I think its more efficient to use pseudo heartbeat.

Btw was that pseudo heartbeat memory blobbing fixed? If not please copypaste original thread from old forums.
               
               

               


                     Modifié par ShaDoOoW, 19 juillet 2010 - 03:33 .
                     
                  


            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
default script caution
« Reply #7 on: July 19, 2010, 04:46:01 am »


               Well it shouldn't be any worse than it was before in terms of the cloning and pc heartbeat. Basically if you don't clone players you don't get the events. Likewise, unless you use scripted traps very often, the difference won't be even noticable.

The script I posted above is very minimal and allows you to efficiently separate them out, but you're right if scripted traps are all over the place, the event will fire more often. Personally I wouldn't worry about it too much until you start trying to do lots of stuff on trap events or player hb. Traps aren't something likely to fire it so much more often as to cause a problem since they are stationary and small. As with all events, if you try to do too much you will suffer. But only testing will tell for sure what the tolerable threshold is.

               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
default script caution
« Reply #8 on: July 19, 2010, 07:12:01 pm »


               1.69 introduced quite few changes I have not liked, and while not knocking the update, I'll say that, it's not something I didn't have to do a lot of reworking to get it to do what I wanted it to, all in all CEP 2.3 & 1.69 have only been a headache for me as a builder....  Enough said



Hi shadoOow XD long time no see mate...