public void MonsterSpawn() { _Logger.Debug($"Monster {monster.name} instanceId [{monster.instanceId}]"); monster.SetAgro(false); monsterMoving = false; _casting = false; _monsterWaiting = false; monster.SetGotoDistance(10); //monsterVelocity = 200; MonsterCoord spawnCoords = monster.monsterCoords.Find(x => x.coordIdx == 0); monster.x = spawnCoords.destination.X; monster.y = spawnCoords.destination.Y; monster.z = spawnCoords.destination.Z; monster.heading = (byte)GetHeading(monster.monsterCoords.Find(x => x.coordIdx == 1).destination); monster.hp.ToMax(); _respawnTime = monster.respawnTime; RecvDataNotifyMonsterData monsterData = new RecvDataNotifyMonsterData(monster); foreach (NecClient client in _map.clientLookup.GetAll()) { if (client.character.hasDied == false) { server.router.Send(client, monsterData.ToPacket()); } } _spawnMonster = false; monster.monsterVisible = true; monster.ClearAgroList(); //MonsterBattlePose(false); }
public MonsterTask(NecServer server, MonsterSpawn monster) { this.monster = monster; this.server = server; monsterFreeze = false; monsterActive = true; monsterMoving = false; _casting = false; _spawnMonster = true; monsterHome = null; this.monster.currentCoordIndex = 1; _pathingTick = 100; _agroTick = 200; _updateTime = _pathingTick; _agroMoveTime = 0; _agroTickMove = new MonsterTick(); _waitTime = 2000; _currentWait = 0; _moveTime = _updateTime; _monsterWaiting = true; agroRange = 1000; _agroCheckTime = -1; _agroDetectAngle = (float)Math.Cos(Math.PI / 1.9); _agroMoveAngle = (float)Math.Cos(Math.PI / 4); _castState = 0; _respawnTime = 10000; _currentSkill = 0; _skillInstanceId = 0; _map = this.server.maps.Get(this.monster.mapId); _currentDest = new Vector3(); }
public MonsterTask(NecServer server, MonsterSpawn monster) { _monster = monster; _server = server; monsterFreeze = false; monsterActive = true; monsterMoving = false; casting = false; spawnMonster = true; monsterHome = null; _monster.CurrentCoordIndex = 1; pathingTick = 100; agroTick = 200; updateTime = pathingTick; agroMoveTime = 0; agroTickMove = new MonsterTick(); waitTime = 2000; currentWait = 0; moveTime = updateTime; monsterWaiting = true; agroRange = 1000; agroCheckTime = -1; agroDetectAngle = (float)Math.Cos(Math.PI / 1.9); agroMoveAngle = (float)Math.Cos(Math.PI / 4); CastState = 0; respawnTime = 10000; currentSkill = 0; skillInstanceId = 0; Map = _server.Maps.Get(_monster.MapId); currentDest = new Vector3(); }
public void MonsterSpawn() { Logger.Debug($"Monster {_monster.Name} instanceId [{_monster.InstanceId}]"); _monster.SetAgro(false); monsterMoving = false; casting = false; monsterWaiting = false; _monster.SetGotoDistance(10); //monsterVelocity = 200; MonsterCoord spawnCoords = _monster.monsterCoords.Find(x => x.CoordIdx == 0); _monster.X = spawnCoords.destination.X; _monster.Y = spawnCoords.destination.Y; _monster.Z = spawnCoords.destination.Z; _monster.Heading = (byte)GetHeading(_monster.monsterCoords.Find(x => x.CoordIdx == 1).destination); _monster.Hp.toMax(); respawnTime = _monster.RespawnTime; RecvDataNotifyMonsterData monsterData = new RecvDataNotifyMonsterData(_monster); _server.Router.Send(Map, monsterData); spawnMonster = false; _monster.MonsterVisible = true; _monster.ClearAgroList(); //MonsterBattlePose(false); }
public List <MonsterCoord> SelectMonsterCoords() { List <MonsterCoord> monsterCoords = new List <MonsterCoord>(); ExecuteReader(SQL_SELECT_MONSTER_COORDS, reader => { while (reader.Read()) { MonsterCoord monsterCoord = ReadMonsterCoord(reader); monsterCoords.Add(monsterCoord); } }); return(monsterCoords); }
public List <MonsterCoord> SelectMonsterCoords() { List <MonsterCoord> monsterCoords = new List <MonsterCoord>(); ExecuteReader(SqlSelectMonsterCoords, reader => { while (reader.Read()) { MonsterCoord monsterCoord = ReadMonsterCoord(reader); monsterCoords.Add(monsterCoord); } }); return(monsterCoords); }
private MonsterCoord ReadMonsterCoord(DbDataReader reader) { MonsterCoord monsterCoord = new MonsterCoord(); Vector3 coords = new Vector3(); monsterCoord.id = GetInt32(reader, "id"); monsterCoord.monsterId = (uint)GetInt32(reader, "monster_id"); monsterCoord.mapId = (uint)GetInt32(reader, "map_id"); monsterCoord.coordIdx = GetInt32(reader, "coord_idx"); coords.X = GetFloat(reader, "x"); coords.Y = GetFloat(reader, "y"); coords.Z = GetFloat(reader, "z"); monsterCoord.destination = coords; return(monsterCoord); }
public bool UpdateMonsterCoord(MonsterCoord monsterCoord) { int rowsAffected = ExecuteNonQuery(SQL_UPDATE_MONSTER_COORD, command => { AddParameter(command, "@monster_id", monsterCoord.monsterId); AddParameter(command, "@map_id", monsterCoord.mapId); AddParameter(command, "@coord_idx", monsterCoord.coordIdx); AddParameter(command, "@x", monsterCoord.destination.X); AddParameter(command, "@y", monsterCoord.destination.Y); AddParameter(command, "@z", monsterCoord.destination.Z); AddParameter(command, "@id", monsterCoord.id); }); return(rowsAffected > NO_ROWS_AFFECTED); }
public bool UpdateMonsterCoord(MonsterCoord monsterCoord) { int rowsAffected = ExecuteNonQuery(SqlUpdateMonsterCoord, command => { AddParameter(command, "@monster_id", monsterCoord.MonsterId); AddParameter(command, "@map_id", monsterCoord.MapId); AddParameter(command, "@coord_idx", monsterCoord.CoordIdx); AddParameter(command, "@x", monsterCoord.destination.X); AddParameter(command, "@y", monsterCoord.destination.Y); AddParameter(command, "@z", monsterCoord.destination.Z); AddParameter(command, "@id", monsterCoord.Id); }); return(rowsAffected > NoRowsAffected); }
public List <MonsterCoord> SelectMonsterCoordsByMonsterId(int mapId) { List <MonsterCoord> monsterCoords = new List <MonsterCoord>(); ExecuteReader(SQL_SELECT_MONSTER_COORD_BY_MONSTER_ID, command => { AddParameter(command, "@monster_id", mapId); }, reader => { while (reader.Read()) { MonsterCoord monsterCoord = ReadMonsterCoord(reader); monsterCoords.Add(monsterCoord); } }); return(monsterCoords); }
public List <MonsterCoord> SelectMonsterCoordsById(int Id) { List <MonsterCoord> monsterCoords = new List <MonsterCoord>(); ExecuteReader(SqlSelectMonsterCoordById, command => { AddParameter(command, "@id", Id); }, reader => { while (reader.Read()) { MonsterCoord monsterCoord = ReadMonsterCoord(reader); monsterCoords.Add(monsterCoord); } }); return(monsterCoords); }
public bool InsertMonsterCoords(MonsterCoord monsterCoord) { int rowsAffected = ExecuteNonQuery(SQL_INSERT_MONSTER_COORD, command => { AddParameter(command, "@monster_id", monsterCoord.monsterId); AddParameter(command, "@map_id", monsterCoord.mapId); AddParameter(command, "@coord_idx", monsterCoord.coordIdx); AddParameter(command, "@x", monsterCoord.destination.X); AddParameter(command, "@y", monsterCoord.destination.Y); AddParameter(command, "@z", monsterCoord.destination.Z); }, out long autoIncrement); if (rowsAffected <= NO_ROWS_AFFECTED || autoIncrement <= NO_AUTO_INCREMENT) { return(false); } monsterCoord.id = (int)autoIncrement; return(true); }
public bool InsertMonsterCoords(MonsterCoord monsterCoord) { int rowsAffected = ExecuteNonQuery(SqlInsertMonsterCoord, command => { AddParameter(command, "@monster_id", monsterCoord.MonsterId); AddParameter(command, "@map_id", monsterCoord.MapId); AddParameter(command, "@coord_idx", monsterCoord.CoordIdx); AddParameter(command, "@x", monsterCoord.destination.X); AddParameter(command, "@y", monsterCoord.destination.Y); AddParameter(command, "@z", monsterCoord.destination.Z); }, out long autoIncrement); if (rowsAffected <= NoRowsAffected || autoIncrement <= NoAutoIncrement) { return(false); } monsterCoord.Id = (int)autoIncrement; return(true); }
private void MonsterMove(MonsterCoord monsterCoord) { //ShowVectorInfo(_monster.X, _monster.Y, monsterCoord.destination.X, monsterCoord.destination.Y); //ShowMonsterInfo(); if (!monsterMoving) { monsterMoving = true; OrientMonster(); monster.MonsterMove(server, monster.monsterWalkVelocity, 2, 0); } else { Vector3 destPos = new Vector3(monsterCoord.destination.X, monsterCoord.destination.Y, monsterCoord.destination.Z); Vector3 monsterPos = new Vector3(monster.x, monster.y, monster.z); Vector3 moveTo = Vector3.Subtract(destPos, monsterPos); float distance = GetDistance(monsterPos, destPos); float travelTime = distance / monster.monsterWalkVelocity; int tickDivisor = 1000 / _updateTime; if (distance >= monster.monsterWalkVelocity / tickDivisor) { monster.x = monster.x + moveTo.X / travelTime / tickDivisor; monster.y = monster.y + moveTo.Y / travelTime / tickDivisor; //_monster.Z = _monster.Z + (moveTo.Z / travelTime) / tickDivisor; } else { monster.x = destPos.X; monster.y = destPos.Y; monster.z = destPos.Z; } //Logger.Debug($"distance [{distance}] travelTime[{travelTime}] moveTo.X [{moveTo.X}] moveTo.Y [{moveTo.Y}] moveTo.Z [{moveTo.Z}]"); } // Logger.Debug($"distance [{distance}]"); // ShowMonsterInfo(); }
private void MonsterMove(MonsterCoord monsterCoord) { //ShowVectorInfo(_monster.X, _monster.Y, monsterCoord.destination.X, monsterCoord.destination.Y); //ShowMonsterInfo(); if (!monsterMoving) { monsterMoving = true; orientMonster(); _monster.MonsterMove(_server, _monster.MonsterWalkVelocity, (byte)2, (byte)0); } else { Vector3 destPos = new Vector3(monsterCoord.destination.X, monsterCoord.destination.Y, monsterCoord.destination.Z); Vector3 monsterPos = new Vector3(_monster.X, _monster.Y, _monster.Z); Vector3 moveTo = Vector3.Subtract(destPos, monsterPos); float distance = GetDistance(monsterPos, destPos); float travelTime = distance / _monster.MonsterWalkVelocity; int tickDivisor = 1000 / updateTime; if (distance >= _monster.MonsterWalkVelocity / tickDivisor) { _monster.X = _monster.X + (moveTo.X / travelTime) / tickDivisor; _monster.Y = _monster.Y + (moveTo.Y / travelTime) / tickDivisor; //_monster.Z = _monster.Z + (moveTo.Z / travelTime) / tickDivisor; } else { _monster.X = destPos.X; _monster.Y = destPos.Y; _monster.Z = destPos.Z; } //Logger.Debug($"distance [{distance}] travelTime[{travelTime}] moveTo.X [{moveTo.X}] moveTo.Y [{moveTo.Y}] moveTo.Z [{moveTo.Z}]"); } // Logger.Debug($"distance [{distance}]"); // ShowMonsterInfo(); }
private void MonsterPath() { MonsterCoord nextCoord = this.monster.monsterCoords.Find(x => x.coordIdx == this.monster.currentCoordIndex); Vector3 monster = new Vector3(this.monster.x, this.monster.y, this.monster.z); float distance = GetDistance(nextCoord.destination, monster); if (distance > this.monster.GetGotoDistance() && !monsterFreeze && !_monsterWaiting && !this.monster.GetAgro()) { MonsterMove(nextCoord); } else if (monsterMoving) { //Thread.Sleep(updateTime/2); //Allow for cases where the remaining distance is less than the gotoDistance this.monster.MonsterStop(server, 1, 0, .1F); monsterMoving = false; if (!this.monster.GetAgro()) { _monsterWaiting = true; _currentWait = 0; // Thread.Sleep(2000); if (this.monster.currentCoordIndex < this.monster.monsterCoords.Count - (this.monster.defaultCoords ? 1 : 2)) { this.monster.currentCoordIndex++; } else { this.monster.currentCoordIndex = 0; } this.monster.heading = (byte)GetHeading(this.monster.monsterCoords .Find(x => x.coordIdx == this.monster.currentCoordIndex).destination); } } if (MonsterCheck()) { _Logger.Debug("MonsterCheck returned true"); return; } if (MonsterAgroCheck()) { this.monster.SetAgro(true); } if (this.monster.GetAgro()) { monsterMoving = false; this.monster.MonsterStop(server, 1, 0, 0.1F); this.monster.MonsterHate(server, true, this.monster.GetCurrentTarget().instanceId); this.monster.SendBattlePoseStartNotify(server); _updateTime = _agroTick; if (this.monster.monsterId == 100201) { this.monster.SetGotoDistance(1000); //Caster Distance } else { this.monster.SetGotoDistance(200); //Melee Distance } //monsterVelocity = 500; _moveTime = _agroTick; _agroCheckTime = 0; OrientMonster(); MonsterAgroMove(); } }