Jump to content

[FO4 CK] General Help Thread


Recommended Posts

OK, I have a collar and the collar can have its security pass access changed from 0-5 by hacking it.

I have a door activation script that checks if a collar is worn and finds it fine but I need to somehow read the collars security access level to know if it can open this door or punish the wearer?

 

Any ideas before I resort to using misc token counts :P

 

I'm also looking for the equivalent of actor.HasEnchantment, does it exist? I looked for hours with no luck finding it. I found HasSpell and HasMagicEffect but they don't appear to detect enchantments, to know if a player is suffering from poison or wearing the effect I cast on him still or a something similar.

Link to comment

"Spells" are fully available. And so "MagicEffects".

About "Enchantments" I don't find them. I suppose "Armor and Weapon Mods" are reusing the base code. But I am not 100% sure about it.

(The object "Enchantment" does exist. And you can call only one function: isHostile(). I don't know more.)

 

 

Link to comment

"Spells" are fully available. And so "MagicEffects".

About "Enchantments" I don't find them. I suppose "Armor and Weapon Mods" are reusing the base code. But I am not 100% sure about it.

(The object "Enchantment" does exist. And you can call only one function: isHostile(). I don't know more.)

Hmm well the Creation Kit has a few hundred "Enchantments"

 

The naming of them is damn confusing because the wiki scripting section doesn't acknowledge their existence but the editor section and the Creation Kit have them.

http://www.creationkit.com/fallout4/index.php?title=Enchantment

http://www.creationkit.com/fallout4/index.php?title=Enchantment

I think they are called MagicEffects in scripting then but in the Wiki and GECK4 Magic Effects are componenets in Enchantments :P

In CK Magic Effects are components of Spells and Enchantments , I'm getting a headache from thinking about it :P

 

The Wiki scripting section has this so I guess aActor.HasMagicEffect() is what I'm looking for assuming RockJoint Effect is the equivalent to an Enchantment in the CK and not a Magik Effect.

 

; Does the player have rockjoint?
if (Game.GetPlayer().HasMagicEffect(RockjointEffect))
  Debug.Trace("The player has rockjoint")
endIf

 

So on my first problem with a door reading a collars security access rating, there's no equivalent of NVSE's NX_Variables yet I guess that I can use to store data on any actor and have it read by objects worn by them to pass data between scripts or do token counts. It also seems there's no way to render Armor/Misc tokens invisible in inventory like FO3/NewVegas?

Other than setting up an array in a quest script or similar?

Link to comment

OK, here goes something from Skyrim experience. And pretty sure the logic for FO4 is the same.

 

Enchantment was an object that was possible to add to weapons and armors, and the only result was to attach a magic effect to the actor wearing the armor or using the weapon.

Probably FO4 does the same, but the name (because in this case will be 100% not lore friendly) is hidden.

And probably you can still use it.

 

Check in the Armor or Weapon properties in CK if you can find something that "resembles" to a "constant effect".

I am not able to open the CK now to check. Sorry.

 

(Terminator Minigun = gives you 50% more critical hits ==> done with a magic effect, and probably attached to the weapon with an "enchantment".)

 

Link to comment

Anyone know how to convert a global number to an int?

 

This won't compile:

int iAlertLevel = gInstituteAlertLevel as int

 

is gInstituteLevel a GlobalVariable?

If yes, then it is an object, and you can use gInstituteLevel.getValueInt()

Link to comment

 

Anyone know how to convert a global number to an int?

 

This won't compile:

int iAlertLevel = gInstituteAlertLevel as int

 

is gInstituteLevel a GlobalVariable?

If yes, then it is an object, and you can use gInstituteLevel.getValueInt()

 

Yes it is one I created, I'll give that a go
Link to comment

Ok next problem, I have this collar script in a collar which works fine except in the section where I try to count tokens where it refuses to work with akActor but works fine with aPlayer I want this to work with any actor not just the player :P

 

;Check for Security Infringments and respond
		int iInfringementLevel = akActor.GetItemCount(armTokenInfringmentLevel)
		if (iInfringementLevel > 0)
			Debug.Notification("iInfringementLevel = " + iInfringementLevel)
		endif
I set akActor at the start of the event:

Event OnTimer(int aiTimerID)
	if (aiTimerID == 1)
;		Debug.MessageBox("Timer running!")

		Actor akActor = (self.GetActorRefOwner()) as Actor
		Actor aPlayer = Game.GetPlayer()
Full script

 

 

Scriptname SexyInstitute:InstittuteCollars extends ObjectReference Const
{This controls the security levels of the collars and controls the wearer as necessary}

GlobalVariable Property gInstituteAlertLevel Auto Const
MiscObject Property moCollarKey Auto Const
float Property fTimerInterval = 1.0 Auto Const

;Keyword from the mods sets the collars security level
Keyword Property kwCollarLevel1 Auto Const
Keyword Property kwCollarLevel2 Auto Const
Keyword Property kwCollarLevel3 Auto Const
Keyword Property kwCollarLevel4 Auto Const
Keyword Property kwCollarLevel5 Auto Const

; keyword tells script which area is default and it then sets colors by object mod in case of unassigned color will be set by random
Keyword Property kwCollarAreaVisitor Auto Const
Keyword Property kwCollarAreaUnassigned Auto Const
Keyword Property kwCollarAreaFacilities Auto Const
Keyword Property kwCollarAreaAdvSys Auto Const
Keyword Property kwCollarAreaRobotics Auto Const
Keyword Property kwCollarAreaBioScience Auto Const
Keyword Property kwCollarAreaSRB Auto Const
Keyword Property kwCollarAreaMedical Auto Const
Keyword Property kwCollarAreaHumanRec Auto Const
Keyword Property kwCollarAreaGenetics Auto Const
Keyword Property kwCollarColorVisitor Auto Const
Keyword Property kwCollarColorUnassigned Auto Const
Keyword Property kwCollarColorFacilities Auto Const
Keyword Property kwCollarColorAdvSys Auto Const
Keyword Property kwCollarColorRobotics Auto Const
Keyword Property kwCollarColorBioScience Auto Const
Keyword Property kwCollarColorSRB Auto Const
Keyword Property kwCollarColorMedical Auto Const
Keyword Property kwCollarColorHumanRec Auto Const
Keyword Property kwCollarColorGenetics Auto Const

ObjectMod Property om_CollarColorVisitor Auto Const
ObjectMod Property om_CollarColorUnassigned Auto Const
ObjectMod Property om_CollarColorFacilities Auto Const
ObjectMod Property om_CollarColorAdvSys Auto Const
ObjectMod Property om_CollarColorRobotics Auto Const
ObjectMod Property om_CollarColorBioScience Auto Const
ObjectMod Property om_CollarColorSRB Auto Const
ObjectMod Property om_CollarColorMedical Auto Const
ObjectMod Property om_CollarColorHumanRec Auto Const
ObjectMod Property om_CollarColorGenetics Auto Const

Keyword Property kwCollarSysBomb5 Auto Const
Keyword Property kwCollarSysCryo5 Auto Const
Keyword Property kwCollarSysShock5 Auto Const
Keyword Property kwCollarSysStim5 Auto Const
Keyword Property kwCollarSysTrack5 Auto Const

; Infringment orders cause collar to respond
Armor Property armTokenInfringmentLevel Auto Const

;Effects
Sound Property sndCollarLock Auto Const
Sound Property sndCollarUnlock Auto Const
Sound Property sndCollarWarning Auto Const
Sound Property sndCollarVibrate Auto Const

;FormList Property flAllowedWolrdspaces Auto Const
;FormList Property flBannedWorldSpaces Auto Const

;-----------------------------------------------------------------------------------------------------------------------------------

Function fnFrequencyTimer(float fTime) 
	StartTimer(fTime, 1) 
EndFunction

Function fnCopyKeyWordACTOR(Actor akActor, KeyWord kwKeyWordArea, KeyWord kwKeyWordColor)
	if ((kwKeyWordArea) && (kwKeyWordColor))
		if ((akActor.HasKeyWord(kwKeyWordArea)) || (self.HasKeyWord(kwKeyWordArea)))
			akActor.AddKeyWord(kwKeyWordColor)
			akActor.AddKeyWord(kwKeyWordArea)
			self.AddKeyWord(kwKeyWordColor)
			Debug.Notification("Keyword Added" +  kwKeyWordColor)
		endif
	else
		Debug.MessageBox("No Keyword set- kwKeyWordArea or kwKeyWordColor")
	endif
EndFunction

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnEquipped(Actor akActor)

	Actor aPlayer = Game.GetPlayer()
	fnCopyKeyWordACTOR(akActor, kwCollarAreaUnassigned, kwCollarColorUnassigned)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaVisitor, kwCollarColorVisitor)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaAdvSys, kwCollarColorAdvSys)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaBioScience, kwCollarColorBioScience)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaFacilities, kwCollarColorFacilities)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaGenetics, kwCollarColorGenetics)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaHumanRec, kwCollarColorHumanRec)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaMedical, kwCollarColorMedical)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaRobotics, kwCollarColorRobotics)
	fnCopyKeyWordACTOR(akActor, kwCollarAreaSRB, kwCollarColorSRB)

	fnCopyKeyWordACTOR(akActor, kwCollarLevel1, kwCollarLevel1)
	fnCopyKeyWordACTOR(akActor, kwCollarLevel2, kwCollarLevel2)
	fnCopyKeyWordACTOR(akActor, kwCollarLevel3, kwCollarLevel3)
	fnCopyKeyWordACTOR(akActor, kwCollarLevel4, kwCollarLevel4)
	fnCopyKeyWordACTOR(akActor, kwCollarLevel5, kwCollarLevel5)

	if ((self.HasKeyWord(kwCollarLevel1)) || (self.HasKeyWord(kwCollarLevel2)) || (self.HasKeyWord(kwCollarLevel3)) || (self.HasKeyWord(kwCollarLevel4)) || (self.HasKeyWord(kwCollarLevel5)))
		akActor.EquipItem(self, True, True)
		if (akActor == aPlayer)
			Debug.MessageBox("You hear a beep and solid click from your collar!")
			int instanceID = sndCollarLock.play(self)
			Sound.SetInstanceVolume(instanceID, 2.0)
		endIf
	endif

	fnFrequencyTimer(fTimerInterval)
