… | |
… | |
93 | { |
93 | { |
94 | // cfplus |
94 | // cfplus |
95 | send_face (sound); |
95 | send_face (sound); |
96 | flush_fx (); |
96 | flush_fx (); |
97 | |
97 | |
98 | sint8 vol = idistance (dx, dy) * -80 / 10; |
98 | uint8 vol = clamp (255 - idistance (dx, dy) * 255 / 10, 0, 255); |
99 | |
99 | |
100 | // cut off volume here |
100 | // cut off volume here |
101 | if (vol < -80) |
101 | if (vol < 16) |
102 | return; |
102 | return; |
103 | |
103 | |
104 | packet sl ("sc"); |
104 | packet sl ("sc"); |
105 | |
105 | |
106 | uint8 *len = sl.cur; |
106 | uint8 *len = sl.cur; |
… | |
… | |
108 | sl << uint8 (0) // group length |
108 | sl << uint8 (0) // group length |
109 | << uint8 (0) // type == one-time effect |
109 | << uint8 (0) // type == one-time effect |
110 | << ber32 (sound) |
110 | << ber32 (sound) |
111 | << sint8 (dx) |
111 | << sint8 (dx) |
112 | << sint8 (dy) |
112 | << sint8 (dy) |
113 | << sint8 (vol); // -128 == silent, 0 normal, 127 twice the amplitude |
113 | << uint8 (vol); // 0 == silent, 255 max |
114 | |
114 | |
115 | *len = sl.cur - len; // patch in group length |
115 | *len = sl.cur - len; // patch in group length |
116 | |
116 | |
117 | send_packet (sl); |
117 | send_packet (sl); |
118 | } |
118 | } |