Jump to content

Need help with scripts for an armor Mod I created recently.


Recommended Posts

I wanted to continue working on the script anyway. Even if it changes and adds an animation still needs the triggers to work.

 

I was thinking arnt the draw animations tied to the weapon because they do fancy things when you draw weapons. So shouldnt we be running the event check against the equipped weapon and not the player?

Link to comment
Share on other sites

  • Replies 86
  • Created
  • Last Reply

Top Posters In This Topic

Well,

Decided to come back to this. Turns out the animations part was fine. Just the object ref the script is attached to is not available in the onanimationevent section.

 

Could someone please tell me how to fix this?

 

 

@r00stafarian had an idea, what if instead of zipping the suit up at night and unzipping during the day, how about we tie it to light levels? So if its bright its probably a warm place so unzip, if its dark probably a cold place so zip up.

Scriptname CGXAM_GhostGoggles extends ObjectReference

Armor Property CGXAM_CourserGhostX92Goggles Auto

Keyword property CGXAMGhostX92GogglesDown auto
Keyword property CGXAMGhostX92GogglesUp auto
Keyword property CGXAMGhostX92GogglesPulsingDown auto
Keyword property CGXAMGhostX92GogglesPulsingUp auto

ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto 
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto

Event OnEquipped(Actor akActor)
	if akActor == Game.GetPlayer()
		ObjectReference GoggleRef = self.
		RegisterForAnimationEvent(game.getplayer(), "WeaponDraw")
		RegisterForAnimationEvent(game.getplayer(), "WeaponSheathe")
		Debug.MessageBox("animations regeisterd")
		if (Game.getplayer().IsWeaponDrawn() == true)
			If (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
				GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
			ElseIF (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
				GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
			EndIf
		ElseIF (Game.getplayer().IsWeaponDrawn() == false)
			If (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
				GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
			ElseIF (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
				GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
			EndIf
		EndIf
	EndIf
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	if (akSource == Game.GetPlayer()) && (asEventName == "WeaponDraw")
		If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
			GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
		ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
			GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
		EndIf
	ElseIf (akSource == Game.GetPlayer()) && (asEventName == "WeaponSheathe")
		If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
			GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
		ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
			GoggleRef.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp)
		EndIf
	EndIf
endEvent

Event OnUnequipped(Actor akActor)
	if akActor == Game.GetPlayer()
		UnregisterForAnimationEvent(game.getplayer(), "WeaponDraw")
		UnregisterForAnimationEvent(game.getplayer(), "WeaponSheathe")
	EndIf
EndEvent

Edited by stonefisher
Link to comment
Share on other sites

Basically your problem was that you are creating the GoggleRef in your OnEquipped function, so it is a "local" variable to that function that can't be used outside of it. But since your GoggleRef is set to Self, you don't need it at all.

Scriptname CGXAM_GhostGoggles extends ObjectReference

Armor Property CGXAM_CourserGhostX92Goggles Auto

Keyword property CGXAMGhostX92GogglesDown auto
Keyword property CGXAMGhostX92GogglesUp auto
Keyword property CGXAMGhostX92GogglesPulsingDown auto
Keyword property CGXAMGhostX92GogglesPulsingUp auto

ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto 
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto

Event OnEquipped(Actor akActor)
    if akActor == Game.GetPlayer()
        RegisterForAnimationEvent(game.getplayer(), "WeaponDraw")
        RegisterForAnimationEvent(game.getplayer(), "WeaponSheathe")
        Debug.MessageBox("animations regeisterd")
        if (Game.getplayer().IsWeaponDrawn() == true)
            If (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
                AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
            ElseIF (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
                AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
            EndIf
        ElseIF (Game.getplayer().IsWeaponDrawn() == false)
            If (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
                AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
            ElseIF (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
                AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
            EndIf
        EndIf
    EndIf
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
    if (akSource == Game.GetPlayer()) && (asEventName == "WeaponDraw")
        If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
            AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
        ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
            AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
        EndIf
    ElseIf (akSource == Game.GetPlayer()) && (asEventName == "WeaponSheathe")
        If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
            AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
        ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
            AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp)
        EndIf
    EndIf
endEvent

Event OnUnequipped(Actor akActor)
    if akActor == Game.GetPlayer()
        UnregisterForAnimationEvent(game.getplayer(), "WeaponDraw")
        UnregisterForAnimationEvent(game.getplayer(), "WeaponSheathe")
    EndIf
EndEvent
Edited by Reneer
Link to comment
Share on other sites

 

 

@r00stafarian had an idea, what if instead of zipping the suit up at night and unzipping during the day, how about we tie it to light levels? So if its bright its probably a warm place so unzip, if its dark probably a cold place so zip up.

 

 

I think that is an acceptable compromise. Working on a 3.0 of the mod (added one more suit variation). Almost done.

Link to comment
Share on other sites

@reneer

 

Heres the old script I was trying to fix with the goggleref. The "self" in the onanimate section did not attach mod to the goggles while the onequip section the self worked for attaching the mods. I did stick message boxs everywhere and everything was working except the attach mod lines section was triggered but no mods were added.

Scriptname CGXAM_GhostGoggles extends ObjectReference

Armor Property CGXAM_CourserGhostX92Goggles Auto

Keyword property CGXAMGhostX92GogglesDown auto
Keyword property CGXAMGhostX92GogglesUp auto
Keyword property CGXAMGhostX92GogglesPulsingDown auto
Keyword property CGXAMGhostX92GogglesPulsingUp auto

ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto 
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto

Event OnEquipped(Actor akActor)
	if akActor == Game.GetPlayer()
		RegisterForAnimationEvent(game.getplayer(), "WeaponDraw")
		RegisterForAnimationEvent(game.getplayer(), "WeaponSheathe")
		if (Game.getplayer().IsWeaponDrawn() == true)
			If (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
				Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
			ElseIF (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
				Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
			EndIf
		ElseIF (Game.getplayer().IsWeaponDrawn() == false)
			If (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
				Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
			ElseIF (Game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
				Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
			EndIf
		EndIf
	EndIf
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	if (akSource == Game.GetPlayer()) && (asEventName == "WeaponDraw")
		If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
			Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
		ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
			Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
		EndIf
	ElseIf (akSource == Game.GetPlayer()) && (asEventName == "WeaponSheathe")
		If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
			Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
		ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
			Self.AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp)
		EndIf
	EndIf
endEvent

Event OnUnequipped(Actor akActor)
	if akActor == Game.GetPlayer()
		UnregisterForAnimationEvent(game.getplayer(), "WeaponDraw")
		UnregisterForAnimationEvent(game.getplayer(), "WeaponSheathe")
	EndIf
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...