From b870ebfa56d6506d73488fcc8114bf713fd14f29 Mon Sep 17 00:00:00 2001 From: Cokemonkey11 Date: Tue, 19 Oct 2021 00:25:55 +0100 Subject: [PATCH] cr --- wurst.build | 18 +++----- .../heroes/DemonLord/HowlOfTerror.wurst | 34 +++++++++------ .../heroes/heroes/DemonLord/Obliterator.wurst | 43 ++++++++++++++----- wurst/players/PlayerData.wurst | 9 +++- 4 files changed, 67 insertions(+), 37 deletions(-) diff --git a/wurst.build b/wurst.build index f3101ef..9a860ae 100644 --- a/wurst.build +++ b/wurst.build @@ -1,5 +1,5 @@ --- -projectName: Gods Arena +projectName: Gods' Arena dependencies: - https://github.com/wurstscript/wurstStdlib2 - https://github.com/Frotty/Frentity.git @@ -17,14 +17,8 @@ buildMapData: loadingScreen: title: by Overkane and Frotty subTitle: Gods' Arena v0.9.9 - text: |- - Try to survive the arena of the gods. - - Some tips: - Press TAB to toggle the shop. - - You can sell items in your inventory with your hero sell ability (hotkey - F). - - You will be revived at the end of each round, but not with full HP and MP. - - You will restore a bit of HP and MP at the end of each round if you survived. + text: "Try to survive the arena of the gods.\n\n Some tips:\n Press TAB to toggle\ + \ the shop.\n\n You can sell items in your inventory with your hero sell ability\ + \ (hotkey - F).\n\n You will be revived at the end of each round, but not\ + \ with full HP and MP.\n\n You will restore a bit of HP and MP at the end\ + \ of each round if you survived." diff --git a/wurst/heroes/heroes/DemonLord/HowlOfTerror.wurst b/wurst/heroes/heroes/DemonLord/HowlOfTerror.wurst index c107ec1..63cdbef 100644 --- a/wurst/heroes/heroes/DemonLord/HowlOfTerror.wurst +++ b/wurst/heroes/heroes/DemonLord/HowlOfTerror.wurst @@ -2,7 +2,7 @@ package HowlOfTerror import Abilities import AbilityTooltipGenerator import BuffIds -import ClosureEvents +import DamageEvent import DemonLordIds import GameConstants import Icons @@ -11,22 +11,28 @@ import TooltipFactory RealLevelClosure DAMAGE_DECREASE = lvl -> 0.25 + 0.1 * (lvl-1) RealLevelClosure DURATION = lvl -> 10 -IntLevelClosure STR_BONUS = lvl -> (0.5 * (lvl - 1)).floor() + 1 // 1, 1, 2, 2, 3 +IntLevelClosure STR_BONUS = _ -> 1 RealLevelClosure HP_RECOVERY = lvl -> 100.0 + 50 * (lvl-1) init - EventListener.add(EVENT_PLAYER_UNIT_DEATH) -> - let killer = EventData.getKillingUnit() - if killer.getTypeId() == DEMON_LORD_ID and EventData.getTriggerUnit().hasAbility(BuffIds.howlofTerror) - let level = killer.getAbilityLevel(HOWL_OF_TERROR_ID) - let str_bonus = STR_BONUS.run(level) - let killer_pos = killer.getPos() - killer.addStr(str_bonus) - killer.addHP(HP_RECOVERY.run(level)) - standardTextTag(killer_pos, "+" + str_bonus.toString()) - ..setColor(255, 0, 0, 255) - ..setVisibility(localPlayer == killer.getOwner()) - flashEffect(Abilities.deathCoilMissile, killer_pos) + DamageEvent.addListener(5) -> + let target = DamageEvent.getTarget() + if DamageEvent.getAmount() > target.getHP() + let killer = DamageEvent.getSource() + if ( + killer.getTypeId() == DEMON_LORD_ID + and target.hasAbility(BuffIds.howlofTerror) + and not target.isType(UNIT_TYPE_SUMMONED) + ) + let level = killer.getAbilityLevel(HOWL_OF_TERROR_ID) + let str_bonus = STR_BONUS.run(level) + let killer_pos = killer.getPos() + killer.addStr(str_bonus) + killer.addHP(HP_RECOVERY.run(level)) + standardTextTag(killer_pos, "+" + str_bonus.toString()) + ..setColor(255, 0, 0, 255) + ..setVisibility(localPlayer == killer.getOwner()) + flashEffect(Abilities.deathCoilMissile, killer_pos) @compiletime function genAbility() let tooltip = new AbilityTooltipGenerator( diff --git a/wurst/heroes/heroes/DemonLord/Obliterator.wurst b/wurst/heroes/heroes/DemonLord/Obliterator.wurst index e764487..707ca99 100644 --- a/wurst/heroes/heroes/DemonLord/Obliterator.wurst +++ b/wurst/heroes/heroes/DemonLord/Obliterator.wurst @@ -1,36 +1,59 @@ package Obliterator + import AbilityTooltipGenerator +import Abilities import ClosureForGroups import ClosureTimers import CreepAggro import DemonLordIds import HashMap +import Hero import Icons +import PassiveAbilityPreset +import PlayerData constant IntLevelClosure BONUS_STRENGTH = _ -> 50 constant IntLevelClosure CREEP_AGGRO = _ -> 200 constant RealLevelClosure CREEP_AGGRO_RANGE = _ -> 400. constant RealLevelClosure BONUS_HEALTH_THRESHOLD = _ -> .5 -constant DEMON_LORD_STR_BONUSES = new HashMap() +constant DEMON_LORD_STR_BONUSES = new HashMap() + +class ObliteratorData + int amt + effect fx + + construct(unit u, int amt) + this.amt = amt + this.fx = amt > 0 ? addEffect(Abilities.vampiricAura, u, "origin") : null + + ondestroy + if this.fx != null + this.fx.destr() function int.toCustomUnitTypeString() returns string return "custom_" + this.toRawCode() init doPeriodically(1.) _ -> - forUnitsOfType(OBLITERATOR_ID.toCustomUnitTypeString()) u -> + maybeHeroFromHeroType(DEMON_LORD_ID).ifPresent() hero -> + let u = hero.actor if not DEMON_LORD_STR_BONUSES.has(u) - DEMON_LORD_STR_BONUSES.put(u, 0) + DEMON_LORD_STR_BONUSES.put(u, new ObliteratorData(u, 0)) + + // Calculate bonus amount based on hero's health without any current bonus. This prevents flip-flop effect. + let currAmt = DEMON_LORD_STR_BONUSES.get(u).amt + u.addStr(-currAmt) + let wants = (u.getHP() / u.getMaxHP()) < BONUS_HEALTH_THRESHOLD.run(1) and u.isAlive() + u.addStr(currAmt) - let wants = (u.getHP() / u.getMaxHP()) < BONUS_HEALTH_THRESHOLD.run(1) let wants_bonus = wants ? BONUS_STRENGTH.run(1) : 0 - let curr_bonus = DEMON_LORD_STR_BONUSES.get(u) + let curr_bonus = DEMON_LORD_STR_BONUSES.get(u).amt if curr_bonus != wants_bonus u.addStr(wants_bonus - curr_bonus) - print(wants_bonus - curr_bonus) - DEMON_LORD_STR_BONUSES.put(u, wants_bonus) + destroy DEMON_LORD_STR_BONUSES.get(u) + DEMON_LORD_STR_BONUSES.put(u, new ObliteratorData(u, wants_bonus)) if wants forUnitsInRange(u.getPos(), CREEP_AGGRO_RANGE.run(1)) fog -> @@ -42,15 +65,15 @@ init Targettype.PASSIVE, "Passively grants bonus strength and nearby creep aggro when the Demon Lord has less than 50% HP." ) - new AbilityDefinitionArchMageBrillianceAura(OBLITERATOR_ID) + new PassiveAbilityPreset(OBLITERATOR_ID, 1, tooltip) ..presetTargetsAllowed(_ -> "none") - ..registerTooltipGenerator(tooltip) ..presetButtonPosNormal(1, 1) ..presetButtonPosResearch(1, 0) ..setIconNormal(Icons.pASBTNFireRocks) + ..tooltipStartListen() ..addTooltipProperty("Bonus Strength", BONUS_STRENGTH) ..addTooltipProperty("Creep Aggro", CREEP_AGGRO) ..addTooltipProperty("Creep Aggro Range", CREEP_AGGRO_RANGE) ..addTooltipProperty("Health Threshold", BONUS_HEALTH_THRESHOLD) - ..setLevels(1) ..setName("Obliterator") + ..tooltipStopListen() diff --git a/wurst/players/PlayerData.wurst b/wurst/players/PlayerData.wurst index 78d879c..165d973 100644 --- a/wurst/players/PlayerData.wurst +++ b/wurst/players/PlayerData.wurst @@ -11,6 +11,7 @@ import Entity public constant ARENA_POINTS_THRESHOLD = 500 public constant pData = new IterableMap +public constant pDataFromHeroType = new IterableMap public function player.getData() returns PlayerData return pData.get(this) @@ -25,6 +26,11 @@ public function maybe_hero.ifPresent(MaybeHeroIfPresent ifPresent) return ifPresent.if_present(this.hero) +public function maybeHeroFromHeroType(int type_id) returns maybe_hero + if pDataFromHeroType.has(type_id) + return pDataFromHeroType.get(type_id).getHero() + return maybe_hero(false, null) + public class PlayerData private player p private maybe_hero maybeHero @@ -47,6 +53,7 @@ public class PlayerData function setHero(Hero h) this.maybeHero = maybe_hero(true, h) + pDataFromHeroType.put(h.actor.getTypeId(), this) function getHero() returns maybe_hero return this.maybeHero @@ -135,7 +142,7 @@ public function initPlayers() if honorShop.getOwner() == p destroy honorShop.getEntity() break - + printTimed(p.getNameColored() + " has left the game", 15.) SetPlayerHandicap(ENEMY_PLAYER, 0.15 + 0.85 * (humanPlayers.size() / 8.))