SandMouseAnarchy Posted March 21, 2019 Share Posted March 21, 2019 (edited) 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 March 21, 2019 by SandMouseAnarchy Link to comment Share on other sites More sharing options...
deadbeeftffn Posted March 21, 2019 Share Posted March 21, 2019 try ObjectReference[] nearbyPowerArmors = FindAllReferencesWithKeyword(powerArmorFurnitureKW, 50.0) instead of ObjectReference{} nearbyPowerArmors = FindAllReferencesWithKeyword(powerArmorFurnitureKW, 50.0) Link to comment Share on other sites More sharing options...
DieFeM Posted March 21, 2019 Share Posted March 21, 2019 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 More sharing options...
SandMouseAnarchy Posted March 21, 2019 Author Share Posted March 21, 2019 Oh man, ^.^ haha I can't believe I used the wrong brackets, I can't really see the difference between them with the font and resolution I have, thankyou Deadbeeftffn! Ah thank-you yet again DieFeM! Legend! The prepend is exactly what I needed to get the script going ^.^ Link to comment Share on other sites More sharing options...
Evangela Posted March 22, 2019 Share Posted March 22, 2019 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 More sharing options...
SandMouseAnarchy Posted March 22, 2019 Author Share Posted March 22, 2019 Good idea Rasikko :) i did have to step the distance up to 120 in the latest itteration of this script, but this is supposed to fire while the player is fixing up the power armor at the workbench so the player will be right on top of the power armor anyway ;) Link to comment Share on other sites More sharing options...
Recommended Posts