调整减伤计算
This commit is contained in:
parent
15defc3444
commit
a96df4d56b
16 changed files with 186 additions and 31 deletions
|
@ -0,0 +1,76 @@
|
||||||
|
package com.atsuishio.superbwarfare.data.gun;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
public class DamageReduce {
|
||||||
|
|
||||||
|
@SerializedName("Type")
|
||||||
|
public ReduceType type = null;
|
||||||
|
|
||||||
|
@SerializedName("Rate")
|
||||||
|
private double rate = 0.007;
|
||||||
|
|
||||||
|
@SerializedName("MinDistance")
|
||||||
|
private double minDistance = 100;
|
||||||
|
|
||||||
|
public DamageReduce() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamageReduce(ReduceType type) {
|
||||||
|
this.type = type;
|
||||||
|
this.rate = type.rate;
|
||||||
|
this.minDistance = type.minDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamageReduce(double rate, double minDistance) {
|
||||||
|
this.rate = rate;
|
||||||
|
this.minDistance = minDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRate() {
|
||||||
|
return this.type == null ? this.rate : this.type.rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRate(double rate) {
|
||||||
|
this.rate = rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMinDistance() {
|
||||||
|
return this.type == null ? this.minDistance : this.type.minDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinDistance(double minDistance) {
|
||||||
|
this.minDistance = minDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ReduceType {
|
||||||
|
@SerializedName("Shotgun")
|
||||||
|
SHOTGUN("Shotgun", 0.05, 15),
|
||||||
|
@SerializedName("Sniper")
|
||||||
|
SNIPER("Sniper", 0.001, 150),
|
||||||
|
@SerializedName("Heavy")
|
||||||
|
HEAVY("Heavy", 0.0007, 250),
|
||||||
|
@SerializedName("Handgun")
|
||||||
|
HANDGUN("Handgun", 0.03, 40),
|
||||||
|
@SerializedName("Rifle")
|
||||||
|
RIFLE("Rifle", 0.007, 100),
|
||||||
|
@SerializedName("Smg")
|
||||||
|
SMG("Smg", 0.02, 50),
|
||||||
|
;
|
||||||
|
|
||||||
|
public final double rate;
|
||||||
|
public final double minDistance;
|
||||||
|
public final String name;
|
||||||
|
|
||||||
|
ReduceType(String name, double rate, double minDistance) {
|
||||||
|
this.name = name;
|
||||||
|
this.rate = rate;
|
||||||
|
this.minDistance = minDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -119,4 +119,7 @@ public class DefaultGunData {
|
||||||
"!superbwarfare:longer_wire",
|
"!superbwarfare:longer_wire",
|
||||||
"!superbwarfare:cupid_arrow"
|
"!superbwarfare:cupid_arrow"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@SerializedName("DamageReduce")
|
||||||
|
public DamageReduce damageReduce = new DamageReduce();
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,6 +558,38 @@ public class GunData {
|
||||||
return defaultGunData().availableFireModes;
|
return defaultGunData().availableFireModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DamageReduce getRawDamageReduce() {
|
||||||
|
return defaultGunData().damageReduce;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRawDamageReduceRate() {
|
||||||
|
return getRawDamageReduce().getRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDamageReduceRate() {
|
||||||
|
for (Perk.Type type : Perk.Type.values()) {
|
||||||
|
var instance = this.perk.getInstance(type);
|
||||||
|
if (instance != null) {
|
||||||
|
return instance.perk().getModifiedDamageReduceRate(getRawDamageReduce());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getRawDamageReduce().getRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRawDamageReduceMinDistance() {
|
||||||
|
return getRawDamageReduce().getMinDistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDamageReduceMinDistance() {
|
||||||
|
for (Perk.Type type : Perk.Type.values()) {
|
||||||
|
var instance = this.perk.getInstance(type);
|
||||||
|
if (instance != null) {
|
||||||
|
return instance.perk().getModifiedDamageReduceMinDistance(getRawDamageReduce());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getRawDamageReduce().getMinDistance();
|
||||||
|
}
|
||||||
|
|
||||||
// 可持久化属性开始
|
// 可持久化属性开始
|
||||||
public final IntValue ammo;
|
public final IntValue ammo;
|
||||||
public final StringEnumValue<FireMode> fireMode;
|
public final StringEnumValue<FireMode> fireMode;
|
||||||
|
|
|
@ -19,7 +19,6 @@ import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
|
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
|
||||||
import com.atsuishio.superbwarfare.network.message.receive.DrawClientMessage;
|
import com.atsuishio.superbwarfare.network.message.receive.DrawClientMessage;
|
||||||
import com.atsuishio.superbwarfare.network.message.receive.PlayerGunKillMessage;
|
import com.atsuishio.superbwarfare.network.message.receive.PlayerGunKillMessage;
|
||||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.tools.*;
|
import com.atsuishio.superbwarfare.tools.*;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -140,33 +139,7 @@ public class LivingEventHandler {
|
||||||
if (DamageTypeTool.isGunDamage(source) && stack.getItem() instanceof GunItem) {
|
if (DamageTypeTool.isGunDamage(source) && stack.getItem() instanceof GunItem) {
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
double distance = entity.position().distanceTo(sourceEntity.position());
|
double distance = entity.position().distanceTo(sourceEntity.position());
|
||||||
|
damage = reduceDamageByDistance(amount, distance, data.getDamageReduceRate(), data.getDamageReduceMinDistance());
|
||||||
var ammoType = data.ammoTypeInfo().playerAmmoType();
|
|
||||||
if (ammoType != null) {
|
|
||||||
switch (ammoType) {
|
|
||||||
case SHOTGUN -> {
|
|
||||||
var perk = data.perk.get(Perk.Type.AMMO);
|
|
||||||
|
|
||||||
if (perk instanceof AmmoPerk ammoPerk && ammoPerk.slug) {
|
|
||||||
damage = reduceDamageByDistance(amount, distance, 0.015, 30);
|
|
||||||
} else {
|
|
||||||
damage = reduceDamageByDistance(amount, distance, 0.05, 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case SNIPER -> damage = reduceDamageByDistance(amount, distance, 0.001, 150);
|
|
||||||
case HEAVY -> damage = reduceDamageByDistance(amount, distance, 0.0007, 250);
|
|
||||||
case HANDGUN -> damage = reduceDamageByDistance(amount, distance, 0.03, 40);
|
|
||||||
case RIFLE -> damage = reduceDamageByDistance(amount, distance, 0.007, 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO 正确计算距离衰减
|
|
||||||
if (stack.is(ModTags.Items.SMG)) {
|
|
||||||
damage = reduceDamageByDistance(amount, distance, 0.02, 50);
|
|
||||||
} else if (stack.getItem() == ModItems.BOCEK.get()) {
|
|
||||||
damage = reduceDamageByDistance(amount, distance, 0.007, 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算防弹插板减伤
|
// 计算防弹插板减伤
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.perk;
|
package com.atsuishio.superbwarfare.perk;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.data.gun.DamageReduce;
|
||||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -62,6 +63,22 @@ public class AmmoPerk extends Perk {
|
||||||
return data.velocity() * this.speedRate;
|
return data.velocity() * this.speedRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getModifiedDamageReduceRate(DamageReduce reduce) {
|
||||||
|
if (this.slug && reduce.type == DamageReduce.ReduceType.SHOTGUN) {
|
||||||
|
return 0.015;
|
||||||
|
}
|
||||||
|
return super.getModifiedDamageReduceRate(reduce);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getModifiedDamageReduceMinDistance(DamageReduce reduce) {
|
||||||
|
if (this.slug && reduce.type == DamageReduce.ReduceType.SHOTGUN) {
|
||||||
|
return super.getModifiedDamageReduceMinDistance(reduce) * 2;
|
||||||
|
}
|
||||||
|
return super.getModifiedDamageReduceMinDistance(reduce);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
String descriptionId;
|
String descriptionId;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.perk;
|
package com.atsuishio.superbwarfare.perk;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.data.gun.DamageReduce;
|
||||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.item.PerkItem;
|
import com.atsuishio.superbwarfare.item.PerkItem;
|
||||||
|
@ -109,6 +110,20 @@ public class Perk {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于处理武器伤害衰减比率
|
||||||
|
*/
|
||||||
|
public double getModifiedDamageReduceRate(DamageReduce reduce) {
|
||||||
|
return reduce.getRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于处理武器伤害衰减最小距离
|
||||||
|
*/
|
||||||
|
public double getModifiedDamageReduceMinDistance(DamageReduce reduce) {
|
||||||
|
return reduce.getMinDistance();
|
||||||
|
}
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
AMMO("Ammo", ChatFormatting.YELLOW),
|
AMMO("Ammo", ChatFormatting.YELLOW),
|
||||||
FUNCTIONAL("Functional", ChatFormatting.GREEN),
|
FUNCTIONAL("Functional", ChatFormatting.GREEN),
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
"SoundRadius": 18,
|
"SoundRadius": 18,
|
||||||
"RPM": 360,
|
"RPM": 360,
|
||||||
"AvailableFireModes": ["Semi", "Auto"],
|
"AvailableFireModes": ["Semi", "Auto"],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Shotgun"
|
||||||
|
},
|
||||||
"AmmoType": "@ShotgunAmmo",
|
"AmmoType": "@ShotgunAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
"SoundRadius": 12,
|
"SoundRadius": 12,
|
||||||
"RPM": 700,
|
"RPM": 700,
|
||||||
"AvailableFireModes": ["Semi", "Auto"],
|
"AvailableFireModes": ["Semi", "Auto"],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Rifle"
|
||||||
|
},
|
||||||
"AmmoType": "@RifleAmmo",
|
"AmmoType": "@RifleAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
"Semi",
|
"Semi",
|
||||||
"Auto"
|
"Auto"
|
||||||
],
|
],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Rifle"
|
||||||
|
},
|
||||||
"AmmoType": "@RifleAmmo",
|
"AmmoType": "@RifleAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
"AvailableFireModes": [
|
"AvailableFireModes": [
|
||||||
"Auto"
|
"Auto"
|
||||||
],
|
],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Handgun"
|
||||||
|
},
|
||||||
"DefaultFireMode": "Auto",
|
"DefaultFireMode": "Auto",
|
||||||
"AmmoType": "@HandgunAmmo",
|
"AmmoType": "@HandgunAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"Magazine": 1,
|
"Magazine": 1,
|
||||||
"EmptyReloadTime": 6,
|
"EmptyReloadTime": 6,
|
||||||
|
"DamageReduce": {
|
||||||
|
"Rate": 0.007,
|
||||||
|
"MinDistance": 100
|
||||||
|
},
|
||||||
"AmmoType": "minecraft:arrow",
|
"AmmoType": "minecraft:arrow",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -15,7 +15,12 @@
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"SoundRadius": 13,
|
"SoundRadius": 13,
|
||||||
"RPM": 400,
|
"RPM": 400,
|
||||||
"AvailableFireModes": ["Auto"],
|
"AvailableFireModes": [
|
||||||
|
"Auto"
|
||||||
|
],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Rifle"
|
||||||
|
},
|
||||||
"AmmoType": "@RifleAmmo",
|
"AmmoType": "@RifleAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
"BypassesArmor": 0.15,
|
"BypassesArmor": 0.15,
|
||||||
"SoundRadius": 8,
|
"SoundRadius": 8,
|
||||||
"RPM": 400,
|
"RPM": 400,
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Handgun"
|
||||||
|
},
|
||||||
"AmmoType": "@HandgunAmmo",
|
"AmmoType": "@HandgunAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -14,7 +14,13 @@
|
||||||
"BypassesArmor": 0.15,
|
"BypassesArmor": 0.15,
|
||||||
"SoundRadius": 8,
|
"SoundRadius": 8,
|
||||||
"RPM": 1300,
|
"RPM": 1300,
|
||||||
"AvailableFireModes": ["Semi", "Auto"],
|
"AvailableFireModes": [
|
||||||
|
"Semi",
|
||||||
|
"Auto"
|
||||||
|
],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Handgun"
|
||||||
|
},
|
||||||
"AmmoType": "@HandgunAmmo",
|
"AmmoType": "@HandgunAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -16,7 +16,13 @@
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"RPM": 900,
|
"RPM": 900,
|
||||||
"AvailableFireModes": ["Semi", "Auto"],
|
"DamageReduce": {
|
||||||
|
"Type": "Rifle"
|
||||||
|
},
|
||||||
|
"AvailableFireModes": [
|
||||||
|
"Semi",
|
||||||
|
"Auto"
|
||||||
|
],
|
||||||
"AmmoType": "@RifleAmmo",
|
"AmmoType": "@RifleAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
"SoundRadius": 11,
|
"SoundRadius": 11,
|
||||||
"RPM": 1200,
|
"RPM": 1200,
|
||||||
"AvailableFireModes": ["Semi", "Burst", "Auto"],
|
"AvailableFireModes": ["Semi", "Burst", "Auto"],
|
||||||
|
"DamageReduce": {
|
||||||
|
"Type": "Smg"
|
||||||
|
},
|
||||||
"AmmoType": "@HandgunAmmo",
|
"AmmoType": "@HandgunAmmo",
|
||||||
"AvailablePerks": [
|
"AvailablePerks": [
|
||||||
"@Ammo",
|
"@Ammo",
|
||||||
|
|
Loading…
Add table
Reference in a new issue