Jump to content

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


Recommended Posts

No idea.

 

So why is self not the same in Event OnEquipped(Actor akActor) and Event OnAnimationEvent(ObjectReference akSource, string asEventName)? I must learn.

"Self" is the same in both functions - the issue is likely that AttachMod is failing for some reason within the OnAnimationEvent function (likely because the object is within the player's inventory). More than likely you will want to use AttachModToInventoryItem instead.

Edited by Reneer
Link to comment
Share on other sites

  • Replies 86
  • Created
  • Last Reply

Top Posters In This Topic

Why does this script work? but only sometimes? When it works i get the messageboxs and when it dousnt i dont.

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

and this dousnt work?

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

nor this?

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	if (akSource == Game.GetPlayer()) && (asEventName == "WeaponDraw")
		Utility.wait(1)
		If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesUp))
			Utility.wait(1)
			AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
		ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
			Utility.wait(1)
			AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
		EndIf
	ElseIf (akSource == Game.GetPlayer()) && (asEventName == "WeaponSheathe")
		Utility.wait(1)
		If (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesDown))
			Utility.wait(1)
			AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
		ElseIF (game.getplayer().wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
			Utility.wait(1)
			AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp)
		EndIf
	EndIf
endEvent
Edited by stonefisher
Link to comment
Share on other sites

Well I think its the unequip event. Seems when adding a mod it unequips and reequips the armour but script dousnt always catch it for onequip. This means i need the registered animation events for it to work for sure.

 

Only way i have found to get it to work has been to remove the unequip event. Is it important for me to unregister for animation events? Are there any repercussions?

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))
				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
Edited by stonefisher
Link to comment
Share on other sites

@r00stafarian

 

Script down below works perfectly, googles up when weapons are away, goggles down when weapons drawn, automatically goes to correct position when equipped, works on anyone who wears it and I have made a toggle using an omod so you can set whether you want the script running on that specific goggles or not.

 

 

Now I have made this it will be very easy and fast to convert it to do the armour.

 

Just wondering in addition would you like any additional parameters to whether its zipped up or unzipped?

Could have it zipped up at night unzipped during the day,

zipped up when raining and unzipped when sunny (would need to make compatibility patches for weather mods),

whether being indoors makes a difference to whether its zipped up or not,

On light intensity so its only unzipped during really bright light.

Or a combination of some or all of these.

 

I can also add some to the goggles, would want them down in a rad storm if it were me.

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
Keyword property CGXAMGhostX92GogglesAnimated auto
Keyword property CGXAMWearingGhostX92Goggles 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

Actor Property ActorRef Auto

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

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

Event OnUnequipped(Actor akActor)
	if akActor == ActorRef
		If !(ActorRef.wornhaskeyword(CGXAMWearingGhostX92Goggles ))
			UnregisterForAnimationEvent(Game.GetPlayer(), "WeaponDraw")
			UnregisterForAnimationEvent(Game.GetPlayer(), "WeaponSheathe")
		EndIf
	EndIf
EndEvent
Link to comment
Share on other sites

 

@r00stafarian

 

Script down below works perfectly, googles up when weapons are away, goggles down when weapons drawn, automatically goes to correct position when equipped, works on anyone who wears it and I have made a toggle using an omod so you can set whether you want the script running on that specific goggles or not.

 

 

Now I have made this it will be very easy and fast to convert it to do the armour.

 

Just wondering in addition would you like any additional parameters to whether its zipped up or unzipped?

Could have it zipped up at night unzipped during the day,

zipped up when raining and unzipped when sunny (would need to make compatibility patches for weather mods),

whether being indoors makes a difference to whether its zipped up or not,

On light intensity so its only unzipped during really bright light.

Or a combination of some or all of these.

 

I can also add some to the goggles, would want them down in a rad storm if it were me.

 

A few Things:

* First, thanks for all your work on this so far!

* Does the script keep track of the mod upgrades to the goggles/suits when it equips the other versions?

* I would like for the zipped/unzipped to be as intuitive/logical as possible: zipped in rain/night/storms and unzipped during the day/good weather. I don't know if brightness would make it zipped indoors since most interiors are pretty dark.

* I think having goggles down when weapon is drawn and during very low visibility (like night with no lights or rad storm) is intuitive/logical too. If you could give night vision effect as well (during rad storm/night).

 

