Author Topic: Listener  (Read 461 times)

Legacy_Zarathustra217

  • Sr. Member
  • ****
  • Posts: 322
  • Karma: +0/-0
Listener
« Reply #15 on: July 15, 2012, 03:02:12 pm »


               

Lightfoot8 wrote...

I think it was Something tthe.gray.fox  said in one of his posts that really got me looking into the VM.   Basicly it boild down to the fact that the Internal functions are faster then any custom function, written in NWscript, used to replace them. Reguardless of whether the internal functions are written poorly or not. 

In Reguards to a listener, In my opinon,  using GetListenPatternNumber  from a single listener,  Will always out perform a script trying to parse the chat from the OnPlayerChat event.   

Now for catching PC chat globally in the in the module the the PCChat event is the way to go.   But for single location monitoring, I would stick with the listener.   They are also easy to turn on and off with the SetIsListening function.  


Sorry for the off topic, but I find this very much interesting. I figure this also entails that if you have to look for a handful spell effects on a creature, it is faster to use GetHasSpellEffect several times than to loop through each effect on the creature and check for the spell ID of that effect. Normally, I would expect latter solution to be most effective (one search vs. multiple) but given that the GetHasSpellEffect is an internal function, it would be far faster than the scripted loop.

Thoughts?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Listener
« Reply #16 on: July 15, 2012, 03:49:41 pm »


               

Zarathustra217 wrote...

Lightfoot8 wrote...

I think it was Something tthe.gray.fox  said in one of his posts that really got me looking into the VM.   Basicly it boild down to the fact that the Internal functions are faster then any custom function, written in NWscript, used to replace them. Reguardless of whether the internal functions are written poorly or not. 

In Reguards to a listener, In my opinon,  using GetListenPatternNumber  from a single listener,  Will always out perform a script trying to parse the chat from the OnPlayerChat event.   

Now for catching PC chat globally in the in the module the the PCChat event is the way to go.   But for single location monitoring, I would stick with the listener.   They are also easy to turn on and off with the SetIsListening function.  


Sorry for the off topic, but I find this very much interesting. I figure this also entails that if you have to look for a handful spell effects on a creature, it is faster to use GetHasSpellEffect several times than to loop through each effect on the creature and check for the spell ID of that effect. Normally, I would expect latter solution to be most effective (one search vs. multiple) but given that the GetHasSpellEffect is an internal function, it would be far faster than the scripted loop.

Thoughts?


  A well written homebrew function compiled with one of the better compilers (like is integrated into Virusman's toolset extender) will be faster than the equivalent likely 95% of the time.  Every single replacement function I've written and compared to the bioware default has been faster, even if only by a few percent over thousands of cycles.

  Likely this deserves its own topic though, so people could get more in depth into replacement function comparisons.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Listener
« Reply #17 on: July 15, 2012, 04:26:51 pm »


               

Zarathustra217 wrote...

Sorry for the off topic, but I find this very much interesting. I figure this also entails that if you have to look for a handful spell effects on a creature, it is faster to use GetHasSpellEffect several times than to loop through each effect on the creature and check for the spell ID of that effect. Normally, I would expect latter solution to be most effective (one search vs. multiple) but given that the GetHasSpellEffect is an internal function, it would be far faster than the scripted loop.

Thoughts?


Yep,  That is what is being said.  


Failed.Bard wrote...

  A well written homebrew function compiled with one of the better compilers (like is integrated into Virusman's toolset extender) will be faster than the equivalent likely 95% of the time.  Every single replacement function I've written and compared to the bioware default has been faster, even if only by a few percent over thousands of cycles.

  Likely this deserves its own topic though, so people could get more in depth into replacement function comparisons.


Yes, Home brew vs Home brew can be compiled better using a better compiler.  

Try and rewrite an internal function with nwscript, something like GetItemPossessedBy, and see if you get any gain.