SphereCommunity
Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? (/Thread-Why-do-NPCs-attacking-eachother-Seemingly-randomly-run-away-from-each-other)

Pages: 1 2 3


Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - Rayvolution - 08-01-2012 09:58 AM

I'm working on my "realistic guards" script, and I'm having trouble getting the AI to act correctly, for some reason (and only with certain NPCs) they will attempt to attack each other, and retreat.

I thought it was something as simple as they detected the stats of the target and run, but that doesn't explain why I can code a guard with 1/1/1 stats to attack a Wyrm, and he does so.

I also noted that it seems to have to do with the type of NPC, for example, I can't get 2 skeletons to fight either.


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - Anarch Cassius - 08-01-2012 10:08 AM

I believe the default brains have some specific behaviors. The relavant ones here seem to be guards are fearless and Undead won't fight.

One solution is to replace their default brains with a blank or simple one and code all attack behaviors. The fear is something that happens mostly with weak NPCs and I'm not sure what to do about it.


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - Rayvolution - 08-01-2012 11:04 AM

Hmm, that might explain it.

Although there must be some other flags too, because I noticed for some reason, even brain_guard will "run away" from other human NPCs, even if you flag them red, criminal, and brain_monster

It's very strange :/

I can't use brain_guard for my script though anyway, because when "spawned" via spawngem, they vanish. They'll only stick around if I manually add them via Axis.

Even stranger: Brain_None on the guard won't change his behavior. He still "runs away" from all human characters.

Looking more into it, it seems that basically any NPC with the same Body won't attack each other.

It's so specific, that my male guards will attack female NPCs but not male ones (and vice versa).

I'm perplexed :/


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - admin phoenix - 08-01-2012 08:13 PM

long time ago, nazghull put some tags in the source code, so that npc will help or attack each other, if they have this tags.
but it was only a testing nightly build from him and I think it was never implented.
Maybe this thinks will be very helpfull for this script if it will implented ...
and maybe it can be coded a little bit more for example
there will be an event that name is hardcoded like
e_brain_undead but you can softcode it in some way like
if (<hitpoints> < 10)
RETURN 1 --> it will stop the hardcoded running away modus (something like that, donĀ“t know the code for it)


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - darksun84 - 08-01-2012 09:24 PM

In @NpcActFight there is this argument

ARGN2

IO

The NPC's motivation level to fight.
Note: NPCs, excluding pets, with a motivation less than zero will flee from their target.

Maybe it can be useful Shock


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - Rayvolution - 08-01-2012 11:05 PM

(08-01-2012 09:24 PM)darksun84 Wrote:  In @NpcActFight there is this argument

ARGN2

IO

The NPC's motivation level to fight.
Note: NPCs, excluding pets, with a motivation less than zero will flee from their target.

Maybe it can be useful Shock

Nope, didn't work. Sad

It's very strange indeed, I can even spawn a generic bad guy NPC (Example, a male bandit) and the guard will see the bandit, "attack" and just turn around and walk away from the target in combat mode.

*but* if I spawn a female bandit, he attacks correctly. I even went as far as summing male NPCs and doing .set body c_woman, and he will instantly stop walking away in combat mode, and attack.

After further tested, I realized this is with *all* characters in the game. For example, 2 skeletons wont fight each other when told, but a skeleton and a zombie will. Same with Dragons, Balrons, Elementals and every single other character I've tested.


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - WRWR - 08-01-2012 11:47 PM

maybe you have something like this in main npc event:
Code:
ON=@ATTACK
IF <SRC.BASEID>==<BASEID>
RETURN 1
ENDIF
?


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - darksun84 - 08-02-2012 12:11 AM

What about this flag in the sphere.ini ?

// Monsters may fight each other
MonsterFight=0


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - Rayvolution - 08-02-2012 02:10 AM

I can dig through my events but thats strange is the NPCs dont just return 1 and resume normal operation. They stay in combat mode, and just steady wander away from their target.

- Trigger fires to fight target
- Goes into combat mode, triggers the NAME attacking TARGET emote
- (still in combat mode) starting slowly walking directly away from the target.
- When out of view completely (screen or so away) leaves combat mode, and wanders back to his spawn point like nothing happened.

Although if it's a different baseID, he'll see them, go in combat mode and run after/kill the target.

I've tried remving their brains, all their speech flags, triggers, events, everything and manually forced them to attack each other, and they still do it. I can't ven get 2 c_chickens to fight. It's really odd. :/

MonsterFight is set to 1, also.


RE: Why do NPCs attacking eachother (Seemingly randomly) run away from each other? - darksun84 - 08-02-2012 02:14 AM

can you show us the script Shock ?