package Knockbacker import Escaper import EscaperKillers import ChannelAbilityPreset import Abilities public constant KNOCKBACKER_ID = 'knck' public constant KNOCK_INC_ID = compiletime(ABIL_ID_GEN.next()) public constant KNOCK_DEC_ID = compiletime(ABIL_ID_GEN.next()) public constant DMG_INC_ID = compiletime(ABIL_ID_GEN.next()) public constant DMG_DEC_ID = compiletime(ABIL_ID_GEN.next()) public class Knockbacker extends EscaperSensorSetup let kforce = new ConfigValue(20, 2.5, "Knockback") let damage = new ConfigValue(50, 25, "Damage") construct(unit existing) super(existing, 78., 164.) setup..addAbility(KNOCK_INC_ID)..addAbility(KNOCK_DEC_ID) ..addAbility(DMG_INC_ID)..addAbility(DMG_DEC_ID) EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) construct(vec2 pos, player owner, angle facing) super(pos.toVec3(), owner, KNOCKBACKER_ID, facing, 64., 160.) setup..addAbility(KNOCK_INC_ID)..addAbility(KNOCK_DEC_ID) ..addAbility(DMG_INC_ID)..addAbility(DMG_DEC_ID) EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) function onCast() returns boolean let id = GetSpellAbilityId() switch id case KNOCK_INC_ID kforce.increment(this, 75) case KNOCK_DEC_ID kforce.decrement(this, -75) case DMG_INC_ID damage.increment(this, 500) case DMG_DEC_ID damage.decrement(this, 0) return false override function onSensor(UnitEntity source, UnitEntity target) if target instanceof Escaper if target.pos.z <= sensorHeight let escaper = target castTo Escaper let epos = escaper.getPos() - escaper.getRealVel() let epos2 = escaper.getPos() + escaper.getRealVel() let ang = pos.angleTo2d((epos + epos2) * 0.5) escaper.addVel(ang.toVec(kforce.get()).toVec3()) actor.damageTarget(escaper.actor, damage.get()) actor.setAnimation("attack") setup.setAnimation("attack") addEffect(Abilities.warStompCaster, escaper.pos).destr() override function serialize() returns Json let json = super.serialize() json ..addProperty(new Property(KEY_TYPE, KNOCKBACKER_INDEX.toString())) return json ondestroy destroy kforce destroy damage @objectgen function genKnockbacker() let inc_spell = new ChannelAbilityPreset(KNOCK_INC_ID, 1, true) inc_spell..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 0) ..setName("Knockbacker: Increase Knockback") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNknockbackincrease.blp") ..presetHotkey("A") ..presetTooltipNormal(lvl -> "Increase Knockback [|cffFFCC00A|r]") ..presetTooltipNormalExtended(lvl -> "More strength to the tauren") ..presetButtonPosNormal(1, 1) let dec_spell = new ChannelAbilityPreset(KNOCK_DEC_ID, 1, true) dec_spell..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 0) ..setName("Knockbacker: Decrease Knockback") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNknockbackdecrease.blp") ..presetHotkey("D") ..presetTooltipNormal(lvl -> "Decrease Knockback [|cffFFCC00D|r]") ..presetTooltipNormalExtended(lvl -> "Less strength to the tauren") ..presetButtonPosNormal(2, 1) let inc_spelld = new ChannelAbilityPreset(DMG_INC_ID, 1, true) inc_spelld..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 0) ..setName("Knockbacker: Increase Damage") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNReplay-Speedup.blp") ..presetHotkey("R") ..presetTooltipNormal(lvl -> "Increase Damage [|cffFFCC00R|r]") ..presetTooltipNormalExtended(lvl -> "Increases damage output") ..presetButtonPosNormal(3, 0) let dec_spelld = new ChannelAbilityPreset(DMG_DEC_ID, 1, true) dec_spelld..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 0) ..setName("Knockbacker: Decrease Knockback") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNReplay-Speeddown.blp") ..presetHotkey("F") ..presetTooltipNormal(lvl -> "Decrease Damage [|cffFFCC00F|r]") ..presetTooltipNormalExtended(lvl -> "Less strength to the tauren") ..presetButtonPosNormal(3, 1) new UnitDefinition(KNOCKBACKER_ID, 'ugho') ..setAttacksEnabled(0) ..setTargetedAs("air") ..setAnimationCastBackswing(0) ..setScalingValue(0.8) ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTauren.blp") ..setButtonPositionX(3) ..setButtonPositionY(2) ..setModelFile("units\\orc\\Tauren\\Tauren.mdl") ..setSelectionScale(0.5) ..setUnitSoundSet("") ..setCollisionSize(0) ..setSpeedBase(180) ..setNormalAbilities(commaList('A01H', 'A01E', REMOVE_OBJECT_ID, GHOST_VIS_ID, INVULNERABILITY_ID)) ..setHotkey("C") ..setName("|cffA56308Knockbacker") ..setTooltipBasic("Train Knockbacker [C]") ..setTooltipExtended("Spawns a Glaive at|cffFFCC00 Rallypoint|n|n|cffD64219Kills Escapers") ..setUpgradesUsed("") ..setCanFlee(false) ..setHitPointsMaximumBase(100000000) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setGoldCost(0) ..setFoodCost(0) ..setHideMinimapDisplay(true)