package BasicSpells import PhysicsProjectile import ChannelAbilityPreset import ItemObjEditing import initlater Ball import BuilderConstants public constant BALL_SPELL_ID = compiletime(ABIL_ID_GEN.next()) public constant BALL_ITEM_ID = compiletime(ABIL_ID_GEN.next()) public class BallProjectile extends AirPhysicsProjectile BallItem ballitem construct(unit caster, vec2 target, BallItem itm) super(caster.getPos3with(128), 32, caster.getOwner(), caster.getPos().angleTo(target), "Cannonball.mdx") setSpeed(17) fx.setTintFromPlayer(caster.getOwner()) setMass(145) setRestitution(0.625) ballitem = itm override function update() super.update() let lensq = vel.lengthSquared() if lensq < 1 ballitem.onIdle(pos.toVec2()) silent = true terminate() function onCast() let id = GetSpellAbilityId() if id == BALL_SPELL_ID let caster = GetSpellAbilityUnit() let tpos = EventData.getSpellTargetPos() caster.removeAbility(BALL_SPELL_ID) item itm = null for i = 0 to 5 let itm2 = UnitItemInSlot(caster, i) if itm2.getTypeId() == BALL_ITEM_ID itm = itm2 caster.removeItem(itm2) break if itm != null new BallProjectile(caster, tpos, itm.getEntity() castTo BallItem) init EventListener.add(EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) @objectgen function genAbils() new ChannelAbilityPreset(BALL_SPELL_ID, 1, true) ..setHeroAbility(false) ..setName("Throw a ball") ..presetTooltipNormal(lvl -> "Throw Ball") ..presetTargetTypes(Targettype.POINT) ..presetCastRange(lvl -> 300.) ..presetManaCost(lvl -> 0) ..presetHotkey("K") ..presetButtonPosNormal(1,1) ..presetIcon("BTNGolemStormBolt") new ItemDefinition(BALL_ITEM_ID, 'rst1') ..setGoldCost(0)..setLumberCost(0) ..setAbilities("")..setName("Ball")..setDescription("Throwable.") ..setTooltipExtended("It is round") ..setDroppedWhenCarrierDies(false) ..setTooltipBasic("Do eet")..setModelUsed("Cannonball.mdx") ..setInterfaceIcon(Icons.bTNGolemStormBolt)