you would need to adapt the magicattack.cs file
so randomly putting area skills in the list is not gonne work rightQuote:
if you take a look at the way the other spells are coded they are setup to only attack 1 player, however you can adapt it and add more targets to the array and attack multiple players, but i think it would get abit complicated,
i didnt even think about area skills and multiple target spells when i was working on that source
no err, those catergories are based upon the incomming userid, if its your ID then you are casting a spell on yourself, this system is badly designed btw :PQuote:
so randomly putting area skills in the list is not gonne work right
and you have :
//Self
xp skills
//Player not self
mana skills
//Monster
summon spells?
//AOE
no idea weapen skills?
so what skills do i put under //monster and AOE
cause i just sorted out all the spells and now i don't know what to put where
doesn't matter is its designed badly as long as it works^^Quote:
no err, those catergories are based upon the incomming userid, if its your ID then you are casting a spell on yourself, this system is badly designed btw :P
So self = your id
player not self = any otherplayer
monster = monster
and AOE = area of effect spell, for multiple targets,
back then my theory was that if you attack with firecircle or something similar it wouldnt send a specific userID as the target, however i never confirmed this as i said, so you would need to run the source in debug mode add a break point near the top after its decoded everything and then see whats in a packet for fastblade, that is if its even a magic attack packet
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using COServer.Network.Packet;
namespace COServer.GamePacketsIncomming
{
public class MagicAttack : GameBasePacket
{
private int SpellID;
private int SpellLevel;
private int TargetID;
private int TimeStamp;
private int CharID;
private int Attack;
private int BaseDmg = 0;
private int Amount = 0;
private double Bless = 1;
private double PlusDef = 0;
private double Defense = 1;
private double FinalDmg = 0;
private int ManaUse = 0;
private int StamUse = 0;
private int Chance = 0;
private COClient Client;
private COClient Target;
private Location TargetLoc;
private Target[] Targets;
private ConquerPacket CPacket = new ConquerPacket();
private Random RND = new Random();
public MagicAttack(byte[] data, COClient _Client)
{
Client = _Client;
TimeStamp = (data[7] << 24) + (data[6] << 16) + (data[5] << 8) + (data[4]);
CharID = (data[11] << 24) + (data[10] << 16) + (data[9] << 8) + (data[8]);
GetSpellID(data[24], data[25]);
GetTargetID(data[12], data[13], data[14], data[15]);
GetTargetLoc(data[16], data[17], data[18], data[19]);
//int PacketType = (data[23] << 24) + (data[22] << 16) + (data[21] << 8) + (data[20]);
GetSpellLevel(data[26], data[27]);
Target = Spawn.LookUpChar(TargetID);
if (Client.Char.IsGhost == true)
{
Client.SendData(CPacket.Chat(Client.MessageID, "SYSTEM", Client.Char.Name, "You are already dead!", ChatType.Top));
return;
}
else if (Target.Char.Invincible == true)
{
return;
}
else if (Target.Char.IsGhost == true)
{
Client.SendData(CPacket.Chat(Client.MessageID, "SYSTEM", Client.Char.Name, "The target is already dead!", ChatType.Top));
return;
}
else if (TargetID == Client.Char.CharID)
{
//Self
foreach (int[] Skill in Client.Char.Skills)
{
if (Skill != null)
{
if (Skill[0] == 1025 && SpellID == 1025)
{
if (Client.Char.XpSkill == 0)
{
Client.Char.XpSkill = SpellID;
Client.Char.Status += (int)(CharStatus.Supermaan);
Client.Char.Status -= (int)(CharStatus.XPList);
Client.Char.XpListCounter = 0;
Client.Char.XpCounter = 20;
Client.Char.XpList = false;
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect));
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer));
}
else if (Client.Char.XpSkill == 1025)
{
Client.Char.Status -= (int)(CharStatus.XPList);
Client.Char.XpListCounter = 0;
Client.Char.XpCounter += 20;
Client.Char.XpList = false;
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect));
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer));
}
}
if (Skill[0] == 1110 && SpellID == 1110)
{
if (Client.Char.XpSkill == 0)
{
Client.Char.XpSkill = SpellID;
Client.Char.Status += (int)(CharStatus.Cyclone);
Client.Char.Status -= (int)(CharStatus.XPList);
Client.Char.XpListCounter = 0;
Client.Char.XpCounter = 20;
Client.Char.XpList = false;
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect));
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer));
}
else if (Client.Char.XpSkill == 1110)
{
Client.Char.Status -= (int)(CharStatus.XPList);
Client.Char.XpListCounter = 0;
Client.Char.XpCounter += 20;
Client.Char.XpList = false;
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect));
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer));
}
}
Spawn.UpdateLocal(Client, CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect));
}
}
}
else if (TargetID >= 1000000)
{
//Player not self
foreach (int[] Skill in Client.Char.Skills)
{
if (Skill != null)
{
if (Skill[0] == 1000 && SpellID == 1000)
{
switch (Skill[1])
{
case 0:
BaseDmg = 7;
ManaUse = 1;
break;
case 1:
BaseDmg = 16;
ManaUse = 6;
break;
case 2:
BaseDmg = 32;
ManaUse = 10;
break;
case 3:
BaseDmg = 57;
ManaUse = 11;
break;
case 4:
BaseDmg = 86;
ManaUse = 17;
break;
}
Chance = 100;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else if (Skill[0] == 1001 && SpellID == 1001)
{
switch (Skill[1])
{
case 0:
BaseDmg = 130;
ManaUse = 21;
break;
case 1:
BaseDmg = 189;
ManaUse = 21;
break;
case 2:
BaseDmg = 275;
ManaUse = 28;
break;
case 3:
BaseDmg = 380;
ManaUse = 32;
break;
}
Chance = 100;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else if (Skill[0] == 1002 && SpellID == 1002)
{
switch (Skill[1])
{
case 0:
BaseDmg = 505;
ManaUse = 32;
break;
case 1:
BaseDmg = 666;
ManaUse = 36;
break;
case 2:
BaseDmg = 882;
ManaUse = 50;
break;
case 3:
BaseDmg = 1166;
ManaUse = 64;
break;
}
Chance = 100;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else if (Skill[0] == 1045 && SpellID == 1045)
{
switch (Skill[1])
{
case 0:
BaseDmg = 1000;
StamUse = 10;
break;
case 1:
BaseDmg = 1500;
StamUse = 10;
break;
case 2:
BaseDmg = 2000;
StamUse = 10;
break;
case 3:
BaseDmg = 2500;
StamUse = 10;
break;
}
Chance = 100;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveStamina(Client, StamUse);
break;
}
else if (Skill[0] == 1150 && SpellID == 1150)
{
switch (Skill[1])
{
case 0:
BaseDmg = 378;
ManaUse = 33;
break;
case 1:
BaseDmg = 550;
ManaUse = 33;
break;
case 2:
BaseDmg = 760;
ManaUse = 46;
break;
case 3:
BaseDmg = 1010;
ManaUse = 53;
break;
case 4:
BaseDmg = 1332;
ManaUse = 53;
break;
case 5:
BaseDmg = 1764;
ManaUse = 60;
break;
case 6:
BaseDmg = 2332;
ManaUse = 82;
break;
case 7:
BaseDmg = 2800;
ManaUse = 105;
break;
}
Chance = 80;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else if (Skill[0] == 1160 && SpellID == 1160)
{
switch (Skill[1])
{
case 0:
BaseDmg = 855;
ManaUse = 53;
break;
case 1:
BaseDmg = 1498;
ManaUse = 60;
break;
case 2:
BaseDmg = 1985;
ManaUse = 82;
break;
case 3:
BaseDmg = 2623;
ManaUse = 105;
break;
}
Chance = 80;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else if (Skill[0] == 1180 && SpellID == 1180)
{
switch (Skill[1])
{
case 0:
BaseDmg = 760;
ManaUse = 62;
Chance = 40;
break;
case 1:
BaseDmg = 1040;
ManaUse = 74;
Chance = 43;
break;
case 2:
BaseDmg = 1250;
ManaUse = 115;
Chance = 50;
break;
case 3:
BaseDmg = 1480;
ManaUse = 130;
Chance = 55;
break;
case 4:
BaseDmg = 1810;
ManaUse = 150;
Chance = 60;
break;
case 5:
BaseDmg = 2210;
ManaUse = 215;
Chance = 65;
break;
case 6:
BaseDmg = 2700;
ManaUse = 285;
Chance = 70;
break;
case 7:
BaseDmg = 3250;
ManaUse = 300;
Chance = 75;
break;
}
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else
{
Console.WriteLine(CharID + " Is Attacking " + TargetID + " With Skill " + SpellID + " Which Is Level " + SpellLevel);
}
}
}
}
else if (TargetID != 0)
{
//Monster
}
else
{
//AOE
foreach (int[] Skill in Client.Char.Skills)
{
if (Skill != null)
{
if (Skill[0] == 1120 && SpellID == 1120)
{
switch (Skill[1])
{
case 0:
BaseDmg = 540;
ManaUse = 150;
break;
case 1:
BaseDmg = 650;
ManaUse = 170;
break;
case 2:
BaseDmg = 720;
ManaUse = 190;
break;
case 3:
BaseDmg = 770;
ManaUse = 210;
break;
}
Chance = 100;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else if (Skill[0] == 1165 && SpellID == 1165)
{
switch (Skill[1])
{
case 0:
BaseDmg = 120;
ManaUse = 180;
break;
case 1:
BaseDmg = 240;
ManaUse = 150;
break;
case 2:
BaseDmg = 310;
ManaUse = 180;
break;
case 3:
BaseDmg = 400;
ManaUse = 210;
break;
}
Chance = 100;
Targets = new Target[1];
Targets[0] = new Target();
SendAttack(Skill, Client, Target);
RemoveMana(Client, ManaUse);
break;
}
else
{
Console.WriteLine(CharID + " Is Attacking " + TargetID + " With Skill " + SpellID + " Which Is Level " + SpellLevel);
}
}
}
}
}
public void RemoveMana(COClient Client, int Mana)
{
Client.Char.CurrentMana -= Mana;
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.CurrentMana, StatusTypes.Mp));
}
public void RemoveStamina(COClient Client, int Stamina)
{
Client.Char.CurrentStam -= Stamina;
Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.CurrentStam, StatusTypes.Stamina));
}
public void SendAttack(int[] Skill, COClient Client, COClient Target)
{
i still need to know how to use the /spell commandQuote:
doesn't matter is its designed badly as long as it works^^
ok but almost every skill can also be used against monsters...and fastblade uses weapon damage so how would you do that and here is apart of my magicatack.cs:
and how does the server knows which skill ID is what spell...Code:using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Timers; using COServer.Network.Packet; namespace COServer.GamePacketsIncomming { public class MagicAttack : GameBasePacket { private int SpellID; private int SpellLevel; private int TargetID; private int TimeStamp; private int CharID; private int Attack; private int BaseDmg = 0; private int Amount = 0; private double Bless = 1; private double PlusDef = 0; private double Defense = 1; private double FinalDmg = 0; private int ManaUse = 0; private int StamUse = 0; private int Chance = 0; private COClient Client; private COClient Target; private Location TargetLoc; private Target[] Targets; private ConquerPacket CPacket = new ConquerPacket(); private Random RND = new Random(); public MagicAttack(byte[] data, COClient _Client) { Client = _Client; TimeStamp = (data[7] << 24) + (data[6] << 16) + (data[5] << 8) + (data[4]); CharID = (data[11] << 24) + (data[10] << 16) + (data[9] << 8) + (data[8]); GetSpellID(data[24], data[25]); GetTargetID(data[12], data[13], data[14], data[15]); GetTargetLoc(data[16], data[17], data[18], data[19]); //int PacketType = (data[23] << 24) + (data[22] << 16) + (data[21] << 8) + (data[20]); GetSpellLevel(data[26], data[27]); Target = Spawn.LookUpChar(TargetID); if (Client.Char.IsGhost == true) { Client.SendData(CPacket.Chat(Client.MessageID, "SYSTEM", Client.Char.Name, "You are already dead!", ChatType.Top)); return; } else if (Target.Char.Invincible == true) { return; } else if (Target.Char.IsGhost == true) { Client.SendData(CPacket.Chat(Client.MessageID, "SYSTEM", Client.Char.Name, "The target is already dead!", ChatType.Top)); return; } else if (TargetID == Client.Char.CharID) { //Self foreach (int[] Skill in Client.Char.Skills) { if (Skill != null) { if (Skill[0] == 1025 && SpellID == 1025) { if (Client.Char.XpSkill == 0) { Client.Char.XpSkill = SpellID; Client.Char.Status += (int)(CharStatus.Supermaan); Client.Char.Status -= (int)(CharStatus.XPList); Client.Char.XpListCounter = 0; Client.Char.XpCounter = 20; Client.Char.XpList = false; Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect)); Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer)); } else if (Client.Char.XpSkill == 1025) { Client.Char.Status -= (int)(CharStatus.XPList); Client.Char.XpListCounter = 0; Client.Char.XpCounter += 20; Client.Char.XpList = false; Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect)); Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer)); } } if (Skill[0] == 1110 && SpellID == 1110) { if (Client.Char.XpSkill == 0) { Client.Char.XpSkill = SpellID; Client.Char.Status += (int)(CharStatus.Cyclone); Client.Char.Status -= (int)(CharStatus.XPList); Client.Char.XpListCounter = 0; Client.Char.XpCounter = 20; Client.Char.XpList = false; Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect)); Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer)); } else if (Client.Char.XpSkill == 1110) { Client.Char.Status -= (int)(CharStatus.XPList); Client.Char.XpListCounter = 0; Client.Char.XpCounter += 20; Client.Char.XpList = false; Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect)); Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.XpCounter, StatusTypes.XpTimer)); } } Spawn.UpdateLocal(Client, CPacket.Status(Client.Char, 1, Client.Char.Status, StatusTypes.StatusEffect)); } } } else if (TargetID >= 1000000) { //Player not self foreach (int[] Skill in Client.Char.Skills) { if (Skill != null) { if (Skill[0] == 1000 && SpellID == 1000) { switch (Skill[1]) { case 0: BaseDmg = 7; ManaUse = 1; break; case 1: BaseDmg = 16; ManaUse = 6; break; case 2: BaseDmg = 32; ManaUse = 10; break; case 3: BaseDmg = 57; ManaUse = 11; break; case 4: BaseDmg = 86; ManaUse = 17; break; } Chance = 100; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else if (Skill[0] == 1001 && SpellID == 1001) { switch (Skill[1]) { case 0: BaseDmg = 130; ManaUse = 21; break; case 1: BaseDmg = 189; ManaUse = 21; break; case 2: BaseDmg = 275; ManaUse = 28; break; case 3: BaseDmg = 380; ManaUse = 32; break; } Chance = 100; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else if (Skill[0] == 1002 && SpellID == 1002) { switch (Skill[1]) { case 0: BaseDmg = 505; ManaUse = 32; break; case 1: BaseDmg = 666; ManaUse = 36; break; case 2: BaseDmg = 882; ManaUse = 50; break; case 3: BaseDmg = 1166; ManaUse = 64; break; } Chance = 100; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else if (Skill[0] == 1045 && SpellID == 1045) { switch (Skill[1]) { case 0: BaseDmg = 1000; StamUse = 10; break; case 1: BaseDmg = 1500; StamUse = 10; break; case 2: BaseDmg = 2000; StamUse = 10; break; case 3: BaseDmg = 2500; StamUse = 10; break; } Chance = 100; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveStamina(Client, StamUse); break; } else if (Skill[0] == 1150 && SpellID == 1150) { switch (Skill[1]) { case 0: BaseDmg = 378; ManaUse = 33; break; case 1: BaseDmg = 550; ManaUse = 33; break; case 2: BaseDmg = 760; ManaUse = 46; break; case 3: BaseDmg = 1010; ManaUse = 53; break; case 4: BaseDmg = 1332; ManaUse = 53; break; case 5: BaseDmg = 1764; ManaUse = 60; break; case 6: BaseDmg = 2332; ManaUse = 82; break; case 7: BaseDmg = 2800; ManaUse = 105; break; } Chance = 80; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else if (Skill[0] == 1160 && SpellID == 1160) { switch (Skill[1]) { case 0: BaseDmg = 855; ManaUse = 53; break; case 1: BaseDmg = 1498; ManaUse = 60; break; case 2: BaseDmg = 1985; ManaUse = 82; break; case 3: BaseDmg = 2623; ManaUse = 105; break; } Chance = 80; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else if (Skill[0] == 1180 && SpellID == 1180) { switch (Skill[1]) { case 0: BaseDmg = 760; ManaUse = 62; Chance = 40; break; case 1: BaseDmg = 1040; ManaUse = 74; Chance = 43; break; case 2: BaseDmg = 1250; ManaUse = 115; Chance = 50; break; case 3: BaseDmg = 1480; ManaUse = 130; Chance = 55; break; case 4: BaseDmg = 1810; ManaUse = 150; Chance = 60; break; case 5: BaseDmg = 2210; ManaUse = 215; Chance = 65; break; case 6: BaseDmg = 2700; ManaUse = 285; Chance = 70; break; case 7: BaseDmg = 3250; ManaUse = 300; Chance = 75; break; } Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else { Console.WriteLine(CharID + " Is Attacking " + TargetID + " With Skill " + SpellID + " Which Is Level " + SpellLevel); } } } } else if (TargetID != 0) { //Monster } else { //AOE foreach (int[] Skill in Client.Char.Skills) { if (Skill != null) { if (Skill[0] == 1120 && SpellID == 1120) { switch (Skill[1]) { case 0: BaseDmg = 540; ManaUse = 150; break; case 1: BaseDmg = 650; ManaUse = 170; break; case 2: BaseDmg = 720; ManaUse = 190; break; case 3: BaseDmg = 770; ManaUse = 210; break; } Chance = 100; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else if (Skill[0] == 1165 && SpellID == 1165) { switch (Skill[1]) { case 0: BaseDmg = 120; ManaUse = 180; break; case 1: BaseDmg = 240; ManaUse = 150; break; case 2: BaseDmg = 310; ManaUse = 180; break; case 3: BaseDmg = 400; ManaUse = 210; break; } Chance = 100; Targets = new Target[1]; Targets[0] = new Target(); SendAttack(Skill, Client, Target); RemoveMana(Client, ManaUse); break; } else { Console.WriteLine(CharID + " Is Attacking " + TargetID + " With Skill " + SpellID + " Which Is Level " + SpellLevel); } } } } } public void RemoveMana(COClient Client, int Mana) { Client.Char.CurrentMana -= Mana; Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.CurrentMana, StatusTypes.Mp)); } public void RemoveStamina(COClient Client, int Stamina) { Client.Char.CurrentStam -= Stamina; Client.SendData(CPacket.Status(Client.Char, 1, Client.Char.CurrentStam, StatusTypes.Stamina)); } public void SendAttack(int[] Skill, COClient Client, COClient Target) {
how does the skill command works cause it seems to do nothing...
but basicly what you are saying is that i need to learn C#...
[edit] i just read a other topic and you said this source was full of bugs etc. so how big is the chance to get this working