Jump to content

How to use FindAllReferencesWithKeyword - in ActiveMagicEffect script?


Recommended Posts

How do you use FindAllReferencesWithKeyword in an ActiveMagicEffect script?

 

This is what i have so far...

Scriptname SM_PA_Spell extends activemagiceffect

Keyword property FrameKWD Auto
Keyword Property powerArmorFurnitureKW Auto
Keyword Property powerArmorKW Auto

bool ExitingPowerArmor = false


Event OnEffectStart(Actor akTarget, Actor akCaster)
Debug.MessageBox("Begin test")

; find nearest suit of power armor
  ObjectReference{} nearbyPowerArmors = FindAllReferencesWithKeyword(powerArmorFurnitureKW, 50.0)
  ObjectReference nearestPowerArmor
    If nearbyPowerArmors.Length > 0
      float fnearestDistance = 999999999999.9
	int i = 0
	while (i < nearbyPowerArmors.Length)
	float fcurrentDistance = GetDistance(nearbyPowerArmors[i])
	  if( fcurrentDistance < fnearestDistance && nearbyPowerArmors[i].IsEnabled() )
	    nearestPowerArmor = nearbyPowerArmors[i]
	    fnearestDistance = fcurrentDistance
	  endIf
	i = i + 1
	endWhile
	  if( nearestPowerArmor )
	    If !NearestPowerArmor.HasKeyword(FrameKWD)
	      Debug.notification("standard frame detected")
	    EndIf
	  EndIf
    EndIf
EndEvent

But i get the compile error - "(20,17): no viable alternative at input ''

 

No idea what the error means, could anyone kindly explain whats going wrong with my script? - and maybe how to fix it ^.^

Edited by SandMouseAnarchy
Link to comment
Share on other sites

As deadbeeftffn said, an array is defined by [], but there's another missing thing; If the script were extending an ObjectReference (or Actor by inheritance of ObjectReference) it would be OK calling FindAllReferencesWithKeyword and GetDistance like that, but you are working on ActiveMagicEffect so you must prepend from which ObjectReference the function is being called:

 

ObjectReference[] nearbyPowerArmors = akCaster.FindAllReferencesWithKeyword(powerArmorFurnitureKW, 50.0)

 

....

 

float fcurrentDistance = akCaster.GetDistance(nearbyPowerArmors[i])

Link to comment
Share on other sites

I'd suggest bumping your radius up. A radius of 50 is only 2.3ft/70cm/0.7xxxx meters. A PA would have to be right next to the player if it is to be found. Usually I use 4096 * n(n being number of cells) when I know the thing I'm searching for is known to be scattered over many cells, so I need a radius big enough to cover enough ground.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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