Change attackDelay variable to be called SwingWarmup | Better Naming

This commit is contained in:
Kam committed 2024-02-12 03:14:23 -05:00
1 parent eb01579f4a
commit 76000ecf55
6 files changed
+23 -14

No files matched your search

+3 -3
View File
@@ -11,7 +11,7 @@ import noppes.npcs.util.ValueUtil;
public class DataStats {
private float attackStrength = 5;
public int attackSpeed = 20, attackDelay = 0, attackRange = 2, knockback = 0;
public int attackSpeed = 20, swingWarmUp = 0, attackRange = 2, knockback = 0;
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
public int aggroRange = 16;
@@ -72,7 +72,7 @@ public class DataStats {
compound.setFloat("AttackStrenght", attackStrength);
compound.setInteger("AttackRange", attackRange);
compound.setInteger("AttackSpeed", attackSpeed);
compound.setInteger("attackDelay", attackDelay);
compound.setInteger("SwingWarmup", swingWarmUp);
compound.setInteger("KnockBack", knockback);
compound.setInteger("PotionEffect", potionType.ordinal());
compound.setInteger("PotionDuration", potionDuration);
@@ -132,7 +132,7 @@ public class DataStats {
setAttackStrength(compound.getFloat("AttackStrenght"));
attackSpeed = compound.getInteger("AttackSpeed");
attackDelay = ValueUtil.clamp(compound.getInteger("attackDelay"), 0, 1000);
swingWarmUp = ValueUtil.clamp(compound.getInteger("SwingWarmup"), 0, 1000);
attackRange = compound.getInteger("AttackRange");
knockback = compound.getInteger("KnockBack");
potionType = EnumPotionType.values()[compound.getInteger("PotionEffect") % EnumPotionType.values().length];
@@ -133,10 +133,10 @@ public class EntityAIAttackTarget extends EntityAIBase
{
if (this.attackTick <= 0) {
this.attackTick = this.npc.stats.attackSpeed;
if(this.npc.stats.attackDelay == 0)
if(this.npc.stats.swingWarmUp == 0)
this.npc.attackEntityAsMob(this.entityTarget);
this.npc.swingItem();
} else if (this.npc.stats.attackDelay > 0 && this.attackTick == this.npc.stats.attackSpeed - this.npc.stats.attackDelay) {
} else if (this.npc.stats.swingWarmUp > 0 && this.attackTick == this.npc.stats.attackSpeed - this.npc.stats.swingWarmUp) {
// Perform the actual attack that deals damage
this.npc.attackEntityAsMob(this.entityTarget);
}
@@ -40,12 +40,6 @@ public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiDat
scroll.guiLeft = guiLeft + 4;
scroll.guiTop = guiTop + 26;
addScroll(scroll);
// GuiMenuTopButton button;
// addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones"));
// button.active = !isServer;
// addTopButton(button = new GuiMenuTopButton(4, button, "gui.server"));
// button.active = isServer;
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search));
@@ -35,8 +35,8 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(8,"stats.swingdelay", guiLeft + 130, guiTop + 75));
addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 220, guiTop + 70, 30, 18, stats.attackDelay+""));
addLabel(new GuiNpcLabel(8,"stats.swingwarmup", guiLeft + 130, guiTop + 75));
addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 220, guiTop + 70, 30, 18, stats.swingWarmUp +""));
getTextField(8).integersOnly = true;
getTextField(8).setMinMaxDefault(0, 1000, 0);
@@ -76,7 +76,7 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
stats.potionDuration = textfield.getInteger();
}
else if(textfield.id == 8){
stats.attackDelay = textfield.getInteger();
stats.swingWarmUp = textfield.getInteger();
}
}
@@ -906,6 +906,20 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.stats.attackRange = range;
}
/**
* @return The swing warmup time in ticks
*/
public int getSwingWarmup(){
return npc.stats.swingWarmUp;
}
/**
* @param ticks The amount of time before damage to swing arm
*/
public void setSwingWarmup(int ticks){
npc.stats.swingWarmUp = ticks;
}
/**
* @return The knockback strength
*/
@@ -312,6 +312,7 @@ stats.projectileproperties=ProjectileType
stats.meleestrength=MeleeStrength
stats.meleerange=MeleeRange
stats.meleespeed=MeleeSpeed
stats.swingwarmup=SwingWarmup
stats.accuracy=Accuracy(%)
stats.rangedrange=RangedRange
stats.burstspeed=FireRate