Jump to content

Recommended Posts

Posted (edited)

Hi again everyone, i have some power armor pieces that add keywords when an OMod is equipped which will swap the ref frame for a new frame - but i cant seem to detect that keyword by checking the power armor reference, i think ill need to search the power armor's worn items, but i dont know how to do that...

((note i need this to happen in the power armor workbench menu, not while the power armor is worn.))

 

This is what i have so far...

Scriptname FMod extends ObjectReference

Keyword property MF_KWD Auto
Armor Property RFrame Auto
Keyword property KWD_F Auto
Keyword property KWD_M Auto
Furniture Property Frame_1 Auto
Furniture Property Frame_2 Auto

Keyword Property powerArmorFurnitureKW Auto
Keyword Property powerArmorKW Auto


Event OnActivate( ObjectReference akActionRef )
    RegisterForTutorialEvent("ModdingSuccess")
EndEvent

Event OnTutorialEvent(String asEventName, Message aMessage)
    if asEventName == "ModdingSuccess"
        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(MFKWD)
                    Debug.notification("Standard Frame detected")	
							
                    If NearestPowerArmor.HasKeyword(KWD_F)
                        Debug.notification("Changing frame...")	
                        nearestPowerArmor.DisableNoWait()
                        nearestPowerArmor.Delete()
                        ObjectReference newFrame = Self.PlaceAtMe(Frame_1)
                        NewFrame.MoveTo(Self)
                    EndIf
                    If NearestPowerArmor.HasKeyword(KWD_M)
                        Debug.notification("Changing frame...")	
                        nearestPowerArmor.DisableNoWait()
                        nearestPowerArmor.Delete()
                        ObjectReference newFrame = Self.PlaceAtMe(Frame_2)
                        NewFrame.MoveTo(Self)
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndEvent

When checking NearestPowerArmor i don't get the debug, meaning that the keyword isnt fornd on the frame, even though the keyword is definiately added to a piece of armor that is on the frame...

 

*Edit* - i tried detecting the keyword on the power armor's worn items...

if NearestPowerArmor.WornHasKeyword(KWD_F)

instead of

If NearestPowerArmor.HasKeyword(KWD_F)

But that gives me a compile error -

(110,27): WornHasKeyword is not a function or does not exist
(110,27): cannot call the member function WornHasKeyword alone or on a type, must call it on a variable

 

as far as i can tell - nearestpowerarmor is a variable, but the "wornHasKeyword" doesnt work here, i get the feeling "wornHasKeyword" belongs to the actor script not the object reference script, which might be why its failing... how can i get this to work in an object reference script?

 

i also tried just looking for any matching keyword nearby...

ObjectReference[] FrameTofit_F = FindAllReferencesWithKeyword(KWD_F, 50.0)
    if( FrameTofit_F )
	Debug.notification("Changing frame...")	
	    nearestPowerArmor.DisableNoWait()
	    nearestPowerArmor.Delete()
	ObjectReference newFrame = Self.PlaceAtMe(Frame_2)
	NewFrame.MoveTo(Self)
    EndIf

But the game doesnt seem to find the keyword in this case either, which is very wierd. i would have expected to be able to find the keyword with this like i can find the "nearestPowerArmor" in the same way with "FindAllReferencesWithKeyword()"

no idea why that one doesnt work???

 

So another idea i had was to use "GetWornItem" like this -

Actor:WornItem wornItem = NearestPowerArmor.GetWornItem(26)
  If WornItem.HasKeyword(KWD_F)

To see if the worn item 26 has the keyword, but unfortionately i get another complie error -

 

(112,19): GetWornItem is not a function or does not exist
(113,5): variable WornItem is undefined
(113,14): none is not a known user-defined script type
(113,2): cannot cast a void to a bool to perform a condition check
(126,5): variable WornItem is undefined
(126,14): none is not a known user-defined script type
(126,2): cannot cast a void to a bool to perform a condition check

 

I have no idea why this one wont compile either, but i suspect that even if it did compile it wouldnt matter because i bet the power armor isnt classed as being "worn" when on the furniture model, its probably in a "power armor container" of some kind... i wonder if we can check items in containers for keywords?

 

***

 

Does anyone know how to detect this keyword on my power armor?

 

Any help or advice on this one would be very appreciated ^.^

Edited by SandMouseAnarchy
  • 10 months later...
Posted

GetWornItem is in F4SE scripts - to use it in scripting you need install f4se and for use in CK you need install modders package too what is in f4se archive. And of course users need install f4se to use your mod then.

  • Recently Browsing   0 members

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