添加维持生计perk
This commit is contained in:
parent
c021f4184f
commit
499c4e739c
5 changed files with 33 additions and 1 deletions
|
@ -324,6 +324,7 @@ public class LivingEventHandler {
|
|||
|
||||
if (DamageTypeTool.isGunDamage(source)) {
|
||||
handleKillingTallyAddCount(stack);
|
||||
handleSubsistence(stack, attacker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,7 +389,7 @@ public class LivingEventHandler {
|
|||
|
||||
int fourthTimesCharmTick = stack.getOrCreateTag().getInt("FourthTimesCharmTick");
|
||||
if (fourthTimesCharmTick <= 0) {
|
||||
stack.getOrCreateTag().putInt("FourthTimesCharmTick", 60);
|
||||
stack.getOrCreateTag().putInt("FourthTimesCharmTick", 40 + 10 * level);
|
||||
stack.getOrCreateTag().putInt("FourthTimesCharmCount", 1);
|
||||
} else {
|
||||
int count = stack.getOrCreateTag().getInt("FourthTimesCharmCount");
|
||||
|
@ -398,4 +399,28 @@ public class LivingEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleSubsistence(ItemStack stack, Player player) {
|
||||
int level = PerkHelper.getItemPerkLevel(ModPerks.SUBSISTENCE.get(), stack);
|
||||
if (level == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float rate = level * 0.1f + (stack.is(ModTags.Items.SMG) || stack.is(ModTags.Items.RIFLE) ? 0.17f : 0f);
|
||||
int mag = stack.getOrCreateTag().getInt("mag");
|
||||
int ammoReload = (int) Math.min(mag, mag * rate);
|
||||
|
||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null)
|
||||
.ifPresent(capability -> {
|
||||
if (stack.is(ModTags.Items.RIFLE)) {
|
||||
capability.rifleAmmo -= Math.min(capability.rifleAmmo, ammoReload);
|
||||
} else if (stack.is(ModTags.Items.SMG) || stack.is(ModTags.Items.HANDGUN)) {
|
||||
capability.handgunAmmo -= Math.min(capability.handgunAmmo, ammoReload);
|
||||
}
|
||||
capability.syncPlayerVariables(player);
|
||||
|
||||
stack.getOrCreateTag().putInt("ammo", ammoReload);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public class ModPerks {
|
|||
|
||||
public static final RegistryObject<Perk> HEAL_CLIP = FUNC_PERKS.register("heal_clip", () -> new Perk("heal_clip", Perk.Type.FUNCTIONAL));
|
||||
public static final RegistryObject<Perk> FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", () -> new Perk("fourth_times_charm", Perk.Type.FUNCTIONAL));
|
||||
public static final RegistryObject<Perk> SUBSISTENCE = FUNC_PERKS.register("subsistence", () -> new Perk("subsistence", Perk.Type.FUNCTIONAL));
|
||||
|
||||
/**
|
||||
* Damage Perks
|
||||
|
|
|
@ -10,11 +10,13 @@ public class ModTags {
|
|||
|
||||
public static class Items {
|
||||
public static final TagKey<Item> GUN = tag("gun");
|
||||
|
||||
public static final TagKey<Item> HANDGUN = tag("handgun");
|
||||
public static final TagKey<Item> RIFLE = tag("rifle");
|
||||
public static final TagKey<Item> SHOTGUN = tag("shotgun");
|
||||
public static final TagKey<Item> SNIPER_RIFLE = tag("sniper_rifle");
|
||||
public static final TagKey<Item> SMG = tag("smg");
|
||||
|
||||
public static final TagKey<Item> NORMAL_GUN = tag("normal_gun");
|
||||
public static final TagKey<Item> LEGENDARY_GUN = tag("legendary_gun");
|
||||
public static final TagKey<Item> SPECIAL_GUN = tag("special_gun");
|
||||
|
|
|
@ -191,6 +191,8 @@
|
|||
"des.superbwarfare.heal_clip": "Reloading after dealing a final blow will heal you and your nearby allies",
|
||||
"item.superbwarfare.fourth_times_charm": "Fourth Time's The Charm",
|
||||
"des.superbwarfare.fourth_times_charm": "Rapidly landing precision hits will return two rounds to the magazine",
|
||||
"item.superbwarfare.subsistence": "Subsistence",
|
||||
"des.superbwarfare.subsistence": "Defeating targets partially reloads the magazine from reserves",
|
||||
|
||||
"item.superbwarfare.kill_clip": "Kill Clip",
|
||||
"des.superbwarfare.kill_clip": "Increases the damage of weapon after dealing a final blow",
|
||||
|
|
|
@ -191,6 +191,8 @@
|
|||
"des.superbwarfare.heal_clip": "最后一击后短时间内填装,可治疗自身和附近队友",
|
||||
"item.superbwarfare.fourth_times_charm": "事不过四",
|
||||
"des.superbwarfare.fourth_times_charm": "快速精准命中目标会向弹匣中返还两枚弹药",
|
||||
"item.superbwarfare.subsistence": "维持生计",
|
||||
"des.superbwarfare.subsistence": "消灭目标会使弹药从备弹中转移并填装部分弹匣",
|
||||
|
||||
"item.superbwarfare.kill_clip": "杀戮弹匣",
|
||||
"des.superbwarfare.kill_clip": "完成击杀后填装可提升武器伤害",
|
||||
|
|
Loading…
Add table
Reference in a new issue