| 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 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
#include <stdarg.h> |
| 43 |
#include <string.h> |
| 44 |
|
| 45 |
#include <cfcitybell.h> |
| 46 |
#include <cfcitybell_proto.h> |
| 47 |
#include <svnversion.h> |
| 48 |
|
| 49 |
CF_PLUGIN char SvnRevPlugin[] = SVN_REV; |
| 50 |
static int last_hr; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
static void ring_scorn(object *pl) |
| 61 |
{ |
| 62 |
const char *god_name = cf_object_get_sstring_property(pl, CFAPI_OBJECT_PROP_GOD); |
| 63 |
char buf[MAX_BUF]; |
| 64 |
|
| 65 |
if (!strcmp(god_name, "Devourers") || |
| 66 |
!strcmp(god_name, "Sorig") || |
| 67 |
!strcmp(god_name, "Ruggilli") || |
| 68 |
!strcmp(god_name, "Gaea") || |
| 69 |
!strcmp(god_name, "Mostrai") || |
| 70 |
!strcmp(god_name, "Lythander")) |
| 71 |
{ |
| 72 |
snprintf(buf, MAX_BUF, "You hear the bell of the glorious temple of %s.", god_name); |
| 73 |
} |
| 74 |
else if (!strcmp(god_name, "Valriel") || |
| 75 |
!strcmp(god_name, "Gorokh")) |
| 76 |
{ |
| 77 |
snprintf(buf, MAX_BUF, "You hear the bell of the glorious church of %s.", god_name); |
| 78 |
} |
| 79 |
else |
| 80 |
strcpy(buf, "You hear the bells of the various temples of Scorn."); |
| 81 |
|
| 82 |
cf_player_message(pl, buf, NDI_UNIQUE|NDI_ORANGE); |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
static void ring_darcap(object *pl) |
| 92 |
{ |
| 93 |
const char *god_name = cf_object_get_sstring_property(pl, CFAPI_OBJECT_PROP_GOD); |
| 94 |
|
| 95 |
if (!strcmp(god_name, "Devourers")) |
| 96 |
{ |
| 97 |
cf_player_message(pl, "You hear the glorious bell of St. Andreas.", NDI_UNIQUE|NDI_ORANGE); |
| 98 |
} |
| 99 |
else |
| 100 |
{ |
| 101 |
cf_player_message(pl, "You hear the bell of St. Andreas.", NDI_UNIQUE|NDI_ORANGE); |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
static void ring_navar(object *pl) |
| 112 |
{ |
| 113 |
const char *god_name = cf_object_get_sstring_property(pl, CFAPI_OBJECT_PROP_GOD); |
| 114 |
|
| 115 |
if (!strcmp(god_name, "Gorokh") || |
| 116 |
!strcmp(god_name, "Ruggilli") || |
| 117 |
!strcmp(god_name, "Sorig") || |
| 118 |
!strcmp(god_name, "Valkyrie") || |
| 119 |
!strcmp(god_name, "Valriel")) |
| 120 |
{ |
| 121 |
char buf[MAX_BUF]; |
| 122 |
snprintf(buf, MAX_BUF, "You hear the bell of the glorious temple of %s.", god_name); |
| 123 |
cf_player_message(pl, buf, NDI_UNIQUE|NDI_ORANGE); |
| 124 |
} |
| 125 |
else if (!strcmp(god_name, "Mostrai")) |
| 126 |
{ |
| 127 |
cf_player_message(pl, "You hear the bell of Mostrai's glorious cathedral.", NDI_UNIQUE|NDI_ORANGE); |
| 128 |
} |
| 129 |
else if (!strcmp(god_name, "Gaea")) |
| 130 |
{ |
| 131 |
cf_player_message(pl, "You hear the bell of Gaea's glorious shrine.", NDI_UNIQUE|NDI_ORANGE); |
| 132 |
} |
| 133 |
else |
| 134 |
{ |
| 135 |
cf_player_message(pl, "You hear the bells of the temples of Navar.", NDI_UNIQUE|NDI_ORANGE); |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
static void ring_bell(void) |
| 143 |
{ |
| 144 |
object *pl; |
| 145 |
region *reg; |
| 146 |
const char *reg_name; |
| 147 |
|
| 148 |
|
| 149 |
pl = cf_object_get_object_property(NULL, CFAPI_PLAYER_PROP_NEXT); |
| 150 |
while (pl) |
| 151 |
{ |
| 152 |
|
| 153 |
if (pl->map) |
| 154 |
{ |
| 155 |
reg = cf_map_get_region_property(pl->map, CFAPI_MAP_PROP_REGION); |
| 156 |
if (reg) |
| 157 |
{ |
| 158 |
reg_name = cf_region_get_name(reg); |
| 159 |
if (!strcmp(reg_name, "scorn")) |
| 160 |
{ |
| 161 |
ring_scorn(pl); |
| 162 |
} |
| 163 |
else if (!strcmp(reg_name, "darcap")) |
| 164 |
{ |
| 165 |
ring_darcap(pl); |
| 166 |
} |
| 167 |
else if (!strcmp(reg_name, "navar")) |
| 168 |
{ |
| 169 |
ring_navar(pl); |
| 170 |
} |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
pl = cf_object_get_object_property(pl, CFAPI_PLAYER_PROP_NEXT); |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
CF_PLUGIN int cfcitybell_globalEventListener(int *type, ...) { |
| 186 |
va_list args; |
| 187 |
int code; |
| 188 |
timeofday_t tod; |
| 189 |
|
| 190 |
va_start(args, type); |
| 191 |
code = va_arg(args, int); |
| 192 |
|
| 193 |
switch (code) |
| 194 |
{ |
| 195 |
case EVENT_CLOCK: |
| 196 |
cf_get_time(&tod); |
| 197 |
if (tod.hour != last_hr) |
| 198 |
{ |
| 199 |
last_hr = tod.hour; |
| 200 |
ring_bell(); |
| 201 |
} |
| 202 |
break; |
| 203 |
} |
| 204 |
|
| 205 |
va_end(args); |
| 206 |
|
| 207 |
return 0; |
| 208 |
} |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
CF_PLUGIN int eventListener(int *type, ...) { |
| 218 |
return 0; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr) { |
| 231 |
cf_init_plugin(gethooksptr); |
| 232 |
|
| 233 |
cf_log(llevDebug, PLUGIN_VERSION " init\n"); |
| 234 |
|
| 235 |
return 0; |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
CF_PLUGIN void *getPluginProperty(int *type, ...) { |
| 246 |
va_list args; |
| 247 |
const char *propname; |
| 248 |
int size; |
| 249 |
char *buf; |
| 250 |
|
| 251 |
va_start(args, type); |
| 252 |
propname = va_arg(args, const char *); |
| 253 |
|
| 254 |
if (!strcmp(propname, "Identification")) { |
| 255 |
buf = va_arg(args, char *); |
| 256 |
size = va_arg(args, int); |
| 257 |
va_end(args); |
| 258 |
snprintf(buf, size, PLUGIN_NAME); |
| 259 |
return NULL; |
| 260 |
} else if (!strcmp(propname, "FullName")) { |
| 261 |
buf = va_arg(args, char *); |
| 262 |
size = va_arg(args, int); |
| 263 |
va_end(args); |
| 264 |
snprintf(buf, size, PLUGIN_VERSION); |
| 265 |
return NULL; |
| 266 |
} |
| 267 |
va_end(args); |
| 268 |
return NULL; |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
CF_PLUGIN int cfcitybell_runPluginCommand(object *op, char *params) { |
| 281 |
return -1; |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
CF_PLUGIN int postInitPlugin(void) { |
| 292 |
timeofday_t tod; |
| 293 |
|
| 294 |
|
| 295 |
cf_get_time(&tod); |
| 296 |
last_hr = tod.hour; |
| 297 |
|
| 298 |
cf_log(llevDebug, PLUGIN_VERSION " post init\n"); |
| 299 |
|
| 300 |
cf_system_register_global_event(EVENT_CLOCK, PLUGIN_NAME, cfcitybell_globalEventListener); |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
return 0; |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
CF_PLUGIN int closePlugin(void) { |
| 313 |
cf_log(llevDebug, PLUGIN_VERSION " closing\n"); |
| 314 |
return 0; |
| 315 |
} |
| 316 |
|
| 317 |
|