Skyes666 Posted November 4, 2012 Share Posted November 4, 2012 I don't know how to script so that's why I'm asking. I'm looking for a script that makes you loose health when using a weapon. When you use the weapon you loose health each second, but when you stop you recover. After using it for about 12 secound you're going to die. Does anyone know how to create this? Link to comment Share on other sites More sharing options...
acidzebra Posted November 4, 2012 Share Posted November 4, 2012 (edited) It's ugly and unpolished and probably a testament to terrible scripting but it works if you attach this script to a weapon. No fancy effects, just saps 1/12th of your total health each second, doesn't take regeneration rate into account, only applies to the player. It's more for you to play with and get an idea of what is possible than it is to actually use in your mod. Scriptname deadlyswordscript extends ObjectReference Actor Myself Float Health Float DamageHealth int equippeddeadlysword Event OnEquipped(Actor akActor) equippeddeadlysword = 1 MySelf = akActor Health = MySelf.GetActorValue("Health") DamageHealth = (Health/12) while (equippeddeadlysword > 0) Game.GetPlayer().DamageActorValue("Health", DamageHealth) utility.wait(1) EndWhile EndEvent Event OnUnequipped(Actor akActor) equippeddeadlysword = 0 EndEvent edit: actually, it will read your total health the moment you equip it so if you equip it with minimal health it will last much longer ha ha Edited November 4, 2012 by acidzebra Link to comment Share on other sites More sharing options...
Skyes666 Posted November 5, 2012 Author Share Posted November 5, 2012 It's ugly and unpolished and probably a testament to terrible scripting but it works if you attach this script to a weapon. No fancy effects, just saps 1/12th of your total health each second, doesn't take regeneration rate into account, only applies to the player. It's more for you to play with and get an idea of what is possible than it is to actually use in your mod. Scriptname deadlyswordscript extends ObjectReference Actor Myself Float Health Float DamageHealth int equippeddeadlysword Event OnEquipped(Actor akActor) equippeddeadlysword = 1 MySelf = akActor Health = MySelf.GetActorValue("Health") DamageHealth = (Health/12) while (equippeddeadlysword > 0) Game.GetPlayer().DamageActorValue("Health", DamageHealth) utility.wait(1) EndWhile EndEvent Event OnUnequipped(Actor akActor) equippeddeadlysword = 0 EndEvent edit: actually, it will read your total health the moment you equip it so if you equip it with minimal health it will last much longer ha ha Thank you very much. I will test it out and maybe improve it once I learn Papyrus. Thank you once again! Link to comment Share on other sites More sharing options...
steve40 Posted November 6, 2012 Share Posted November 6, 2012 (edited) A few little tweaks: - only does damage while the player is in combat- the damage per second is 1/12 of the players base health- the effect will only work on the player (acidzebra messed that bit up, his script would damage the player regardless of who wielded the sword, heh)- cleaned up the code a bit Scriptname deadlyswordscript extends ObjectReference bool equippeddeadlysword Event OnEquipped(Actor Myself) If Myself == Game.GetPlayer() equippeddeadlysword = true float DamageHealth = MySelf.GetBaseAV("Health") / 12.0 while equippeddeadlysword If Myself.isInCombat() Myself.DamageAV("Health", DamageHealth) EndIf utility.wait(1) EndWhile EndIf EndEvent Event OnUnequipped(Actor Myself) equippeddeadlysword = false EndEvent Edited November 6, 2012 by steve40 Link to comment Share on other sites More sharing options...
acidzebra Posted November 6, 2012 Share Posted November 6, 2012 Lol I tried bool but kept trying to set it to "1" instead of "true" so eventually I said "sod it" and made it an int :wallbash: Ah well, learning. Cheers Steve :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts