/// <inheritdoc /> public void Execute(IEntity entity, SystemEventArgs args) { if (!(entity is IPlayerEntity player)) { this._logger.LogError($"Cannot execute DeathSystem. {entity.Object.Name} is not a player."); return; } IMapRevivalRegion revivalRegion = player.Object.CurrentMap.GetNearRevivalRegion(player.Object.Position); if (revivalRegion == null) { this._logger.LogError($"Cannot find any revival region for map '{player.Object.CurrentMap.Name}'."); return; } decimal recoveryRate = GameResources.Instance.Penalities.GetRevivalPenality(player.Object.Level) / 100; var jobData = player.PlayerData.JobData; int strength = player.Attributes[DefineAttributes.STR]; int stamina = player.Attributes[DefineAttributes.STA]; int dexterity = player.Attributes[DefineAttributes.DEX]; int intelligence = player.Attributes[DefineAttributes.INT]; player.Health.Hp = (int)(HealthFormulas.GetMaxOriginHp(player.Object.Level, stamina, jobData.MaxHpFactor) * recoveryRate); player.Health.Mp = (int)(HealthFormulas.GetMaxOriginMp(player.Object.Level, intelligence, jobData.MaxMpFactor, true) * recoveryRate); player.Health.Fp = (int)(HealthFormulas.GetMaxOriginFp(player.Object.Level, stamina, dexterity, strength, jobData.MaxFpFactor, true) * recoveryRate); if (player.Object.MapId != revivalRegion.MapId) { IMapInstance revivalMap = this._mapLoader.GetMapById(revivalRegion.MapId); if (revivalMap == null) { this._logger.LogError($"Cannot find revival map with id '{revivalRegion.MapId}'."); player.Connection.Server.DisconnectClient(player.Connection.Id); return; } revivalRegion = revivalMap.GetRevivalRegion(revivalRegion.Key); } var teleportEvent = new TeleportEventArgs(revivalRegion.MapId, revivalRegion.RevivalPosition.X, revivalRegion.RevivalPosition.Z); player.NotifySystem <TeleportSystem>(teleportEvent); WorldPacketFactory.SendMotion(player, ObjectMessageType.OBJMSG_ACC_STOP | ObjectMessageType.OBJMSG_STOP_TURN | ObjectMessageType.OBJMSG_STAND); WorldPacketFactory.SendPlayerRevival(player); WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.HP, player.Health.Hp); WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.MP, player.Health.Mp); WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.FP, player.Health.Fp); this.ProcessDeathPenality(player); }
/// <inheritdoc /> public void ResurectLodelight(IPlayerEntity player) { IMapRevivalRegion revivalRegion = player.Object.CurrentMap.GetNearRevivalRegion(player.Object.Position); if (revivalRegion == null) { _logger.LogError($"Cannot find any revival region for map '{player.Object.CurrentMap.Name}'."); return; } decimal recoveryRate = _gameResources.Penalities.GetRevivalPenality(player.Object.Level) / 100; var jobData = player.PlayerData.JobData; int strength = player.Attributes[DefineAttributes.STR]; int stamina = player.Attributes[DefineAttributes.STA]; int dexterity = player.Attributes[DefineAttributes.DEX]; int intelligence = player.Attributes[DefineAttributes.INT]; player.Attributes[DefineAttributes.HP] = (int)(HealthFormulas.GetMaxOriginHp(player.Object.Level, stamina, jobData.MaxHpFactor) * recoveryRate); player.Attributes[DefineAttributes.MP] = (int)(HealthFormulas.GetMaxOriginMp(player.Object.Level, intelligence, jobData.MaxMpFactor, true) * recoveryRate); player.Attributes[DefineAttributes.FP] = (int)(HealthFormulas.GetMaxOriginFp(player.Object.Level, stamina, dexterity, strength, jobData.MaxFpFactor, true) * recoveryRate); if (player.Object.MapId != revivalRegion.MapId) { IMapInstance revivalMap = _mapManager.GetMap(revivalRegion.MapId); if (revivalMap == null) { _logger.LogError($"Cannot find revival map with id '{revivalRegion.MapId}'."); // TODO: disconnect client //player.Connection.Server.DisconnectClient(player.Connection.Id); return; } revivalRegion = revivalMap.GetRevivalRegion(revivalRegion.Key); } _teleportSystem.Teleport(player, revivalRegion.MapId, revivalRegion.RevivalPosition.X, null, revivalRegion.RevivalPosition.Z); _moverPacketFactory.SendMotion(player, ObjectMessageType.OBJMSG_ACC_STOP | ObjectMessageType.OBJMSG_STOP_TURN | ObjectMessageType.OBJMSG_STAND); _playerPacketFactory.SendPlayerRevival(player); _moverPacketFactory.SendUpdateAttributes(player, DefineAttributes.HP, player.Attributes[DefineAttributes.HP]); _moverPacketFactory.SendUpdateAttributes(player, DefineAttributes.MP, player.Attributes[DefineAttributes.MP]); _moverPacketFactory.SendUpdateAttributes(player, DefineAttributes.FP, player.Attributes[DefineAttributes.FP]); ProcessDeathPenality(player); }
/// <summary> /// Load regions from the RGN file. /// </summary> private void LoadRgn() { string rgn = Path.Combine(this._mapPath, $"{this.Name}.rgn"); using (var rgnFile = new RgnFile(rgn)) { IEnumerable <IMapRespawnRegion> respawnersRgn = rgnFile.GetElements <RgnRespawn7>() .Select(x => MapRespawnRegion.FromRgnElement(x)); this._regions.AddRange(respawnersRgn); foreach (RgnRegion3 region in rgnFile.GetElements <RgnRegion3>()) { switch (region.Index) { case RegionInfo.RI_REVIVAL: int revivalMapId = this._worldInformations.RevivalMapId == 0 ? this.Id : this._worldInformations.RevivalMapId; var newRevivalRegion = MapRevivalRegion.FromRgnElement(region, revivalMapId); this._regions.Add(newRevivalRegion); break; case RegionInfo.RI_TRIGGER: this._regions.Add(MapTriggerRegion.FromRgnElement(region)); break; // TODO: load collector regions } } if (!this._regions.Any(x => x is IMapRevivalRegion)) { // Loads the default revival region if no revival region is loaded. this.DefaultRevivalRegion = new MapRevivalRegion(0, 0, 0, 0, this._worldInformations.RevivalMapId, this._worldInformations.RevivalKey, null, false, false); } } }
public void UseBlinkwingItem(IPlayerEntity player, Item blinkwing) { if (player.Object.Level < blinkwing.Data.LimitLevel) { _logger.LogError($"Player {player.Object.Name} cannot use {blinkwing.Data.Name}. Level too low."); _textPacketFactory.SendDefinedText(player, DefineText.TID_GAME_USINGNOTLEVEL); return; } // TODO: Check if player is sit // TODO: Check if player is on Kebaras island // TODO: Check if player is in guild war map TeleportEventArgs teleportEvent; if (blinkwing.Data.ItemKind3 == ItemKind3.TOWNBLINKWING) { IMapRevivalRegion revivalRegion = player.Object.CurrentMap.GetNearRevivalRegion(player.Object.Position); if (revivalRegion == null) { _logger.LogError($"Cannot find any revival region for map '{player.Object.CurrentMap.Name}'."); return; } if (player.Object.MapId != revivalRegion.MapId) { IMapInstance revivalMap = _mapManager.GetMap(revivalRegion.MapId); if (revivalMap == null) { _logger.LogError($"Cannot find revival map with id '{revivalRegion.MapId}'."); // TODO: disconnect client //player.Connection.Server.DisconnectClient(player.Connection.Id); return; } revivalRegion = revivalMap.GetRevivalRegion(revivalRegion.Key); } teleportEvent = new TeleportEventArgs(revivalRegion.MapId, revivalRegion.RevivalPosition.X, revivalRegion.RevivalPosition.Z, revivalRegion.RevivalPosition.Y); } else { teleportEvent = new TeleportEventArgs(blinkwing.Data.WeaponTypeId, // Map Id blinkwing.Data.ItemAtkOrder1, // X blinkwing.Data.ItemAtkOrder3, // Z blinkwing.Data.ItemAtkOrder2, // Y blinkwing.Data.ItemAtkOrder4); // Angle } player.Inventory.ItemInUseActionId = player.Delayer.DelayAction(TimeSpan.FromMilliseconds(blinkwing.Data.SkillReadyType), () => { _teleportSystem.Teleport(player, teleportEvent.MapId, teleportEvent.PositionX, teleportEvent.PositionY, teleportEvent.PositionZ, teleportEvent.Angle); _specialEffectSystem.SetStateModeBaseMotion(player, StateModeBaseMotion.BASEMOTION_OFF); player.Inventory.ItemInUseActionId = Guid.Empty; DecreaseItem(player, blinkwing); }); _specialEffectSystem.SetStateModeBaseMotion(player, StateModeBaseMotion.BASEMOTION_ON, blinkwing); }