* Move monster sprite. * * There are 16 monster sprite frames: * * Frame 0: NorthEast Left Foot * Frame 1: NorthEast Both Feet * Frame 2: NorthEast Right Foot * Frame 3: SouthEast Right Foot * Frame 4: SouthEast Both Feet * Frame 5: SouthEast Left Foot * Frame 6: SouthWest Right Foot * Frame 7: SouthWest Both Feet * Frame 8: SouthWest Left Foot * Frame 9: NorthWest Left Foot * Frame
| 1000 | * @todo Remove local magic constants and document the code. |
| 1001 | */ |
| 1002 | void Micropolis::doMonsterSprite(SimSprite *sprite) |
| 1003 | { |
| 1004 | static const short Gx[5] = { 2, 2, -2, -2, 0 }; |
| 1005 | static const short Gy[5] = { -2, 2, 2, -2, 0 }; |
| 1006 | static const short ND1[4] = { 0, 1, 2, 3 }; |
| 1007 | static const short ND2[4] = { 1, 2, 3, 0 }; |
| 1008 | static const short nn1[4] = { 2, 5, 8, 11 }; |
| 1009 | static const short nn2[4] = { 11, 2, 5, 8 }; |
| 1010 | short d, z, c; |
| 1011 | |
| 1012 | if (sprite->soundCount > 0) { |
| 1013 | sprite->soundCount--; |
| 1014 | } |
| 1015 | |
| 1016 | if (sprite->control < 0) { |
| 1017 | /* business as usual */ |
| 1018 | |
| 1019 | if (sprite->control == -2) { |
| 1020 | |
| 1021 | d = (sprite->frame - 1) / 3; |
| 1022 | z = (sprite->frame - 1) % 3; |
| 1023 | |
| 1024 | if (z == 2) { |
| 1025 | sprite->step = 0; |
| 1026 | } |
| 1027 | |
| 1028 | if (z == 0) { |
| 1029 | sprite->step = 1; |
| 1030 | } |
| 1031 | |
| 1032 | if (sprite->step) { |
| 1033 | z++; |
| 1034 | } else { |
| 1035 | z--; |
| 1036 | } |
| 1037 | |
| 1038 | c = getDir(sprite->x, sprite->y, sprite->destX, sprite->destY); |
| 1039 | |
| 1040 | if (absDist < 18) { |
| 1041 | |
| 1042 | sprite->control = -1; |
| 1043 | sprite->count = 1000; |
| 1044 | sprite->flag = 1; |
| 1045 | sprite->destX = sprite->origX; |
| 1046 | sprite->destY = sprite->origY; |
| 1047 | |
| 1048 | } else { |
| 1049 | |
| 1050 | c = (c - 1) / 2; |
| 1051 | |
| 1052 | if ((c != d && getRandom(5) == 0) || getRandom(20) == 0) { |
| 1053 | |
| 1054 | int diff = (c - d) & 3; |
| 1055 | |
| 1056 | if (diff == 1 || diff == 3) { |
| 1057 | d = c; |
| 1058 | } else { |
| 1059 |
nothing calls this directly
no outgoing calls
no test coverage detected