MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / CheckNewPath

Function CheckNewPath

Source/player.cpp:1146–1447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1144}
1145
1146void CheckNewPath(Player &player, bool pmWillBeCalled)
1147{
1148 int x = 0;
1149 int y = 0;
1150
1151 Monster *monster;
1152 Player *target;
1153 Object *object;
1154 Item *item;
1155
1156 int targetId = player.destParam1;
1157
1158 switch (player.destAction) {
1159 case ACTION_ATTACKMON:
1160 case ACTION_RATTACKMON:
1161 case ACTION_SPELLMON:
1162 monster = &Monsters[targetId];
1163 if ((monster->hitPoints >> 6) <= 0) {
1164 player.Stop();
1165 return;
1166 }
1167 if (player.destAction == ACTION_ATTACKMON)
1168 MakePlrPath(player, monster->position.future, false);
1169 break;
1170 case ACTION_ATTACKPLR:
1171 case ACTION_RATTACKPLR:
1172 case ACTION_SPELLPLR:
1173 target = &Players[targetId];
1174 if ((target->_pHitPoints >> 6) <= 0) {
1175 player.Stop();
1176 return;
1177 }
1178 if (player.destAction == ACTION_ATTACKPLR)
1179 MakePlrPath(player, target->position.future, false);
1180 break;
1181 case ACTION_OPERATE:
1182 case ACTION_DISARM:
1183 case ACTION_OPERATETK:
1184 object = &Objects[targetId];
1185 break;
1186 case ACTION_PICKUPITEM:
1187 case ACTION_PICKUPAITEM:
1188 item = &Items[targetId];
1189 break;
1190 default:
1191 break;
1192 }
1193
1194 Direction d;
1195 if (player.walkpath[0] != WALK_NONE) {
1196 if (player._pmode == PM_STAND) {
1197 if (&player == MyPlayer) {
1198 if (player.destAction == ACTION_ATTACKMON || player.destAction == ACTION_ATTACKPLR) {
1199 if (player.destAction == ACTION_ATTACKMON) {
1200 x = abs(player.position.future.x - monster->position.future.x);
1201 y = abs(player.position.future.y - monster->position.future.y);
1202 d = GetDirection(player.position.future, monster->position.future);
1203 } else {

Callers 1

ProcessPlayersFunction · 0.85

Calls 15

MakePlrPathFunction · 0.85
GetDirectionFunction · 0.85
ClrPlrPathFunction · 0.85
TalktoMonsterFunction · 0.85
StartWalkFunction · 0.85
StartStandFunction · 0.85
StartRangeAttackFunction · 0.85
StartSpellFunction · 0.85
IsPlayerAdjacentToObjectFunction · 0.85
OperateObjectFunction · 0.85
TryDisarmFunction · 0.85
NetSendCmdGItemFunction · 0.85

Tested by

no test coverage detected