Skip to content
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

Arrow hit limit #45

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
4 changes: 0 additions & 4 deletions ideas/ideas for feature updates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ Allow clients to add a port number to the end of the ip with ":". for example: 1

----

make arrows go away after hitting a certain number of enemies, or dealing a certain amount of damage

----

make creeper holes like TNT, just only one block. Though I should still have the thing where it hurts entities based on distance.

----
Expand Down
9 changes: 8 additions & 1 deletion src/minicraft/entity/Arrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Arrow extends Entity implements ClientTickable {
private int damage;
public Mob owner;
private int speed;
private int mobsHit;

public Arrow(Mob owner, Direction dir, int dmg) {
this(owner, owner.x, owner.y, dir, dmg);
Expand All @@ -30,6 +31,8 @@ public Arrow(Mob owner, int x, int y, Direction dir, int dmg) {
if (damage > 3) speed = 8;
else if (damage >= 0) speed = 7;
else speed = 6;

mobsHit = 0;

/* // maybe this was a "critical arrow" system or something?
if (flag) {
Expand Down Expand Up @@ -64,8 +67,12 @@ public void tick() {

if (hit != null && hit instanceof Mob && hit != owner) {
Mob mob = (Mob) hit;
mobsHit++;
int extradamage = (hit instanceof Player ? 0 : 3) + (criticalHit ? 0 : 1);
mob.hurt(owner, damage + extradamage, dir);
mob.hurt(owner, damage / (3 * (mobsHit - 1) + 1) + extradamage, dir);
if (mobsHit > 1) {
this.remove();
}
}

// if(owner instanceof Player && Game.isMode("creative") && Game.debug) {
Expand Down