Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
Cokemonkey11 committed Oct 18, 2021
1 parent ec46b55 commit b870ebf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 37 deletions.
18 changes: 6 additions & 12 deletions wurst.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
projectName: Gods Arena
projectName: Gods' Arena
dependencies:
- https://github.com/wurstscript/wurstStdlib2
- https://github.com/Frotty/Frentity.git
Expand All @@ -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."
34 changes: 20 additions & 14 deletions wurst/heroes/heroes/DemonLord/HowlOfTerror.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package HowlOfTerror
import Abilities
import AbilityTooltipGenerator
import BuffIds
import ClosureEvents
import DamageEvent
import DemonLordIds
import GameConstants
import Icons
Expand All @@ -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(
Expand Down
43 changes: 33 additions & 10 deletions wurst/heroes/heroes/DemonLord/Obliterator.wurst
Original file line number Diff line number Diff line change
@@ -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<unit, int>()
constant DEMON_LORD_STR_BONUSES = new HashMap<unit, ObliteratorData>()

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 ->
Expand All @@ -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()
9 changes: 8 additions & 1 deletion wurst/players/PlayerData.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Entity
public constant ARENA_POINTS_THRESHOLD = 500

public constant pData = new IterableMap<player, PlayerData>
public constant pDataFromHeroType = new IterableMap<int, PlayerData>

public function player.getData() returns PlayerData
return pData.get(this)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.))

0 comments on commit b870ebf

Please sign in to comment.