;	Debug.MessageBox("Equipped and Timer Started")

endEvent

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnTimer(int aiTimerID)
	if (aiTimerID == 1)
;		Debug.MessageBox("Timer running!")

		Actor akActor = (self.GetActorRefOwner()) as Actor
		Actor aPlayer = Game.GetPlayer()
		int iCollarLevel = 0
		if ((kwCollarLevel1) && (kwCollarLevel2) && (kwCollarLevel3) && (kwCollarLevel4) && (kwCollarLevel5))
			if (self.HasKeyWord(kwCollarLevel1))
				iCollarLevel = 1
				akActor.AddKeyWord(kwCollarLevel1)
				akActor.RemoveKeyWord(kwCollarLevel2)
				akActor.RemoveKeyWord(kwCollarLevel3)
				akActor.RemoveKeyWord(kwCollarLevel4)
				akActor.RemoveKeyWord(kwCollarLevel5)
;				Debug.Notification("Keyword Added- CollarLevel1")

			elseif (self.HasKeyWord(kwCollarLevel2))
				iCollarLevel = 2
				akActor.AddKeyWord(kwCollarLevel2)
				akActor.RemoveKeyWord(kwCollarLevel1)
				akActor.RemoveKeyWord(kwCollarLevel3)
				akActor.RemoveKeyWord(kwCollarLevel4)
				akActor.RemoveKeyWord(kwCollarLevel5)

			elseif (self.HasKeyWord(kwCollarLevel3))
				iCollarLevel = 3
				akActor.AddKeyWord(kwCollarLevel3)
				akActor.RemoveKeyWord(kwCollarLevel1)
				akActor.RemoveKeyWord(kwCollarLevel2)
				akActor.RemoveKeyWord(kwCollarLevel4)
				akActor.RemoveKeyWord(kwCollarLevel5)

			elseif (self.HasKeyWord(kwCollarLevel4))
				iCollarLevel = 4
				akActor.AddKeyWord(kwCollarLevel4)
				self.RemoveKeyWord(kwCollarLevel1)
				akActor.RemoveKeyWord(kwCollarLevel2)
				akActor.RemoveKeyWord(kwCollarLevel3)
				akActor.RemoveKeyWord(kwCollarLevel5)

			elseif (self.HasKeyWord(kwCollarLevel5))
				iCollarLevel = 5
				akActor.AddKeyWord(kwCollarLevel5)
				akActor.RemoveKeyWord(kwCollarLevel1)
				akActor.RemoveKeyWord(kwCollarLevel2)
				akActor.RemoveKeyWord(kwCollarLevel3)
				akActor.RemoveKeyWord(kwCollarLevel4)
			else
				Debug.MessageBox("No CollarLevel Keyword detected")
			endif
		else
			Debug.MessageBox("No Keyword set CollarLevel1-5")
		endif

; Check collar status
		if (iCollarlevel < 1)
