Aller au contenu

Photo

Creating Non-Aggressive Enemies


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

#1
AstralPhenomenon

AstralPhenomenon
  • Members
  • 10 messages
So I've been trying to dig up information on this, and so far I haven't come up with any real solution. Hopefully someone here can help!

I'm trying to create some enemies that don't attack until attacked. To use WoW as an example, this would be your yellow-named creature as opposed to a red-named hostile. Here are some issues I've encountered during my trial and error:

- If I set the creatures as neutral, it isn't possible to begin combat with a spell. It seems the only way to initiate combat with a neutral is through a physical attack or applying a faction change with OnConversation. I'm aware that I can change .2das to allow casting on neutrals, but I'd rather not go through the headache!

- If I use a script to change faction from neutral to hostile either through PhysicalAttack or OnConversation, nearby creatures of the same type switch to hostile as well. This is when referencing OBJECT_SELF for faction switch.

- Ideally I'd like to have the creatures set to 0 with players so casters can begin combat with a spell, however I've tried everything from removing the shout lines in OnPhysicalAttack to removing the OnPerception script. The creatures still attack as soon as my character spawns in.

If anyone could help me solve this, it'd be greatly appreciated!

#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Allowing players to attack neutral faction NPCs is a campaign option, just set it to True (default is False). Then you can use the SetIsTemporaryEnemy() function to make just that individual into a hostile creature.

There is a UsesPersonalReputations option in the campaign options that should do the same/similar thing as the function, but I've had problems with turning it to True - though maybe I did something else wrong.

Modifié par _Knightmare_, 12 juillet 2011 - 12:15 .


#3
AstralPhenomenon

AstralPhenomenon
  • Members
  • 10 messages
Ack, probably should've mentioned trying that one too >.< I've attempted to use SetIsTemporaryEnemy in both the OnPhysicalAttack and OnConversation scripts to no avail, the creatures refuse to acknowledge the attacker as an enemy.

I've also tried toying with the UsesPersonalReputations setting, but that comes back down to the issue of all nearby enemies of the same type assisting even when not set as allies. This is with the AdjustReputation function.

#4
Dann-J

Dann-J
  • Members
  • 3 161 messages
I found a partial compromise by having a custom OnPerceived script that causes a neutral creature (in my case, a snake) to attack a player only if they get too close, then turn around after one strike and flee while still neutral. Rather than change its faction, I simply added an attack action to its action queue.

The snake only becomes truly hostile (via a custom OnDamaged script) if you damage it with a weapon. That way you have the option of backing off and waiting for it to turn and flee, if you'd rather not kill an innocent animal (or just don't want to tangle with a level 3 poisonous animal if you're at level 1).

Any neutral creature that attacks a party member will trigger a melee counter-attack from the party member in question (which, if successful in my case, causes the snake to become truly hostile). However you still can't target them with a hostile spell while they're neutral. You can however attack them with a ranged weapon, then fire off a spell after it becomes hostile and before it reaches you.

Modifié par DannJ, 12 juillet 2011 - 03:17 .


#5
MasterChanger

MasterChanger
  • Members
  • 686 messages

AstralPhenomenon wrote...

Ack, probably should've mentioned trying that one too >.< I've attempted to use SetIsTemporaryEnemy in both the OnPhysicalAttack and OnConversation scripts to no avail, the creatures refuse to acknowledge the attacker as an enemy.

I've also tried toying with the UsesPersonalReputations setting, but that comes back down to the issue of all nearby enemies of the same type assisting even when not set as allies. This is with the AdjustReputation function.


AdjustReputation is for changing how the object--the PC, for example--is viewed by the subject's group--the potential enemies, in this case. If you make the potential enemy and its group all suddenly hate the player, then yes, they'll all jump in. 
I think a better approach would be to change the faction of the enemy from potential enemy to actual enemy when they're attacked. This would probably mean using a custom faction grid.

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Casting hostile spells on neutral opponents is a problem that no one has solved yet to my knowledge. There are some work-aroudnds, though. You can use either a dialogue or GUI interface to allow the player to turn the enemy hostile, allowing you to attack it or cast hostile spells on it. With careful use of the pause button, this is almost as good as just being able to attack it.

If you use the GUI approach, you can look at Lance Botelle's GUI tutorial on the vault. It will proabably be a good place to start.

If you use the conversation approach, it will probably be easier. Make sure you set the conversation to ignore start distance so that the PC does not walk up to the character and just starts the convo from where they are. Also, make sure the convo is set to NWN1 style to avoid the beginning of the cutscene.

From within the convo, you can just use the ga_faction_join script to make the NPC hostile if the PC chooses that option.

#7
MasterChanger

MasterChanger
  • Members
  • 686 messages
A custom Quick-cast GUI would also allow you to cast hostile spells on neutrals/friendlies or friendly spells on hostiles. I started working on such a GUI but it was extremely clunky. I was also working from a system in which known spells were stored in a database and used spell points. Translating it to the Vancian system wasn't something I could wrap my head around.

It's not a practical solution, but I figured I'd toss it out there.

#8
AstralPhenomenon

AstralPhenomenon
  • Members
  • 10 messages
Thanks for the tips everyone! From the sounds of it I think the best route is going to be using the OnConversation event so that a player clicks on a passive enemy and begins combat, but setting the range to start that conversation to something more reasonable for casters.

I managed to get SetIsTemporaryEnemy working, seems it required the use of Personal Reputation, but the issue of all nearby copies of the enemy assisting still persists. This is with the enemies all set to a custom faction, viewing itself as neutral.

Edit: Current script is as follows

#include "hench_i0_monsho"
#include "ginc_behavior"

void main()
{

	object oTarget = GetLastSpeaker();
	object oSource = OBJECT_SELF;
	SetIsTemporaryEnemy(oTarget, oSource, FALSE);
	DetermineCombatRound();

}

Modifié par AstralPhenomenon, 12 juillet 2011 - 04:23 .


#9
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

M. Rieder wrote...

Casting hostile spells on neutral opponents is a problem that no one has solved yet to my knowledge. There are some work-aroudnds, though. You can use either a dialogue or GUI interface to allow the player to turn the enemy hostile, allowing you to attack it or cast hostile spells on it. With careful use of the pause button, this is almost as good as just being able to attack it.

If you use the GUI approach, you can look at Lance Botelle's GUI tutorial on the vault. It will proabably be a good place to start.


Creating a GUI to control the attack is what I did. (Thanks for the plug Matt.)

Here is my blog explaining the GUI: http://worldofalthea...n-neutrals.html

The blog also points out some other details you may want to be aware of, like ensuring "plot" PCs cannot be changed to an "enemy of the PC".

Lance.