Skip to content

Burstfire #1430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 1.12.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void checkEventKeys()
animations.doReload(type.reloadTime, pumpDelay, pumpTime);

data.reloadingRight = true;
data.burstRoundsRemainingRight = 0;
data.burstTicksRemainingRight = 0;
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/com/flansmod/common/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class PlayerData
/**
* When the player shoots a burst fire weapon, one shot is fired immediately and this counter keeps track of how many more should be fired
*/
public int burstRoundsRemainingLeft = 0, burstRoundsRemainingRight = 0;
public int burstTicksRemainingLeft = 0, burstTicksRemainingRight = 0;

// Handed getters and setters
public float GetShootTime(EnumHand hand)
Expand All @@ -99,15 +99,22 @@ public void SetShootTime(EnumHand hand, float set)
else shootTimeRight = set;
}

public int GetBurstRoundsRemaining(EnumHand hand)
public int GetBurstTicksRemaining(EnumHand hand)
{
return hand == EnumHand.OFF_HAND ? burstRoundsRemainingLeft : burstRoundsRemainingRight;
return hand == EnumHand.OFF_HAND ? burstTicksRemainingLeft : burstTicksRemainingRight;
}

public void SetBurstRoundsRemaining(EnumHand hand, int set)
public void SetBurstTicksRemaining(EnumHand hand, int set)
{
if(hand == EnumHand.OFF_HAND) burstRoundsRemainingLeft = set;
else burstRoundsRemainingRight = set;
if(hand == EnumHand.OFF_HAND) burstTicksRemainingLeft = set;
else burstTicksRemainingRight = set;
}

public boolean IsBursting(EnumHand hand)
{
if(GetBurstTicksRemaining(hand) > 0)
return true;
else return false;
}

public Vector3f[] lastMeleePositions;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/flansmod/common/guns/GunType.java
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ public float GetShootDelay(ItemStack stack)
for(AttachmentType attachment : getCurrentAttachments(stack))
{
if(attachment.modeOverride == EnumFireMode.BURST)
return Math.max(shootDelay, 3);
return Math.max(shootDelay, 1.5F);
}

float stackShootDelay = shootDelay;
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/com/flansmod/common/guns/ItemGun.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.flansmod.common.enchantments.EnchantmentModule;
import com.flansmod.common.enchantments.ItemGlove;
import com.flansmod.common.guns.raytracing.FlansModRaytracer;
import com.flansmod.common.guns.GunType;
import com.flansmod.common.network.PacketGunFire;
import com.flansmod.common.network.PacketPlaySound;
import com.flansmod.common.network.PacketReload;
Expand Down Expand Up @@ -349,11 +350,23 @@ public void onUpdateClient(ItemStack gunstack, int gunSlot, World world, Entity
case BURST:
{
//PlayerData burst rounds handled on client
if(data.GetBurstRoundsRemaining(hand) > 0)
if(hold && !held)
{
shouldShootThisTick = true;
if(type.mode != EnumFireMode.BURST)
data.SetBurstTicksRemaining(hand, (int) (Math.max(type.shootDelay, 1.5F) * 3));
else
data.SetBurstTicksRemaining(hand, (int) type.shootDelay * 3);
}
else if(held)
{
if(data.IsBursting(hand))
{
shouldShootThisTick = true;
data.SetBurstTicksRemaining(hand, data.GetBurstTicksRemaining(hand) - 1);
}
}
// Fallthrough to semi auto
else needsToReload = false;
break;
}
case SEMIAUTO:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void handleAnimation(GunAnimations animations, AnimationType type, Entit
animations.doReload(reloadtime, pumpdelay, pumptime);
PlayerData data = PlayerHandler.getPlayerData(player);
data.shootTimeRight = data.shootTimeLeft = reloadtime;
data.SetBurstRoundsRemaining(hand, 0);
data.SetBurstTicksRemaining(hand, 0);
data.reloadingLeft = data.reloadingRight = true;
break;

Expand Down