;			aKActor.EquipItem(self, False, False)
;			aKActor.UnequipItem(self, False, False)
			if (akActor == aPlayer)
				Debug.Notification("You hear a beep and solid click from your collar as it unlocks:" + iCollarLevel)
				int instanceID = sndCollarUnlock.play(self) ; play mySFX sound from my self
				Sound.SetInstanceVolume(instanceID, 1.0) ; play at half volume
				return
			endIf
		endif

; Set Collar area Colormod from actor keyword, the collars keyword remains as the default area
; **** Disabled waiting on F4SE Armor.HasMod function.........
		if ((1 == 0) && (kwCollarColorAdvSys) && (kwCollarColorBioScience) && (kwCollarColorFacilities) && (kwCollarColorGenetics) && (kwCollarColorHumanRec) && (kwCollarColorMedical) && (kwCollarColorRobotics) && (kwCollarColorSRB) && (kwCollarColorUnassigned) && (kwCollarColorVisitor))
			if (self.HasKeyWord(kwCollarColorUnassigned))
				self.AttachMod(om_CollarColorUnassigned)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorAdvSys))
				self.AttachMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorBioScience))
				self.AttachMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorFacilities))
				self.AttachMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorGenetics))
				self.AttachMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorHumanRec))
				self.AttachMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorMedical))
				self.AttachMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorRobotics))
				self.AttachMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorSRB))
				self.AttachMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorUnAssigned)
				self.RemoveMod(om_CollarColorVisitor)

			elseif (self.HasKeyWord(kwCollarColorVisitor))
;				Debug.Notification("Collar detected as Visitor type")
				self.AttachMod(om_CollarColorVisitor)
				self.RemoveMod(om_CollarColorAdvSys)
				self.RemoveMod(om_CollarColorBioScience)
				self.RemoveMod(om_CollarColorFacilities)
				self.RemoveMod(om_CollarColorGenetics)
				self.RemoveMod(om_CollarColorHumanRec)
				self.RemoveMod(om_CollarColorMedical)
				self.RemoveMod(om_CollarColorRobotics)
				self.RemoveMod(om_CollarColorSRB)
				self.RemoveMod(om_CollarColorUnAssigned)
			else
				Debug.MessageBox("No Collar keyword detected to set colors")
			endif
		else
;			Debug.MessageBox("No Keyword set - kwCollarColor")
		endif ; Check Keywords are set

;Check for Security Infringments and respond
		int iInfringementLevel = akActor.GetItemCount(armTokenInfringmentLevel)
		if (iInfringementLevel > 0)
			Debug.Notification("iInfringementLevel = " + iInfringementLevel)
		endif
		if ((iInfringementLevel > 0) && (iInfringementLevel < 10))
			akActor.RemoveItem(armTokenInfringmentLevel, 9)
			Debug.Notification("Your Collar Buzzes!")
			int instanceID = sndCollarWarning.play(self)
			Sound.SetInstanceVolume(instanceID, 1.0)
		elseif (iInfringementLevel >= 10)
			akActor.RemoveItem(armTokenInfringmentLevel, 9)
			Debug.Notification("Your Collar Vibrates!")
			int instanceID = sndCollarVibrate.play(self)
			Sound.SetInstanceVolume(instanceID, 1.0)
		endif

;			Debug.Notification("Your Collar Shocks You!")
;			Debug.Notification("Your Collar Freezes You!")
;			Debug.Notification("Your Collar Starts Beeping!")
;			Debug.Notification("Your Collar Explodes!")

		fnFrequencyTimer(fTimerInterval)
	endif

EndEvent

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnUnequipped(Actor akActor)
;Cleanup
	akActor.RemoveKeyWord(kwCollarLevel1)
	akActor.RemoveKeyWord(kwCollarLevel2)
	akActor.RemoveKeyWord(kwCollarLevel3)
	akActor.RemoveKeyWord(kwCollarLevel4)
	akActor.RemoveKeyWord(kwCollarLevel5)
	akActor.RemoveKeyWord(kwCollarAreaVisitor)
	akActor.RemoveKeyWord(kwCollarAreaUnassigned)
	akActor.RemoveKeyWord(kwCollarAreaFacilities)
	akActor.RemoveKeyWord(kwCollarAreaAdvSys)
	akActor.RemoveKeyWord(kwCollarAreaRobotics)
	akActor.RemoveKeyWord(kwCollarAreaBioScience)
	akActor.RemoveKeyWord(kwCollarAreaSRB)
	akActor.RemoveKeyWord(kwCollarAreaMedical)
	akActor.RemoveKeyWord(kwCollarAreaHumanRec)
	akActor.RemoveItem(armTokenInfringmentLevel, 9)

EndEvent

 

Link to comment

It does not work, because there is a substantial difference between a Base Object and an ObjectReference.

NPCs do not have "ObjectReferences" in their inventories, then have "base object" (with the number of items), so when you call getObjectRefOwner you may get a None as result.

Link to comment

It does not work, because there is a substantial difference between a Base Object and an ObjectReference.

NPCs do not have "ObjectReferences" in their inventories, then have "base object" (with the number of items), so when you call getObjectRefOwner you may get a None as result.

Damn so its currently impossible to use GetItemCount on NPC's like I could in FONV ? That means I'm going to have to make it Player only I guess till F4SE gets out of alpha :/
Link to comment

 

Can anyone figure out why I can't dismember the player?  This is to make the slave collar work.

 

I have code like this:

 

Actor p = Game.GetPlayer()

p.Dismember("Head1", true, true)

p.Kill()

 

The dismember does nothing.  (The  kill works.)

 

However, if I call it on an NPC, it works fine.

 

Here is the code that I use for explosive collars on runaway slaves in F4SS. There is some additional code that you wouldn't need, since in my case the function triggers if the slave is running away and reaches a certain distance from the player - then the function first checks whether the slave has a collar and only if he does it will detonate it. Also it checks if the actor in question is one of the players slaves in the first place, just to make sure it doesn't fire on someone that isn't a slave.

 

Explosion Property explosionSmall Auto

is the property for explosionSmall, I'm using small electrical explosion for the FX.

 

Keyword Property kwExplosiveCollar Auto

is a keyword that I add on all gear that should allow detonating.

 

Tested and works on NPCs. Untested on player.

; Attempts to detonate a slave collar on the specified actor. Returns true on success
bool function explodeCollar(Actor akActor)
	Actor _slave = AkActor
	F4SSscrSlotAlias _slotscript = F4SSfunctions.GetSlotScript(_slave)
	
	if _slotscript
		if _slave.WornHasKeyword(kwExplosiveCollar)
			_slave.UnequipItem(_slotscript.gearCollar)
			_slave.RemoveItem(_slotscript.gearCollar, 1)
			_slave.Dismember("Head1", true)
			_slave.PlaceAtMe(explosionSmall, 1)
			_slave.Kill(Game.GetPlayer())
		endif
	endif
