How to get enemy reference?

Post » Tue Sep 06, 2011 12:55 pm

As it's in title - what's easiest way to get reference of actor, who's attacking player character? I tried two different methods, but neither was simple nor working. I need this reference for casting scripted effect on enemies.
User avatar
Becky Cox
 
Posts: 3389
Joined: Thu Jun 22, 2006 8:38 am

Post » Tue Sep 06, 2011 12:19 pm

In what context? Gunfire, melee, just after the player is hit, any actor in combat with the player at a given time...?
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Tue Sep 06, 2011 1:32 pm

In what context? Gunfire, melee, just after the player is hit, any actor in combat with the player at a given time...?


I just need reference, conditions are much easier to figure out. However if you're willing to help - I'm going to use one of conditions desribed below, but I'm not sure which one will be best. I want this to work, when enemy detected player and is about to engage combat (when sneak indicator changes from [Caution] to [Danger]).

self.IsInCombatself.GetCombatTarget playerself.GetFactionRelation player == 1self.GetDetected player


"self" is enemy reference, that I need.
User avatar
Justin Bywater
 
Posts: 3264
Joined: Tue Sep 11, 2007 10:44 pm

Post » Tue Sep 06, 2011 8:32 pm

If you're running the script on the actual reference you're trying to get then you have to declare reference variable using

ref MyRef

then you can use a function that runs implicitly on the calling actor like This or GetSelf, to set the MyRef variable to that value.

So, from your code example.


ref MyRefbegin GameModeset MyRef to GetSelf  ;now GetSelf is the reference of your actorself.IsInCombatself.GetCombatTarget playerself.GetFactionRelation player == 1self.GetDetected playerend


Although I have a feeling this isn't what you want either.
User avatar
Kristina Campbell
 
Posts: 3512
Joined: Sun Oct 15, 2006 7:08 am

Post » Tue Sep 06, 2011 6:20 pm

Although I have a feeling this isn't what you want either.


If only it would be that easy... GetSelf works only in effect scripts, which are applied by something else. This "something else" is what I need to figure out.

EDIT: Also your code is wrong, there is no "if" and I'm not going to add all these conditions. It was just suggestion.
User avatar
Damned_Queen
 
Posts: 3425
Joined: Fri Apr 20, 2007 5:18 pm

Post » Tue Sep 06, 2011 5:35 pm

So basically you just want to get the references of every NPC in the nearby area, and then determine if they're in combat. Use the NVSE function GetFirstRef- it's a bit complicated so look it up on the wiki, but it's basically going to be like:
set refVar to GetFirstRef 200 1label 10if(refVar)   ;Do whatever   set refVar to GetNextRef   goto 10endif

User avatar
Alexander Horton
 
Posts: 3318
Joined: Thu Oct 11, 2007 9:19 pm

Post » Tue Sep 06, 2011 6:06 pm

So basically you just want to get the references of every NPC in the nearby area, and then determine if they're in combat. Use the NVSE function GetFirstRef- it's a bit complicated so look it up on the wiki, but it's basically going to be like:
set refVar to GetFirstRef 200 1label 10if(refVar)   ;Do whatever   set refVar to GetNextRef   goto 10endif



Thanks. I tried GetFirstRef already, but without label.
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am


Return to Fallout: New Vegas