Skip to content

Commit

Permalink
1.修復裝備魔法攻擊力
Browse files Browse the repository at this point in the history
2.修復寵物
3.修復玩家受到傷害異常
4.修復怪物攻擊玩家
5.修復全部的技能任務
6.修復使用飛鏢
7.修復怪物移動類型、攻擊類型、攻擊範圍、添加狀態
8.修復攻擊距離
9.修正錯誤
  • Loading branch information
a12182565 committed Jun 15, 2016
1 parent d24c7e9 commit e6d72d8
Show file tree
Hide file tree
Showing 36 changed files with 2,743 additions and 315 deletions.
1 change: 1 addition & 0 deletions Server/CharServer/CharServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Compile Include="Characters\CharacterItems.cs" />
<Compile Include="Characters\CharacterSkills.cs" />
<Compile Include="Characters\CharacterStorages.cs" />
<Compile Include="Characters\CharacterUseSlot.cs" />
<Compile Include="CharServer.cs" />
<Compile Include="Interoperability\InteroperabilityClient.cs" />
<Compile Include="Item.cs" />
Expand Down
6 changes: 6 additions & 0 deletions Server/CharServer/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public sealed class Character
public CharacterSkills Skills { get; private set; }
public CharacterKeyMap Keymap { get; private set; }

public CharacterUseSlot UseSlot { get; private set; }

private bool Assigned { get; set; }

public Character(int id = 0, Client gc = null)
Expand All @@ -71,6 +73,7 @@ public Character(int id = 0, Client gc = null)
this.Storages = new CharacterStorages(this);
this.Skills = new CharacterSkills(this);
this.Keymap = new CharacterKeyMap(this);
this.UseSlot = new CharacterUseSlot(this);
}

public void Load(bool IsFullLoad = true)
Expand Down Expand Up @@ -131,6 +134,7 @@ public void Load(bool IsFullLoad = true)
this.Storages.Load();
this.Skills.Load();
this.Keymap.Load();
this.UseSlot.Load();
}

public void Save()
Expand Down Expand Up @@ -199,6 +203,7 @@ public void Save()
this.Storages.Save();
this.Skills.Save();
this.Keymap.Save();
this.UseSlot.Save();

Log.Inform("角色'{0}'的資料已儲存至資料庫。", this.Name);
}
Expand All @@ -209,6 +214,7 @@ public void Delete()
this.Storages.Delete();
this.Skills.Delete();
this.Keymap.Delete();
this.UseSlot.Delete();

Database.Delete("Characters", "id = '{0}'", this.ID);

Expand Down
53 changes: 53 additions & 0 deletions Server/CharServer/Characters/CharacterUseSlot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Server.Common.Constants;
using Server.Common.Data;
using Server.Ghost.Characters;
using System.Collections.Generic;

namespace Server.Characters
{
public class CharacterUseSlot : Dictionary<byte, byte>
{
public Character Parent { get; private set; }

public CharacterUseSlot(Character parent)
{
this.Parent = parent;
}

public void Load()
{
foreach (dynamic datum in new Datums("useslot").Populate("cid = '{0}'", this.Parent.ID))
{
this.Add((byte)datum.type, (byte)datum.slot);
}
}

public int Slot(InventoryType.ItemType Type)
{
foreach (KeyValuePair<byte, byte> UseSlot in this)
{
if (UseSlot.Key == (byte)Type)
return UseSlot.Value;
}
return -1;
}

public void Save()
{
foreach (KeyValuePair<byte, byte> UseSlot in this)
{
dynamic datum = new Datum("useslot");

datum.cid = this.Parent.ID;
datum.type = UseSlot.Key;
datum.slot = UseSlot.Value;
datum.Insert();
}
}

public void Delete()
{
Database.Delete("useslot", "cid = '{0}'", this.Parent.ID);
}
}
}
3 changes: 2 additions & 1 deletion Server/CharServer/Net/CharHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public static void Create_MyChar_Req(InPacket lea, Client gc)
chr.Keymap.Add("Z", new Shortcut(1, 0, 0));
chr.Keymap.Add("X", new Shortcut(4, 0, 3));
chr.Keymap.Add("C", new Shortcut(3, 0, 2));

chr.UseSlot.Add((byte)InventoryType.ItemType.Spend3, 0xFF);
chr.UseSlot.Add((byte)InventoryType.ItemType.Pet5, 0xFF);

