Skip to content

Commit b128398

Browse files
committed
Add status icon for Marceline W, fix game over issues with practice mode and tutorial, improve the finn bot and fix bugs
1 parent c414e23 commit b128398

File tree

7 files changed

+103
-48
lines changed

7 files changed

+103
-48
lines changed

ATBPExtension/src/main/java/xyz/openatbp/extension/PracticeRoomHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public void gameOver(int winningTeam) {
230230
parentExt, ua.getUser(), "music", "music/music_defeat");
231231
}
232232
}
233+
parentExt.stopScript(room.getName(), false);
233234
} catch (Exception e) {
234235
e.printStackTrace();
235236
}

ATBPExtension/src/main/java/xyz/openatbp/extension/TutorialRoomHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ public void gameOver(int winningTeam) {
568568
}
569569
}
570570
ExtensionCommands.gameOver(
571-
parentExt, this.room, dcPlayers, winningTeam, false, tutorialCoins);
571+
parentExt, room, dcPlayers, winningTeam, false, tutorialCoins);
572+
parentExt.stopScript(room.getName(), false);
572573
} catch (Exception e) {
573574
e.printStackTrace();
574575
}

ATBPExtension/src/main/java/xyz/openatbp/extension/game/actors/Bot.java

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public class Bot extends Actor {
3636
private static final float TOWER_RANGE = 6f;
3737
private static final Point2D firstPoint = new Point2D.Float(15, 0);
3838
private static final int Q_DURATION = 3000;
39+
private static final double HP_PERCENT_HP_PACK = 0.6;
40+
private static final double HP_PERCENT_BASE = 0.2;
41+
private static final double HP_PERCENT_MINIONS = 0.6;
42+
private static final double HP_PERCENT_OWLS_LOW_LV = 0.6;
43+
private static final double HP_PERCENT_OWLS_HIGH_LV = 0.2;
44+
private static final double HP_PERCENT_GNOMES = 0.4;
3945
private final Point2D spawnPoint;
4046
private static final int E_CAST_DELAY = 500;
4147
private static final int POLYMORPH_DURATION = 3000;
@@ -173,6 +179,11 @@ private boolean isNonStructure(Actor a) {
173179
@Override
174180
public boolean damaged(Actor a, int damage, JsonNode attackData) {
175181
agressors.put(a, System.currentTimeMillis());
182+
if (a instanceof UserActor) {
183+
UserActor ua = (UserActor) a;
184+
ua.checkTowerAggro(ua);
185+
}
186+
176187
if (a.equals(enemy) && location.distance(a.getLocation()) <= 8) {
177188
enemyDmgTime = System.currentTimeMillis();
178189
}
@@ -398,17 +409,17 @@ public void update(int msRan) {
398409
ExtensionCommands.removeFx(parentExt, room, id + "healthPackFX");
399410
}
400411

401-
if (getPHealth() < 0.6
412+
if (getPHealth() < HP_PERCENT_HP_PACK
402413
&& room.getVariable("spawns").getSFSObjectValue().getInt("bh1") == 91) {
403414
// Console.debugLog("Health pack");
404415
Point2D bh1 = new Point2D.Float(MapData.L1_BLUE_HEALTH_X, MapData.L1_BLUE_HEALTH_Z);
405-
moveWithCollision(bh1);
416+
handleMoving(bh1);
406417
return;
407418
}
408419

409-
if (getPHealth() < 0.2) {
420+
if (getPHealth() < HP_PERCENT_BASE) {
410421
// Console.debugLog("Return to base");
411-
moveWithCollision(spawnPoint);
422+
handleMoving(spawnPoint);
412423
return;
413424
}
414425

@@ -423,11 +434,12 @@ && shouldAttackTarget(enemy)) {
423434
if (location.distance(firstPoint) <= 0.5) wentToStartPoint = true;
424435

425436
if (!wentToStartPoint) {
426-
moveWithCollision(firstPoint);
437+
handleMoving(firstPoint);
427438
return;
428439
}
429440

430-
if (System.currentTimeMillis() - lastAttackedByMinion <= 1000
441+
if ((System.currentTimeMillis() - lastAttackedByMinion <= 1000
442+
&& getPHealth() < HP_PERCENT_MINIONS)
431443
|| System.currentTimeMillis() - lastAttackedByTower <= 1000) {
432444
run();
433445
return;
@@ -448,8 +460,8 @@ && shouldAttackTarget(enemy)) {
448460
}
449461
}
450462

451-
if (topStatus == 10 && botStatus == 10) {
452-
// Console.debugLog("Altars captured, attack something");
463+
if ((topStatus == 10 && botStatus == 10) || !shouldMoveToAltar()) {
464+
// Console.debugLog("Altars captured or shouldn't move there, do something else");
453465
List<Actor> actors = handler.getActors();
454466
List<Actor> enemies =
455467
actors.stream().filter(a -> a.getTeam() != team).collect(Collectors.toList());
@@ -489,12 +501,12 @@ && shouldAttackTarget(enemy)) {
489501
// Console.debugLog("Attack closest enemy");
490502
attackClosestActor(enemies);
491503

492-
} else if (topStatus != 10) {
504+
} else if (topStatus != 10 && shouldMoveToAltar()) {
493505
// Console.debugLog("Top altar");
494-
moveWithCollision(topAltarLocation);
495-
} else {
506+
handleMoving(topAltarLocation);
507+
} else if (shouldMoveToAltar()) {
496508
// Console.debugLog("Bot altar");
497-
moveWithCollision(botAltarLocation);
509+
handleMoving(botAltarLocation);
498510
}
499511
}
500512

@@ -759,6 +771,25 @@ private void handleQDeath() {
759771
team);
760772
}
761773

774+
private void handleMoving(Point2D destination) {
775+
if (location.distance(destination) > 0.1) {
776+
moveWithCollision(destination);
777+
}
778+
}
779+
780+
private boolean shouldMoveToAltar() {
781+
Tower firstBlueTower = null;
782+
RoomHandler handler = parentExt.getRoomHandler(room.getName());
783+
List<Tower> towers = handler.getTowers();
784+
for (Tower t : towers) {
785+
if (t.getTeam() == team && t.getTowerNum() == 4) {
786+
firstBlueTower = t;
787+
}
788+
}
789+
return firstBlueTower != null || enemy.isDead();
790+
// move to altars if first tower is not destroyed or when enemy is dead
791+
}
792+
762793
protected double handlePassive(Actor target, double damage) {
763794
if (furyTarget != null) {
764795
if (furyTarget.getId().equalsIgnoreCase(target.getId())) {
@@ -901,17 +932,15 @@ public void handleCyclopsHealing() {
901932
private void run() {
902933
// Console.debugLog("Run");
903934
Point2D runPoint = new Point2D.Float((float) location.getX() + 5, (float) location.getY());
904-
moveWithCollision(runPoint);
935+
handleMoving(runPoint);
905936
}
906937

907938
private boolean shouldAttackJungleCamp(boolean owls) {
908-
if (level > 2 && level < 6 && getPLevel() > 0.6 && owls
909-
|| level > 5 && getPLevel() > 0.2 && owls) {
939+
if (level > 2 && level < 6 && getPHealth() > HP_PERCENT_OWLS_LOW_LV && owls
940+
|| level > 5 && getPHealth() > HP_PERCENT_OWLS_HIGH_LV && owls) {
910941
return true;
911942
}
912-
if (level > 4 && getPLevel() > 0.4 && enemyTower.isDead() && !owls) return true;
913-
914-
return false;
943+
return level > 4 && getPHealth() > HP_PERCENT_GNOMES && enemyTower.isDead() && !owls;
915944
}
916945

917946
private boolean shouldAttackTarget(Actor a) {
@@ -981,7 +1010,7 @@ private boolean shouldAttackTarget(Actor a) {
9811010
private void attemptAttack(Actor target) {
9821011
if (target != null) {
9831012
if (!withinRange(target) && canMove()) {
984-
moveWithCollision(target.getLocation());
1013+
handleMoving(target.getLocation());
9851014
} else if (withinRange(target)) {
9861015
if (!isStopped()) stopMoving();
9871016
if (canAttack()) attack(target);

ATBPExtension/src/main/java/xyz/openatbp/extension/game/actors/Tower.java

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.ArrayList;
55
import java.util.List;
66
import java.util.concurrent.TimeUnit;
7+
import java.util.function.Predicate;
78

89
import com.fasterxml.jackson.databind.JsonNode;
910

@@ -25,12 +26,12 @@ public class Tower extends Actor {
2526
private boolean destroyed = false;
2627
protected long lastMissSoundTime = 0;
2728
protected long lastSpellDeniedTime = 0;
28-
protected List<Actor> nearbyActors;
29+
protected List<Actor> actorsInRadius;
2930
private boolean isFocusingPlayer = false;
3031
private boolean isFocusingCompanion = false;
3132
private int numberOfAttacks = 0;
3233
private List<UserActor> usersTargeted;
33-
private boolean reduceDamageTaken = false;
34+
private boolean reduceDmgTaken = false;
3435

3536
public Tower(ATBPExtension parentExt, Room room, String id, int team, Point2D location) {
3637
this.currentHealth = 800;
@@ -98,7 +99,7 @@ public Tower(ATBPExtension parentExt, Room room, String id, int team) {
9899
@Override
99100
public boolean damaged(Actor a, int damage, JsonNode attackData) {
100101
if (this.destroyed) return true;
101-
if (this.target == null && nearbyActors.isEmpty()) {
102+
if (this.target == null && actorsInRadius.isEmpty()) {
102103
if (a.getActorType() == ActorType.PLAYER) {
103104
UserActor ua = (UserActor) a;
104105
if (System.currentTimeMillis() - this.lastMissSoundTime >= 1500
@@ -127,7 +128,8 @@ && getAttackType(attackData) == AttackType.PHYSICAL) {
127128
return false;
128129
} else if (a.getActorType() == ActorType.MINION) damage *= 0.5;
129130

130-
if (reduceDamageTaken) damage *= DAMAGE_REDUCTION_NO_MINIONS;
131+
if (reduceDmgTaken) damage *= (1 - DAMAGE_REDUCTION_NO_MINIONS);
132+
131133
this.changeHealth(this.getMitigatedDamage(damage, this.getAttackType(attackData), a) * -1);
132134
boolean notify = System.currentTimeMillis() - this.lastHit >= 1000 * 5;
133135
if (notify) ExtensionCommands.towerAttacked(parentExt, this.room, this.getTowerNum());
@@ -261,34 +263,24 @@ public void update(int msRan) {
261263
if (!this.destroyed) {
262264
this.handleDamageQueue();
263265
if (this.destroyed) return;
264-
nearbyActors =
265-
Champion.getEnemyActorsInRadius(
266-
this.parentExt.getRoomHandler(this.room.getName()),
267-
this.team,
268-
this.location,
269-
(float) this.getPlayerStat("attackRange"));
270-
if (!nearbyActors.isEmpty()) {
271-
List<Actor> minionsInRadius = new ArrayList<>();
272-
for (Actor a : nearbyActors) {
273-
if (a.getActorType() == ActorType.MINION) {
274-
minionsInRadius.add(a);
275-
}
276-
}
277-
if (minionsInRadius.isEmpty() && !reduceDamageTaken) {
278-
reduceDamageTaken = true;
279-
} else if (reduceDamageTaken) {
280-
reduceDamageTaken = false;
281-
}
282-
}
283-
if (nearbyActors.isEmpty() && this.attackCooldown != 1000) {
266+
267+
RoomHandler rh = parentExt.getRoomHandler(room.getName());
268+
float radius = (float) getPlayerStat("attackRange");
269+
actorsInRadius = Champion.getEnemyActorsInRadius(rh, team, location, radius);
270+
271+
Predicate<Actor> isMinion = actor -> actor.getActorType() == ActorType.MINION;
272+
273+
reduceDmgTaken = actorsInRadius.stream().noneMatch(isMinion);
274+
275+
if (actorsInRadius.isEmpty() && this.attackCooldown != 1000) {
284276
if (numberOfAttacks != 0) this.numberOfAttacks = 0;
285277
this.attackCooldown = 1000;
286278
}
287279
if (this.target == null) {
288280
boolean hasMinion = false;
289281
double distance = 1000;
290282
Actor potentialTarget = null;
291-
for (Actor a : nearbyActors) {
283+
for (Actor a : actorsInRadius) {
292284
if (hasMinion && a.getActorType() == ActorType.MINION) {
293285
if (a.getLocation().distance(this.location)
294286
< distance) { // If minions exist in range, it only focuses on
@@ -405,7 +397,7 @@ public void update(int msRan) {
405397
}
406398
}
407399
if (this.attackCooldown > 0) this.reduceAttackCooldown();
408-
if (nearbyActors.isEmpty()) {
400+
if (actorsInRadius.isEmpty()) {
409401
if (this.target != null
410402
&& (this.target.getActorType() == ActorType.PLAYER
411403
|| target instanceof Bot)) {

ATBPExtension/src/main/java/xyz/openatbp/extension/game/actors/UserActor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ public boolean damaged(Actor a, int damage, JsonNode attackData) {
378378
if (a.getActorType() == ActorType.COMPANION) {
379379
checkTowerAggroCompanion(a);
380380
}
381+
381382
if (this.pickedUpHealthPack) {
382383
removeHealthPackEffect();
383384
}

ATBPExtension/src/main/java/xyz/openatbp/extension/game/champions/Marceline.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ public class Marceline extends UserActor {
2323
private static final int W_DURATION = 3000;
2424
private static final double W_BEAST_SPEED_VALUE = 0.4d;
2525
private static final double W_VAMPIRE_SPEED_VALUE = 0.15d;
26+
private static final String W_BEAST_ICON = "beast_w";
27+
private static final String W_VAMP_ICON = "vamp_w";
2628
private static final int E_CAST_DELAY = 750;
2729
private static final int E_ATTACKSPEED_DURATION = 3000;
2830
private static final int E_IMMUNITY_DURATION = 2000;
2931
private static final int E_CHARM_DURATION = 2000;
3032
private static final int E_FEAR_DURATION = 2000;
33+
3134
private int passiveHits = 0;
3235
private boolean hpRegenActive = false;
3336
private Actor qVictim;
@@ -59,10 +62,12 @@ public void update(int msRan) {
5962
&& System.currentTimeMillis() - this.vampireWStartTime >= W_DURATION) {
6063
this.vampireWActive = false;
6164
updateStatMenu("speed");
65+
ExtensionCommands.removeStatusIcon(parentExt, player, W_VAMP_ICON);
6266
}
6367
if (this.beastWActive && System.currentTimeMillis() - this.bestWStartTime >= W_DURATION) {
6468
this.beastWActive = false;
6569
updateStatMenu("speed");
70+
ExtensionCommands.removeStatusIcon(parentExt, player, W_BEAST_ICON);
6671
}
6772
if (this.currentHealth < this.maxHealth
6873
&& !this.hpRegenActive
@@ -223,7 +228,15 @@ public void handleLifeSteal() {
223228
@Override
224229
public void die(Actor a) {
225230
super.die(a);
226-
this.vampireWActive = false;
231+
if (vampireWActive) {
232+
vampireWActive = false;
233+
ExtensionCommands.removeStatusIcon(parentExt, player, W_VAMP_ICON);
234+
}
235+
236+
if (beastWActive) {
237+
beastWActive = false;
238+
ExtensionCommands.removeStatusIcon(parentExt, player, W_BEAST_ICON);
239+
}
227240
}
228241

229242
@Override
@@ -281,16 +294,20 @@ public void useAbility(
281294
this.canCast[1] = false;
282295
try {
283296
String wVO = SkinData.getMarcelineWVO(avatar);
297+
addWStatusIcon(form);
298+
284299
if (this.form == Form.BEAST) {
285300
this.beastWActive = true;
286301
this.bestWStartTime = System.currentTimeMillis();
287302
attackCooldown = 0;
303+
288304
ExtensionCommands.playSound(
289305
this.parentExt,
290306
this.room,
291307
this.id,
292308
"sfx_marceline_beast_crit_activate",
293309
this.location);
310+
294311
ExtensionCommands.createActorFX(
295312
this.parentExt,
296313
this.room,
@@ -316,6 +333,7 @@ public void useAbility(
316333
true,
317334
false,
318335
this.team);
336+
319337
// this.addEffect("speed", this.getStat("speed") * W_BEAST_SPEED_VALUE,
320338
// W_DURATION);
321339
} else {
@@ -416,6 +434,16 @@ public void useAbility(
416434
}
417435
}
418436

437+
private void addWStatusIcon(Form currentForm) {
438+
String iconDesc = "marceline_spell_2_description";
439+
String monoName = "icon_marceline_s2";
440+
441+
String iconName = currentForm == Form.BEAST ? W_BEAST_ICON : W_VAMP_ICON;
442+
443+
ExtensionCommands.addStatusIcon(
444+
parentExt, player, iconName, iconDesc, monoName, W_DURATION);
445+
}
446+
419447
private void checkForDisablingUltAttack() {
420448
if (eUsed && !hadCCDuringECast && hasInterrupingCC()) {
421449
canDoUltAttack = false;
@@ -453,6 +481,8 @@ && isNeitherStructureNorAlly(target)
453481
changeHealth((int) Math.round(damage * lifesteal));
454482
}
455483

484+
ExtensionCommands.removeStatusIcon(parentExt, player, W_BEAST_ICON);
485+
456486
} else if (form == Form.BEAST && crit) {
457487
damage *= 1.25d;
458488
}

ATBPExtension/src/main/java/xyz/openatbp/extension/game/champions/RattleBalls.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class RattleBalls extends UserActor {
2525
private static final int Q_COUNTER_ATTACK_ANIM_DURATION = 1000;
2626
private static final float Q_SPELL_RANGE = 6f;
2727
private static final float Q_OFFSET_DISTANCE = 0.85f;
28+
private static final int Q_SPIN_ATTACK_BONUS_BASE_DMG = 55;
2829
private static final int W_CAST_DELAY = 500;
2930
private static final int E_DURATION = 3500;
3031
private static final double E_SPEED_VALUE = 0.14d;
@@ -446,7 +447,7 @@ private void performQSpinAttack() {
446447
for (Actor a : affectedActors) {
447448
if (isNeitherTowerNorAlly(a)) {
448449
JsonNode spellData = parentExt.getAttackData(avatar, "spell1");
449-
double dmg = getSpellDamage(spellData, true) + 25;
450+
double dmg = getSpellDamage(spellData, true) + Q_SPIN_ATTACK_BONUS_BASE_DMG;
450451
a.addToDamageQueue(this, dmg, spellData, false);
451452
}
452453
}

0 commit comments

Comments
 (0)