package InstantDummyCaster import NoWurst import MagicFunctions import ObjectIdGenerator import Basics import ObjectIds import Unit import Widget import AbilityObjEditing import MapBounds import Annotations /** * Dummy caster for casting instant spells. * vec3 can be used for casterpos so that any effects/projectiles on/from caster will be on given height. * * Can't cast channeling spells or impale. * If not specified otherwise, any damage from spells will be inflicted by DUMMY_PLAYER. * Spells are recommended to be 0 cooldown, 92083 cast range and 0 manacost. */ public class InstantDummyCaster protected static unit caster private construct() private static function prepare(player owner, int id, int lvl, vec3 pos) caster..addAbility(id)..setMana(1000000) if pos.inBounds() caster.setXYZ(pos) if lvl > 1 caster.setAbilityLevel(id, lvl) if owner != null caster.setOwner(owner, false) private static function finish(int id) caster.setOwner(DUMMY_PLAYER, false) caster.removeAbility(id) caster.setPos(boundMax) static function castImmediate(player owner, int abilityId, int lvl, int orderId, vec3 pos) returns boolean prepare(owner, abilityId, lvl, pos) let success = caster.issueImmediateOrderById(orderId) finish(abilityId) return success static function castTarget(player owner, int abilityId, int lvl, int orderId, widget target, vec3 casterPos) returns boolean prepare(owner, abilityId, lvl, casterPos) caster.setFacing(caster.getPos().angleTo(target.getPos())) let success = caster.issueTargetOrderById(orderId, target) finish(abilityId) return success static function castPoint(player owner, int abilityId, int lvl, int orderId, vec2 targetPos, vec3 casterPos) returns boolean prepare(owner, abilityId, lvl, casterPos) caster.setFacing(caster.getPos().angleTo(targetPos)) let success = caster.issuePointOrderById(orderId, targetPos) finish(abilityId) return success // Use with Orders package static function castTarget(player owner, int abilityId, int lvl, int orderId, widget target) returns boolean return castTarget(owner, abilityId, lvl, orderId, target, vec2(GetWidgetX(target), GetWidgetY(target)).toVec3()) static function castPoint(player owner, int abilityId, int lvl, int orderId, vec2 targetPos) returns boolean return castPoint(owner, abilityId, lvl, orderId, targetPos, targetPos.toVec3()) // string orders / vec2 casterpos wrappers static function castImmediate(player owner, int abilityId, int lvl, string order, vec3 pos) returns boolean return castImmediate(owner, abilityId, lvl, OrderId(order), pos) static function castImmediate(player owner, int abilityId, int lvl, string order, vec2 pos) returns boolean return castImmediate(owner, abilityId, lvl, OrderId(order), pos.toVec3()) static function castImmediate(player owner, int abilityId, int lvl, int orderId, vec2 pos) returns boolean return castImmediate(owner, abilityId, lvl, orderId, pos.toVec3()) static function castTarget(player owner, int abilityId, int lvl, string order, widget target) returns boolean return castTarget(owner, abilityId, lvl, OrderId(order), target) static function castTarget(player owner, int abilityId, int lvl, string order, widget target, vec3 casterPos) returns boolean return castTarget(owner, abilityId, lvl, OrderId(order), target, casterPos) static function castTarget(player owner, int abilityId, int lvl, string order, widget target, vec2 casterPos) returns boolean return castTarget(owner, abilityId, lvl, OrderId(order), target, casterPos.toVec3()) static function castTarget(player owner, int abilityId, int lvl, int orderId, widget target, vec2 casterPos) returns boolean return castTarget(owner, abilityId, lvl, orderId, target, casterPos.toVec3()) static function castPoint(player owner, int abilityId, int lvl, string order, vec2 targetPos) returns boolean return castPoint(owner, abilityId, lvl, OrderId(order), targetPos) static function castPoint(player owner, int abilityId, int lvl, string order, vec2 targetPos, vec3 casterPos) returns boolean return castPoint(owner, abilityId, lvl, OrderId(order), targetPos, casterPos) static function castPoint(player owner, int abilityId, int lvl, string order, vec2 targetPos, vec2 casterPos) returns boolean return castPoint(owner, abilityId, lvl, OrderId(order), targetPos, casterPos.toVec3()) static function castPoint(player owner, int abilityId, int lvl, int orderId, vec2 targetPos, vec2 casterPos) returns boolean return castPoint(owner, abilityId, lvl, orderId, targetPos, casterPos.toVec3()) public constant DUMMY_CASTER_UNIT_ID = compiletime(UNIT_ID_GEN.next()) public constant DUMMY_ROOT_ABIL_ID = compiletime(ABIL_ID_GEN.next()) init InstantDummyCaster.caster = createUnit(DUMMY_PLAYER, DUMMY_CASTER_UNIT_ID, boundMax, angle(0)) ..setPathing(false)..addAbility(HEIGHT_ENABLER)..removeAbility(HEIGHT_ENABLER)..addAbility(DUMMY_ROOT_ABIL_ID)..removeAbility(DUMMY_ROOT_ABIL_ID) @compiletime function generateObject() new AbilityDefinitionRootAncients(DUMMY_ROOT_ABIL_ID) new UnitDefinition(DUMMY_CASTER_UNIT_ID, 'ewsp') ..setName("Dummy Caster") ..setManaMaximum(1000000) ..setMovementType(MovementType.Fly) ..setUpgradesUsed("") ..setCollisionSize(0.0) ..setStructuresBuilt("") ..setRace(Race.Commoner) ..setFoodCost(0) ..setArmorType(ArmorType.Divine) ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNtemp.blp") ..setSpeedBase(522) ..setModelFile("dummy.mdl") ..setAnimationBlendTimeseconds(0.0) ..setAnimationCastBackswing(0.0) ..setMaximumPitchAngledegrees(0.0) ..setMaximumRollAngledegrees(0.0) ..setTurnRate(3) ..setArtSpecial("") ..setProjectileImpactZ(0.0) ..setProjectileLaunchZ(0.0) ..setNameEditorSuffix("(Basics)") ..setSightRadiusDay(1) ..setSightRadiusNight(1) ..setUnitClassification("_") ..setPropulsionWindowdegrees(1.0) ..setTooltipBasic("") ..setNormalAbilities(commaList(LOCUST_ID, GHOST_INVIS_ID)) ..setCollisionSize(0)