Skip to content

Suggestion: Diversifying the default PC event handlers

SorenSoren 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.

Comments

  • FinalStandFinalStand Member Posts: 87
    Do they actually work? You can modify the values with nwn-gff, but not sure they would actual fire.
  • xorbaxianxorbaxian Member Posts: 3

    Do they actually work? You can modify the values with nwn-gff, but not sure they would actual fire.

    i think soren's point is that, while they are available, they do not work. i agree w/him ; there have been so many times when i've bemoaned the lack of an on-damaged event handler for pc's [well, and several others available for npc's too, for that matter].
  • zunathzunath Member Posts: 92
    At the very least, I can confirm the heartbeat event fires. I've used it many times to track various things with PCs. I'd be very happy if they could be opened up, too.
  • DazDaz Member Posts: 125
    Patch 8164 added this:

    NWScript
    New functions: GetEventScript, SetEventScript to set NWScript event handlers on any supported object (including PCs).

    It works for PCs, I think I died.
  • FinalStandFinalStand Member Posts: 87
    Daz said:

    Patch 8164 added this:

    NWScript
    New functions: GetEventScript, SetEventScript to set NWScript event handlers on any supported object (including PCs).

    It works for PCs, I think I died.

    HUGE, nicely done beam dog

  • SorenSoren Member, Developer Posts: 48
    Stoked!
  • TerrorbleTerrorble Member Posts: 169
    Daz said:

    Patch 8164 added this:

    NWScript
    New functions: GetEventScript, SetEventScript to set NWScript event handlers on any supported object (including PCs).

    So, I think I get what this means. But what does it mean? Just so that I can confirm that what I think it means is what it means. Because if it doesn't mean what I think it means then getting me excited like this was mean.
  • DazDaz Member Posts: 125
    Terrorble said:

    Daz said:

    Patch 8164 added this:

    NWScript
    New functions: GetEventScript, SetEventScript to set NWScript event handlers on any supported object (including PCs).

    So, I think I get what this means. But what does it mean? Just so that I can confirm that what I think it means is what it means. Because if it doesn't mean what I think it means then getting me excited like this was mean.
    It lets you set the scripts for objects on the fly with scripting

    Like the OnUse script for placeables, OnEnter for areas, OnDamages for creatures/Player characters, etc
  • squattingmonksquattingmonk Member Posts: 59
    I just tested this. SetEventScript() will apply the script to the event just fine. However, the OnDamaged event is never called for PCs, so it doesn't do anything. The OnHeartbeat script does fire, however.
  • ProlericProleric Member Posts: 1,281
    @squattingmonk Do any other events fire for PCs?

    Does PC OnHeartbeat offer any advantage over the module heartbeat event?
  • squattingmonksquattingmonk Member Posts: 59
    Proleric said:

    Do any other events fire for PCs?

    Been trying to test it. So far, only OnUserDefined and OnConversation are triggered.

  • ShadowMShadowM Member Posts: 573
    I have not had time to check the event handlers heartbeat timing. I remember reading that NPC / heartbeat do not fire every 6 seconds (something 3-4) so I wondering if the heartbeat on PC will fire 6 or like npc? I do some testing later and find out or check back here and see what others have found.
    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.
  • ValgavValgav Member Posts: 25
    Heartbeat recurs but is not reliable for precise time calculation due to impact of lag and cpu clock delays.
  • squattingmonksquattingmonk Member Posts: 59
    edited May 2018
    As of 8171, the OnSpellCastAt, OnPerception, and OnCombatRoundEnd events fire for PCs. The patch notes say that OnMeleeAttacked should work as well, but I cannot get it to trigger.

    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.
  • PaphjortPaphjort Member Posts: 25
    edited February 2020
    Sorry, to dig this up... but anyone know if OnPhysicalAttacked event can be set on the PC with SetEventScript() now? or can you use OnUserDefined on the PC to get the same result?

    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)
    Post edited by Paphjort on
Sign In or Register to comment.