package MGWarlock import Minigame import PlayerData import Assets import ChannelAbilityPreset import Projectile import ReviveManager import Execute import DummyDamage constant ARENA_POS = vec2(3200, 7500) public class MGWarlock extends Minigame static constant warlocks = new LinkedList() CallbackPeriodic cb override function getGameRect() returns rect return gg_rct_warlockgamearea override function getCamBounds() returns rect return gg_rct_warlockgamebounds override function onBegin() for pd in escaperPlayers if pd.escaper != null if not pd.escaper.alive forceRevive(pd.escaper) printTimedToPlayer("Use your [Q] Spell and be the last warlock standing!", 15., pd.p) warlocks.add(new Warlock(ARENA_POS + vec2(GetRandomReal(-16, 16), GetRandomReal(-16, 16)), pd.escaper)) cb = doPeriodically(1.) (CallbackPeriodic cb) -> if warlocks.filter(warlock -> warlock.actor.isAlive()).size() == 1 for ep in escaperPlayers printTimedToPlayer(warlocks.filter(warlock -> warlock.actor.isAlive()).peek().mounter.owner.getNameColored(true) + " has won!", 10, ep.p) reset() override function onEnd() execute() -> for warlock in warlocks if warlock != null and not warlock.done warlock.terminate() warlocks.clear() destroy cb override function getStartPosition() returns vec2 return getGameRect().getCenter() override function getName() returns string return "|cff3322e2Spacey Adventure" constant minigame = new MGWarlock() init minigames.add(minigame) constant WARLOCK_ID = compiletime(UNIT_ID_GEN.next()) constant FIREBALL_ID = compiletime(ABIL_ID_GEN.next()) public class Warlock extends UnitEntity Escaper mounter construct(vec2 pos, Escaper mounter) super(createUnit(mounter.owner, WARLOCK_ID, pos, (90).fromDeg()), pos.toVec3(), 32.) this.mounter = mounter this.mounter.alive = false mounter.actor..pause()..hide() setPos(this.pos+vec3(0,0,32)) sleeps = false mounter.owner.selectSingle(actor) EventListener.onPointCast(actor, FIREBALL_ID, (caster, target) -> begin new Fireball(this, caster.getPos().angleTo(target)) end) override function update() super.update() vel *= 0.9175 if not IsUnitSelected(actor, mounter.owner) mounter.owner.selectSingle(actor) if getPos().toVec2().getTerrainType() == 1147958883 new DummyDamage()..target(actor)..amount(0.5).apply(true) flashEffect(Abilities.flameStrikeEmbers, getPos()) if not actor.isAliveTrick() mounter.kill(null, KillMode.FORCE) let tpos = pos + vel*2. if tpos.x < gg_rct_warlockgamearea.getMinX() vel.x = -0.5*vel.x else if tpos.x > gg_rct_warlockgamearea.getMaxX() vel.x = -0.5*vel.x if tpos.y < gg_rct_warlockgamearea.getMinY() vel.y = -0.5*vel.y else if tpos.y > gg_rct_warlockgamearea.getMaxY() vel.y = -0.5*vel.y ondestroy if mounter != null and not mounter.done mounter.alive = true if mounter.actor.isAlive() mounter.actor..unpause()..show() public class Fireball extends Projectile Warlock caster RegionData reg construct(Warlock caster, angle direction) super(caster.pos.toVec2().withZ(42.) + direction.toVec(20.), 46., STAFF_PLAYER, direction, Abilities.fireBallMissile) this.caster = caster setSpeed(12) setRanged(800) reg = this.setCurrentRegion() override function update() super.update() MGWarlock.warlocks.forEach() (Warlock target) -> if target.actor.isAlive() and target != caster and target.getPos().distanceTo2dSq(pos.toVec2()) < (radius2 + target.radius2) new DummyDamage()..target(target.actor)..amount(20).apply(true) (target).addVel(((target.getPos().toVec2() - getPos().toVec2()).norm() * 40).toVec3()) terminate() @objectgen function genObjs() new UnitDefinition(WARLOCK_ID, UnitIds.war2warlock) ..setName("Warlock") ..setNormalAbilities(commaList(FIREBALL_ID)) ..setHitPointsMaximumBase(100) ..setManaMaximum(10) ..setCollisionSize(0) ..setScalingValue(0.6) ..setAttacksEnabled(0) ..setAnimationCastPoint(0.0) ..setSpeedBase(255) new ChannelAbilityPreset(FIREBALL_ID, 1, true) ..presetIcon(Icons.bTNFireBolt) ..presetCooldown(lvl -> 3.) ..presetManaCost(lvl -> 0) ..setName("Fireball") ..presetTooltipNormal(lvl -> "Fireball") ..presetButtonPosNormal(0, 0) ..presetHotkey("Q") ..presetTargetTypes(Targettype.POINT) ..presetCastRange(lvl -> 1500.)