Suggestion: Diversifying the default PC event handlers
Soren
Member, Developer Posts: 48
As many of you probably know, PCs mechanically actually have event handlers for all the same events NPCs do (like OnDamaged, OnHeartBeat etc.), but since you can't set them manually, this fact is of little use. They all (except the OnConversation event that has nw_g0_onconversat iirc) default to the nonexistent but aptly named script “default”.
Being able to set these manually (e.g. on the module properties) would open up a lot of opportunities and I'm sure this has been requested elsewhere already (otherwise consider this a formal request!) But a solution that would be much simpler to integrate and yield almost the same opportunities would be to diversify the name of the default event handlers - for example the OnDamaged could default to nw_g0_ondamaged and so forth.
This would be a very simple way to open up a large array of opportunities for module designers.
Being able to set these manually (e.g. on the module properties) would open up a lot of opportunities and I'm sure this has been requested elsewhere already (otherwise consider this a formal request!) But a solution that would be much simpler to integrate and yield almost the same opportunities would be to diversify the name of the default event handlers - for example the OnDamaged could default to nw_g0_ondamaged and so forth.
This would be a very simple way to open up a large array of opportunities for module designers.
8
Comments
NWScript
New functions: GetEventScript, SetEventScript to set NWScript event handlers on any supported object (including PCs).
It works for PCs, I think I died.
Like the OnUse script for placeables, OnEnter for areas, OnDamages for creatures/Player characters, etc
Does PC OnHeartbeat offer any advantage over the module heartbeat event?
On the heartbeat on PC over module one it should give a little/minor efficiency over module, but testing would be need to confirm. It also will give better organization for specific pc function. I wonder why they went scripting event way instead of .2da lookup maybe just more flexibility.
Also, OnDeath appears to work. My tests had failed because I was having my PC speak a string when the event fired, but the PC cannot be commanded to speak when dead.
EDIT: I just tested this and it works perfectly.
SetEventScript(oPC,EVENT_SCRIPT_CREATURE_ON_MELEE_ATTACKED,“pc_attacked”);
I can make a script ("pc_attacked") that fires everytime the PC is attacked (works for both melee and ranged attacks, despite the name)