endFunction

Edit: the description lies. It does not return true on success. I will change that in my script immediately.

 

Edit: My slowness strikes again. I just realized that you're specifically looking for a script that works on player. 

Have you tried using Game.ForceThirdPerson() in conjunction with checking against Is3DLoaded before exploding the collar?

 

 

Hello. I've been trying to dismember the player with a script with no luck. Of course it works for the npcs, but not for the player. I even added your suggestions:

Scriptname zzzPlayerDismemberment extends Quest

Event OnQuestInit()
    RegisterForAnimationEvent(Game.GetPlayer(), "weaponFire")
EndEvent  
  
;Not what I actually want to do, just used this for quick testing of the dismemberment function
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
    If (akSource == Game.GetPlayer() && asEventName == "weaponFire")
        Actor _player = Game.GetPlayer();
	Debug.Notification("Weapon fired by player.")
        Utility.Wait(3.0)
        Game.ForceThirdPerson()
        if _player.WaitFor3DLoad()
            _player.Dismember("Head1", true)
            Debug.Notification("KABOOM")
        else
            Debug.Notification(":(")
        endIf
	EndIf
    
EndEvent 

When firing a weapon, the script works and i get the messages: "weapon fired by player" and "Kaboom".

But no dismemberment (same with other pody parts). The quoted post is the only other attempt to achieve this that i've found on the web. Does someone know how to do this? Btw Im a noob in modding. sad.png

Thank you blush.gif

Link to comment
...

When firing a weapon, the script works and i get the messages: "weapon fired by player" and "Kaboom".

But no dismemberment (same with other pody parts). The quoted post is the only other attempt to achieve this that i've found on the web. Does someone know how to do this? Btw Im a noob in modding. sad.png

Thank you blush.gif

 

 

The player cannot be really "dismembered", if you force it, then the player dies right away.

You can do it for NPCs.

Link to comment

Is there a way to:

 

generate an armor item from a leveled list into an NPC's inventory via a script

and then

make that NPC equip the item that was previously generated (the equip might happen seconds or minutes after the generation of the item)?

 

I can do the first part, but I don't know how to refer to the item that was added (for the purpose of using it in the EquipItem function).

I tried using piece of dummy equipment for the same slot (as this link suggests, but that link appears to be for FO3 or NV), but that didn't seem to force a re-equip.

 

If I can't figure out how to equip a LLI-generated item, I'll probably just have a bunch of Armor Property in my script, and use RandomInt to pick one of the armors to AddItem and later EquipItem directly. Just gonna be a huge ugly script, but there aren't THAT many items in my list.

Link to comment

Is there a way to:

 

generate an armor item from a leveled list into an NPC's inventory via a script

and then

make that NPC equip the item that was previously generated (the equip might happen seconds or minutes after the generation of the item)?

 

I can do the first part, but I don't know how to refer to the item that was added (for the purpose of using it in the EquipItem function).

I tried using piece of dummy equipment for the same slot (as this link suggests, but that link appears to be for FO3 or NV), but that didn't seem to force a re-equip.

 

If I can't figure out how to equip a LLI-generated item, I'll probably just have a bunch of Armor Property in my script, and use RandomInt to pick one of the armors to AddItem and later EquipItem directly. Just gonna be a huge ugly script, but there aren't THAT many items in my list.

Maybe have a script in the item that makes it equip itself? I'm not sure what event trigger you would use though, maybe Event OnAdd?
Link to comment

I'm having problems getting this script to work properly, it is contained in a collar worn by actors. It has a security level of 1-5 that allows automatic institute doors to open, which works ok. If the wearer attempts to access door above their level security infringement tokens are added to the actor by the door. The collar counts them and if over 10 it shocks the wearer by applying a shock spell. The count decays a token every 300 seconds.

It won't lock itself on like its supposed to when I use the lock flag in equipping, so the player can remove it anytime.

It's not counting the tokens in the inventory unless I specifically use the PlayerRef, so it doesn't seem to work for NPC's.

Also if seems to forget the iCurrPassLevel and lose Keywords added during game saves.

 

There's also some junk variables in there for color changing the colr too so the wearer can be assigned different areas in the institute to perform duties.

I'm suspecting most of my problem centres around Actor vs ObjectRef issues in someway.

Any other pointers on stuff I'm screwing up are also welcome :)

 

 

I'm using Object mods for the 5 security levels and having them add keywords so I can know what mod is added, the idea being I'm going to allow the player to hack the collar at workbenches or terminals to increase its security level.

 

 

 

Scriptname SexyInstitute:InstittuteCollars extends ObjectReference
{This controls the security levels of the collars and controls the wearer as necessary}

GlobalVariable Property gInstituteAlertLevel Auto Const
MiscObject Property moCollarKey Auto Const
float Property fTimerInterval = 1.0 Auto Const
float Property fInfringementRemovalTimerInterval = 300.0 Auto Const
Armor Property armThisDevice Auto Const
Actor Property akPlayer Auto Const

;Keyword from the mods sets the collars security level
Keyword Property kwCollarLevel1 Auto Const
Keyword Property kwCollarLevel2 Auto Const
Keyword Property kwCollarLevel3 Auto Const
Keyword Property kwCollarLevel4 Auto Const
Keyword Property kwCollarLevel5 Auto Const

; keyword tells script which area is default and it then sets colors by object mod in case of unassigned color will be set by random
Keyword Property kwCollarAreaVisitor Auto Const
Keyword Property kwCollarAreaUnassigned Auto Const
Keyword Property kwCollarAreaFacilities Auto Const
Keyword Property kwCollarAreaAdvSys Auto Const
Keyword Property kwCollarAreaRobotics Auto Const
Keyword Property kwCollarAreaBioScience Auto Const
Keyword Property kwCollarAreaSRB Auto Const
Keyword Property kwCollarAreaMedical Auto Const
Keyword Property kwCollarAreaHumanRec Auto Const
Keyword Property kwCollarAreaGenetics Auto Const
Keyword Property kwCollarColorVisitor Auto Const
Keyword Property kwCollarColorUnassigned Auto Const
Keyword Property kwCollarColorFacilities Auto Const
Keyword Property kwCollarColorAdvSys Auto Const
Keyword Property kwCollarColorRobotics Auto Const
Keyword Property kwCollarColorBioScience Auto Const
Keyword Property kwCollarColorSRB Auto Const
Keyword Property kwCollarColorMedical Auto Const
Keyword Property kwCollarColorHumanRec Auto Const
Keyword Property kwCollarColorGenetics Auto Const

ObjectMod Property om_CollarColorVisitor Auto Const
ObjectMod Property om_CollarColorUnassigned Auto Const
ObjectMod Property om_CollarColorFacilities Auto Const
ObjectMod Property om_CollarColorAdvSys Auto Const
ObjectMod Property om_CollarColorRobotics Auto Const
ObjectMod Property om_CollarColorBioScience Auto Const
ObjectMod Property om_CollarColorSRB Auto Const
ObjectMod Property om_CollarColorMedical Auto Const
ObjectMod Property om_CollarColorHumanRec Auto Const
ObjectMod Property om_CollarColorGenetics Auto Const

Keyword Property kwCollarSysBomb5 Auto Const
Keyword Property kwCollarSysCryo5 Auto Const
Keyword Property kwCollarSysShock5 Auto Const
Keyword Property kwCollarSysStim5 Auto Const
Keyword Property kwCollarSysTrack5 Auto Const

; Infringment orders cause collar to respond
Armor Property armTokenInfringementLevel Auto Const

;Effects
Sound Property sndCollarLock Auto Const
Sound Property sndCollarUnlock Auto Const
Sound Property sndCollarWarning Auto Const
Sound Property sndCollarVibrate Auto Const

Spell Property spCollarBomb Auto Const
Spell Property spCollarCryo Auto Const
Spell Property spCollarShock Auto Const
Spell Property spCollarStim Auto Const
Spell Property spCollarTrack Auto Const

;FormList Property flAllowedWolrdspaces Auto Const
;FormList Property flBannedWorldSpaces Auto Const

Actor akActor
int iCurrPassLevel
int iPrevPassLevel
int iCurrInfringementLevel
int iPrevInfringementLevel
int iTokenRemoval


;-----------------------------------------------------------------------------------------------------------------------------------

Function fnFrequencyTimer(float fTime) 
	StartTimer(fTime, 1)
EndFunction

Function fnInfringmentDecayTimer(float fTime) 
	StartTimer(fTime, 2)
EndFunction

Function fnCopyKeyWordAreaToColor(KeyWord kwKeyWordArea, KeyWord kwKeyWordColor)
	if ((kwKeyWordArea) && (kwKeyWordColor))
		if ((akActor.HasKeyWord(kwKeyWordArea)) || (self.HasKeyWord(kwKeyWordArea)))
			akActor.AddKeyWord(kwKeyWordColor)
			akActor.AddKeyWord(kwKeyWordArea)
			self.AddKeyWord(kwKeyWordColor)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added" +  kwKeyWordColor)
			endif
		endif
	else
		Debug.MessageBox("No Keyword set- kwKeyWordArea or kwKeyWordColor")
	endif
EndFunction

Function fnCopyKeyWordSelfToActor(KeyWord kwKeyWord1)
	if (kwKeyWord1)
		if (self.HasKeyWord(kwKeyWord1))
			akActor.AddKeyWord(kwKeyWord1)
			if (akActor == akPlayer)
				Debug.Notification("PassKeyword1 Added" +  kwKeyWord1)
			endif
		endif
	else
		Debug.MessageBox("No Keyword set- kwKeyWord1")
	endif
EndFunction

Function fnCheckPassLevel()
	if ((kwCollarLevel1) && (kwCollarLevel2) && (kwCollarLevel3) && (kwCollarLevel4) && (kwCollarLevel5))
		if ((self.HasKeyWord(kwCollarLevel1)) && (iCurrPassLevel != 1))
			iCurrPassLevel = 1
			akActor.AddKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel1)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel1")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel2)) && (iCurrPassLevel != 2))
			iCurrPassLevel = 2
			akActor.AddKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel2)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel2")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel3)) && (iCurrPassLevel != 3))
			iCurrPassLevel = 3
			akActor.AddKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel3)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel3")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel4)) && (iCurrPassLevel != 4))
			iCurrPassLevel = 4
			akActor.AddKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel4)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel4")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel5)) && (iCurrPassLevel != 5))
			iCurrPassLevel = 5
			akActor.AddKeyWord(kwCollarLevel5)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel4)
			fnCopyKeyWordSelfToActor(kwCollarLevel5)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel5")
			endif
		else
			iCurrPassLevel = 0
			Debug.Notification("No CollarLevel Keyword detected")
		endif
	endif
EndFunction

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnEquipped(Actor akActorEquipping)

	akActor = AkActorEquipping
	fnCopyKeyWordAreaToColor(kwCollarAreaUnassigned, kwCollarColorUnassigned)
	fnCopyKeyWordAreaToColor(kwCollarAreaVisitor, kwCollarColorVisitor)
	fnCopyKeyWordAreaToColor(kwCollarAreaAdvSys, kwCollarColorAdvSys)
	fnCopyKeyWordAreaToColor(kwCollarAreaBioScience, kwCollarColorBioScience)
	fnCopyKeyWordAreaToColor(kwCollarAreaFacilities, kwCollarColorFacilities)
	fnCopyKeyWordAreaToColor(kwCollarAreaGenetics, kwCollarColorGenetics)
	fnCopyKeyWordAreaToColor(kwCollarAreaHumanRec, kwCollarColorHumanRec)
	fnCopyKeyWordAreaToColor(kwCollarAreaMedical, kwCollarColorMedical)
	fnCopyKeyWordAreaToColor(kwCollarAreaRobotics, kwCollarColorRobotics)
	fnCopyKeyWordAreaToColor(kwCollarAreaSRB, kwCollarColorSRB)

	fnCheckPassLevel()
	fnFrequencyTimer(fTimerInterval)
	fnInfringmentDecayTimer(fInfringementRemovalTimerInterval)
;	Debug.MessageBox("Equipped and Timer Started")

endEvent

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnTimer(int aiTimerID)

	if ((aiTimerID == 1))
;		Debug.MessageBox("Timer running!")
		fnCheckPassLevel()

; Check collar status

		if (iCurrPassLevel != iPrevPassLevel)
			if ((self.HasKeyWord(kwCollarLevel1)) || (self.HasKeyWord(kwCollarLevel2)) || (self.HasKeyWord(kwCollarLevel3)) || (self.HasKeyWord(kwCollarLevel4)) || (self.HasKeyWord(kwCollarLevel5)))
				if (iCurrPassLevel > 0)
					akActor.EquipItem(self, True, True) ; **** This doesn't lock the collar on like it should?
					if (akActor == akPlayer)
						Debug.MessageBox("You hear a beep and solid click from your collar!")
					endif
					int instanceID = sndCollarLock.play(akActor)
					Sound.SetInstanceVolume(instanceID, 1.0)
				else
					if (akActor == akPlayer)
						Debug.Notification("You hear a beep and solid click from your collar as it unlocks:" + iCurrPassLevel)
					endif
					int instanceID = sndCollarUnlock.play(akActor)
					Sound.SetInstanceVolume(instanceID, 1.0)
					akActor.UnequipItem(self, False, False)
					return
				endIf
			else
				if (akActor == akPlayer)
					Debug.MessageBox("No Keyword set CollarLevel1-5")
				endif
			endif
		endif

