PiyScripts - Advanced Death System

*Created by Piysta.*

A rework of my old death script, similar to modern death systems.

When you die, it drains all your MP and HP and a timer starts with a dialog telling you that you have collapsed.
At this time, a player can come revive you, but if you are not revived in 2 minutes (before the time runs out) you are transported to a graveyard and take a 25% reduction in your defence stat.

Also, when you collapse (die) your armor takes 10% damage.

REQUIRED ITEMS:
- Defence (Attibute)
- Graveyard (Zone Waypoint)
- Health (Attribute)
- Mana (Attibute)

v1.0 PLEASE REPORT BUGS AS THIS WAS NOT TESTED

```
Using "RC_Core.rcm"

; Default death script for player characters

; You may alter this script however you like, but DO NOT RENAME OR DELETE IT

; The entry function for this script is always "Main"

; The context actor for the script is set to whoever killed the player

Function Main()

Player = Actor()

SetAttribute(Player, "Health", 0)

SetAttribute(Player, "Mana", 0)

Output(Player, "You have collapsed! Your items take 10% damage.", 255, 0, 0)

AnimateActor(Player, "Death 2", 1.7)

A1 = ActorAmulet(Player, 1)

A2 = ActorAmulet(Player, 2)

Belt = ActorBelt(Player)

Chest = ActorChest(Player)

Feet = ActorFeet(Player)

Hands = ActorHands(Player)

Hat = ActorHat(Player)

Legs = ActorLegs(Player)

R1 = ActorRing(Player, 1)

R2 = ActorRing(Player, 2)

R3 = ActorRing(Player, 3)

R4 = ActorRing(Player, 4)

Shield = ActorShield(Player)

Wep = ActorWeapon(Player)

A1H% = ItemHealth(A1) * 0.9

A2H% = ItemHealth(A2) * 0.9

BH% = ItemHealth(Belt) * 0.9

CH% = ItemHealth(Chest) * 0.9

FH% = ItemHealth(Feet) * 0.9

HH% = ItemHealth(Hands) * 0.9

HatH% = ItemHealth(Hat) * 0.9

LH% = ItemHealth(Legs) * 0.9

R1H% = ItemHealth(R1) * 0.9

R2H% = ItemHealth(R2) * 0.9

R3H% = ItemHealth(R3) * 0.9

R4H% = ItemHealth(R4) * 0.9

SH% = ItemHealth(Shield) * 0.9

WH% = ItemHealth(Wep) * 0.9

SetItemHealth(A1, A1H)

SetItemHealth(A2, A2H)

SetItemHealth(Belt, BH)

SetItemHealth(Chest, CH)

SetItemHealth(Feet, FH)

SetItemHealth(Hands, HH)

SetItemHealth(Hat, HatH)

SetItemHealth(Legs, LH)

SetItemHealth(R1, R1H)

SetItemHealth(R2, R2H)

SetItemHealth(R3, R3H)

SetItemHealth(R4, R4H)

SetItemHealth(Shield, SH)

SetItemHealth(Wep, WH)

D = OpenDialog(Player, 0, "Collapsed")

DialogOutput(Player, D, "You have collapsed from taking too much damage. If you are not revived in two minutes you will die.")

Bar = CreateProgressBar(Player, 255, 255, 255, 0.4, 0.7, 0.2, 0.025, 30, 30, "Until Death")

Clicks = 120

Repeat

    Health = Attribute(Player, "Health")

    Clicks = Clicks - 1

    If Health > 0

        DeleteProgressBar(Player, Bar)

      CloseDialog(Player, D)

      Return

    EndIf

    DoEvents(1000)

    UpdateProgressBar(Player, Bar, Clicks)

Until Clicks = 0

DeleteProgressBar(Player, Bar)

Warp(Player, ActorZone(Player), "Graveyard")

HP% = MaxAttribute(Player, "Health") * 50

MP% = MaxAttribute(Player, "Mana") * 35

Defence% = Attribute(Player, "Defence") * 0.25

AddActorEffect(Player, "Weakened Spirit", "Defence", -Defence, 60, 1)

SetAttribute(Player, "Health", HP)

SetAttribute(Player, "Mana", MP)

Return

End Function

```