if ((gc.Account.Characters.Count + 1) <= 4)
{
Expand Down
8 changes: 4 additions & 4 deletions Server/CharServer/Net/CharPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public static void getCharactersData(OutPacket plew, Character chr)
plew.WriteByte(chr != null ? chr.Class : 0);
plew.WriteByte(chr != null ? chr.ClassLevel : 0);
plew.WriteByte(0);
plew.WriteByte(chr != null ? chr.MapX : 0);
plew.WriteByte(chr != null ? chr.MapY : 0);
plew.WriteByte(0);
plew.WriteByte(0);
plew.WriteByte(0);
plew.WriteShort(chr != null ? 1 : 0);
plew.WriteShort(chr != null ? 1 : 0);
plew.WriteShort(chr != null ? chr.PlayerX : 0);
plew.WriteShort(chr != null ? chr.PlayerY : 0);
Dictionary<InventoryType.EquipType, int> equip = getEquip(chr);
plew.WriteInt(equip.ContainsKey(InventoryType.EquipType.Weapon) ? equip[InventoryType.EquipType.Weapon] : 0); // 武器[Weapon] 8010101
plew.WriteInt(equip.ContainsKey(InventoryType.EquipType.Outfit) ? equip[InventoryType.EquipType.Outfit] : 0); // [Outfit] 8160351
Expand Down
1 change: 1 addition & 0 deletions Server/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Compile Include="Data\Meta.cs" />
<Compile Include="Data\RowNotUniqueException.cs" />
<Compile Include="IO\HackException.cs" />
<Compile Include="IO\SkillFullException.cs" />
<Compile Include="IO\InventoryFullException.cs" />
<Compile Include="IO\Log.cs" />
<Compile Include="IO\LogLevel.cs" />
Expand Down
7 changes: 7 additions & 0 deletions Server/Common/Constants/GameConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ public static int getExpNeededForLevel(byte level)
}
return exp[level - 1];
}

public static bool isPhysicalWeapon(int ItemID)
{
if (ItemID >= 8050101 && ItemID <= 8061531)
return false;
return true;
}
}
}
15 changes: 15 additions & 0 deletions Server/Common/IO/SkillFullException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace Server.Ghost.Characters
{
public class SkillFullException : Exception
{
public override string Message
{
get
{
return "Skill full";
}
}
}
}
2 changes: 2 additions & 0 deletions Server/Common/Net/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public enum ClientOpcode : ushort
// Inventory
PICKUP_ITEM = 0x4C,
MOVE_ITEM_REQ = 0x6C,
INVEN_SELECTSLOT_REQ = 0x6D,
USE_SPEND_REQ = 0x6F,
// Status
PLAYER_DAMAGE_REQ = 0x70,
Expand All @@ -90,6 +91,7 @@ public enum ClientOpcode : ushort
QUEST_GIVEUP_REQ = 0x7B,
QUEST_DONE_REQ = 0x7C,
QUEST_RETURN_REQ = 0x7D,
QUEST_DONE2_REQ = 0x7E,
QUEST_UPDATE_REQ = 0x7F,
// Map
CAN_WARP_ACK_REQ = 0x85,
Expand Down
3 changes: 3 additions & 0 deletions Server/GameServer/GameServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@
<Compile Include="Ghost\Accounts\Account.cs" />
<Compile Include="Ghost\Accounts\NoAccountException.cs" />
<Compile Include="Ghost\Characters\Character.cs" />
<Compile Include="Ghost\Characters\CharacterPets.cs" />
<Compile Include="Ghost\Characters\CharacterItems.cs" />
<Compile Include="GameServer.cs" />
<Compile Include="Ghost\Characters\CharacterQuests.cs" />
<Compile Include="Ghost\Characters\CharacterKeyMap.cs" />
<Compile Include="Ghost\Characters\CharacterShop.cs" />
<Compile Include="Ghost\Characters\CharacterStorages.cs" />
<Compile Include="Ghost\Characters\CharacterUseSlot.cs" />
<Compile Include="Ghost\Pet.cs" />
<Compile Include="Ghost\Map\Drop.cs" />
<Compile Include="Ghost\Item.cs" />
<Compile Include="Ghost\Characters\CharacterSkills.cs" />
Expand Down
15 changes: 15 additions & 0 deletions Server/GameServer/Ghost/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,21 @@ public sealed class Character
public short SkillBonus { get; set; }
public byte JumpHeight { get; set; }
public byte Position { get; set; }

public bool IsAlive { get; set; }

public IPAddress IP { get; set; }

public CharacterItems Items { get; private set; }
public CharacterPets Pets { get; private set; }
public CharacterStorages Storages { get; private set; }
public CharacterSkills Skills { get; private set; }
public CharacterQuests Quests { get; private set; }
public CharacterKeyMap Keymap { get; private set; }
public CharacterShop Shop { get; set; }

public CharacterUseSlot UseSlot { get; private set; }

public Dictionary<int, Common.Threading.Delay> SkillState { get; private set; }