I have attached a new esp file (rename .txt to .esp) that I plan to upload (new file paths, included materials, new armor set, new breastplate armor). If you could add the script to it, that would be great.

 

Thanks again!

Edited by r00stafarian
Link to comment
Share on other sites

It keeps track of the vanilla mods and ballistic weave. I have given Omod support to select whether the goggles are up/down, steady/pulsing and whether you want it animated or manual.

 

I havnt generated any dynamic names for the OMOD's yet though.

 

I have kept the ghost and spectre armour sets separate as they look to be made of different materials.

 

If you want it zipped in interior cells it can be detected whether they are in one.

 

 

I cant add the script to just an esp, it needs to be the full mod or creation kit will crash.

 

I'll send you a link to download what I have done so far so you can test it out and see how to add it.

Link to comment
Share on other sites

Well made a nightvision effect cloned from the one used from scopes and made it work with magic.

 

And heres the new script for the goggles. It compiles, now to test.

Scriptname CGXAM_GhostGoggles extends ObjectReference

Keyword property CGXAMGhostX92GogglesDown auto
Keyword property CGXAMGhostX92GogglesUp auto
Keyword property CGXAMGhostX92GogglesPulsingDown auto
Keyword property CGXAMGhostX92GogglesPulsingUp auto
Keyword property CGXAMGhostX92GogglesAnimated auto
Keyword property CGXAMWearingGhostX92Goggles auto
;Keyword property CGXAMGhostX92GogglesAutoNightVisionOff auto
Keyword property CGXAMGhostX92GogglesAutoNightVisionOn auto
Keyword property CGXAMX92GogglesNightVisionOff auto
Keyword property CGXAMX92GogglesNightVisionOn 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
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOff Auto
ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOn Auto

Actor Property ActorRef Auto
Float Property TimerSeconds Auto
Float Property LightLevelFraction Auto

Event OnEquipped(Actor akActor)
	ActorRef = akActor
	TimerSeconds = (0.5)
	LightLevelFraction = (0.5)
	If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAnimated))
		If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAutoNightVisionOn))
			If (ActorRef.GetLightLevel() <= LightLevelFraction)
				If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
				ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
				EndIf
				If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOff))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOn)
				EndIf
			Else
				If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff)
				EndIf
				if (ActorRef.IsWeaponDrawn() == true)
					If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
					ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
					EndIf
				Else
					If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
					ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
					EndIf
				EndIf
			EndIf
		Else
			If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn))
				AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff)
			EndIf
			if (ActorRef.IsWeaponDrawn() == true)
				If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
				ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
				EndIf
			Else
				If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
				ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
				EndIf
			EndIf
		EndIf		
		StartTimer(0.5)
	EndIf
EndEvent

Event OnTimer(int aiTimerID)	
	If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAnimated))
		If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAutoNightVisionOn))
			If (ActorRef.GetLightLevel() <= LightLevelFraction)
				If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
				ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
				EndIf
				If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOff))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOn)
				EndIf
			Else
				If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff)
				EndIf
				if (ActorRef.IsWeaponDrawn() == true)
					If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
					ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
					EndIf
				Else
					If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
					ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
						AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
					EndIf
				EndIf
			EndIf
		Else
			If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn))
				AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff)
			EndIf
			if (ActorRef.IsWeaponDrawn() == true)
				If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesDown)
				ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
				EndIf
			Else
				If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesUp)
				ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown))
					AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown)
				EndIf
			EndIf
		EndIf		
		StartTimer(0.5)
	EndIf
EndEvent	

Event OnUnequipped(Actor akActor)
	If !(ActorRef.wornhaskeyword(CGXAMWearingGhostX92Goggles))
		CancelTimer()
	EndIf
EndEvent
Link to comment
Share on other sites

Light level at 35 is a good trigger number but i heard light levels are different indoors and out doors but dont know how much so will have to see if its asthetics or just for sneaking detection.

 

Script works perfect;y so far though i changed it to LightLevelNumber from LightLevelFraction. I also changed it to :

 

If ((ActorRef.GetLightLevel()) <= (LightLevelNumber))

 

in the two lines.

 

I think it would be a good idea to make LightLevelNumber a global variable and add consumable pills that increase and decrease the number allowing the player to choose there own trigger light level in the game.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...