public void healChampions(Map map, long diff) { healTickTimer += diff; if (healTickTimer > 1000) { healTickTimer = 0; int team = 0; foreach (var f in healLocations) { foreach (var c in map.getChampionsInRange(f, fountainSize)) { if (c.getTeam() == Convert.toTeamId(team)) { var hp = c.getStats().getCurrentHealth(); var maxHP = c.getStats().getMaxHealth(); if (hp + maxHP * PERCENT_MAX_HEALTH_HEAL < maxHP) c.getStats().setCurrentHealth(hp + maxHP * PERCENT_MAX_HEALTH_HEAL); else if (hp < maxHP) c.getStats().setCurrentHealth(maxHP); var mp = c.getStats().getCurrentMana(); var maxMp = c.getStats().getMaxMana(); if (mp + maxMp * PERCENT_MAX_MANA_HEAL < maxMp) c.getStats().setCurrentMana(mp + maxMp * PERCENT_MAX_MANA_HEAL); else if (mp < maxMp) c.getStats().setCurrentMana(maxMp); } } team++; } } }
public Monster(Map map, int id, float x, float y, float facingX, float facingY, string model, string name) : base(map, id, model, new Stats(), 40, x, y) { setTeam(Convert.toTeamId(2)); for (int i = 0; i < 3; i++) setVisibleByTeam(i, true); setMoveOrder(MoveOrder.MOVE_ORDER_MOVE); facing = new Vector2(facingX, facingY); stats.setAttackSpeedMultiplier(1.0f); this.name = name; Inibin inibin; if (!RAFManager.getInstance().readInibin("DATA/Characters/" + model + "/" + model + ".inibin", out inibin)) { Logger.LogCoreError("couldn't find monster stats for " + model); return; } stats.setCurrentHealth(inibin.getFloatValue("Data", "BaseHP")); stats.setMaxHealth(inibin.getFloatValue("Data", "BaseHP")); // stats.setCurrentMana(inibin.getFloatValue("Data", "BaseMP")); // stats.setMaxMana(inibin.getFloatValue("Data", "BaseMP")); stats.setBaseAd(inibin.getFloatValue("DATA", "BaseDamage")); stats.setRange(inibin.getFloatValue("DATA", "AttackRange")); stats.setBaseMovementSpeed(inibin.getFloatValue("DATA", "MoveSpeed")); stats.setArmor(inibin.getFloatValue("DATA", "Armor")); stats.setMagicArmor(inibin.getFloatValue("DATA", "SpellBlock")); stats.setHp5(inibin.getFloatValue("DATA", "BaseStaticHPRegen")); stats.setMp5(inibin.getFloatValue("DATA", "BaseStaticMPRegen")); stats.setHealthPerLevel(inibin.getFloatValue("DATA", "HPPerLevel")); stats.setManaPerLevel(inibin.getFloatValue("DATA", "MPPerLevel")); stats.setAdPerLevel(inibin.getFloatValue("DATA", "DamagePerLevel")); stats.setArmorPerLevel(inibin.getFloatValue("DATA", "ArmorPerLevel")); stats.setMagicArmorPerLevel(inibin.getFloatValue("DATA", "SpellBlockPerLevel")); stats.setHp5RegenPerLevel(inibin.getFloatValue("DATA", "HPRegenPerLevel")); stats.setMp5RegenPerLevel(inibin.getFloatValue("DATA", "MPRegenPerLevel")); stats.setBaseAttackSpeed(0.625f / (1 + inibin.getFloatValue("DATA", "AttackDelayOffsetPercent"))); setMelee(inibin.getBoolValue("DATA", "IsMelee")); setCollisionRadius(inibin.getIntValue("DATA", "PathfindingCollisionRadius")); Inibin autoAttack; if (!RAFManager.getInstance().readInibin("DATA/Characters/" + model + "/Spells/" + model + "BasicAttack.inibin", out autoAttack)) { if (!RAFManager.getInstance().readInibin("DATA/Spells/" + model + "BasicAttack.inibin", out autoAttack)) { Logger.LogCoreError("Couldn't find monster auto-attack data for " + model); return; } } autoAttackDelay = autoAttack.getFloatValue("SpellData", "castFrame") / 30.0f; autoAttackProjectileSpeed = autoAttack.getFloatValue("SpellData", "MissileSpeed"); }
public LevelProp(Map map, int id, float x, float y, float z, float dirX, float dirY, float dirZ, float unk1, float unk2, string name, string type) : base(map, id, x, y, 0) { this.z = z; this.dirX = dirX; this.dirY = dirY; this.dirZ = dirZ; this.unk1 = unk1; this.unk2 = unk2; this.name = name; this.type = type; }
public CollisionHandler(Map map) { chart = map; Pathfinder.setMap(map); // Initialise the pathfinder. divisionCount = -1; // We have no divisions yet. Waiting for the AIMesh to initialise. if (simple) Logger.LogCoreWarning("Using simple collision. This could impact performance with larger amounts of minions."); }
public Turret(Map map, int id, string name, float x = 0, float y = 0, float hp = 0, float ad = 0, int team = 0) : base(map, id, "", new TurretStats(), 50, x, y, 1200) { this.name = name; stats.setCurrentHealth(hp); stats.setMaxHealth(hp); stats.setBaseAd(ad); stats.setRange(TURRET_RANGE); autoAttackDelay = 4.95f / 30.0f; autoAttackProjectileSpeed = 1200.0f; setTeam(Convert.toTeamId(team)); }
public GameObject(Map map, int id, float x, float y, int collisionRadius, int visionRadius = 0) : base(x, y) { this.map = map; this.id = id; this.target = null; this.collisionRadius = collisionRadius; this.visionRadius = visionRadius; this.team = 0; this.movementUpdated = false; this.toRemove = false; this.attackerCount = 0; this.dashing = false; this.visibleByTeam = new bool[] { false, false, false }; }
public Projectile(Map map, int id, float x, float y, int collisionRadius, Unit owner, Target target, Spell originSpell, float moveSpeed, int projectileId, int flags = 0) : base(map, id, x, y, collisionRadius) { this.originSpell = originSpell; this.moveSpeed = moveSpeed; this.owner = owner; this.projectileId = projectileId; this.flags = flags; setTarget(target); if (!target.isSimpleTarget()) ((GameObject)target).incrementAttackerCount(); owner.incrementAttackerCount(); }
public Minion(Map map, int id, MinionSpawnType type, MinionSpawnPosition position, List<Vector2> mainWaypoints) : base(map, id, "", new MinionStats(), 40, 0, 0, 1100) { this.type = type; this.spawnPosition = position; this.mainWaypoints = mainWaypoints; this.curMainWaypoint = 0; var spawnSpecifics = map.getMinionSpawnPosition(spawnPosition); setTeam(Convert.toTeamId(spawnSpecifics.Item1)); setPosition(spawnSpecifics.Item2.X, spawnSpecifics.Item2.Y); map.setMinionStats(this); // Let the map decide how strong this minion has to be. string minionModel = ""; if (spawnSpecifics.Item1 == 0) // If we're the blue side minionModel += "Blue_Minion_"; // make it a blue minion else minionModel += "Red_Minion_"; // otherwise make it a red minion // Finish model name with type if (type == MinionSpawnType.MINION_TYPE_MELEE) minionModel += "Basic"; else if (type == MinionSpawnType.MINION_TYPE_CASTER) minionModel += "Wizard"; else minionModel += "MechCannon"; // Set model setModel(minionModel); if (mainWaypoints.Count > 0) // If we have lane path instructions from the map setWaypoints(new List<Vector2> { mainWaypoints[0], mainWaypoints[1] }); // Follow these instructions else setWaypoints(new List<Vector2> { new Vector2(x, y), new Vector2(x, y) }); // Otherwise path to own position. (Stand still) setMoveOrder(MoveOrder.MOVE_ORDER_ATTACKMOVE); }
private List<Vector2> readWaypoints(byte[] buffer, int coordCount, Map map) { var reader = new BinaryReader(new MemoryStream(buffer)); var mapSize = map.getSize(); int vectorCount = coordCount / 2; var vMoves = new List<Vector2>(); var lastCoord = new Vector2(0.0f, 0.0f); reader.BaseStream.Position = (coordCount + 5) / 8 + coordCount % 2; for (int i = 0; i < vectorCount; i++) { if (GetBitmaskValue(buffer, 2 * i - 2)) lastCoord.X += reader.ReadByte(); else lastCoord.X = reader.ReadInt16(); if (GetBitmaskValue(buffer, 2 * i - 1)) lastCoord.Y += reader.ReadByte(); else lastCoord.Y = reader.ReadInt16(); vMoves.Add(new Vector2(2.0f * lastCoord.X + mapSize.X, 2.0f * lastCoord.Y + mapSize.Y)); } return vMoves; }
public void setHealLocations(Map map) { for (int i = 0; i < NUM_SIDES; i++) healLocations.Add(map.getRespawnLocation(i)); }
internal static void setMap(Map m) { map = m; }
public static Champion getChampionFromType(string type, Map map, int id, int playerId) { return new Champion(type, map, id, playerId); }
public Unit(Map map, int id, string model, Stats stats, int collisionRadius = 40, float x = 0, float y = 0, int visionRadius = 0) : base(map, id, x, y, collisionRadius, visionRadius) { this.stats = stats; this.model = model; }
public Champion(string type, Map map, int id, int playerId) : base(map, id, type, new Stats(), 30, 0, 0, 1200) { this.type = type; this.playerId = playerId; stats.setGold(475.0f); stats.setAttackSpeedMultiplier(1.0f); stats.setGoldPerSecond(map.getGoldPerSecond()); stats.setGeneratingGold(false); Inibin inibin; if (!RAFManager.getInstance().readInibin("DATA/Characters/" + type + "/" + type + ".inibin", out inibin)) { Logger.LogCoreError("couldn't find champion stats for " + type); return; } stats.setCurrentHealth(inibin.getFloatValue("Data", "BaseHP")); stats.setMaxHealth(inibin.getFloatValue("Data", "BaseHP")); stats.setCurrentMana(inibin.getFloatValue("Data", "BaseMP")); stats.setMaxMana(inibin.getFloatValue("Data", "BaseMP")); stats.setBaseAd(inibin.getFloatValue("DATA", "BaseDamage")); stats.setRange(inibin.getFloatValue("DATA", "AttackRange")); stats.setBaseMovementSpeed(inibin.getFloatValue("DATA", "MoveSpeed")); stats.setArmor(inibin.getFloatValue("DATA", "Armor")); stats.setMagicArmor(inibin.getFloatValue("DATA", "SpellBlock")); stats.setHp5(inibin.getFloatValue("DATA", "BaseStaticHPRegen")); stats.setMp5(inibin.getFloatValue("DATA", "BaseStaticMPRegen")); stats.setHealthPerLevel(inibin.getFloatValue("DATA", "HPPerLevel")); stats.setManaPerLevel(inibin.getFloatValue("DATA", "MPPerLevel")); stats.setAdPerLevel(inibin.getFloatValue("DATA", "DamagePerLevel")); stats.setArmorPerLevel(inibin.getFloatValue("DATA", "ArmorPerLevel")); stats.setMagicArmorPerLevel(inibin.getFloatValue("DATA", "SpellBlockPerLevel")); stats.setHp5RegenPerLevel(inibin.getFloatValue("DATA", "HPRegenPerLevel")); stats.setMp5RegenPerLevel(inibin.getFloatValue("DATA", "MPRegenPerLevel")); stats.setBaseAttackSpeed(0.625f / (1 + inibin.getFloatValue("DATA", "AttackDelayOffsetPercent"))); spells.Add(new Spell(this, inibin.getStringValue("Data", "Spell1"), 0)); spells.Add(new Spell(this, inibin.getStringValue("Data", "Spell2"), 1)); spells.Add(new Spell(this, inibin.getStringValue("Data", "Spell3"), 2)); spells.Add(new Spell(this, inibin.getStringValue("Data", "Spell4"), 3)); setMelee(inibin.getBoolValue("DATA", "IsMelee")); setCollisionRadius(inibin.getIntValue("DATA", "PathfindingCollisionRadius")); Inibin autoAttack; if (!RAFManager.getInstance().readInibin("DATA/Characters/" + type + "/Spells/" + type + "BasicAttack.inibin", out autoAttack)) { if (!RAFManager.getInstance().readInibin("DATA/Spells/" + type + "BasicAttack.inibin", out autoAttack)) { Logger.LogCoreError("Couldn't find champion auto-attack data for " + type); return; } } autoAttackDelay = autoAttack.getFloatValue("SpellData", "castFrame") / 30.0f; autoAttackProjectileSpeed = autoAttack.getFloatValue("SpellData", "MissileSpeed"); //F**k LUA /* var scriptloc = "../../lua/champions/" + getType() + "/Passive.lua"; Logger.LogCoreInfo("Loading " + scriptloc); try { unitScript = LuaScript(true);//fix unitScript.lua.set("me", this); unitScript.loadScript(scriptloc); unitScript.lua.set_function("dealMagicDamage", [this](Unit * target, float amount) { this.dealDamageTo(target, amount, DAMAGE_TYPE_MAGICAL, DAMAGE_SOURCE_SPELL); }); unitScript.lua.set_function("addBuff", [this](Buff b, Unit * target){ target.addBuff(new Buff(b)); return; }); unitScript.lua.set_function("addParticleTarget", [this](const std::string&particle, Target* u) { this.getMap().getGame().notifyParticleSpawn(this, u, particle); return; }); // unitScript.lua.set ("me", this); } catch { }*/ }
private const double REFRESH_RATE = 16.666; // 60 fps public bool initialize(ENetAddress address, string baseKey) { if (enet_initialize() < 0) return false; _server = enet_host_create(&address, new IntPtr(32), new IntPtr(32), 0, 0); if (_server == null) return false; var key = System.Convert.FromBase64String(baseKey); if (key.Length <= 0) return false; fixed (byte* s = key) { _blowfish = BlowFishCS.BlowFishCS.BlowFishCreate(s, new IntPtr(16)); } PacketHandlerManager.getInstace().InitHandlers(this); map = new SummonersRift(this); PacketNotifier.setMap(map); //TODO: better lua implementation var id = 1; foreach (var p in Config.players) { var player = new ClientInfo(p.Value.rank, ((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE), p.Value.ribbon, p.Value.icon); player.setName(p.Value.name); player.setSkinNo(p.Value.skin); player.userId = id; // same as StartClient.bat id++; player.setSummoners(strToId(p.Value.summoner1), strToId(p.Value.summoner2)); Champion c = ChampionFactory.getChampionFromType(p.Value.champion, map, GetNewNetID(), (int)player.userId); var pos = c.getRespawnPosition(); c.setPosition(pos.Item1, pos.Item2); c.setTeam((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE); c.levelUp(); player.setChampion(c); var pair = new Pair<uint, ClientInfo>(); pair.Item2 = player; players.Add(pair); } // Uncomment the following to get 2-players /*ClientInfo* player2 = new ClientInfo("GOLD", TEAM_PURPLE); player2->setName("tseT"); Champion* c2 = ChampionFactory::getChampionFromType("Ezreal", map, GetNewNetID()); c2->setPosition(100.f, 273.55f); c2->setTeam(1); map->addObject(c2); player2->setChampion(c2); player2->setSkinNo(4); player2->userId = 2; // same as StartClient.bat player2->setSummoners(SPL_Ignite, SPL_Flash); players.push_back(player2);*/ return _isAlive = true; }
//see PKT_S2C_CharStats mask //TODO movement public MovementAns(GameObject actor, Map map) : base(PacketCmdS2C.PKT_S2C_MoveAns) { var waypoints = actor.getWaypoints(); buffer.Write((short)1); //count buffer.Write((byte)(2 * waypoints.Count)); buffer.Write((int)actor.getNetId()); int startPos = (int)buffer.BaseStream.Position; int coordCount = 2 * waypoints.Count(); var maskSize = (coordCount + 5) / 8; //mask size //buffer.reserve(pos + maskSize + coordCount * sizeof(short)); //reserve max total size for (uint i = 0; i < maskSize; i++) { buffer.Write((byte)0); } var lastCoord = new Vector2(); for (int i = 0; i < waypoints.Count; i++) { var mapSize = map.getSize(); var curVector = new Vector2((waypoints[i].X - mapSize.X) / 2, (waypoints[i].Y - mapSize.Y) / 2); var relative = new Vector2(curVector.X - lastCoord.X, curVector.Y - lastCoord.Y); var isAbsolute = new Tuple<bool, bool>( i == 0 || relative.X < sbyte.MinValue || relative.X > sbyte.MaxValue, i == 0 || relative.Y < sbyte.MinValue || relative.Y > sbyte.MaxValue); Change(SetBitmaskValue(GetBytes(), startPos, (2 * i - 2), !isAbsolute.Item1)); if (isAbsolute.Item1) buffer.Write((short)curVector.X); else buffer.Write((byte)relative.X); Change(SetBitmaskValue(GetBytes(), startPos, (2 * i - 1), !isAbsolute.Item2)); if (isAbsolute.Item2) buffer.Write((short)curVector.Y); else buffer.Write((byte)relative.Y); lastCoord = curVector; } }
public Minion(Map map, int id, MinionSpawnType type, MinionSpawnPosition position) : this(map, id, type, position, new List<Vector2>()) { }
public static void setMap(Map map)// { chart = map; mesh = chart->getAIMesh(); } { chart = map; }
public void insertObstructions(Map chart, AIMesh mesh) { if (mesh != null) { // Now to draw the mesh onto the thing. if (mesh.isLoaded()) // if we have loaded the mesh for (int x = 0; x < GRID_WIDTH; x++) // for every grid piece for (int y = 0; y < GRID_HEIGHT; y++) { Vector2 translated = fromGridToPosition(new Vector2(x, y)); if (!mesh.isWalkable(translated.X, translated.Y)) // If there's nothing at this position map[x, y].occupied = true; // This is obstructed } } if (chart != null) { var objects = chart.getObjects(); foreach (var i in objects) // For every object { if (!(i.Value is Minion) && !(i.Value is Champion)) continue; Vector2 gridPos = fromPositionToGrid(i.Value.getPosition()); // get the position in grid size int radius = ((int)Math.Ceiling((float)i.Value.getCollisionRadius() / (float)PATH_DEFAULT_BOX_SIZE(mesh.getSize()))) / 2; // How many boxes does the radius of this object cover? for (int dx = -radius; dx < radius; dx++) // For the whole radius in the width if (gridPos.X + dx >= 0 && gridPos.X + dx < GRID_WIDTH) // As long as we're in the map (x) for (int dy = -radius; dy < radius; dy++) // for the whole radius in the y if (gridPos.Y + dy >= 0 && gridPos.Y + dy < GRID_HEIGHT) // As long as we're in the map (y) map[(int)gridPos.X + dx, (int)gridPos.Y + dy].occupied = true; // Occupy this piece of the map. } } /* if (debugOutput()) { auto width = GRID_WIDTH; auto height = GRID_HEIGHT; #define MIN(a,b) (((a)>(b))?(b):(a)) #define MAX(a,b) (((a)>(b))?(a):(b)) std::ofstream imageFile("..\\..\\test.tga", std::ios::out | std::ios::binary); if (!imageFile) return; // The image header unsigned char header[18] = { 0 }; header[2] = 1; // truecolor header[12] = width & 0xFF; header[13] = (width >> 8) & 0xFF; header[14] = height & 0xFF; header[15] = (height >> 8) & 0xFF; header[16] = 24; // bits per pixel imageFile.write((const char*)header, 18); //for (int y = 0; y < height; y++) for (int y = height - 1; y >= 0; y--) for (int x = 0; x < width; x++) { // blue imageFile.put(map[x][y].occupied * 128); // green imageFile.put(map[x][y].occupied * 128); // red imageFile.put(map[x][y].occupied * 128); } // The file footer. This part is totally optional. static const char footer[26] = "\0\0\0\0" // no extension area "\0\0\0\0" // no developer directory "TRUEVISION-XFILE" // Yep, this is a TGA file "."; imageFile.write(footer, 26); imageFile.close(); }*/ }