I'm trying to make the AI run a check on a local variable mid-combat and immediately stop attacking if that flag is set, but it's turning out to be an immense pain. Can anyone give me a hand here and point me at the right part of the right script?
Trouble stopping AI mid-combat
#1
Posté 12 août 2015 - 03:56
#2
Posté 12 août 2015 - 04:46
Are you using a custom heartbeat script or implementing it as a user event?
#3
Posté 12 août 2015 - 05:41
I did something like this, by putting the code in the creature's On End Combat Round script. (Technically I set the creature to signal the event and used the On User Defined Event, but the effect is the same.)
SurrenderAllToEnemies(OBJECT_SELF); object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC); SurrenderAllToEnemies(oPC); ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER); ActionStartConversation(oPC);(oPC);
First the creature stops fighting, then I also make the PC stop fighting so it doesn't start a new fight, then I change the creature's faction to Commoner.
Since this is at the end of the combat round, it's not immediate, but it's no more than 6 seconds (if the command came at the very beginning of the round).
Note, you need:
#include "x0_i0_partywide"
at the beginning of the script to use the SurrenderAllToEnemies() function.
#4
Posté 12 août 2015 - 07:21
Is there a way to run the check instead when the creature is attacked, makes an attack, or is damaged in combat? (The OnDamaged event doesn't fire off during combat.) I'd rather not wait until the end of the round if possible.
#5
Posté 12 août 2015 - 07:27
Are you using a custom heartbeat script or implementing it as a user event?
Custom heartbeat. I know it's polite to use UserDef, but I just want to get it working quick and dirty before I go to the trouble. Copy/pasted the heartbeat, added my check to the very top of it. Does not seem to be called during combat, though...
#6
Posté 12 août 2015 - 07:44
You don't need to use On User Defined if you don't want to, as long as it does what you want.
On Damaged does fire during combat in my experience. On Damaged is what I used to signal the phase changes for my boss battles in BSoCC.
#7
Posté 12 août 2015 - 10:46
On Damaged does fire during combat in my experience.
Indeed. My ankheg scripts use the OnDamaged script to determine whether or not they should retreat and burrow down into the ground (with the likelihood increasing as they lose more hit points).
A quick and dirty way to stop a creature from fighting back is to blind and deafen it and to assign ClearAllActions(TRUE) to it. Once it's blind and deaf it can't reinitiate combat (provided it doesn't have True Seeing, of course), even if it's still in a hostile faction. It become the very epitome of the sitting duck.
#8
Posté 13 août 2015 - 03:44
Thanks! I think I've got it now! (Switched to UserDef events; much cleaner and easier now. Turns out the problem is that when two creatures are in combat the orientation check doesn't work the way it's supposed to, so I did some quick vector math. The check was firing when needed!) I'm applying the cutscene immobilize effect to stop it from fighting.
Quick question: Is there a way to make NPCs immune to all damage? Flagging them as immortal just prevents them from dying; I want to preserve their hitpoints. (Edit: It's the plot flag! I hate that naming convention.)
#9
Posté 13 août 2015 - 03:49
You're all totally right; OnDamaged fires in combat. I dunno where I got it into my head that it doesn't.
#10
Posté 15 août 2015 - 09:50
You're all totally right; OnDamaged fires in combat. I dunno where I got it into my head that it doesn't.
Hi,
Actually, can I clarify/ask something ... Surely, "OnDamaged" will only fire if the attack in a combat does damage? i.e. If an attack misses, then any script attached to this hook will NOT fire during combat. That is how I understand it anyway.
Why not use the "OnPhysicallyAttacked" and "OnSpellCastAt" hooks?
Cheers,
Lance.





Retour en haut






