Author Topic: NPC checks the distance to PC on combatRoundEnd  (Read 359 times)

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
NPC checks the distance to PC on combatRoundEnd
« on: July 13, 2014, 12:05:38 pm »


               

Hello you scriptors,


 


I want to have an enemy npc (ranger type guy) checking the distance to the PC on combat round end and let him try to keep a specific distance as long as is in combat. So i think i need him to always check the distance to the PC while in combat but attacking via a ranged weapon is priority. So he is not checking and walking like an idiot while under fire but trying to move closer or further away still attacking the player. Can someone help me a little bit please?


 


I want to have my soldiers not shooting from 50 meters away in a jungle where the fog covers everything and they shoot out of the nowhere. Thats why i need a distance setup for all soldiers.


 


Thank you in advance '<img'>



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
NPC checks the distance to PC on combatRoundEnd
« Reply #1 on: July 13, 2014, 05:18:22 pm »


               

Just some food for thought and not an actual attempt to fix your problem, but what stops PCs from doing the same thing to these foes?


 


I had a similar conundrum a few years back and in the end just left things alone. Mainly because PCs with a ranged weapon equipped would usually auto fire back at the unseen enemies anyhow.


 


A non-scripted solution which I have used at times is to just decrease an NPCs perception range in the toolset (even if this meant making tweaked copies of "normal" versions). Default perception ranges are set in the Appearance 2da, but you can increase/decrease the ranges in a window found at the bottom of the advanced page in a creatures properties.



               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
NPC checks the distance to PC on combatRoundEnd
« Reply #2 on: July 13, 2014, 08:06:38 pm »


               

Yes i thought and tried all the perception ranges out but the problem is YOU the PC dont see the enemys either. The problem is more that the enemys fire behind the fog so to say and not you. I have a script that uses the heartbeat but it seems a bit strange at times and i dont even understand what it does. IT just works a little bit for me. Well, another way is a real usage of "obscuring" walkmeshs for groundcover and trees but if anyone can anyway give me an example how to tell a creature to keep a specific distance to the PC i would be very happy. There are other events i need distance. I think in modern combat distance is one of the most important things you have to be a bit more specific.


 


So thanks anyway and if something pops up let it out '<img'>


               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
NPC checks the distance to PC on combatRoundEnd
« Reply #3 on: July 13, 2014, 08:51:14 pm »


               

If you use Bioware AIs or a variant based on them, you can try using the following:


 


#include "x0_i0_combat"
 
SetCombatCondition(X0_COMBAT_FLAG_RANGED);

 


This should work from the OnSpawn Event, though I've not tested it. According to the NWN Lexicon, the NPC will first change targets to a further one if its present target gets too close and failing that, it'll attempt to retreat to a better ranged attack distance.



               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
NPC checks the distance to PC on combatRoundEnd
« Reply #4 on: July 17, 2014, 07:36:28 pm »


               

Thanks again and i tried that one too. It´s not perfect by any means but they are smarter then most AI in modern games who only stand there and shoot... or they jump silly around and do nothing randomly bugged when you are in plain sight. So i must say that the NWN AI is better then many other so called AI´s of modern games. Our dudes defintely use spot/search and shoot at you and chase you and if you are clever enough you can do many more things with scripting. Let them move back to a hideout to rest/ getting fixed so to say via steroids/ bandages etc. when their hitpoints are terrible low.


 


Oh and the grenades are hardcore... one nade one hit and boom you are dead!