Aller au contenu

Photo

Actions (moveawayfromobject) in Combat


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
Darin

Darin
  • Members
  • 282 messages
 I have this bit of code in my main OnAttacked Script:

// nSkirmish = 1// Move away from attacker when attacked in general        if(GetLocalInt(OBJECT_SELF,"nSkirmish")==1)                {                        ClearAllActions(FALSE);
                        ActionMoveAwayFromObject(oPC,TRUE,6.0);
                 }

(this runs before the standard...

This is the end ofthe script:

// *** Run the Regular Script ***//  *** Keep this LAST ***/* This part returns to the regular scripts based on the variable that defines the creature... this variable can and should be changed when creatures join/leave the party*/ string sScript = "nw_c2_default5"; if(GetLocalInt(OBJECT_SELF,"nCompanion")==1) sScript = "gb_comp_attack"; else if(GetLocalInt(OBJECT_SELF,"nHenchmen")==1) sScript = "gb_assoc_attack"; ExecuteScript(sScript,OBJECT_SELF); }

Question is: I attack kobolds summoned with nSkirmish set to 1; why don't they move away when I attack (and they don't die from it)?

#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
If the kobolds are in combat at the time, then you might need to use ClearAllActions(TRUE). Even then, they might end up running back and forth as their AI and OnDamage scripts fight each other. I find that making them temporarily blind stops them from re-initiating an attack.

Modifié par DannJ, 25 juin 2013 - 01:44 .


#3
Darin

Darin
  • Members
  • 282 messages
running back and forth isn't an issue for me; it's in some ways the point (though I may want to add in equipmostdamagingranged or whatever it's called). Temp blindness...interesting, though I'd rather not if I can avoid it (though it sounds like I may not be able to avoid it)

#4
diophant

diophant
  • Members
  • 116 messages
Try a return statement after ActionMoveAwayFromObject; most likely, somewhere later in your script (or in the default scripts) someone calls DetermineCombatRound, which calls ClearAllActions, canceling your command.

#5
Darin

Darin
  • Members
  • 282 messages
DannJ's suggestion worked, or at least, works MOST of the time...

#6
MasterChanger

MasterChanger
  • Members
  • 686 messages
It seems like it could be safer to have this behavior in the heartbeat or a SpecialCombatAI script rather than in the OnAttacked... As Dio mentioned, DCR would probably just override your command.

#7
kevL

kevL
  • Members
  • 4 070 messages
might get away with

SetCommandable() FALSE
DelayCommand(SetCommandble() TRUE, 6.f)


The Delay is for the duration that an NPC won't accept other commands, such as those from DCR ..

( not sure what other issues might crop up there, tho )

#8
Dann-J

Dann-J
  • Members
  • 3 161 messages

EpicFetus wrote...

DannJ's suggestion worked, or at least, works MOST of the time...


Yes - I've noticed that sometimes an archer will manage to take one more shot at you after being blinded. Occasionally, a blinded melee opponent will also decide to run up to you (even if they can't actually attack you).

Since there was nothing worth watching on TV last night (thanks to a Prime Ministerial revenge back-stabbing), I spent the evening creating a simple morale system for my overland encounters. I originally tried the blindness technique to get fleeing enemies to run to a trigger that makes them disappear, but the results weren't consistent. The simplest solution was to use EffectFrighten(), and put numerous escape triggers about to give them a chance to blunder into them. That way I used the existing AI system to my own advantage, rather than trying to fight against it.

#9
Darin

Darin
  • Members
  • 282 messages
I didn't even bother with the blindness; just the TRUE on the combat seemed to do the trick...also switched the command to MoveAwayFromLocation(GetLocation(OBJECT_SELF)); otherwise they were moving toward the PC to be ther distance specified away.

#10
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
If you're ready to make it more complicated, I use a simple 3-stage AI to control hit-n-run. Set a local int on your NPC, lets call it iAIState. 0 (the default) is attack, where the NPC runs towards and attacks the PC. 1 is retreat, where the NPC runs away from the PC. 2 is sneak, where the NPC sneaks towards the PC.

When iAIState == 0, and the NPC is close to the PC, reset iAIState to 1 and order the NPC to run away. When iAIState == 1, and the NPC is far enough away from the PC, reset AIState to 2 and order the NPC to sneak towards the PC. When close enough for the final charge, reset AIState to 0 and order the NPC to attack.

If you check out my Danaan Tactics (http://neverwinter2....s.com/mods/95/?), you can see this played out real simply with the Raptor's AI scripts.

#11
Dann-J

Dann-J
  • Members
  • 3 161 messages

EpicFetus wrote...

I didn't even bother with the blindness; just the TRUE on the combat seemed to do the trick...also switched the command to MoveAwayFromLocation(GetLocation(OBJECT_SELF)); otherwise they were moving toward the PC to be ther distance specified away.


For actions that only take a second or two, there's probably little chance of them determining their combat round halfway through. It's when your queued action takes more than a few seconds (especially more than six) that they tend to stop and re-engage before completing the action. That's when blindness seems to help, although it's still not 100% - perhaps deafening them at the same time would improve the odds.

ActionMoveAwayFromObject, combined with a calculated distance (current distance between objects + retreat distance) might guarantee they always run away. There may be something in "x0_i0_position" that does it better (there usually is).

#12
Darin

Darin
  • Members
  • 282 messages
That would probably work to ensure the direction is always away, though really a random 10 foot move is probably okay for my purposes...keeps 'em movin' which is the point.

Lugaid, good idea.

#13
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
IIRC, the calls to begin combat come not just from perceiving an enemy (on-perception event), but also from the on-physically-attacked, on-damaged, on-spell-cast, and on-conversation (when dying allies ask for aid) event. I use custom versions of all those scripts, with a check on a variable to keep them from attacking when they should be running away. The combat condition switches, especially the cowardly switch, might be a good way to quickly do something similar. Look up the default on-spawn script to see how it works.

#14
Darin

Darin
  • Members
  • 282 messages
hmm... I have my own versions of those scripts (all end with a command to run whichever general one you're supposed to run; the default, gb, or comp...) I could delay a reset of a variable and have that variable "return;" all of my scripts before the ending...