| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include "material.h" |
| 29 |
|
| 30 |
#include "objs.h" |
| 31 |
#include "thing.h" |
| 32 |
|
| 33 |
static bool IsTileFloor(const Tile *t) |
| 34 |
{ |
| 35 |
return t != NULL && t->Class != NULL && t->Class->Type == TILE_CLASS_FLOOR; |
| 36 |
} |
| 37 |
|
| 38 |
void MatGetFootstepSound(const CharacterClass *c, const Tile *t, char *out) |
| 39 |
{ |
| 40 |
if (c->Footsteps) |
| 41 |
{ |
| 42 |
sprintf(out, "footsteps/%s", c->Footsteps); |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
if (IsTileFloor(t) && t->Class->Style != NULL) |
| 47 |
{ |
| 48 |
|
| 49 |
CA_FOREACH(const ThingId, tid, t->things) |
| 50 |
if (tid->Kind == KIND_OBJECT) |
| 51 |
{ |
| 52 |
const TObject *obj = CArrayGet(&gObjs, tid->Id); |
| 53 |
if (obj && obj->Class->DrawBelow && obj->Class->FootstepSound) |
| 54 |
{ |
| 55 |
strcpy(out, obj->Class->FootstepSound); |
| 56 |
return; |
| 57 |
} |
| 58 |
} |
| 59 |
CA_FOREACH_END() |
| 60 |
|
| 61 |
|
| 62 |
if (StrStartsWith(t->Class->Style, "checker") || |
| 63 |
StrStartsWith(t->Class->Style, "tile")) |
| 64 |
{ |
| 65 |
strcpy(out, "footsteps/tile"); |
| 66 |
return; |
| 67 |
} |
| 68 |
if (StrStartsWith(t->Class->Style, "cobble")) |
| 69 |
{ |
| 70 |
strcpy(out, "footsteps/gravel"); |
| 71 |
return; |
| 72 |
} |
| 73 |
if (StrStartsWith(t->Class->Style, "dirt")) |
| 74 |
{ |
| 75 |
strcpy(out, "footsteps/grass"); |
| 76 |
return; |
| 77 |
} |
| 78 |
if (StrStartsWith(t->Class->Style, "grate")) |
| 79 |
{ |
| 80 |
strcpy(out, "footsteps/metal"); |
| 81 |
return; |
| 82 |
} |
| 83 |
if (StrStartsWith(t->Class->Style, "water")) |
| 84 |
{ |
| 85 |
strcpy(out, "footsteps/water"); |
| 86 |
return; |
| 87 |
} |
| 88 |
if (StrStartsWith(t->Class->Style, "wood")) |
| 89 |
{ |
| 90 |
strcpy(out, "footsteps/wood"); |
| 91 |
return; |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
strcpy(out, "footsteps/boots"); |
| 97 |
} |
| 98 |
|
| 99 |
color_t MatGetFootprintMask(const Tile *t) |
| 100 |
{ |
| 101 |
if (IsTileFloor(t)) |
| 102 |
{ |
| 103 |
|
| 104 |
CA_FOREACH(const ThingId, tid, t->things) |
| 105 |
if (tid->Kind == KIND_OBJECT) |
| 106 |
{ |
| 107 |
const TObject *obj = CArrayGet(&gObjs, tid->Id); |
| 108 |
if (obj && obj->Class->DrawBelow) |
| 109 |
{ |
| 110 |
|
| 111 |
|
| 112 |
color_t mask = obj->Class->FootprintMask; |
| 113 |
if (!ColorEquals(obj->thing.CPic.Mask, colorWhite)) |
| 114 |
{ |
| 115 |
mask = obj->thing.CPic.Mask; |
| 116 |
const color_t darken = {33, 33, 33, 255}; |
| 117 |
mask = ColorMult(mask, darken); |
| 118 |
} |
| 119 |
if (mask.a != 0) |
| 120 |
{ |
| 121 |
return mask; |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
CA_FOREACH_END() |
| 126 |
|
| 127 |
|
| 128 |
if (StrStartsWith(t->Class->Style, "water")) |
| 129 |
{ |
| 130 |
color_t mask = colorBlack; |
| 131 |
mask.a = 0x99; |
| 132 |
return mask; |
| 133 |
} |
| 134 |
} |
| 135 |
return colorTransparent; |
| 136 |
} |
| 137 |
|
| 138 |
BulletClass *MatGetDamageBullet(const Tile *t) |
| 139 |
{ |
| 140 |
return IsTileFloor(t) ? StrBulletClass(t->Class->DamageBullet) : NULL; |
| 141 |
} |