EOSERV Bug Tracker > Bug #104: Attacking through NPCs

Bug #104: Attacking through NPCs

Attacking through NPCs
ID #104
Submitter Ramy
Product EOSERV
Severity Normal
Status OPEN, CONFIRMED
Submitted 11th Sep 2012
Updated 11th Sep 2012
Ramy Submitter 12 years, 5 weeks ago

On a PK enabled map, players with ranged weapon will attack through an NPC to hit a player behind it.

Example:

O = Player X = NPC -> = Attack

O -> X

O X -> O

Sorry if you don't like my visual examples, thought it would make it easier to understand.

Comments

Sausage Developer 12 years, 5 weeks ago

Updated Status to CONFIRMED

Apollo 12 years, 5 weeks ago

There are probably other bugs with the PK system that should also be fixed. Shooting thru team members to hit other players and shooting thru team members to hit NPCs are most likely missing. Probably needs to be some command for admin to be ignored by ranged attacks as well.

Ryouken 11 years, 44 weeks ago

I was able to fix this by making a boolean function to check if a player was closer.

bool Map::IsPlayerCloser(Character *from)

{

int range = 1;

if (this->world->eif->Get(from->paperdoll[Character::Weapon])->subtype == EIF::Ranged) range = static_cast<int>(this->world->config["RangedDistance"]);

int target_x = from->x;

int target_y = from->y;

for (int i = 0; i < range; ++i)

{

switch (from->direction)

{

case DIRECTION_UP: target_y -= 1; break;

case DIRECTION_RIGHT: target_x += 1; break;

case DIRECTION_DOWN: target_y += 1; break;

case DIRECTION_LEFT: target_x -= 1; break;

}

UTIL_FOREACH(this->npcs, npc)

{

if(npc->x == target_x && npc->y == target_y) return false;

}

UTIL_FOREACH(this->characters, character)

{

if(character->x == target_x && character->y == target_y) return true;

}

}

return true;

}

Apollo 11 years, 44 weeks ago

That is entirely too much code for this. Simply check for the tile to be occupied by an NPC. One-liner.

Ryouken 11 years, 44 weeks ago

I'm not sure what you mean, but I've only been coding for a few months. ;.; If you mean one tile in the direction the player is facing, then what if they're holding a ranged item?

Apollo 11 years, 44 weeks ago

In you AttackPK you will need to add a simple if statement. It is something like: if(Occupied(NPC)) continue; Search thru EOSERV to find the exact declaration for Occupied. I am mobile and have no access to a source at the moment.

Ryouken 11 years, 44 weeks ago

Oh, I get what you mean now. Yea, that would be simpler. o.o

Add Comment

Please don't post unless you have something relevant to the bug to say.
Do not comment to say "thanks" or "fix this please".

Please log in to add comments. EOSERV Bug Tracker > Bug #104: Attacking through NPCs