Events - How To properly Override them
#26
Posté 25 janvier 2010 - 09:34
I'd like to know how you'd accomplish this or if it's even possible.
#27
Posté 27 janvier 2010 - 04:28
1 - I have no combat music whatsoever. However, I read the code for GM_MODE change and it doesn't look like it's tackled there
2 - The main controlled character doesn't go on attacking during fights. You have to manually right-click everytime and it's annoying. What's even weirder is that for placeables, when I set my combat dummies in the festival, I saw code in placeable_core that basically said "tell attacker to repeat last command" but I didn't see a similar thing in the combat scripts. I could be looking at the wrong events though.
3 - The perception heartbeat is a little flaky. I had fight encounters where killed PCs got back up midfight as if they no longer sensed enemies around. Mind you, this happened to me in the single player game too. The problem is that it allows you to speak to your followers midfight, putting them out of combat mode and triggering rezzing/regen, which is gamebreaking in my mod.
I've been sick, so I might be reading stuff wrong too. Is there a way I could fix those issues through overriding?
#28
Posté 05 mai 2010 - 06:35
wyvern14 wrote...
I'm having 3 major bugs in my mod atm and someone told me overriding the corresponding events could solve them (event type game mode change, event type attacked, etc.), but I'm not sure how to prperly do so without breaking stuff further. I overrode a single event through the events.xls, which is EVENT_TYPE_PARTY_MEMBER_HIRED to apply proper custom packages to followers, but now I'm wondering if it ain't the cause of my mod breaks >
1 - I have no combat music whatsoever. However, I read the code for GM_MODE change and it doesn't look like it's tackled there
2 - The main controlled character doesn't go on attacking during fights. You have to manually right-click everytime and it's annoying. What's even weirder is that for placeables, when I set my combat dummies in the festival, I saw code in placeable_core that basically said "tell attacker to repeat last command" but I didn't see a similar thing in the combat scripts. I could be looking at the wrong events though.
3 - The perception heartbeat is a little flaky. I had fight encounters where killed PCs got back up midfight as if they no longer sensed enemies around. Mind you, this happened to me in the single player game too. The problem is that it allows you to speak to your followers midfight, putting them out of combat mode and triggering rezzing/regen, which is gamebreaking in my mod.
I've been sick, so I might be reading stuff wrong too. Is there a way I could fix those issues through overriding?
The following script (developed with the help of Magic) corrects two of three issues you are having (not the music), but I suspect you only have those issues when there are a lot of NPC's or you are generally pushing the performance envelope...that has been the case with me....additionally, I have added a check for a local integer check which will pass my overrides to CREATURE_CORE should the int not have been set by my module_core script...at first, without the int set, I was breaking the single player campaign....with the int check, it works (events do not get overridden)...that said - I am still troubleshooting a little bit as it appears the integer might be staying set to a 1, or my IF flow is jacked a little (help on constants on how long they stick around would be cool):
UPDATE - My constant set/check is not working correctly.....the rest of this script does work quite well in standalone....I am still tripping up single player/awkenings....working this over here for now:
http://social.biowar...1/index/2499932
// Event Intercept Script to solve NPC behaviour problems
//
// File: dmo001_event_intercept.nss
// Module: Dark Alliances
// Sources: code from Magic (Bioware Social) & DA Builder Wiki
// Author: RecklezzRogue
// Date: 5-5-2010
// Revision 0.09
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "sys_ambient_h"
#include "ai_main_h_2"
#include "dmo001_module_constants_h"
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
object oOwner = GetEventObject(ev,0);
object oHero = GetHero();
int bEventHandled = FALSE;
switch (nEvent)
{
// If a hostile creature disappeared, update the threat table with the
// remaining perceived enemies.
//
// This code solves the problem of NPC's standing and taunting in combat
// mode, but not attacking visible combatant hostiles unless they are
// directly attacked
//
case EVENT_TYPE_PERCEPTION_DISAPPEAR:
{
// If this isn't Dark Alliances, bail to default handler
//
object oModule = GetModule();
if (GetLocalInt(oModule, "DMO001_EVENTS_OVERRIDE") != 1)
{
DisplayFloatyMessage(GetHero(), "Event Int Exit", FLOATY_MESSAGE, 16777215,35.0); //Debug
HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
}
//Perception Fix Follows
//
if ((IsObjectHostile(OBJECT_SELF,GetEventObject(ev,0)))
&& OBJECT_SELF != GetMainControlled()
&& !IsPartyMember(OBJECT_SELF))
{
DisplayFloatyMessage(GetHero(), "Event Int - Perception", FLOATY_MESSAGE, 16777215,35.0); //Debug
int i;
object[] oEnemies = GetNearestObjectByGroup(OBJECT_SELF,TRUE,OBJECT_TYPE_CREATURE,AI_THREAT_SIZE,TRUE,TRUE);
int nEnemyCount = GetArraySize(oEnemies);
if (GetThreatTableSize(OBJECT_SELF)<nEnemyCount)
{
for (i = 0; i<nEnemyCount; i++)
{
if (GetThreatValueByObjectID(OBJECT_SELF,oEnemies[i])==0.0)
{
AI_Threat_UpdateEnemyAppeared(OBJECT_SELF,oEnemies[i]);
}
}
int bEventHandled = FALSE;
}
else
HandleEvent(ev);
}
break;
}
// NPC's Re-engage after an AOE effect (fireball, freeze, etc)
//
// This solves the problem of NPC's disengaging from combat
// after recoveing from an AOE attack, especially Fireballs.
//
case EVENT_TYPE_COMMAND_COMPLETE:
{
// If this isn't Dark Alliances, bail to default handler
//
object oModule = GetModule();
if (GetLocalInt(oModule, "DMO001_EVENTS_OVERRIDE") != 1)
{
HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
}
// Creature finished the ExecuteEffect command
//
if ((GetEventInteger(ev,0)==32) && (bEventHandled == FALSE)
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
DisplayFloatyMessage(GetHero(), "Event Int - EV = 32", FLOATY_MESSAGE, 16777215,35.0); //Debug
WR_ClearAllCommands(OBJECT_SELF,TRUE);
AI_DetermineCombatRound();
int bEventHandled = TRUE;
}
// The following code makes sure that NPC's go home after the battle
// Using this means that you will need to use commands that
// Rubber_SetHome (like UT_Quickmove) to keep NPC's at waypoints.
// This code also accomodates Ambient move patterns, but those with
// active move patterns still risk being stuck after battle...
//
else if (GetCommandType(GetCurrentCommand(OBJECT_SELF))==COMMAND_TYPE_INVALID
&& GetCommandQueueSize(OBJECT_SELF)==0
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
DisplayFloatyMessage(GetHero(), "Event Int - EV = RGH", FLOATY_MESSAGE, 16777215,35.0); //Debug
// Issue Rubber_GoHome and Ambient_Start if not fighting, not at
// home wp, event not handled, and there is no ambient move
// pattern variable set (other than 0 or FALSE), and the Ambient
// system is enabled (the creature associated with the event)
//
// Adding conditional for PartyMembers...(must be false)
//
if (!GetCombatState(OBJECT_SELF)
&& GetDistanceBetweenLocations(GetLocation(OBJECT_SELF),Rubber_GetHome())>1.0
&& bEventHandled == FALSE
&& !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
Rubber_GoHome();
int bEventHandled = FALSE;
}
else
HandleEvent(ev);
if (GetLocalInt(OBJECT_SELF,AMBIENT_SYSTEM_STATE) & AMBIENT_SYSTEM_ENABLED
&& bEventHandled == FALSE
&& !GetCombatState(OBJECT_SELF)
&& !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
Ambient_Start();
int bEventHandled = TRUE;
}
else
HandleEvent(ev);
}
break;
}
}
if (!bEventHandled)
{
HandleEvent(ev); // pass to the event to the default handler for Event
}
}
// --- script end ---
Modifié par RecklezzRogue, 05 mai 2010 - 11:13 .





Retour en haut






