Jump to content

How do I make this in Papyrus?


Skyes666

Recommended Posts

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

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

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

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

  • Recently Browsing   0 members

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