;Check for Security Infringments and respond
		iCurrInfringementLevel = akActor.GetItemCount(armTokenInfringementLevel)
		if (iCurrInfringementLevel != iPrevInfringementLevel)
			if ((iCurrInfringementLevel > 0) && (iCurrInfringementLevel < 10))
				Debug.Notification("Your Collar Buzzes!")
				int instanceID = sndCollarWarning.play(akActor)
				Sound.SetInstanceVolume(instanceID, 1.0)
			elseif (iCurrInfringementLevel >= 10)
				akActor.RemoveItem(armTokenInfringementLevel, 9)
				Debug.Notification("Your Collar Shocks You!")
				akActor.AddSpell(spCollarShock)
;			elseif (iCurrInfringementLevel >= 100)
;				Debug.Notification("Your Collar Starts Beeping!")
;			elseif (iCurrInfringementLevel >= 100)
;				Debug.Notification("Your Collar Freezes You!")
;			elseif (iCurrInfringementLevel >= 100)
;				akActor.RemoveItem(armTokenInfringementLevel, 9)
;				Debug.Notification("Your Collar Vibrates!")
;				int instanceID = sndCollarVibrate.play(akActor)
;				Sound.SetInstanceVolume(instanceID, 1.0)
;			elseif (iCurrInfringementLevel >= 100)
;				Debug.Notification("Your Collar Explodes!")
			endif
		endif

		iPrevPassLevel = iCurrPassLevel
		iPrevInfringementLevel = iCurrInfringementLevel
		fnFrequencyTimer(fTimerInterval)
	endif

	if ((aiTimerID == 2))
		if (iCurrInfringementLevel > 0)
			Debug.Notification("iInfringementLevel = " + iCurrInfringementLevel)
		endif
		if ((iCurrInfringementLevel > 0) && (iCurrInfringementLevel < 10))
			akActor.RemoveItem(armTokenInfringementLevel, 1)
		endif
		fnInfringmentDecayTimer(fInfringementRemovalTimerInterval)
	endif

EndEvent

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnUnequipped(Actor akActorUnequipping)
;Cleanup
	akActor = AkActorUnequipping
	akActor.RemoveKeyWord(kwCollarLevel1)
	akActor.RemoveKeyWord(kwCollarLevel2)
	akActor.RemoveKeyWord(kwCollarLevel3)
	akActor.RemoveKeyWord(kwCollarLevel4)
	akActor.RemoveKeyWord(kwCollarLevel5)
	akActor.RemoveKeyWord(kwCollarAreaVisitor)
	akActor.RemoveKeyWord(kwCollarAreaUnassigned)
	akActor.RemoveKeyWord(kwCollarAreaFacilities)
	akActor.RemoveKeyWord(kwCollarAreaAdvSys)
	akActor.RemoveKeyWord(kwCollarAreaRobotics)
	akActor.RemoveKeyWord(kwCollarAreaBioScience)
	akActor.RemoveKeyWord(kwCollarAreaSRB)
	akActor.RemoveKeyWord(kwCollarAreaMedical)
	akActor.RemoveKeyWord(kwCollarAreaHumanRec)
	akActor.RemoveItem(armTokenInfringementLevel, 9)

EndEvent

 

Link to comment

 

 

I'm having problems getting this script to work properly, it is contained in a collar worn by actors. It has a security level of 1-5 that allows automatic institute doors to open, which works ok. If the wearer attempts to access door above their level security infringement tokens are added to the actor by the door. The collar counts them and if over 10 it shocks the wearer by applying a shock spell. The count decays a token every 300 seconds.
It won't lock itself on like its supposed to when I use the lock flag in equipping, so the player can remove it anytime.
It's not counting the tokens in the inventory unless I specifically use the PlayerRef, so it doesn't seem to work for NPC's.
Also if seems to forget the iCurrPassLevel and lose Keywords added during game saves.

There's also some junk variables in there for color changing the colr too so the wearer can be assigned different areas in the institute to perform duties.
I'm suspecting most of my problem centres around Actor vs ObjectRef issues in someway.
Any other pointers on stuff I'm screwing up are also welcome :)


I'm using Object mods for the 5 security levels and having them add keywords so I can know what mod is added, the idea being I'm going to allow the player to hack the collar at workbenches or terminals to increase its security level.

 

Scriptname SexyInstitute:InstittuteCollars extends ObjectReference
{This controls the security levels of the collars and controls the wearer as necessary}

GlobalVariable Property gInstituteAlertLevel Auto Const
MiscObject Property moCollarKey Auto Const
float Property fTimerInterval = 1.0 Auto Const
float Property fInfringementRemovalTimerInterval = 300.0 Auto Const
Armor Property armThisDevice Auto Const
Actor Property akPlayer Auto Const

;Keyword from the mods sets the collars security level
Keyword Property kwCollarLevel1 Auto Const
Keyword Property kwCollarLevel2 Auto Const
Keyword Property kwCollarLevel3 Auto Const
Keyword Property kwCollarLevel4 Auto Const
Keyword Property kwCollarLevel5 Auto Const

; keyword tells script which area is default and it then sets colors by object mod in case of unassigned color will be set by random
Keyword Property kwCollarAreaVisitor Auto Const
Keyword Property kwCollarAreaUnassigned Auto Const
Keyword Property kwCollarAreaFacilities Auto Const
Keyword Property kwCollarAreaAdvSys Auto Const
Keyword Property kwCollarAreaRobotics Auto Const
Keyword Property kwCollarAreaBioScience Auto Const
Keyword Property kwCollarAreaSRB Auto Const
Keyword Property kwCollarAreaMedical Auto Const
Keyword Property kwCollarAreaHumanRec Auto Const
Keyword Property kwCollarAreaGenetics Auto Const
Keyword Property kwCollarColorVisitor Auto Const
Keyword Property kwCollarColorUnassigned Auto Const
Keyword Property kwCollarColorFacilities Auto Const
Keyword Property kwCollarColorAdvSys Auto Const
Keyword Property kwCollarColorRobotics Auto Const
Keyword Property kwCollarColorBioScience Auto Const
Keyword Property kwCollarColorSRB Auto Const
Keyword Property kwCollarColorMedical Auto Const
Keyword Property kwCollarColorHumanRec Auto Const
Keyword Property kwCollarColorGenetics Auto Const

