Skip to content

Commit

Permalink
Add death penality dimishing returns: Dieing within 5 minutes reduces…
Browse files Browse the repository at this point in the history
… the damage to tools. The more often you die the less it takes, until you manage to live for 5 minutes.
  • Loading branch information
bonii-xx committed Oct 10, 2014
1 parent 66bfc70 commit e3c3fa3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/tconstruct/armor/player/TPlayerStats.java
Expand Up @@ -30,6 +30,9 @@ public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedI
public boolean smelteryManual;
public boolean battlesignBonus;

// death-penality
public int derpLevel;

public ArmorExtended armor;
public KnapsackInventory knapsack;

Expand All @@ -46,6 +49,8 @@ public TPlayerStats(EntityPlayer entityplayer)

this.knapsack = new KnapsackInventory();
this.knapsack.init(entityplayer);

this.derpLevel = 1;
}

@Override
Expand All @@ -58,6 +63,7 @@ public void saveNBTData (NBTTagCompound compound)
tTag.setBoolean("materialManual", this.materialManual);
tTag.setBoolean("smelteryManual", this.smelteryManual);
tTag.setBoolean("battlesignBonus", this.battlesignBonus);
tTag.setInteger("derpLevel", this.derpLevel);
compound.setTag(PROP_NAME, tTag);
}

Expand All @@ -72,6 +78,7 @@ public void loadNBTData (NBTTagCompound compound)
this.materialManual = properties.getBoolean("materialManual");
this.smelteryManual = properties.getBoolean("smelteryManual");
this.battlesignBonus = properties.getBoolean("battlesignBonus");
this.derpLevel = properties.getInteger("derpLevel");
}

@Override
Expand All @@ -91,6 +98,8 @@ public void copyFrom (TPlayerStats stats, boolean copyCalc)
this.smelteryManual = stats.smelteryManual;
this.battlesignBonus = stats.battlesignBonus;

this.derpLevel = stats.derpLevel;

if (copyCalc)
{
this.bonusHealth = stats.bonusHealth;
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/tconstruct/tools/TinkerToolEvents.java
Expand Up @@ -2,6 +2,7 @@

import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.*;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import java.util.List;
import net.minecraft.entity.*;
Expand Down Expand Up @@ -453,6 +454,17 @@ public void damageToolsOnDeath (PlayerDropsEvent event)
if(difficulty == EnumDifficulty.HARD)
punishment = 10; // hard has 10%

// check if we have to reduce it
// did the player live long enough to receive derp-protection?
// (yes, you receive protection every time you log in. we're that nice.)
int derp = 1;
if(event.entityPlayer.ticksExisted < 60*5*20 ) {
derp = TPlayerStats.get(event.entityPlayer).derpLevel;
if(derp <= 0) derp = 1;
punishment *= derp;
}

boolean damaged = false;
for(EntityItem drop : event.drops)
{
// we're only interested in tools
Expand All @@ -465,6 +477,14 @@ public void damageToolsOnDeath (PlayerDropsEvent event)
dur /= punishment;

AbilityHelper.damageTool(drop.getEntityItem(), dur, event.entityPlayer, true);
damaged = true;
}

if(damaged) {
derp++;
}

// increase derplevel by 1. Minimal derp level is 1.
TPlayerStats.get(event.entityPlayer).derpLevel = derp+1;
}
}

0 comments on commit e3c3fa3

Please sign in to comment.