Jump to content

Health drain weapon mod script


LionelLeonhart

Recommended Posts

Hi!

 

I'm trying to create a weapon using the creation kit that constantly drains the health of the player while it is equipped and increases the players one-handed skill at the same time.

 

After doing a bit of research already, I've come to the realization that I would need a script to make this happen.

 

My knowledge of the creation kit is limited and even more limited is my knowledge of scripting.

 

I would really appreciate a hand with this.

Link to comment
Share on other sites

I would try something like this first. It would be placed on the weapon itself.

Scriptname SomeScript Extends ObjectReference

Float Property DamageHealthAmount Auto
Int Property IncreaseSkillAmount Auto
Float Property TimeBetween Auto

Event OnEquipped(Actor akActor)
	If akActor == Game.GetPlayer()
		DamageActorValue("Health",DamageHealthAmount)
		game.advanceskill("OneHanded", IncreaseSkillAmount)
		RegisterForSingleUpdate(TimeBetween)
	EndIf
EndEvent

Event OnUpdate()
	If Game.GetPlayer().IsEquipped(Self)
		DamageActorValue("Health",DamageHealthAmount)
		game.advanceskill("OneHanded", IncreaseSkillAmount)
		RegisterForSingleUpdate(TimeBetween)
	EndIf
EndEvent

There is the possibility that it may not work because some functions do not process on objects which are in containers and that includes the player inventory. If necessary it could be adapted to run from a player alias script, but I would try it first from the weapon in question.

Link to comment
Share on other sites

  • 1 month later...
  On 3/20/2014 at 2:38 AM, IsharaMeradin said:

I would try something like this first. It would be placed on the weapon itself.

Scriptname SomeScript Extends ObjectReference

Float Property DamageHealthAmount Auto
Int Property IncreaseSkillAmount Auto
Float Property TimeBetween Auto

Event OnEquipped(Actor akActor)
	If akActor == Game.GetPlayer()
		DamageActorValue("Health",DamageHealthAmount)
		game.advanceskill("OneHanded", IncreaseSkillAmount)
		RegisterForSingleUpdate(TimeBetween)
	EndIf
EndEvent

Event OnUpdate()
	If Game.GetPlayer().IsEquipped(Self)
		DamageActorValue("Health",DamageHealthAmount)
		game.advanceskill("OneHanded", IncreaseSkillAmount)
		RegisterForSingleUpdate(TimeBetween)
	EndIf
EndEvent

There is the possibility that it may not work because some functions do not process on objects which are in containers and that includes the player inventory. If necessary it could be adapted to run from a player alias script, but I would try it first from the weapon in question.

 

 

Thank you for your help! I've been away from Skyrim for a long while so I'm just seeing this now.

 

I tried compiling the script and got the error message:

 

C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\drainplayerhealth.psc(9,2): DamageActorValue is not a function or does not exist
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\drainplayerhealth.psc(17,2): DamageActorValue is not a function or does not exist
No output generated for drainplayerhealth, compilation failed.
Do you know how I could add DamageActorValue as a function?
Link to comment
Share on other sites

Sometimes, I forget things.... Let's people know I'm human and not just pixels on the screen. :P

 

Try this. I forgot to have the player call the function.

 

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 5/17/2014 at 12:19 AM, IsharaMeradin said:

Sometimes, I forget things.... Let's people know I'm human and not just pixels on the screen. :tongue:

 

Try this. I forgot to have the player call the function.

 

  Reveal hidden contents

 

Thank you so much for your help on this. It is starting to turn out exactly as I'd hoped.

 

Could you give me further assistance with one problem I'm having? I've been messing around with the variables, and when I equip the weapon, my health is automatically reduced by the value I set to the "DamageHealthAmount" Float, but it doesn't seem to update, regardless of the value given to the "TimeBetween" Float.

 

Any suggestions?

Link to comment
Share on other sites

That might be because the weapon is in the player inventory. Some things cannot run on objects when they are inside a container (the player inventory is a container). There isn't any documentation stating what cannot be run just that some things cannot run. My guess, the update event does not work when the object is in a container.

 

Looks like an entirely different approach will need to be done.

 

Since you want this for player only, there is one more approach that can be tried: A script on the player alias on a start game enabled quest

 

  Reveal hidden contents

 

Link to comment
Share on other sites

  • 1 year later...
  • Recently Browsing   0 members

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