Jump to content

Have a script apply to all hostile enemies nearby


superfid2006

Recommended Posts

Hello everyone,

 

I've recently been working on adapting the Pariah Dog encounter from FO2 into NV, and finished replicating the critical failures from FO2 into the game.

Sadly, as of right now, the critical failures only work on the player himself, while in FO2 it affected not just you but every enemy as well.

 

My question is: how can you reference every hostile enemy from within the script? As I imagine it, it should be possible to reuse (most of) the functions I already wrote by just replacing the references to the player character with references to the enemies, but I have no clue how I could go about doing so.

 

Here is the mod if you wish to take a look.

 

 

PS: I just started out with scripting New Vegas, or scripting in general really, a few days ago. So if you happen to spot common newbie mistakes or have some suggestions about common practices, I'd appreciate it.

 

Cheers!

 

 

EDIT: One way I could think of (without actually testing it, mind you) would be to use NVSE's GetRefs function to get a list off all actors, and maybe somehow filter the resulting array for only hostiles?

int i
int j
int iNumberVictims
int iNumberEnemies

array_var aJinxedVictims
array_var aJinxedEnemies

Begin OnStartCombat
let aJinxedVictims := GetRefs 200, -1 ;Gives an array with each actor's Ref inside
set i to 1
set j to 1
set iNumberVictims to Ar_Size aJinxedVictims

while i <= iNumberVictims   ;Goes through the whole array and adds only the ones who are in Combat with the player to the other array.
   if eval (aJinxedVictims[i].IsInCombatWithPlayer == 1)
      let aJinxedEnemies[j]:= aJinxedVictims[i] ; This array should have keys filled with refs of enemies and empty keys
      let j+= 1
   endif
   let i += 1
loop
END

This is the first time I looked at arrays, but this SHOULD give us an array named aJinxedEnemies containing actors who are in combat with us, right?

If so, then it should be possible to loop the script I am using on only the player right now for every single REF inside of the array, making it affect every enemy as well (this might also affect friendlies, but that's even better considering the original Jinxed perk).

Link to comment
Share on other sites

Please see the 'Scripting' section of the wiki "Getting started creating mods using GECK" article. Lots of "lessons learned" contributed from many sources, including links to articles on EventHandlers.

 

-Dubious-

 

 

I'm going to bookmark that page for later, thanks for the link. So far, I struggled along self-contained while reading the Geckwiki, so having some perspective from other modders should be helpful. Thanks!

Link to comment
Share on other sites

FYI: The GECKWiki is primarily a "dictionary" of functions, with a few "official" very basic tutorials. The community based one I've linked is now more complete than the official one, including functions from the various "Script Extension" plugins. But outside of the tutorials, the "category" pages (under "Index | Scripting" on the main page) are the most helpful because if you don't know what functions are available, then you don't know what to look up. The 'Scripting' section of "Getting Started" I previously referenced is more "how to" oriented from questions asked here.

 

Good luck!

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...