Author Topic: hostile do nothing  (Read 576 times)

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
hostile do nothing
« on: March 14, 2012, 07:04:08 pm »


               so...  for the life of me, i can't figure this out.  i can't get a hostile NPC to just stand there and do nothing while a PC beats on him.  well, i don't want him to do nothing, but i want him to fire a heartbeat script each round that performs an action.

anyway, i guess what i'm really looking for is a walkthrough of what happens when a PC approaches an NPC.  all of the scripting tutorials i've found cover how to write scripts (i already know how to code) but i've not found something that walks through the NPC scripts.

i assume that the first thing that happens is the onperception script.  then that script will eventually tell the NPC to attack the PC, right?  DetermineCombatRound looks like what is happening, but i've put print statements in there and it doesn't seem to be called.  or is that hostility internally taken care of with internal bioware functions of the faction?


yeah, i know.  probably a really stupid question, but i've not been able to figure out exactly what causes a hostile faction NPC to attack a PC when he's seen.  i wanted to change that behavior (while keeping him in the hostile faction).
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
hostile do nothing
« Reply #1 on: March 14, 2012, 07:27:49 pm »


               

acomputerdood wrote...

so...  for the life of me, i can't figure this out.  i can't get a hostile NPC to just stand there and do nothing while a PC beats on him.  well, i don't want him to do nothing, but i want him to fire a heartbeat script each round that performs an action.


Sounds like you need to call DetermineCombatRound() and set the creature with a special AI script.  This script will fire every round and allow you to do whatever action with the NPC you want.  Keeping him with no scripts will cause him to go into the DetermineCombatRound() mode if ever he gets a chance at an attack of opportunity.
               
               

               


                     Modifié par WhiZard, 14 mars 2012 - 07:29 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
hostile do nothing
« Reply #2 on: March 14, 2012, 07:31:16 pm »


               The OnDamaged call DetermineCombatRound if the NPC takes damage.

The OnSpellCastAt calls DetermineCombatRound if the NPC has a hostile spell cast at him.

OnHeartBeat will call DetermineCombatRound if the NPC is already in combat.

The OnConversation event call DetermineCombatRound if a friend to the NPC calls for help(If the Friend was Attacked)
search the boards on special AI or google it.  IT has been talked about many times.




instead of changing all the above scripts, it may be simpler to just add a Special AI.  The Special AI will be called  every time DetermineCombatRound is called.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
hostile do nothing
« Reply #3 on: March 14, 2012, 07:38:38 pm »


               

Lightfoot8 wrote...

The OnDamaged call DetermineCombatRound if the NPC takes damage.

The OnSpellCastAt calls DetermineCombatRound if the NPC has a hostile spell cast at him.

OnHeartBeat will call DetermineCombatRound if the NPC is already in combat.

The OnConversation event call DetermineCombatRound if a friend to the NPC calls for help(If the Friend was Attacked)
search the boards on special AI or google it.  IT has been talked about many times.




instead of changing all the above scripts, it may be simpler to just add a Special AI.  The Special AI will be called  every time DetermineCombatRound is called.


DetermineCombatRound() is self-looping also.  If he doesn't need the other scripts to call the event, they may just be clutter.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
hostile do nothing
« Reply #4 on: March 14, 2012, 09:40:48 pm »


               A different way to state what has been spelled out above:
If you short circuit the potential for a hostile to attack during the on perception event, they are not as likely to attack. If the PC does not attack the NPC in that situation, there won't be hostilities.

You might be able to use that info to your advantage.

I discovered this info when I made my lightshy AI. And thats why that AI has a heartbeat event script.
               
               

               
            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
hostile do nothing
« Reply #5 on: March 15, 2012, 03:48:48 am »


               thanks a ton guys - i had to wind up googling (why can't i EVER find anything with the forum's search?) and came up with this thread:

http://social.biowar...index/6598615/1

basically, you just set a local string variable on the creature VAR_X2_SPECIAL_COMBAT_AI_SCRIPT = script_name

then flesh out that script with what you want him to do each round.  the game takes care of the rest.

i knew it would be simple, i just couldn't get there myself.