SphereCommunity
NPCs not fighting back? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: NPCs not fighting back? (/Thread-NPCs-not-fighting-back)

Pages: 1 2


NPCs not fighting back? - Arathil - 10-01-2016 04:19 PM

I have some NPC guards in a city with a very simple script that fires when they see a flagged criminal player.

Essentially:
ON=@NPCSeeNewPlayer
IF (<SRC.FLAGS>&STATF_CRIMINAL)
ATTACK <SRC.UID>
SAY=Meet your fate, criminal!
...
...
...

It seems to fire correctly, You see a *Guard is attacking Criminal* emote, and the guard gets into war mode, but the NPC doesn't actually start attacking and wanders away.

If the Criminal makes an effort to attack the guard and hits them, then it will fight back as it should. I cannot figure out for the life of me why this is happening. Any ideas?


RE: NPCs not fighting back? - Kanibal - 10-01-2016 09:16 PM

.GM and .INVUL must be off Big Grin


RE: NPCs not fighting back? - x77x - 10-02-2016 01:46 PM

it does in to regular accounts too...

its like the memory deletes after a few seconds


RE: NPCs not fighting back? - Coruja - 10-06-2016 08:34 AM

I found an problem where guards NPCs already placed on world are not attacking criminal/murderer chars nearby
but I already fixed it on latest build, try using it:
https://ci.appveyor.com/project/coruja747/source/build/0.56.4.222/artifacts


RE: NPCs not fighting back? - x77x - 10-06-2016 09:16 PM

but if hes using the above, i doesnt have a guard brain =P
mine looks like this
Code:
[events e_army_soldier]
ON=@NPCLookAtChar//TO INTERACT WITH NPCS
IF (<SRC.TAG0.MILITARY>)
    IF !(<SRC.TAG0.ARMYNUMBER>==<TAG0.ARMYNUMBER>)
    ATTACK <SRC>
    ELIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK MILITARY CRIMINALS
    Say Beat it military criminal!
    ATTACK <SRC>
    ELIF (<SRC.MEMORYFINDTYPE.0400.LINK> > 040004010)//ATTACK every PLAYER made guild
    ATTACK <SRC>
    ENDIF
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK CIVILIAN CRIMINALS
    Say Beat it civilian criminal!
    ATTACK <SRC>
ENDIF

ON=@NotoSend//2 ALLY 5 ENEMY 6 RED    
IF (<SRC.TAG0.MILITARY>)
    IF !(<SRC.TAG0.ARMYNUMBER>==<TAG0.ARMYNUMBER>)
    //IF !<GUILD>
    ARGN1=5
    ELIF (<SRC.TAG0.ARMYNUMBER>==<TAG0.ARMYNUMBER>)
    //ELIF <GUILD>
    ARGN1=2
    ENDIF
ENDIF

ON=@GetHit
IF (<SRC.TAG0.MILITARY>)
    IF (<SRC.TAG0.ARMYNUMBER>==<TAG0.ARMYNUMBER>)
    src.criminal 1
    ENDIF
ENDIF



RE: NPCs not fighting back? - Leonidas - 11-05-2016 05:09 AM

Did you ever figure this out because I'm having a similar issue.

Code:
ON=@NPCSeeNewPlayer
IF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 5 )
Say Criminals are not allowed here!
ATTACK <SRC.UID>

They go into war mode, they say "Criminals arent allowed" then they start walking around.


RE: NPCs not fighting back? - Coruja - 11-05-2016 01:15 PM

I think it makes more sense use 'brain_guard' (which already attack criminal/murderers nearby) instead use another custom brain with @NPCSeeNewPlayer -> ATTACK

just set brain_guard on NPC and use @NPCSeeNewPlayer -> return 1 if you want skip the internal check (eg: don't attack if outside region X, don't attack targets that doesn't have TAG.LOL, etc)


RE: NPCs not fighting back? - Anarch Cassius - 01-26-2017 04:48 PM

The problem is that neither ATTACKER.ADD or ATTACK reliably cause an NPC to attack another NPC anymore. This has made pretty much all NPC fight scripts useless. All my faction AI is broken.


RE: NPCs not fighting back? - massis87 - 01-26-2017 08:19 PM

same as cassius, you have to change brain and karma of the npc like u want.
Code:
[CHARDEF C_Guardia_Umana]
NAME=#NAMES_HUMANMALE Guardia Umana
SOUND=snd_HUMAN_M_DIE_01
ID=C_MAN
DESIRES=i_gold,t_wand,t_reagent,t_bone
AVERSIONS=t_TRAP,t_eerie_stuff
CAN=MT_EQUIP|MT_RUN|MT_USEHANDS|MT_WALK
DEF=200
ARMOR=1000
MOVERATE=100
DAM=5,10
TEVENTS=e_Human_guardie_click
CATEGORY=Seven - Npg Razze
SUBSECTION=Guardie Razziali
DESCRIPTION=Guardia Umana

ON=@Create
NPC=BRAIN_animal
STR=150
DEX=500
INT=1
TAG.NAME.HUE=0065
MAXHITS=9000

//EVENTS=+E_Rigenerazione_Fisica


HEALING=100.0
MAGICRESISTANCE=100.0
PARRYING=100.0
SWORDSMANSHIP=100.0
FENCING=100.0
MACEFIGHTING=100.0
TACTICS=100.0
ANATOMY=100.0

KARMA=-2000
FAME={1000 1500}
COLOR=colors_skin

ITEMNEWBIE=i_hair_long
COLOR=colors_hair
ITEMNEWBIE=I_Spada_delle_Guardie_Umane
ITEMNEWBIE=i_platemail_gloves
NAME=Human steel armor
COLOR=0698
ITEMNEWBIE=i_platemail_arms
NAME=Human steel armor
COLOR=0698
ITEMNEWBIE=i_platemail_gorget
NAME=Human steel armor
COLOR=0698
ITEMNEWBIE=i_platemail_chest
NAME=Human steel armor
COLOR=0698
ITEMNEWBIE=i_platemail_leggings
NAME=Human steel armor
COLOR=0698
ITEMNEWBIE=i_cape
NAME=Cape human guard
COLOR=0073e
ITEMNEWBIE=i_SASH
NAME=sash human guard
COLOR=0073e
ITEMNEWBIE=i_shield_round_metal
NAME=Shield human guard
COLOR=0698


////////////////////////////////////////
//--- Evento : @NPCSeeNewPlayer ------//
////////////////////////////////////////

ON=@NPCseenewplayer

    IF (<SRC.FLAGS>&000000001)
       RETURN 1
    ENDIF

    IF <SRC.FINDID.I_Memory_Messaggero>
        RETURN 1
    ENDIF


//--- Attacco su Drow - Vampiro - Efreet ---//
  
   IF (0<src.tag.razzadef>=1) || (0<src.tag.razzadef>=5) || (0<src.TAG.RAZZADEF>=2)
       ATTACK
       IF  <SRC.STAMINA>>0
            SRC.STAMINA=0
         ENDIF      
   ENDIF

this is my custom guard


RE: NPCs not fighting back? - Anarch Cassius - 01-27-2017 05:07 AM

Quote:same as cassius, you have to change brain and karma of the npc like u want.

No. I explained in the other thread. NPCs should attack when ordered by script regardless.

ATTACK does not work, this is a bug.

Changing karma is a crude workaround people should have stopped using years ago. We want this user controlable, not relying on the hard code to allow a few predetermined behavoir types.