ATtack of a Certain Monster

03/18/2012 10:54 marlyandedsel#1
can someone tell me how to to code
1. Terato Dragon will attack multiple player around him in just 1 blow...
meaning not single player affected...

I have made like this but I know its error or do you have Idea or some clue just a guide to do this...


Quote:
Sector sector = new Sector(attacker.X, attacker.Y, X, Y);
sector.Arrange(spell.Sector, spell.Distance);

foreach (Interfaces.IMapObject _obj in attacker.Monster.Screen.Objects)
{
if (_obj == null)
continue;
if ( _obj.MapObjType == MapObjectType.Player)
{
attacked = _obj as Entity;
if (sector.Inside(attacked.X, attacked.Y))
{
attack.Effect1 = Attack.AttackEffects1.None;
uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, spell, ref attack);
ReceiveAttack(attacker, attacked, attack, damage, spell);

suse.Targets.Add(attacked.UID, damage);
}
}
}
03/18/2012 11:33 shadowman123#2
y dont u make it With spell.Range ? it would be Easier like this

Code:
if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
{
     // Attacker in this case is monster
     Ur Calculations
}
03/18/2012 11:34 m7mdxlife#3
A. Use code tags.
B. I'm pretty sure lots of public sources got Terato attacking multiple players with 1 blow. check pro4never's source
03/18/2012 11:46 -impulse-#4
Code:
Sector sector = new Sector(attacker.X, attacker.Y, X, Y);
Your problem is probably related to the fact that maybe the variables X and Y got the value 0. You should do
Code:
Sector sector = new Sector(attacker.X, attacker.Y, attacked.X, attacked.Y);
In which case the sector will cover the main target and the ones around it, not some random direction.
03/18/2012 14:50 marlyandedsel#5
thanks ... and i got error in this part

foreach (IMapObject objs in attacker.Owner.Screen.Objects.ToArray())

the attacker is monster... is that correct I called it like attacker.Owner.Screen.Objects.ToArray() i have use the Impulse public source...
03/18/2012 21:38 -impulse-#6
Quote:
Originally Posted by marlyandedsel View Post
thanks ... and i got error in this part

foreach (IMapObject objs in attacker.Owner.Screen.Objects.ToArray())

the attacker is monster... is that correct I called it like attacker.Owner.Screen.Objects.ToArray() i have use the Impulse public source...
You should use: attacked.Owner.Screen.Objects (as monsters don't have a Screen variable - they do have a variable called Owner but that is null).
Other than that your code is good except you should add before that foreach
this:
Code:
if (sector.Inside(attacked.X, attacked.Y))
{
attack.Effect1 = Attack.AttackEffects1.None;
uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, spell, ref attack);
ReceiveAttack(attacker, attacked, attack, damage, spell);

suse.Targets.Add(attacked.UID, damage);
}
With this code you will also attack the main target (without it you would attack just the players around).
03/19/2012 00:47 marlyandedsel#7
Thank very much impulse I got it.... :)

edit:
some little error, dead player can still receive damage but I have manage it to correct....Thanks very much.... working Good Request Close