zombieplague.inc
Original include source with line numbers.
| 1 | /*================================================================================ |
| 2 | |
| 3 | --------------------------------------- |
| 4 | -*- Zombie Plague 4.3 Includes File -*- |
| 5 | --------------------------------------- |
| 6 | |
| 7 | ~~~~~~~~~~ |
| 8 | - How To - |
| 9 | ~~~~~~~~~~ |
| 10 | |
| 11 | To make use of the Zombie Plague API features in your plugin, just |
| 12 | add the following line at the beginning of your script: |
| 13 | |
| 14 | #include <zombieplague> |
| 15 | |
| 16 | ~~~~~~~~~~~ |
| 17 | - Natives - |
| 18 | ~~~~~~~~~~~ |
| 19 | |
| 20 | These work just like any other functions: you may have to pass |
| 21 | parameters and they usually return values. |
| 22 | |
| 23 | Example: |
| 24 | |
| 25 | if ( is_user_alive( id ) && zp_get_user_zombie( id ) ) |
| 26 | { |
| 27 | server_print( "Player %d is alive and a zombie", id ) |
| 28 | } |
| 29 | |
| 30 | ~~~~~~~~~~~~ |
| 31 | - Forwards - |
| 32 | ~~~~~~~~~~~~ |
| 33 | |
| 34 | Forwards get called whenever an event happens during the game. |
| 35 | You need to make a public callback somewhere on your script, |
| 36 | and it will automatically be triggered when the event occurs. |
| 37 | |
| 38 | Example: |
| 39 | |
| 40 | public zp_user_infected_post( id, infector, nemesis ) |
| 41 | { |
| 42 | if ( !infector || nemesis ) |
| 43 | return; |
| 44 | |
| 45 | server_print( "Player %d just got infected by %d!", id, infector ) |
| 46 | } |
| 47 | |
| 48 | Also, take note of cases when there's a suffix: |
| 49 | |
| 50 | * _pre : means the forward will be called BEFORE the event happens |
| 51 | * _post : means it will be called AFTER the event takes place |
| 52 | |
| 53 | =================================================================================*/ |
| 54 | |
| 55 | #if defined _zombieplague_included |
| 56 | #endinput |
| 57 | #endif |
| 58 | #define _zombieplague_included |
| 59 | |
| 60 | /* Teams for zp_register_extra_item() */ |
| 61 | #define ZP_TEAM_ZOMBIE (1<<0) |
| 62 | #define ZP_TEAM_HUMAN (1<<1) |
| 63 | #define ZP_TEAM_NEMESIS (1<<2) |
| 64 | #define ZP_TEAM_SURVIVOR (1<<3) |
| 65 | |
| 66 | /* Game modes for zp_round_started() */ |
| 67 | enum |
| 68 | { |
| 69 | MODE_INFECTION = 1, |
| 70 | MODE_NEMESIS, |
| 71 | MODE_SURVIVOR, |
| 72 | MODE_SWARM, |
| 73 | MODE_MULTI, |
| 74 | MODE_PLAGUE |
| 75 | } |
| 76 | |
| 77 | /* Winner teams for zp_round_ended() */ |
| 78 | enum |
| 79 | { |
| 80 | WIN_NO_ONE = 0, |
| 81 | WIN_ZOMBIES, |
| 82 | WIN_HUMANS |
| 83 | } |
| 84 | |
| 85 | /* Custom forward return values */ |
| 86 | #define ZP_PLUGIN_HANDLED 97 |
| 87 | |
| 88 | /** |
| 89 | * Returns whether a player is a zombie. |
| 90 | * |
| 91 | * @param id Player index. |
| 92 | * @return True if it is, false otherwise. |
| 93 | */ |
| 94 | native zp_get_user_zombie(id) |
| 95 | |
| 96 | /** |
| 97 | * Returns whether a player is a nemesis. |
| 98 | * |
| 99 | * @param id Player index. |
| 100 | * @return True if it is, false otherwise. |
| 101 | */ |
| 102 | native zp_get_user_nemesis(id) |
| 103 | |
| 104 | /** |
| 105 | * Returns whether a player is a survivor. |
| 106 | * |
| 107 | * @param id Player index. |
| 108 | * @return True if it is, false otherwise. |
| 109 | */ |
| 110 | native zp_get_user_survivor(id) |
| 111 | |
| 112 | /** |
| 113 | * Returns whether a player is the first zombie. |
| 114 | * |
| 115 | * @param id Player index. |
| 116 | * @return True if it is, false otherwise. |
| 117 | */ |
| 118 | native zp_get_user_first_zombie(id) |
| 119 | |
| 120 | /** |
| 121 | * Returns whether a player is the last zombie. |
| 122 | * |
| 123 | * @param id Player index. |
| 124 | * @return True if it is, false otherwise. |
| 125 | */ |
| 126 | native zp_get_user_last_zombie(id) |
| 127 | |
| 128 | /** |
| 129 | * Returns whether a player is the last human. |
| 130 | * |
| 131 | * @param id Player index. |
| 132 | * @return True if it is, false otherwise. |
| 133 | */ |
| 134 | native zp_get_user_last_human(id) |
| 135 | |
| 136 | /** |
| 137 | * Returns a player's current zombie class ID. |
| 138 | * |
| 139 | * @param id Player index. |
| 140 | * @return Internal zombie class ID, or -1 if not yet chosen. |
| 141 | */ |
| 142 | native zp_get_user_zombie_class(id) |
| 143 | |
| 144 | /** |
| 145 | * Returns a player's next zombie class ID (for the next infection). |
| 146 | * |
| 147 | * @param id Player index. |
| 148 | * @return Internal zombie class ID, or -1 if not yet chosen. |
| 149 | */ |
| 150 | native zp_get_user_next_class(id) |
| 151 | |
| 152 | /** |
| 153 | * Sets a player's next zombie class ID (for the next infection). |
| 154 | * |
| 155 | * @param id Player index. |
| 156 | * @param classid A valid zombie class ID. |
| 157 | * @return True on success, false otherwise. |
| 158 | */ |
| 159 | native zp_set_user_zombie_class(id, classid) |
| 160 | |
| 161 | /** |
| 162 | * Returns a player's ammo pack count. |
| 163 | * |
| 164 | * @param id Player index. |
| 165 | * @return Number of ammo packs owned. |
| 166 | */ |
| 167 | native zp_get_user_ammo_packs(id) |
| 168 | |
| 169 | /** |
| 170 | * Sets a player's ammo pack count. |
| 171 | * |
| 172 | * @param id Player index. |
| 173 | * @param amount New quantity of ammo packs owned. |
| 174 | */ |
| 175 | native zp_set_user_ammo_packs(id, amount) |
| 176 | |
| 177 | /** |
| 178 | * Returns the default maximum health of a zombie. |
| 179 | * |
| 180 | * Note: Takes into account first zombie's HP multiplier. |
| 181 | * |
| 182 | * @param id Player index. |
| 183 | * @return Maximum amount of health points, or -1 if not a normal zombie. |
| 184 | */ |
| 185 | native zp_get_zombie_maxhealth(id) |
| 186 | |
| 187 | /** |
| 188 | * Returns a player's custom flashlight batteries charge. |
| 189 | * |
| 190 | * @param id Player index. |
| 191 | * @return Charge percent (0 to 100). |
| 192 | */ |
| 193 | native zp_get_user_batteries(id) |
| 194 | |
| 195 | /** |
| 196 | * Sets a player's custom flashlight batteries charge. |
| 197 | * |
| 198 | * @param id Player index. |
| 199 | * @param value New charge percent (0 to 100). |
| 200 | */ |
| 201 | native zp_set_user_batteries(id, charge) |
| 202 | |
| 203 | /** |
| 204 | * Returns whether a player has night vision. |
| 205 | * |
| 206 | * @param id Player index. |
| 207 | * @return True if it has, false otherwise. |
| 208 | */ |
| 209 | native zp_get_user_nightvision(id) |
| 210 | |
| 211 | /** |
| 212 | * Sets whether a player has night vision. |
| 213 | * |
| 214 | * @param id Player index. |
| 215 | * @param set True to give, false for removing it. |
| 216 | */ |
| 217 | native zp_set_user_nightvision(id, set) |
| 218 | |
| 219 | /** |
| 220 | * Forces a player to become a zombie. |
| 221 | * |
| 222 | * Note: Unavailable for last human/survivor. |
| 223 | * |
| 224 | * @param id Player index to be infected. |
| 225 | * @param infector Player index who infected him (optional). |
| 226 | * @param silent If set, there will be no HUD messages or infection sounds. |
| 227 | * @param rewards Whether to show DeathMsg and reward frags, hp, and ammo packs to infector. |
| 228 | * @return True on success, false otherwise. |
| 229 | */ |
| 230 | native zp_infect_user(id, infector = 0, silent = 0, rewards = 0) |
| 231 | |
| 232 | /** |
| 233 | * Forces a player to become a human. |
| 234 | * |
| 235 | * Note: Unavailable for last zombie/nemesis. |
| 236 | * |
| 237 | * @param id Player index to be cured. |
| 238 | * @param silent If set, there will be no HUD messages or antidote sounds. |
| 239 | * @return True on success, false otherwise. |
| 240 | */ |
| 241 | native zp_disinfect_user(id, silent = 0) |
| 242 | |
| 243 | /** |
| 244 | * Forces a player to become a nemesis. |
| 245 | * |
| 246 | * Note: Unavailable for last human/survivor. |
| 247 | * |
| 248 | * @param id Player index to turn into nemesis. |
| 249 | * @return True on success, false otherwise. |
| 250 | */ |
| 251 | native zp_make_user_nemesis(id) |
| 252 | |
| 253 | /** |
| 254 | * Forces a player to become a survivor. |
| 255 | * |
| 256 | * Note: Unavailable for last zombie/nemesis. |
| 257 | * |
| 258 | * @param id Player index to turn into survivor. |
| 259 | * @return True on success, false otherwise. |
| 260 | */ |
| 261 | native zp_make_user_survivor(id) |
| 262 | |
| 263 | /** |
| 264 | * Respawns a player into a specific team. |
| 265 | * |
| 266 | * @param id Player index to be respawned. |
| 267 | * @param team Team to respawn the player into (ZP_TEAM_ZOMBIE or ZP_TEAM_HUMAN). |
| 268 | * @return True on success, false otherwise. |
| 269 | */ |
| 270 | native zp_respawn_user(id, team) |
| 271 | |
| 272 | /** |
| 273 | * Forces a player to buy an extra item. |
| 274 | * |
| 275 | * @param id Player index. |
| 276 | * @param itemid A valid extra item ID. |
| 277 | * @param ignorecost If set, item's cost won't be deduced from player. |
| 278 | * @return True on success, false otherwise. |
| 279 | */ |
| 280 | native zp_force_buy_extra_item(id, itemid, ignorecost = 0) |
| 281 | |
| 282 | /** |
| 283 | * Returns whether the ZP round has started, i.e. first zombie |
| 284 | * has been chosen or a game mode has begun. |
| 285 | * |
| 286 | * @return 0 - Round not started |
| 287 | * 1 - Round started |
| 288 | * 2 - Round starting |
| 289 | */ |
| 290 | native zp_has_round_started() |
| 291 | |
| 292 | /** |
| 293 | * Returns whether the current round is a nemesis round. |
| 294 | * |
| 295 | * @return True if it is, false otherwise. |
| 296 | */ |
| 297 | native zp_is_nemesis_round() |
| 298 | |
| 299 | /** |
| 300 | * Returns whether the current round is a survivor round. |
| 301 | * |
| 302 | * @return True if it is, false otherwise. |
| 303 | */ |
| 304 | native zp_is_survivor_round() |
| 305 | |
| 306 | /** |
| 307 | * Returns whether the current round is a swarm round. |
| 308 | * |
| 309 | * @return True if it is, false otherwise. |
| 310 | */ |
| 311 | native zp_is_swarm_round() |
| 312 | |
| 313 | /** |
| 314 | * Returns whether the current round is a plague round. |
| 315 | * |
| 316 | * @return True if it is, false otherwise. |
| 317 | */ |
| 318 | native zp_is_plague_round() |
| 319 | |
| 320 | /** |
| 321 | * Returns number of alive zombies. |
| 322 | * |
| 323 | * @return Zombie count. |
| 324 | */ |
| 325 | native zp_get_zombie_count() |
| 326 | |
| 327 | /** |
| 328 | * Returns number of alive humans. |
| 329 | * |
| 330 | * @return Human count. |
| 331 | */ |
| 332 | native zp_get_human_count() |
| 333 | |
| 334 | /** |
| 335 | * Returns number of alive nemesis. |
| 336 | * |
| 337 | * @return Nemesis count. |
| 338 | */ |
| 339 | native zp_get_nemesis_count() |
| 340 | |
| 341 | /** |
| 342 | * Returns number of alive survivors. |
| 343 | * |
| 344 | * @return Survivor count. |
| 345 | */ |
| 346 | native zp_get_survivor_count() |
| 347 | |
| 348 | /** |
| 349 | * Registers a custom item which will be added to the extra items menu of ZP. |
| 350 | * |
| 351 | * Note: The returned extra item ID can be later used to catch item |
| 352 | * purchase events for the zp_extra_item_selected() forward. |
| 353 | * |
| 354 | * Note: ZP_TEAM_NEMESIS and ZP_TEAM_SURVIVOR can be used to make |
| 355 | * an item available to Nemesis and Survivors respectively. |
| 356 | * |
| 357 | * @param name Caption to display on the menu. |
| 358 | * @param cost Ammo packs to be deducted on purchase. |
| 359 | * @param teams Bitsum of teams it should be available for. |
| 360 | * @return An internal extra item ID, or -1 on failure. |
| 361 | */ |
| 362 | native zp_register_extra_item(const name[], cost, teams) |
| 363 | |
| 364 | /** |
| 365 | * Registers a custom class which will be added to the zombie classes menu of ZP. |
| 366 | * |
| 367 | * Note: The returned zombie class ID can be later used to identify |
| 368 | * the class when calling the zp_get_user_zombie_class() natives. |
| 369 | * |
| 370 | * @param name Caption to display on the menu. |
| 371 | * @param info Brief description of the class. |
| 372 | * @param model Player model to be used. |
| 373 | * @param clawmodel Claws model to be used. |
| 374 | * @param hp Initial health points. |
| 375 | * @param speed Maximum speed. |
| 376 | * @param gravity Gravity multiplier. |
| 377 | * @param knockback Knockback multiplier. |
| 378 | * @return An internal zombie class ID, or -1 on failure. |
| 379 | */ |
| 380 | native zp_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback) |
| 381 | |
| 382 | /** |
| 383 | * Returns an extra item's ID. |
| 384 | * |
| 385 | * @param name Item name to look for. |
| 386 | * @return Internal extra item ID, or -1 if not found. |
| 387 | */ |
| 388 | native zp_get_extra_item_id(const name[]) |
| 389 | |
| 390 | /** |
| 391 | * Returns a zombie class' ID. |
| 392 | * |
| 393 | * @param name Class name to look for. |
| 394 | * @return Internal zombie class ID, or -1 if not found. |
| 395 | */ |
| 396 | native zp_get_zombie_class_id(const name[]) |
| 397 | |
| 398 | /** |
| 399 | * Called when the ZP round starts, i.e. first zombie |
| 400 | * is chosen or a game mode begins. |
| 401 | * |
| 402 | * @param gamemode Mode which has started. |
| 403 | * @param id Affected player's index (if applicable). |
| 404 | */ |
| 405 | forward zp_round_started(gamemode, id) |
| 406 | |
| 407 | /** |
| 408 | * Called when the round ends. |
| 409 | * |
| 410 | * @param winteam Team which has won the round. |
| 411 | */ |
| 412 | forward zp_round_ended(winteam) |
| 413 | |
| 414 | /** |
| 415 | * Called when a player gets infected. |
| 416 | * |
| 417 | * @param id Player index who was infected. |
| 418 | * @param infector Player index who infected him (if applicable). |
| 419 | * @param nemesis Whether the player was turned into a nemesis. |
| 420 | */ |
| 421 | forward zp_user_infected_pre(id, infector, nemesis) |
| 422 | forward zp_user_infected_post(id, infector, nemesis) |
| 423 | |
| 424 | /** |
| 425 | * Called when a player turns back to human. |
| 426 | * |
| 427 | * @param id Player index who was cured. |
| 428 | * @param survivor Whether the player was turned into a survivor. |
| 429 | */ |
| 430 | forward zp_user_humanized_pre(id, survivor) |
| 431 | forward zp_user_humanized_post(id, survivor) |
| 432 | |
| 433 | /** |
| 434 | * Called on a player infect/cure attempt. You can use this to block |
| 435 | * an infection/humanization by returning ZP_PLUGIN_HANDLED in your plugin. |
| 436 | * |
| 437 | * Note: Right now this is only available after the ZP round starts, since some |
| 438 | * situations (like blocking a first zombie's infection) are not yet handled. |
| 439 | */ |
| 440 | forward zp_user_infect_attempt(id, infector, nemesis) |
| 441 | forward zp_user_humanize_attempt(id, survivor) |
| 442 | |
| 443 | /** |
| 444 | * Called when a player buys an extra item from the ZP menu. |
| 445 | * |
| 446 | * Note: You can now return ZP_PLUGIN_HANDLED in your plugin to block |
| 447 | * the purchase and the player will be automatically refunded. |
| 448 | * |
| 449 | * @param id Player index of purchaser. |
| 450 | * @param itemid Internal extra item ID. |
| 451 | */ |
| 452 | forward zp_extra_item_selected(id, itemid) |
| 453 | |
| 454 | /** |
| 455 | * Called when a player gets unfrozen (frostnades). |
| 456 | * |
| 457 | * @param id Player index. |
| 458 | */ |
| 459 | forward zp_user_unfrozen(id) |
| 460 | |
| 461 | /** |
| 462 | * Called when a player becomes the last zombie. |
| 463 | * |
| 464 | * Note: This is called for the first zombie too. |
| 465 | * |
| 466 | * @param id Player index. |
| 467 | */ |
| 468 | forward zp_user_last_zombie(id) |
| 469 | |
| 470 | /** |
| 471 | * Called when a player becomes the last human. |
| 472 | * |
| 473 | * @param id Player index. |
| 474 | */ |
| 475 | forward zp_user_last_human(id) |
| 476 | |
| 477 | |
| 478 | /** |
| 479 | * @deprecated - Do not use! |
| 480 | * For backwards compatibility only. |
| 481 | */ |
| 482 | #define ZP_TEAM_ANY 0 |
| 483 | |