ObjectMod Property om_CollarColorVisitor Auto Const
ObjectMod Property om_CollarColorUnassigned Auto Const
ObjectMod Property om_CollarColorFacilities Auto Const
ObjectMod Property om_CollarColorAdvSys Auto Const
ObjectMod Property om_CollarColorRobotics Auto Const
ObjectMod Property om_CollarColorBioScience Auto Const
ObjectMod Property om_CollarColorSRB Auto Const
ObjectMod Property om_CollarColorMedical Auto Const
ObjectMod Property om_CollarColorHumanRec Auto Const
ObjectMod Property om_CollarColorGenetics Auto Const

Keyword Property kwCollarSysBomb5 Auto Const
Keyword Property kwCollarSysCryo5 Auto Const
Keyword Property kwCollarSysShock5 Auto Const
Keyword Property kwCollarSysStim5 Auto Const
Keyword Property kwCollarSysTrack5 Auto Const

; Infringment orders cause collar to respond
Armor Property armTokenInfringementLevel Auto Const

;Effects
Sound Property sndCollarLock Auto Const
Sound Property sndCollarUnlock Auto Const
Sound Property sndCollarWarning Auto Const
Sound Property sndCollarVibrate Auto Const

Spell Property spCollarBomb Auto Const
Spell Property spCollarCryo Auto Const
Spell Property spCollarShock Auto Const
Spell Property spCollarStim Auto Const
Spell Property spCollarTrack Auto Const

;FormList Property flAllowedWolrdspaces Auto Const
;FormList Property flBannedWorldSpaces Auto Const

Actor akActor
int iCurrPassLevel
int iPrevPassLevel
int iCurrInfringementLevel
int iPrevInfringementLevel
int iTokenRemoval


;-----------------------------------------------------------------------------------------------------------------------------------

Function fnFrequencyTimer(float fTime) 
	StartTimer(fTime, 1)
EndFunction

Function fnInfringmentDecayTimer(float fTime) 
	StartTimer(fTime, 2)
EndFunction

Function fnCopyKeyWordAreaToColor(KeyWord kwKeyWordArea, KeyWord kwKeyWordColor)
	if ((kwKeyWordArea) && (kwKeyWordColor))
		if ((akActor.HasKeyWord(kwKeyWordArea)) || (self.HasKeyWord(kwKeyWordArea)))
			akActor.AddKeyWord(kwKeyWordColor)
			akActor.AddKeyWord(kwKeyWordArea)
			self.AddKeyWord(kwKeyWordColor)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added" +  kwKeyWordColor)
			endif
		endif
	else
		Debug.MessageBox("No Keyword set- kwKeyWordArea or kwKeyWordColor")
	endif
EndFunction

Function fnCopyKeyWordSelfToActor(KeyWord kwKeyWord1)
	if (kwKeyWord1)
		if (self.HasKeyWord(kwKeyWord1))
			akActor.AddKeyWord(kwKeyWord1)
			if (akActor == akPlayer)
				Debug.Notification("PassKeyword1 Added" +  kwKeyWord1)
			endif
		endif
	else
		Debug.MessageBox("No Keyword set- kwKeyWord1")
	endif
EndFunction

Function fnCheckPassLevel()
	if ((kwCollarLevel1) && (kwCollarLevel2) && (kwCollarLevel3) && (kwCollarLevel4) && (kwCollarLevel5))
		if ((self.HasKeyWord(kwCollarLevel1)) && (iCurrPassLevel != 1))
			iCurrPassLevel = 1
			akActor.AddKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel1)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel1")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel2)) && (iCurrPassLevel != 2))
			iCurrPassLevel = 2
			akActor.AddKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel2)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel2")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel3)) && (iCurrPassLevel != 3))
			iCurrPassLevel = 3
			akActor.AddKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel3)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel3")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel4)) && (iCurrPassLevel != 4))
			iCurrPassLevel = 4
			akActor.AddKeyWord(kwCollarLevel4)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel5)
			fnCopyKeyWordSelfToActor(kwCollarLevel4)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel4")
			endif
		elseif ((self.HasKeyWord(kwCollarLevel5)) && (iCurrPassLevel != 5))
			iCurrPassLevel = 5
			akActor.AddKeyWord(kwCollarLevel5)
			akActor.RemoveKeyWord(kwCollarLevel1)
			akActor.RemoveKeyWord(kwCollarLevel2)
			akActor.RemoveKeyWord(kwCollarLevel3)
			akActor.RemoveKeyWord(kwCollarLevel4)
			fnCopyKeyWordSelfToActor(kwCollarLevel5)
			if (akActor == akPlayer)
				Debug.Notification("Keyword Added- CollarLevel5")
			endif
		else
			iCurrPassLevel = 0
			Debug.Notification("No CollarLevel Keyword detected")
		endif
	endif
EndFunction

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnEquipped(Actor akActorEquipping)

	akActor = AkActorEquipping
	fnCopyKeyWordAreaToColor(kwCollarAreaUnassigned, kwCollarColorUnassigned)
	fnCopyKeyWordAreaToColor(kwCollarAreaVisitor, kwCollarColorVisitor)
	fnCopyKeyWordAreaToColor(kwCollarAreaAdvSys, kwCollarColorAdvSys)
	fnCopyKeyWordAreaToColor(kwCollarAreaBioScience, kwCollarColorBioScience)
	fnCopyKeyWordAreaToColor(kwCollarAreaFacilities, kwCollarColorFacilities)
	fnCopyKeyWordAreaToColor(kwCollarAreaGenetics, kwCollarColorGenetics)
	fnCopyKeyWordAreaToColor(kwCollarAreaHumanRec, kwCollarColorHumanRec)
	fnCopyKeyWordAreaToColor(kwCollarAreaMedical, kwCollarColorMedical)
	fnCopyKeyWordAreaToColor(kwCollarAreaRobotics, kwCollarColorRobotics)
	fnCopyKeyWordAreaToColor(kwCollarAreaSRB, kwCollarColorSRB)

	fnCheckPassLevel()
	fnFrequencyTimer(fTimerInterval)
	fnInfringmentDecayTimer(fInfringementRemovalTimerInterval)
;	Debug.MessageBox("Equipped and Timer Started")

endEvent

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnTimer(int aiTimerID)

	if ((aiTimerID == 1))
;		Debug.MessageBox("Timer running!")
		fnCheckPassLevel()

