This is just a way to make an amulet that will revive a player on a percentage you want.
wServer > Realm > Entities > Player > Player.cs
or CTRL+SHIFT+F "Death("
Add
Code:
if (CheckBrokenAmulet(MathsUtils.GenerateProb(50)))
return;
into the Death() method.
Goto MathsUtils.cs
and add
Code:
public static bool GenerateProb(int percent)
{
Random random = new Random();
int rand = random.Next(0, 101);
if (rand < percent)
return true;
else
return false;
}
public static bool GenerateProb(double percent)
{
Random random = new Random();
int rand = random.Next(0, 101);
if (rand < percent)
return true;
else
return false;
}
In Player.cs add
Code:
private bool CheckBrokenAmulet(bool doesRevive)
{
for (int i = 0; i < 4; i++)
{
Item item = Inventory[i];
if (item == null || !item.BrokenResurrect) continue;
if (doesRevive)
{
HP = Stats[0] + Stats[0];
MP = Stats[1] + Stats[1];
Inventory[i] = null;
foreach (Player player in Owner.Players.Values)
player.SendInfo($"{Name}'s {item.ObjectId} successfully saved him from death");
client.Reconnect(new ReconnectPacket
{
Host = "",
Port = 2050,
GameId = World.NEXUS_ID,
Name = "Nexus",
Key = Empty<byte>.Array,
});
newbieTime += 1000;
resurrecting = true;
return true;
}
else
{
foreach (Player player in Owner.Players.Values)
player.SendInfo($"{Name}'s {item.ObjectId} unfortunately did not save him from death");
}
}
return false;
}
below the Death() method.
Goto Descriptors and add
Code:
BrokenResurrect = elem.Element("BrokenResurrect") != null;
into the "Item" class/constructor
Add your item with the tag "<BrokenResurrect />" and you're done:
Code:
<Object id="Amulet of Broken Resurrection" ext="true">
<Class>Equipment</Class>
<Item />
<Texture>
<File>lofiObj2</File>
<Index>0x50</Index>
</Texture>
<SlotType>9</SlotType>
<Description>A poor mans amulet</Description>
<ActivateOnEquip stat="20" amount="4">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="21" amount="4">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="22" amount="4">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="26" amount="4">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="27" amount="4">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="28" amount="4">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="0" amount="40">IncrementStat</ActivateOnEquip>
<ActivateOnEquip stat="3" amount="40">IncrementStat</ActivateOnEquip>
<BrokenResurrect />
<BagType>4</BagType>
</Object>