package Builder import initlater Selector import initlater PlayerData import WarningBuff import Assets import Projectile import ClosureTimers public class Builder extends UnitEntity construct(vec3 pos, PlayerData owner, int id) super(createUnit(owner.p, id, pos, angle(0))) actor..addAbility(GHOST_VIS_ID)..addAbility('AInv')..addAbility('Ahrp') if id == FAT_ID actor.setTimeScale(0.25) owner.p.panCamToTimed(actor, 0) actor.issueImmediateOrder("repairon") owner.p.selectSingle(actor) new WarningBuff().apply(actor) super.update() actor.setXYZReal(pos) ondestroy pDatas[owner.getId()].builder = null public function getPathingNormal(vec2 pos) returns vec2 let numberOfTests = 9 let radius = 32. vec2 addedVecs = vec2(0, 0) for int i = 0 to numberOfTests-1 let direction = vec2(0,0).polarOffset((i*2*bj_PI/numberOfTests).asAngleRadians(), radius) let testPoint = pos + direction let eff = addEffect(Abilities.bansheeMissile, testPoint) doAfter(1, () -> eff.destr()) if testPoint.isTerrainWalkable() addedVecs += direction return addedVecs.setLength(1.) * (-1.) public function getBounceVec(vec3 vel3, vec2 nor2) returns vec3 let nor3 = nor2.toVec3() let pv3 = vel3.project(nor3) vec2 pv2 = pv3.toVec2() pv2 *= (-1.9) return vel3 + pv2 class Ball extends Fx2Entity construct(vec3 pos, player owner, vec2 target) super(owner, pos, 32, pos.angleTo2d(target), Abilities.fireBallMissile) setVel(pos.angleTo2d(target).toVec(10).toVec3()) override function update() super.update() if not pos.toVec2().isTerrainWalkable() var normal = getPathingNormal(pos.toVec2()) if(normal.lengthSq() == 0) normal = (vel.norm() * -1).toVec2() if(vel.norm().toVec2().dot(normal) < 0) print("bounced " + vel.norm().toVec2().dot(normal).toString()) vel = getBounceVec(vel, normal) pos += vel fx.eff.setPos(pos) fx.eff.setYaw(pos.angleTo2d(pos+vel))