; Check collar status

		if (iCurrPassLevel != iPrevPassLevel)
			if ((self.HasKeyWord(kwCollarLevel1)) || (self.HasKeyWord(kwCollarLevel2)) || (self.HasKeyWord(kwCollarLevel3)) || (self.HasKeyWord(kwCollarLevel4)) || (self.HasKeyWord(kwCollarLevel5)))
				if (iCurrPassLevel > 0)
					akActor.EquipItem(self, True, True) ; **** This doesn't lock the collar on like it should?
					if (akActor == akPlayer)
						Debug.MessageBox("You hear a beep and solid click from your collar!")
					endif
					int instanceID = sndCollarLock.play(akActor)
					Sound.SetInstanceVolume(instanceID, 1.0)
				else
					if (akActor == akPlayer)
						Debug.Notification("You hear a beep and solid click from your collar as it unlocks:" + iCurrPassLevel)
					endif
					int instanceID = sndCollarUnlock.play(akActor)
					Sound.SetInstanceVolume(instanceID, 1.0)
					akActor.UnequipItem(self, False, False)
					return
				endIf
			else
				if (akActor == akPlayer)
					Debug.MessageBox("No Keyword set CollarLevel1-5")
				endif
			endif
		endif

;Check for Security Infringments and respond
		iCurrInfringementLevel = akActor.GetItemCount(armTokenInfringementLevel)
		if (iCurrInfringementLevel != iPrevInfringementLevel)
			if ((iCurrInfringementLevel > 0) && (iCurrInfringementLevel < 10))
				Debug.Notification("Your Collar Buzzes!")
				int instanceID = sndCollarWarning.play(akActor)
				Sound.SetInstanceVolume(instanceID, 1.0)
			elseif (iCurrInfringementLevel >= 10)
				akActor.RemoveItem(armTokenInfringementLevel, 9)
				Debug.Notification("Your Collar Shocks You!")
				akActor.AddSpell(spCollarShock)
;			elseif (iCurrInfringementLevel >= 100)
;				Debug.Notification("Your Collar Starts Beeping!")
;			elseif (iCurrInfringementLevel >= 100)
;				Debug.Notification("Your Collar Freezes You!")
;			elseif (iCurrInfringementLevel >= 100)
;				akActor.RemoveItem(armTokenInfringementLevel, 9)
;				Debug.Notification("Your Collar Vibrates!")
;				int instanceID = sndCollarVibrate.play(akActor)
;				Sound.SetInstanceVolume(instanceID, 1.0)
;			elseif (iCurrInfringementLevel >= 100)
;				Debug.Notification("Your Collar Explodes!")
			endif
		endif

		iPrevPassLevel = iCurrPassLevel
		iPrevInfringementLevel = iCurrInfringementLevel
		fnFrequencyTimer(fTimerInterval)
	endif

	if ((aiTimerID == 2))
		if (iCurrInfringementLevel > 0)
			Debug.Notification("iInfringementLevel = " + iCurrInfringementLevel)
		endif
		if ((iCurrInfringementLevel > 0) && (iCurrInfringementLevel < 10))
			akActor.RemoveItem(armTokenInfringementLevel, 1)
		endif
		fnInfringmentDecayTimer(fInfringementRemovalTimerInterval)
	endif

EndEvent

;-----------------------------------------------------------------------------------------------------------------------------------

Event OnUnequipped(Actor akActorUnequipping)
;Cleanup
	akActor = AkActorUnequipping
	akActor.RemoveKeyWord(kwCollarLevel1)
	akActor.RemoveKeyWord(kwCollarLevel2)
	akActor.RemoveKeyWord(kwCollarLevel3)
	akActor.RemoveKeyWord(kwCollarLevel4)
	akActor.RemoveKeyWord(kwCollarLevel5)
	akActor.RemoveKeyWord(kwCollarAreaVisitor)
	akActor.RemoveKeyWord(kwCollarAreaUnassigned)
	akActor.RemoveKeyWord(kwCollarAreaFacilities)
	akActor.RemoveKeyWord(kwCollarAreaAdvSys)
	akActor.RemoveKeyWord(kwCollarAreaRobotics)
	akActor.RemoveKeyWord(kwCollarAreaBioScience)
	akActor.RemoveKeyWord(kwCollarAreaSRB)
	akActor.RemoveKeyWord(kwCollarAreaMedical)
	akActor.RemoveKeyWord(kwCollarAreaHumanRec)
	akActor.RemoveItem(armTokenInfringementLevel, 9)

EndEvent

 

 

 

Is akActor being set properly? I'm still wrapping my head around papyrus but something looks wrong there to me for some reason. 

 

This is probably a dumb question to be honest but why don't you use Game.GetPlayer as your check instead of initialising via a property? I would've done something along the lines of

bool bIsPlayer = (Game.GetPlayer() == akActor) ? true : false  

in C-style ternary logic. 

Link to comment

Is akActor being set properly? I'm still wrapping my head around papyrus but something looks wrong there to me for some reason.

I don't think it is, I think that's my problem, I had it working reasonably well by replacing akActor with Player reff at one point but was getting crazy results with some commands and I want this to work on NPC's too. I could use akActor to get a count of tokens on the player but things like akActor.RemoveItem would fail to compile till I replaced them with PlayerRef. And PlayerRef.CastSpell(ElectricShockEffect) caste the spell on something but it wasn't the player.

 

The Papyrus coding isn't too bad to learn its all the side rules that apply to objects, effects, actors etc that drive me nuts.

Link to comment

The Papyrus coding isn't too bad to learn its all the side rules that apply to objects, effects, actors etc that drive me nuts.

I'm slowly working that out vs GECK scripting; I'm having trouble working out when and how to use ... extends ... on my scripts as well as the best methods that attach scripts to actors. 

 

I'd rather not use tokens and stuff, the coding mindset feels like an irritating mix of C#, Java, C++ and GECK scripting - I'm having so much trouble with some of the basic concepts annoyingly. 

 

Also, sorry edited the above post after you replied, wasn't expecting you to reply back to me so fast :P

Link to comment

Yeah unfortunately the only way I see to pass information from one item to another seems to be smoke signals (Tokens or Keywords) :)

Yeah, it's giving me a bit of a headache really, I'm sure there's other ways but meh.

 

Try using the explicit statement:

Event OnEquipped(Actor akActor)

then init another variable called akContainerRef or something like that, whatever sounds descriptive enough, with this code beneath:

akContainerRef = akActor

After reviewing the source all instances of OnEquipped seem to use that specific syntax.  I don't know how persistent variables are for equipped items so I'd probably do something like GetContainer() in your OnTimer event - if GetContainer works on equipped items. 

 

I guess I'd try to avoid declaring akActor outside of specific events.  I honestly have no idea though, I'm just basing this on the available script source. 

 

I'd probably make some other minor changes as well like rather than adding a script to the door, I'd have a script on the collar that looks for doors around the player using RegisterForDistanceLessThanEvent and unlocks them on approach after checking the door's security level.  NPCs probably wouldn't need that check but meh. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use