Jump to content

How to get nearby actor reference?


Med111

Recommended Posts

I wrote effect script that modifies enemy AI, but I'm unable to cast it on them without reference. What's easiest way to get it, if conditions below are met?

 

if self.GetDetected player && self.GetCombatTarget player

 

I'm not sure if I should add self.GetFactionRelation player == 1 too.

Link to comment
Share on other sites

I wrote effect script that modifies enemy AI, but I'm unable to cast it on them without reference. What's easiest way to get it, if conditions below are met?

 

if self.GetDetected player && self.GetCombatTarget player

 

I'm not sure if I should add self.GetFactionRelation player == 1 too.

 

You could create a new spell set to "Self" and "Area" = 2000 or any large value. This would theoretically apply the effect to everything in that area.

Link to comment
Share on other sites

You could create a new spell set to "Self" and "Area" = 2000 or any large value. This would theoretically apply the effect to everything in that area.

 

How about GetFirstRef form NVSE? It's complex function and I don't know how to use it properly, but this probably would be easiest way to do the trick.

Link to comment
Share on other sites

You could create a new spell set to "Self" and "Area" = 2000 or any large value. This would theoretically apply the effect to everything in that area.

 

How about GetFirstRef form NVSE? It's complex function and I don't know how to use it properly, but this probably would be easiest way to do the trick.

 

You could. But I thought GetFirstRef cycled through everything in a given cell. What I proposed was a way to limit this radius ("nearby") and to do it without NVSE.

 

But by all means, whatever works.

Link to comment
Share on other sites

If I set base effect to "Self", I'm unable to set area effect for actor effect.

 

I actually haven't tried this approach at all :D. It's all speculation. If "Self" doesn't work, try making it "Touch" then. It really shouldn't matter which you choose since you will be applying the spell through script.

Link to comment
Share on other sites

I use a spell in my Wendy Gilbert mod that acts like a 'Actor radar' with a radius of 3500 units. Using a quest script, I apply the spell to the player every few seconds to scan for enemies and get a kill count. It runs a small script on every actor that is affected, so you can do whatever you need in the ScriptEffectStart block.

 

so on the Actor Effect settings:

Type: Actor Effect

Area effect ignores LOS

Force Touch Explode

In the effects area, Add the base effect below with a Range - Touch, area 7000. duration 1 second

 

Base Effect:

Type: script

Flags: No hit effect, No death dispel, Self, Touch, Target, No magnitude, Painless

 

Example base effect script:

scn RHKWendyCBRadarEffectScript

short iRelation
ref rTarget

BEGIN ScriptEffectStart

set rTarget to GetSelf	;returns zero on spawned actors but doesn't matter

if (GetDisabled)
	return
endif

if (rTarget)
	if (rTarget.GetPlayerTeammate)
		return
	endif
endif

if ((rTarget != Player) && (rTarget != RHKWendyREF))

	
	if ((IsActor) && (GetDead == 0))
		set iRelation to GetFactionRelation Player
		if ((iRelation <= 1) && (GetDistance Player < 3000))		; Neutral or enemy within 140 feet
			if (iRelation == 0)		;Neutral
				if (GetAv Aggression > 1)	;Attacks neutrals on sight
					set RHKWendyCB.iEnemyCount to RHKWendyCB.iEnemyCount + 1
					if (GetAV Health > 450)
						set RHKWendyCB.iBigEnemy to RHKWendyCB.iBigEnemy + 1
					endif
				endif
			elseif (iRelation == 1)	;Enemy
				set RHKWendyCB.iEnemyCount to RHKWendyCB.iEnemyCount + 1
				if (GetAV Health > 450)
					set RHKWendyCB.iBigEnemy to RHKWendyCB.iBigEnemy + 1
				endif
			endif
		endif
	endif
endif

END

Link to comment
Share on other sites

I actually haven't tried this approach at all :D. It's all speculation. If "Self" doesn't work, try making it "Touch" then. It really shouldn't matter which you choose since you will be applying the spell through script.

 

Looks like it matters, because any effect except "Self" applied to my character, crashes NV to desktop. Hmm.

 

EDIT: "Touch" effect works, but it doesn't affect actors around. I won't get references this way.

Edited by Med111
Link to comment
Share on other sites

  • Recently Browsing   0 members

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