private bool Assigned { get; set; }
Expand All @@ -77,11 +83,14 @@ public Character(int id = 0, Client gc = null)
this.Client = gc;

this.Items = new CharacterItems(this);
this.Pets = new CharacterPets(this);
this.Storages = new CharacterStorages(this);
this.Skills = new CharacterSkills(this);
this.SkillState = new Dictionary<int, Common.Threading.Delay>();
this.Quests = new CharacterQuests(this);
this.Keymap = new CharacterKeyMap(this);
this.UseSlot = new CharacterUseSlot(this);
this.IsAlive = true;
}

public void Load(bool IsFullLoad = true)
Expand Down Expand Up @@ -139,10 +148,12 @@ public void Load(bool IsFullLoad = true)
this.Position = (byte)datum.position;

this.Items.Load();
this.Pets.Load();
this.Storages.Load();
this.Skills.Load();
this.Quests.Load();
this.Keymap.Load();
this.UseSlot.Load();
}

public void Save()
Expand Down Expand Up @@ -208,10 +219,12 @@ public void Save()
}

this.Items.Save();
this.Pets.Save();
this.Storages.Save();
this.Skills.Save();
this.Quests.Save();
this.Keymap.Save();
this.UseSlot.Save();

Map map = MapFactory.GetMap(this.MapX, this.MapY);
MapFactory.AllCharacters.Remove(this);
Expand All @@ -225,10 +238,12 @@ public void Save()
public void Delete()
{
this.Items.Delete();
this.Pets.Delete();
this.Storages.Delete();
this.Skills.Delete();
this.Quests.Delete();
this.Keymap.Delete();
this.UseSlot.Delete();

Database.Delete("Characters", "id = '{0}'", this.ID);

Expand Down
26 changes: 16 additions & 10 deletions Server/GameServer/Ghost/Characters/CharacterItems.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Server.Common.Constants;
using Server.Common.Data;
using Server.Common.IO;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -64,26 +63,33 @@ public void Add(Item item)

public void Remove(byte type, byte slot)
{
Item item = this.Items.Find(i => (i.type == type && i.slot == slot));
Item item = this.Items.Find(i => (i.Type == type && i.Slot == slot));
this.Items.Remove(item);
item.Delete();
}

public void Remove(InventoryType.ItemType type, byte slot)
{
Item item = this.Items.Find(i => (i.type == (byte)type && i.slot == slot));
Item item = this.Items.Find(i => (i.Type == (byte)type && i.Slot == slot));
this.Items.Remove(item);
item.Delete();
}

public void Remove(byte type, byte slot, int Quantity)
{
Item item = this.Items.Find(i => (i.type == type && i.slot == slot));
Item item = this.Items.Find(i => (i.Type == type && i.Slot == slot));
int SourceQuantity = item.Quantity;
item.Quantity = (short)Quantity;
this.Remove(type, slot);
int AddQuantity = SourceQuantity - item.Quantity;
this.Add(new Item(item.ItemID, item.slot, item.type, (short)AddQuantity));
this.Add(new Item(item.ItemID, item.Slot, item.Type, (short)AddQuantity));
}

public void Remove(int ItemID)
{
Item item = this.Items.Find(i => (i.ItemID == ItemID));
this.Items.Remove(item);
item.Delete();
}

public List<Item> getItems()
Expand All @@ -93,21 +99,21 @@ public List<Item> getItems()

public Item GetItem(byte type, byte slot)
{
Item item = this.Items.Find(i => (i.type == type && i.slot == slot));
Item item = this.Items.Find(i => (i.Type == type && i.Slot == slot));
return item;
}

public int GetItemID(InventoryType.ItemType type, byte slot)
{
Item item = this.Items.Find(i => (i.type == (byte)type && i.slot == slot));
Item item = this.Items.Find(i => (i.Type == (byte)type && i.Slot == slot));
if (item == null)
return 0;
return item.ItemID;
}

public int GetItemQuantity(InventoryType.ItemType type, byte slot)
{
Item item = this.Items.Find(i => (i.type == (byte)type && i.slot == slot));
Item item = this.Items.Find(i => (i.Type == (byte)type && i.Slot == slot));
if (item == null)
return 0;
return item.Quantity;
Expand All @@ -132,7 +138,7 @@ public bool IsFull(InventoryType.ItemType type)

foreach (Item item in this)
{
if (item.type == (byte)type)
if (item.Type == (byte)type)
{
count++;
}
Expand All @@ -147,7 +153,7 @@ public bool IsFull(InventoryType.ItemType type)
{
foreach (Item item in this)
{
if (item.type == (byte)type && item.slot == slot)
if (item.Type == (byte)type && item.Slot == slot)
{
return item;
}
Expand Down
Loading

0 comments on commit e6d72d8

Please sign in to comment.