Changeset e70b66b in network-game for client


Ignore:
Timestamp:
Jan 23, 2014, 1:37:40 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
7f884ea
Parents:
06fc7f7
Message:

Player targeting logic has been fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r06fc7f7 re70b66b  
    432432                  target = it->second;
    433433                  cout << "set target" << endl;
    434                   if (target->getId() != curPlayerId && target->team != curPlayer->team)
     434                  if (target->team != curPlayer->team)
    435435                  {
    436436                     cout << "Found valid target" << endl;
    437437
    438                      unsigned int targetId = target->getId();
    439 
    440                      msgTo.type = MSG_TYPE_ATTACK;
    441                      memcpy(msgTo.buffer, &curPlayerId, 4);
    442                      memcpy(msgTo.buffer+4, &targetId, 4);
    443 
    444                      msgProcessor.sendMessage(&msgTo, &server);
     438                     POSITION cursorPos;
     439                     cursorPos.x = ev.mouse.x;
     440                     cursorPos.y = ev.mouse.y;
     441                     cursorPos = screenToMap(cursorPos);
     442
     443                     float distance =posDistance(cursorPos.toFloat(), target->pos);
     444
     445                     if (distance < 25) {
     446                        unsigned int targetId = target->getId();
     447
     448                        msgTo.type = MSG_TYPE_ATTACK;
     449                        memcpy(msgTo.buffer, &curPlayerId, 4);
     450                        memcpy(msgTo.buffer+4, &targetId, 4);
     451
     452                        msgProcessor.sendMessage(&msgTo, &server);
     453                     }
    445454                  }
    446455               }
Note: See TracChangeset for help on using the changeset viewer.