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

Function CheckNewPath

Source/player.cpp:3019–3336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3017}
3018
3019void CheckNewPath(int pnum)
3020{
3021 int i, x, y, d;
3022 int xvel3, xvel, yvel;
3023
3024 if ((DWORD)pnum >= MAX_PLRS) {
3025 app_fatal("CheckNewPath: illegal player %d", pnum);
3026 }
3027
3028 if (plr[pnum].destAction == ACTION_ATTACKMON) {
3029 MakePlrPath(pnum, monster[plr[pnum].destParam1]._mfutx, monster[plr[pnum].destParam1]._mfuty, FALSE);
3030 }
3031
3032 if (plr[pnum].destAction == ACTION_ATTACKPLR) {
3033 MakePlrPath(pnum, plr[plr[pnum].destParam1]._px, plr[plr[pnum].destParam1]._py, FALSE);
3034 }
3035
3036 if (plr[pnum].walkpath[0] != WALK_NONE) {
3037 if (plr[pnum]._pmode == PM_STAND) {
3038 if (pnum == myplr) {
3039 if (plr[pnum].destAction == ACTION_ATTACKMON || plr[pnum].destAction == ACTION_ATTACKPLR) {
3040 i = plr[pnum].destParam1;
3041
3042 if (plr[pnum].destAction == ACTION_ATTACKMON) {
3043 x = abs(plr[pnum]._px - monster[i]._mfutx);
3044 y = abs(plr[pnum]._py - monster[i]._mfuty);
3045 d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty);
3046 } else {
3047 x = abs(plr[pnum]._px - plr[i]._px);
3048 y = abs(plr[pnum]._py - plr[i]._py);
3049 d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py);
3050 }
3051
3052 if (x < 2 && y < 2) {
3053 ClrPlrPath(pnum);
3054 if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) {
3055 TalktoMonster(i);
3056 } else {
3057 StartAttack(pnum, d);
3058 }
3059 plr[pnum].destAction = ACTION_NONE;
3060 }
3061 }
3062 }
3063
3064 if (currlevel != 0) {
3065 xvel3 = PWVel[plr[pnum]._pClass][0];
3066 xvel = PWVel[plr[pnum]._pClass][1];
3067 yvel = PWVel[plr[pnum]._pClass][2];
3068 } else {
3069 xvel3 = 2048;
3070 xvel = 1024;
3071 yvel = 512;
3072 }
3073
3074 switch (plr[pnum].walkpath[0]) {
3075 case WALK_N:
3076 StartWalk(pnum, 0, -xvel, -1, -1, DIR_N, SDIR_N);

Callers 1

ProcessPlayersFunction · 0.85

Calls 15

app_fatalFunction · 0.85
MakePlrPathFunction · 0.85
GetDirectionFunction · 0.85
ClrPlrPathFunction · 0.85
TalktoMonsterFunction · 0.85
StartAttackFunction · 0.85
StartWalkFunction · 0.85
StartWalk3Function · 0.85
StartWalk2Function · 0.85
StartStandFunction · 0.85
StartRangeAttackFunction · 0.85
StartSpellFunction · 0.85

Tested by

no test coverage detected