Vampirism for hardcore mode, needs testing.

This commit is contained in:
nossr50 2012-05-01 08:47:57 -07:00
parent f7405a82e6
commit 9d510815b4
5 changed files with 26 additions and 1 deletions

View File

@ -8,7 +8,7 @@ Key:
- Removal
Version 1.3.07
+ Added new Hardcore mode functionality to mcMMO
+ Added new configurable Hardcore mode functionality to mcMMO
+ Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode'
+ Added a permission node for Archery bonus damage
+ Added a permission node for Greater Impact ability

View File

@ -46,7 +46,9 @@ public class Config extends ConfigLoader {
/* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5); }
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
/* Commands */
public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); }

View File

@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Hardcore;
import com.gmail.nossr50.util.Permissions;
@ -13,7 +14,14 @@ public class HardcoreListener implements Listener {
@EventHandler()
public void PlayerDeathEvent(PlayerDeathEvent event) {
Player player = event.getEntity(); //Note this returns a Player object for this subevent
if(!Permissions.getInstance().hardcoremodeBypass(player)) {
if(player.getKiller() instanceof Player) {
if(Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(((Player)player.getKiller()), player);
}
}
Hardcore.invokeStatPenalty(player);
}
}

View File

@ -24,4 +24,18 @@ public class Hardcore {
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've suffered a penalty to skills from death.");
}
public static void invokeVampirism(Player killer, Player defender) {
PlayerProfile PPk = Users.getProfile(killer);
PlayerProfile PPd = Users.getProfile(defender);
for(SkillType st : SkillType.values()) {
if(st.equals(SkillType.ALL))
continue;
int newValue = (int) (PPd.getSkillLevel(st) - (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D)));
PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
}
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen knowledge from that player.");
}
}

View File

@ -38,6 +38,7 @@ Hardcore:
Enabled: false
Death_Stat_Loss_Penalty_Percentage: 75
Vampirism: false
Vampirism_Stat_Leech_Percentage: 5
#
# Settings for mcMMO items