Aller au contenu

Photo

Need a summonable creature to only perform healing...


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

#1
rjshae

rjshae
  • Members
  • 4 505 messages
Hello. I have an item that summons a magical "construct", which is only supposed to perform a healing function on party members. Instead the darn thing just runs up and starts trying to feebly punch out the nearest opponent. Is there a local variable I can set that will correct this A.I. behavior? I'm not seeing one in the summonable companion scripts for MotB.

Thank you.

#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
Sounds like its faction is being set to defender or the summoner's faction, either in the blueprint (if defender) or by the summoning spell (if summoner's faction). Maybe you can set its faction to be merchant so you can interact with it but it won't fight for you. You could create a custom neutral faction for it as well.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
++ on neutral faction. I use the neutral faction a lot and it is very useful in curbing NPC behavior.

Another option is to add the construct as a companion for the duration of the spell. This way you will have complete control over the construct. You can give it a very poor attack bonus to discourage misuse. It will probably be easier to just give complete control to the PC than to try to make the AI do what you want.

#4
The Fred

The Fred
  • Members
  • 2 516 messages
Are enemies meant to attack the creature? A neutral one will not be attacked. What you could do is write a very simple AI or OnHeartbeat script (probably removing some of the other default scripts) which has it just cast healing spells over and over.

#5
rjshae

rjshae
  • Members
  • 4 505 messages
Yes, the faction is set to the same as the summoner and enemies could attack the summoned creature; it's primarily intended to be a non-controlled companion, much as per a summon monster spell. I guess I could give it a creature hide item that has a big attack penalty and see if that tempers its AI aggressiveness. Otherwise, yes it sounds like I'll have to customize the heartbeat. Oh well, I thought there might just be a variable I could set. Thanks.

#6
Dann-J

Dann-J
  • Members
  • 3 161 messages
The ghost-girl Lucy in 'Dark Waters' pretty much did the same thing as you want. She had unlimited healing abilities, and automatically used them if the PC was injured in any way. Although you could exploit her to prevent the PC from drowning while underwater if you wanted to.

#7
ghowriter

ghowriter
  • Members
  • 21 messages
I had same issue when using the Summon command in the toolset. It essentially adds the summoned as an ally. I fixed my issue by using the CreateObject and assigned the commands to it I needed. I used the summoned genie merchant from NWN1 x2 as my guide for this.

#8
The Fred

The Fred
  • Members
  • 2 516 messages
There are variables you're meant to be able to from HotU to govern behaviour, but I'm not sure if they're respected any more. I think you could try the following:

X2_L_BEH_MAGIC = 100
X2_L_BEH_COMPASSION = 100

That should make it prefer helping allies with magic, but as I said, I'm not sure they actually work.

#9
kevL

kevL
  • Members
  • 4 070 messages
Fred


yes, They're there.

it appears that if a call is made to DCR ( DetermineCombatRound, 'nw_i0_generic' ) those values set on the creature will still have effect: DCR -> chooseTactics -> CalculateTactics (but might get shorted or replaced by TalentPersistentAbilities, TalentHealingSelf, SpecialTactics, TryclassTactic). CalculateTactics( ) has:

// Bahavior variable adjustments
nMagic = nMagic + AdjustBehaviorVariable(nMagic, "X2_L_BEH_MAGIC");
nOffense = nOffense + AdjustBehaviorVariable(nOffense, "X2_L_BEH_OFFENSE");
nCompassion = nCompassion + AdjustBehaviorVariable(nCompassion, "X2_L_BEH_COMPASSION");

which is just

GetLocalInt(OBJECT_SELF, sVarName) + Random(10) + nBaseValue

BaseValue being set by chooseTactics( ) .. all seemingly in accord w/ 'x2_inc_switches':

//------------------------------------------------------------------------------
// * The value of this variable (int) is added to the chance that a creature
// * will use magic in combat. Set to 100 for always, 0 for never
//------------------------------------------------------------------------------
const string CREATURE_AI_MODIFIED_MAGIC_RATE = "X2_L_BEH_MAGIC";

//------------------------------------------------------------------------------
// * The higher value of this variable, the higher the chance that the creature
// * will use offensive abilities in combat. Set to 0 to make them flee.
//------------------------------------------------------------------------------
const string CREATURE_AI_MODIFIED_OFFENSE_RATE = "X2_L_BEH_OFFENSE";

//------------------------------------------------------------------------------
// * The higher value of this variable, the higher the chance that the creature
// * will aid friendly creatures in combat. Not that helping usually degrades
// * the overall difficulty of an encounter, but makes it more interesting.
//------------------------------------------------------------------------------
const string CREATURE_AI_MODIFIED_COMPASSION_RATE = "X2_L_BEH_COMPASSION";


Again, it requires a call to DCR that makes it through to CalculateTactics( ) and then to DetermineActionFromTactics( )


that's as far as i got; although I didn't test anything, i Think it comes down to choosing the right class ( or, more accurately, not the wrong class ) any NPC-class except Commoner should increase chances, Contruct is good eg. because several PC-classes will just go straight for Attacks or Songs, eg.

someday I'm going to come across where NPC casters go running into melee .... actually think i came across it the other day, but like a ninny i forgot to write it down ..

#10
kevL

kevL
  • Members
  • 4 070 messages
hey,

just did a peruse of HenchDetermineCombatRound( )

unlike the older DetermineCombatRound( )

hDCR does *not* apparently respect those values ....

#11
kevL

kevL
  • Members
  • 4 070 messages
Ps. Just noticed in the final OC KoS scene the scripters use X2_L_BEH_MAGIC on Qara/Sand, and X2_L_BEH_MAGIC = 100 plus X2_L_BEH_COMPASSION = 0 on Garius himsef, so ..

#12
MasterChanger

MasterChanger
  • Members
  • 686 messages
When I want to force AI to use specific simple behavior in combat, I've had good luck with using the special combat script variable. This is defined in nw_i0_generic:

string VAR_X2_SPECIAL_COMBAT_AI_SCRIPT     = "X2_SPECIAL_COMBAT_AI_SCRIPT";

This local string is then checked for on the creature in question and executed if applicable. This check takes place in the first few lines of DetermineCombatRound.

To set up this variable, write your script and then add the script name as a local string on the creature (either on the blueprint or by script after spawn).

You could have this custom AI script loop through nearby faction mates and check if they're low on HP and heal them if so (via spell, item, or plot MacGuffin that you may choose).

Modifié par MasterChanger, 02 octobre 2011 - 03:54 .