LionelLeonhart Posted March 18, 2014 Share Posted March 18, 2014 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 More sharing options...
IsharaMeradin Posted March 20, 2014 Share Posted March 20, 2014 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 EndEventThere 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 More sharing options...
LionelLeonhart Posted May 16, 2014 Author Share Posted May 16, 2014 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 EndEventThere 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 existC:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\drainplayerhealth.psc(17,2): DamageActorValue is not a function or does not existNo output generated for drainplayerhealth, compilation failed. Do you know how I could add DamageActorValue as a function? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 17, 2014 Share Posted May 17, 2014 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 Scriptname SomeScript Extends ObjectReference Float Property DamageHealthAmount Auto Int Property IncreaseSkillAmount Auto Float Property TimeBetween Auto Event OnEquipped(Actor akActor) If akActor == Game.GetPlayer() Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount) game.advanceskill("OneHanded", IncreaseSkillAmount) RegisterForSingleUpdate(TimeBetween) EndIf EndEvent Event OnUpdate() If Game.GetPlayer().IsEquipped(Self) Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount) game.advanceskill("OneHanded", IncreaseSkillAmount) RegisterForSingleUpdate(TimeBetween) EndIf EndEvent Link to comment Share on other sites More sharing options...
LionelLeonhart Posted May 18, 2014 Author Share Posted May 18, 2014 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 Scriptname SomeScript Extends ObjectReference Float Property DamageHealthAmount Auto Int Property IncreaseSkillAmount Auto Float Property TimeBetween Auto Event OnEquipped(Actor akActor) If akActor == Game.GetPlayer() Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount) game.advanceskill("OneHanded", IncreaseSkillAmount) RegisterForSingleUpdate(TimeBetween) EndIf EndEvent Event OnUpdate() If Game.GetPlayer().IsEquipped(Self) Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount) game.advanceskill("OneHanded", IncreaseSkillAmount) RegisterForSingleUpdate(TimeBetween) EndIf EndEvent 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 More sharing options...
IsharaMeradin Posted May 18, 2014 Share Posted May 18, 2014 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 You will need to test compilation and functionalityScriptname SomeScript Extends ReferenceAlias Float Property DamageHealthAmount Auto Int Property IncreaseSkillAmount Auto Float Property TimeBetween Auto Weapon Property WeaponRequired Auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If akBaseObject as Weapon If akBaseObject as Weapon == WeaponRequired Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount) game.advanceskill("OneHanded", IncreaseSkillAmount) RegisterForSingleUpdate(TimeBetween) EndIf EndIf EndEvent Event OnUpdate() If Game.GetPlayer().IsEquipped(WeaponRequired) Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount) game.advanceskill("OneHanded", IncreaseSkillAmount) RegisterForSingleUpdate(TimeBetween) EndIf EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If akBaseObject as Weapon If akBaseObject as Weapon == WeaponRequired UnregisterForUpdate() EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
Brudisios Posted January 5, 2016 Share Posted January 5, 2016 can this scrip be used on one of the dragon priest masks? but only the health drain aspect? Link to comment Share on other sites More sharing options...
Recommended Posts