msgstocks.inc
Original include source with line numbers.
| 1 | // vim: set ts=4 sw=4 tw=99 noet: |
| 2 | // |
| 3 | // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). |
| 4 | // Copyright (C) The AMX Mod X Development Team. |
| 5 | // |
| 6 | // This software is licensed under the GNU General Public License, version 3 or higher. |
| 7 | // Additional exceptions apply. For full license details, see LICENSE.txt or visit: |
| 8 | // https://alliedmods.net/amxmodx-license |
| 9 | |
| 10 | // |
| 11 | // Message Stocks |
| 12 | // |
| 13 | |
| 14 | #if defined _msgnatives_included |
| 15 | #endinput |
| 16 | #endif |
| 17 | |
| 18 | #if defined _msgstocks_included |
| 19 | #endinput |
| 20 | #endif |
| 21 | |
| 22 | #define _msgstocks_included |
| 23 | |
| 24 | #define MSGSTOCKS_VERSION 1.0 |
| 25 | |
| 26 | /** |
| 27 | * @section Normal message stocks |
| 28 | */ |
| 29 | |
| 30 | /** |
| 31 | * Temporarily draws HUD numerical ammo amount and corresponding ammo |
| 32 | * HUD icon in the middle of the right side of the screen. |
| 33 | * |
| 34 | * @note Draw time depends on the hud_drawhistory_time client cvar value. |
| 35 | * |
| 36 | * @param id Client index or 0 for all clients |
| 37 | * @param ammoid Ammunition id |
| 38 | * @param amount Ammunition amount |
| 39 | * @param reliable If true, the message will be sent via the reliable |
| 40 | * channel, otherwise it will use the unreliable one |
| 41 | * |
| 42 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 43 | * 1 otherwise |
| 44 | */ |
| 45 | stock draw_ammo_pickup_icon(id, ammoid, amount, bool:reliable = true) |
| 46 | { |
| 47 | if(id && !is_user_connected(id)) |
| 48 | return 0; |
| 49 | |
| 50 | static MSG_AmmoPickup; |
| 51 | |
| 52 | if(!MSG_AmmoPickup) |
| 53 | MSG_AmmoPickup = get_user_msgid("AmmoPickup"); |
| 54 | |
| 55 | message_begin(get_msg_destination(id, reliable), MSG_AmmoPickup, .player = id); |
| 56 | write_byte(ammoid); |
| 57 | write_byte(amount); |
| 58 | message_end(); |
| 59 | |
| 60 | return 1; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Temporarily draws a corresponding item HUD icon in the middle of the |
| 65 | * right side of the screen. |
| 66 | * |
| 67 | * @note This stock isn't available in Day of Defeat. |
| 68 | * @note Draw time depends on the hud_drawhistory_time client cvar value. |
| 69 | * @note A list of all icons and screenshots of them can be found here: |
| 70 | * http://doktor.haze.free.fr/counter-strike/sprites_screens/index.php |
| 71 | * |
| 72 | * @param id Client index or 0 for all clients |
| 73 | * @param itemname Item name |
| 74 | * @param reliable If true, the message will be sent via the reliable |
| 75 | * channel, otherwise it will use the unreliable one |
| 76 | * |
| 77 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 78 | * 1 otherwise |
| 79 | */ |
| 80 | stock draw_item_pickup_icon(id, itemname[], bool:reliable = true) |
| 81 | { |
| 82 | if(id && !is_user_connected(id)) |
| 83 | return 0; |
| 84 | |
| 85 | static MSG_ItemPickup; |
| 86 | |
| 87 | if(!MSG_ItemPickup) |
| 88 | MSG_ItemPickup = get_user_msgid("ItemPickup"); |
| 89 | |
| 90 | message_begin(get_msg_destination(id, reliable), MSG_ItemPickup, .player = id); |
| 91 | write_string(itemname); |
| 92 | message_end(); |
| 93 | |
| 94 | return 1; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Temporarily draws the corresponding weapon HUD icon in the middle of the |
| 99 | * right side of the screen. |
| 100 | * |
| 101 | * @note Draw time depends on the hud_drawhistory_time client cvar value. |
| 102 | * |
| 103 | * @param id Client index or 0 for all clients |
| 104 | * @param weaponid Weapon id |
| 105 | * @param reliable If true, the message will be sent via the reliable |
| 106 | * channel, otherwise it will use the unreliable one |
| 107 | * |
| 108 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 109 | * 1 otherwise |
| 110 | */ |
| 111 | stock draw_weapon_pickup_icon(id, weaponid, bool:reliable = true) |
| 112 | { |
| 113 | if(id && !is_user_connected(id)) |
| 114 | return 0; |
| 115 | |
| 116 | static MSG_WeapPickup; |
| 117 | |
| 118 | if(!MSG_WeapPickup) |
| 119 | MSG_WeapPickup = get_user_msgid("WeapPickup"); |
| 120 | |
| 121 | message_begin(get_msg_destination(id, reliable), MSG_WeapPickup, .player = id); |
| 122 | write_byte(weaponid); |
| 123 | message_end(); |
| 124 | |
| 125 | return 1; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Flags used in draw_status_icon() |
| 130 | */ |
| 131 | enum StatusIconFlags |
| 132 | { |
| 133 | StatusIcon_Hide = 0, |
| 134 | StatusIcon_Show, |
| 135 | StatusIcon_Flash |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Draws a specified status HUD icon. |
| 140 | * |
| 141 | * @note This stock is available only in the following games: |
| 142 | * Counter-Strike |
| 143 | * Counter-Strike: Condition Zero |
| 144 | * Half-Life: Opposing Force |
| 145 | * Team Fortress Classic |
| 146 | * @note A list of all icons and screenshots of them can be found here: |
| 147 | * http://doktor.haze.free.fr/counter-strike/sprites_screens/index.php |
| 148 | * |
| 149 | * @param id Client index or 0 for all clients |
| 150 | * @param sprite Sprite name (valid names are listed in sprites/hud.txt) |
| 151 | * @param status Valid status values: |
| 152 | * StatusIcon_Hide - hides the status icon |
| 153 | * StatusIcon_Show - shows the status icon |
| 154 | * StatusIcon_Flash - flashes the status icon |
| 155 | * @param r Red color amount (0 - 255) |
| 156 | * @param g Green color amount (0 - 255) |
| 157 | * @param b Blue color amount (0 - 255) |
| 158 | * @param reliable If true, the message will be sent via the reliable |
| 159 | * channel, otherwise it will use the unreliable one |
| 160 | * |
| 161 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 162 | * 1 otherwise |
| 163 | */ |
| 164 | stock draw_status_icon(id, sprite[] = "", StatusIconFlags:status = StatusIcon_Hide, r = 0, g = 0, b = 0, bool:reliable = true) |
| 165 | { |
| 166 | if(id && !is_user_connected(id)) |
| 167 | return 0; |
| 168 | |
| 169 | static MSG_StatusIcon; |
| 170 | |
| 171 | if(!MSG_StatusIcon) |
| 172 | MSG_StatusIcon = get_user_msgid("StatusIcon"); |
| 173 | |
| 174 | message_begin(get_msg_destination(id, reliable), MSG_StatusIcon, .player = id); |
| 175 | write_byte(_:status); |
| 176 | |
| 177 | if(status) |
| 178 | { |
| 179 | write_string(sprite); |
| 180 | write_byte(r); |
| 181 | write_byte(g); |
| 182 | write_byte(b); |
| 183 | } |
| 184 | |
| 185 | message_end(); |
| 186 | return 1; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Train controls used in draw_train_controls() |
| 191 | */ |
| 192 | enum TrainControlFlags |
| 193 | { |
| 194 | TrainControls_None = 0, |
| 195 | TrainControls_Neutral, |
| 196 | TrainControls_Slow, |
| 197 | TrainControls_Medium, |
| 198 | TrainControls_Maximum, |
| 199 | TrainControls_Reverse |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Displays the speed bar used for controlling a train. |
| 204 | * |
| 205 | * @note This stock isn't available in Day of Defeat. |
| 206 | * |
| 207 | * @param id Client index or 0 for all clients |
| 208 | * @param speed Train speed: |
| 209 | * TrainControls_None |
| 210 | * TrainControls_Neutral |
| 211 | * TrainControls_Slow |
| 212 | * TrainControls_Medium |
| 213 | * TrainControls_Maximum |
| 214 | * TrainControls_Reverse |
| 215 | * @param reliable If true, the message will be sent via the reliable |
| 216 | * channel, otherwise it will use the unreliable one |
| 217 | * |
| 218 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 219 | * 1 otherwise |
| 220 | */ |
| 221 | stock draw_train_controls(id, TrainControlFlags:speed = TrainControls_None, bool:reliable = true) |
| 222 | { |
| 223 | if(id && !is_user_connected(id)) |
| 224 | return 0; |
| 225 | |
| 226 | static MSG_Train; |
| 227 | |
| 228 | if(!MSG_Train) |
| 229 | MSG_Train = get_user_msgid("Train"); |
| 230 | |
| 231 | message_begin(get_msg_destination(id, reliable), MSG_Train, .player = id); |
| 232 | write_byte(_:speed); |
| 233 | message_end(); |
| 234 | |
| 235 | return 1; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Sends the geiger signal that notifies the player of nearby radiation level. |
| 240 | * |
| 241 | * @note This stock isn't available in Day of Defeat. |
| 242 | * |
| 243 | * @param id Client index or 0 for all clients |
| 244 | * @param distance Signal distance |
| 245 | * @param reliable If true, the message will be sent via the reliable |
| 246 | * channel, otherwise it will use the unreliable one |
| 247 | * |
| 248 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 249 | * 1 otherwise |
| 250 | */ |
| 251 | stock send_geiger_signal(id, distance, bool:reliable = true) |
| 252 | { |
| 253 | if(id && !is_user_connected(id)) |
| 254 | return 0; |
| 255 | |
| 256 | static MSG_Geiger; |
| 257 | |
| 258 | if(!MSG_Geiger) |
| 259 | MSG_Geiger = get_user_msgid("Geiger"); |
| 260 | |
| 261 | message_begin(get_msg_destination(id, reliable), MSG_Geiger, .player = id); |
| 262 | write_byte(distance); |
| 263 | message_end(); |
| 264 | |
| 265 | return 1; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Flags used in hide_hud_elements() |
| 270 | */ |
| 271 | enum HideElemenentFlags (<<= 1) |
| 272 | { |
| 273 | HideElement_None = 0, |
| 274 | HideElement_Cross_Ammo_WPNList = 1, |
| 275 | HideElement_Flashlight, |
| 276 | HideElement_All, |
| 277 | HideElement_Radar_Health_Armor, |
| 278 | HideElement_Timer, |
| 279 | HideElement_Money, |
| 280 | HideElement_Crosshair |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Hides specific elements from the HUD. |
| 285 | * |
| 286 | * @note The symbol + means that an additional crosshair will be drawn. |
| 287 | * This crosshair looks not like the regular one, but like the one that |
| 288 | * is drawn in spectator mode. You can remove this crosshair by setting |
| 289 | * the "noadd" argument to "true". |
| 290 | * |
| 291 | * @param id Client index or 0 for all clients |
| 292 | * @param elements HUD elements to hide. The names are self-explanatory: |
| 293 | * HideElement_Cross_Ammo_WPNList |
| 294 | * HideElement_Flashlight (+) |
| 295 | * HideElement_All |
| 296 | * HideElement_Radar_Health_Armor (+) |
| 297 | * HideElement_Timer (+) |
| 298 | * HideElement_Money (+) |
| 299 | * HideElement_Crosshair |
| 300 | * @param noadd If set to false and the chosen element names have |
| 301 | * a "+" sign, an additional crosshair will be drawn. |
| 302 | * @param reliable If true, the message will be sent via the reliable |
| 303 | * channel, otherwise it will use the unreliable one |
| 304 | * |
| 305 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 306 | * 1 otherwise |
| 307 | */ |
| 308 | stock hide_hud_elements(id, HideElemenentFlags:elements, bool:noadd = true, bool:reliable = true) |
| 309 | { |
| 310 | if(id && !is_user_connected(id)) |
| 311 | return 0; |
| 312 | |
| 313 | static MSG_HideWeapon; |
| 314 | |
| 315 | if(!MSG_HideWeapon) |
| 316 | MSG_HideWeapon = get_user_msgid("HideWeapon"); |
| 317 | |
| 318 | new iDest = get_msg_destination(id, reliable); |
| 319 | |
| 320 | message_begin(iDest, MSG_HideWeapon, .player = id); |
| 321 | write_byte(_:elements); |
| 322 | message_end(); |
| 323 | |
| 324 | if(noadd) |
| 325 | { |
| 326 | static MSG_Crosshair; |
| 327 | |
| 328 | if(!MSG_Crosshair) |
| 329 | MSG_Crosshair = get_user_msgid("Crosshair"); |
| 330 | |
| 331 | message_begin(iDest, MSG_Crosshair, .player = id); |
| 332 | write_byte(0); |
| 333 | message_end(); |
| 334 | } |
| 335 | |
| 336 | return 1; |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * Flags used in fade_user_screen() |
| 341 | */ |
| 342 | enum ScreenFadeFlags |
| 343 | { |
| 344 | ScreenFade_FadeIn = 0x0000, |
| 345 | ScreenFade_FadeOut = 0x0001, |
| 346 | ScreenFade_Modulate = 0x0002, |
| 347 | ScreenFade_StayOut = 0x0004 |
| 348 | } |
| 349 | |
| 350 | /** |
| 351 | * Fades the client's screen. |
| 352 | * |
| 353 | * @param id Client index or 0 for all clients |
| 354 | * @param duration How long (in seconds) the fade is going to stay |
| 355 | * on the screen (0 - 16) |
| 356 | * @param fadetime How many seconds is the fade going to fade in (0 - 16) |
| 357 | * @param flags Screen fade flags: |
| 358 | * ScreenFade_FadeIn - default |
| 359 | * ScreenFade_FadeOut - fade out (not in) |
| 360 | * ScreenFade_Modulate - modulate (don't blend) |
| 361 | * ScreenFade_StayOut - ignores the duration and stays faded out until a new ScreenFade messages is received |
| 362 | * @param r Red color amount (0 - 255) |
| 363 | * @param g Green color amount (0 - 255) |
| 364 | * @param b Blue color amount (0 - 255) |
| 365 | * @param a Color alpha (brightness) (0 - 255) |
| 366 | * @param reliable If true, the message will be sent via the reliable |
| 367 | * channel, otherwise it will use the unreliable one |
| 368 | * |
| 369 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 370 | * 1 otherwise |
| 371 | */ |
| 372 | stock fade_user_screen(id, Float:duration = 1.0, Float:fadetime = 1.0, ScreenFadeFlags:flags = ScreenFade_FadeIn, r = 0, g = 0, b = 255, a = 75, bool:reliable = true) |
| 373 | { |
| 374 | if(id && !is_user_connected(id)) |
| 375 | return 0; |
| 376 | |
| 377 | static MSG_ScreenFade; |
| 378 | |
| 379 | if(!MSG_ScreenFade) |
| 380 | MSG_ScreenFade = get_user_msgid("ScreenFade"); |
| 381 | |
| 382 | message_begin(get_msg_destination(id, reliable), MSG_ScreenFade, .player = id); |
| 383 | write_short(float_to_short(fadetime)); |
| 384 | write_short(float_to_short(duration)); |
| 385 | write_short(_:flags); |
| 386 | write_byte(r); |
| 387 | write_byte(g); |
| 388 | write_byte(b); |
| 389 | write_byte(a); |
| 390 | message_end(); |
| 391 | |
| 392 | return 1; |
| 393 | } |
| 394 | |
| 395 | /** |
| 396 | * Shakes the client's screen. |
| 397 | * |
| 398 | * @param id Client index or 0 for all clients |
| 399 | * @param amplitude Shake amplitude (0 - 16) |
| 400 | * @param duration Shake duration (in seconds) (0 - 16) |
| 401 | * @param frequency Delay between each shake (0 - 16) |
| 402 | * @param reliable If true, the message will be sent via the reliable |
| 403 | * channel, otherwise it will use the unreliable one |
| 404 | * |
| 405 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 406 | * 1 otherwise |
| 407 | */ |
| 408 | stock shake_user_screen(id, Float:amplitude = 3.0, Float:duration = 3.0, Float:frequency = 1.0, bool:reliable = true) |
| 409 | { |
| 410 | if(id && !is_user_connected(id)) |
| 411 | return 0; |
| 412 | |
| 413 | static MSG_ScreenShake; |
| 414 | |
| 415 | if(!MSG_ScreenShake) |
| 416 | MSG_ScreenShake = get_user_msgid("ScreenShake"); |
| 417 | |
| 418 | message_begin(get_msg_destination(id, reliable), MSG_ScreenShake, .player = id); |
| 419 | write_short(float_to_short(amplitude)); |
| 420 | write_short(float_to_short(duration)); |
| 421 | write_short(float_to_short(frequency)); |
| 422 | message_end(); |
| 423 | |
| 424 | return 1; |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Changes the client's field of view (FOV). |
| 429 | * |
| 430 | * @note Setting the "fov" argument below 45 will also draw a sniper scope. |
| 431 | * |
| 432 | * @param id Client index or 0 for all clients |
| 433 | * @param fov Field of view degrees (0 - 255) |
| 434 | * @param reliable If true, the message will be sent via the reliable |
| 435 | * channel, otherwise it will use the unreliable one |
| 436 | * |
| 437 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 438 | * 1 otherwise |
| 439 | */ |
| 440 | stock set_user_fov(id, fov = 0, bool:reliable = true) |
| 441 | { |
| 442 | if(id && !is_user_connected(id)) |
| 443 | return 0; |
| 444 | |
| 445 | static MSG_SetFOV; |
| 446 | |
| 447 | if(!MSG_SetFOV) |
| 448 | MSG_SetFOV = get_user_msgid("SetFOV"); |
| 449 | |
| 450 | message_begin(get_msg_destination(id, reliable), MSG_SetFOV, .player = id); |
| 451 | write_byte(fov); |
| 452 | message_end(); |
| 453 | |
| 454 | return 1; |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * @endsection |
| 459 | */ |
| 460 | |
| 461 | /** |
| 462 | * @section Counter-Strike message stocks |
| 463 | */ |
| 464 | |
| 465 | /** |
| 466 | * Draws a HUD progress bar which is filled from 0% to 100% for the given |
| 467 | * amount of seconds. Once the bar is fully filled it will be removed from |
| 468 | * the screen automatically. |
| 469 | * |
| 470 | * @note If the "startpercent" argument is greater than 0, the bar will be |
| 471 | * filled from that amount of percentage instead of starting from 0%. |
| 472 | * |
| 473 | * @param id Client index or 0 for all clients |
| 474 | * @param duration How long (in seconds) until the bar is fully filled |
| 475 | * @param startpercent Bar starting percentage (0-100) |
| 476 | * @param reliable If true, the message will be sent via the reliable |
| 477 | * channel, otherwise it will use the unreliable one |
| 478 | * |
| 479 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 480 | * 1 otherwise |
| 481 | */ |
| 482 | stock cs_draw_progress_bar(id, duration, startpercent = 0, bool:reliable = true) |
| 483 | { |
| 484 | if(id && !is_user_connected(id)) |
| 485 | return 0; |
| 486 | |
| 487 | if(startpercent) |
| 488 | { |
| 489 | static MSG_BarTime2; |
| 490 | |
| 491 | if(!MSG_BarTime2) |
| 492 | MSG_BarTime2 = get_user_msgid("BarTime2"); |
| 493 | |
| 494 | message_begin(get_msg_destination(id, reliable), MSG_BarTime2, .player = id); |
| 495 | } |
| 496 | else |
| 497 | { |
| 498 | static MSG_BarTime; |
| 499 | |
| 500 | if(!MSG_BarTime) |
| 501 | MSG_BarTime = get_user_msgid("BarTime"); |
| 502 | |
| 503 | message_begin(get_msg_destination(id, reliable), MSG_BarTime, .player = id); |
| 504 | } |
| 505 | |
| 506 | write_short(duration); |
| 507 | |
| 508 | if(startpercent) |
| 509 | write_short(startpercent); |
| 510 | |
| 511 | message_end(); |
| 512 | return 1; |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * Plays a generic reload sound. |
| 517 | * |
| 518 | * @param id Client index or 0 for all clients |
| 519 | * @param shotgun If set to true, it will play "weapons/generic_shot_reload.wav", |
| 520 | * otherwise it will play "weapons/generic_reload.wav". |
| 521 | * @param volume Volume amount (0 - 255) |
| 522 | * @param reliable If true, the message will be sent via the reliable |
| 523 | * channel, otherwise it will use the unreliable one |
| 524 | * |
| 525 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 526 | * 1 otherwise |
| 527 | */ |
| 528 | stock cs_play_reload_sound(id, bool:shotgun = false, volume = 100, bool:reliable = true) |
| 529 | { |
| 530 | if(id && !is_user_connected(id)) |
| 531 | return 0; |
| 532 | |
| 533 | static MSG_ReloadSound; |
| 534 | |
| 535 | if(!MSG_ReloadSound) |
| 536 | MSG_ReloadSound = get_user_msgid("ReloadSound"); |
| 537 | |
| 538 | message_begin(get_msg_destination(id, reliable), MSG_ReloadSound, .player = id); |
| 539 | write_byte(volume); |
| 540 | write_byte(!shotgun); |
| 541 | message_end(); |
| 542 | |
| 543 | return 1; |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Displays a sprite to the right side of the round timer. |
| 548 | * |
| 549 | * @note A list of all icons and screenshots of them can be found here: |
| 550 | * http://doktor.haze.free.fr/counter-strike/sprites_screens/index.php |
| 551 | * |
| 552 | * @param id Client index or 0 for all clients |
| 553 | * @param active If set to 0, it will remove the scenario icon and |
| 554 | * ignore all other arguments. Always set this to 1 |
| 555 | * if you want to use any of the other arguments |
| 556 | * @param sprite Sprite name (valid names are listed in sprites.hud.txt) |
| 557 | * @param alpha Sprite alpha (100-255) |
| 558 | * @param flashrate If nonzero, the sprite will flash from the given alpha |
| 559 | * in the "alpha" argument to an alpha of 100, at a rate |
| 560 | * set in this argument |
| 561 | * @param flashdelay Delay (in seconds) between each flash |
| 562 | * @param reliable If true, the message will be sent via the reliable |
| 563 | * channel, otherwise it will use the unreliable one |
| 564 | * |
| 565 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 566 | * 1 otherwise |
| 567 | */ |
| 568 | stock cs_set_hud_icon(id, active = 0, sprite[] = "", alpha = 100, flashrate = 0, flashdelay = 0, bool:reliable = true) |
| 569 | { |
| 570 | if(id && !is_user_connected(id)) |
| 571 | return 0; |
| 572 | |
| 573 | static MSG_Scenario; |
| 574 | |
| 575 | if(!MSG_Scenario) |
| 576 | MSG_Scenario = get_user_msgid("Scenario"); |
| 577 | |
| 578 | message_begin(get_msg_destination(id, reliable), MSG_Scenario, .player = id); |
| 579 | write_byte(active); |
| 580 | |
| 581 | if(active) |
| 582 | { |
| 583 | write_string(sprite); |
| 584 | write_byte(alpha); |
| 585 | } |
| 586 | |
| 587 | if(flashrate) |
| 588 | { |
| 589 | write_short(flashrate); |
| 590 | write_short(flashdelay); |
| 591 | } |
| 592 | |
| 593 | message_end(); |
| 594 | return 1; |
| 595 | } |
| 596 | |
| 597 | /** |
| 598 | * Creates/Hides the shadow beneath players. |
| 599 | * |
| 600 | * @note This stock can't be used to set shadow to a specific player. It can |
| 601 | * only set the shadow that a specific player sees for all other players. |
| 602 | * |
| 603 | * @param id Client index or 0 for all clients |
| 604 | * @param shadowid Sprite index or 0 to disable the shadow |
| 605 | * @param reliable If true, the message will be sent via the reliable |
| 606 | * channel, otherwise it will use the unreliable one |
| 607 | * |
| 608 | * @return 0 if "id" is non-zero and the client isn't connected, |
| 609 | * 1 otherwise |
| 610 | */ |
| 611 | stock cs_set_user_shadow(id, shadowid = 0, bool:reliable = true) |
| 612 | { |
| 613 | if(id && !is_user_connected(id)) |
| 614 | return 0; |
| 615 | |
| 616 | static MSG_ShadowIdx; |
| 617 | |
| 618 | if(!MSG_ShadowIdx) |
| 619 | MSG_ShadowIdx = get_user_msgid("ShadowIdx"); |
| 620 | |
| 621 | message_begin(get_msg_destination(id, reliable), MSG_ShadowIdx, .player = id); |
| 622 | write_long(shadowid); |
| 623 | message_end(); |
| 624 | |
| 625 | return 1; |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * @endsection |
| 630 | */ |
| 631 | |
| 632 | /** |
| 633 | * @section Stocks using temporary entities (SVC_TEMPENTITY) |
| 634 | */ |
| 635 | |
| 636 | /** |
| 637 | * Creates a beam between two points. |
| 638 | * |
| 639 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 640 | * @note Video preview of this and all other te_ stocks can be found here: |
| 641 | * https://youtu.be/szW-bSMPuyQ?t=3s |
| 642 | * |
| 643 | * @param startpos Starting coordinates of the beam |
| 644 | * @param endpos Ending coordinates of the beam |
| 645 | * @param sprite The sprite index to use in the beam |
| 646 | * @param startframe The frame to start with in the sprite (0 - 255) |
| 647 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 648 | * @param life The length of time the beam shall remain (0 - 255) |
| 649 | * @param width The width of the beam (0 - 255) |
| 650 | * @param noise The noise amplitude of the beam, this controls |
| 651 | * the distorsion of the beam (0 - 255) |
| 652 | * @param r Red color amount (0 - 255) |
| 653 | * @param g Green color amount (0 - 255) |
| 654 | * @param b Blue color amount (0 - 255) |
| 655 | * @param a Beam brightness (alpha) (0 - 255) |
| 656 | * @param speed The scroll speed of the beam (0 - 255) |
| 657 | * @param receiver Client index that will be able to see the beam |
| 658 | * or 0 for all clients |
| 659 | * @param reliable If true, the message will be sent via the reliable |
| 660 | * channel, otherwise it will use the unreliable one |
| 661 | * |
| 662 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 663 | * 1 otherwise |
| 664 | */ |
| 665 | stock te_create_beam_between_points(startpos[3], endpos[3], sprite, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 666 | { |
| 667 | if(receiver && !is_user_connected(receiver)) |
| 668 | return 0; |
| 669 | |
| 670 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 671 | write_byte(TE_BEAMPOINTS); |
| 672 | write_coord(startpos[0]); |
| 673 | write_coord(startpos[1]); |
| 674 | write_coord(startpos[2]); |
| 675 | write_coord(endpos[0]); |
| 676 | write_coord(endpos[1]); |
| 677 | write_coord(endpos[2]); |
| 678 | write_short(sprite); |
| 679 | write_byte(startframe); |
| 680 | write_byte(framerate); |
| 681 | write_byte(life); |
| 682 | write_byte(width); |
| 683 | write_byte(noise); |
| 684 | write_byte(r); |
| 685 | write_byte(g); |
| 686 | write_byte(b); |
| 687 | write_byte(a); |
| 688 | write_byte(speed); |
| 689 | message_end(); |
| 690 | |
| 691 | return 1; |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * Creates a beam between an entity and a point. |
| 696 | * |
| 697 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 698 | * @note Video preview of this and all other te_ stocks can be found here: |
| 699 | * https://youtu.be/szW-bSMPuyQ?t=20s |
| 700 | * |
| 701 | * @param startent Primary entity id |
| 702 | * @param endpos Ending coordinates of the beam |
| 703 | * @param sprite The sprite index to use in the beam |
| 704 | * @param startframe The frame to start with in the sprite (0 - 255) |
| 705 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 706 | * @param life The length of time the beam shall remain (0 - 255) |
| 707 | * @param width The width of the beam (0 - 255) |
| 708 | * @param noise The noise amplitude of the beam, this controls |
| 709 | * the distorsion of the beam (0 - 255) |
| 710 | * @param r Red color amount (0 - 255) |
| 711 | * @param g Green color amount (0 - 255) |
| 712 | * @param b Blue color amount (0 - 255) |
| 713 | * @param a Beam brightness (alpha) (0 - 255) |
| 714 | * @param speed The scroll speed of the beam (0 - 255) |
| 715 | * @param receiver Client index that will be able to see the beam |
| 716 | * or 0 for all clients |
| 717 | * @param reliable If true, the message will be sent via the reliable |
| 718 | * channel, otherwise it will use the unreliable one |
| 719 | * |
| 720 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 721 | * 1 otherwise |
| 722 | */ |
| 723 | stock te_create_beam_from_entity(startent, endpos[3], sprite, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 724 | { |
| 725 | if(receiver && !is_user_connected(receiver)) |
| 726 | return 0; |
| 727 | |
| 728 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 729 | write_byte(TE_BEAMENTPOINT); |
| 730 | write_short(startent); |
| 731 | write_coord(endpos[0]); |
| 732 | write_coord(endpos[1]); |
| 733 | write_coord(endpos[2]); |
| 734 | write_short(sprite); |
| 735 | write_byte(startframe); |
| 736 | write_byte(framerate); |
| 737 | write_byte(life); |
| 738 | write_byte(width); |
| 739 | write_byte(noise); |
| 740 | write_byte(r); |
| 741 | write_byte(g); |
| 742 | write_byte(b); |
| 743 | write_byte(a); |
| 744 | write_byte(speed); |
| 745 | message_end(); |
| 746 | |
| 747 | return 1; |
| 748 | } |
| 749 | |
| 750 | /** |
| 751 | * Creates a gunshot that consists of a particle effect and a ricochet sound. |
| 752 | * |
| 753 | * @note Video preview of this and all other te_ stocks can be found here: |
| 754 | * https://youtu.be/szW-bSMPuyQ?t=36s |
| 755 | * |
| 756 | * @param position Gunshot coordinates |
| 757 | * @param receiver Client index that will be able to see the gunshot |
| 758 | * or 0 for all clients |
| 759 | * @param reliable If true, the message will be sent via the reliable |
| 760 | * channel, otherwise it will use the unreliable one |
| 761 | * |
| 762 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 763 | * 1 otherwise |
| 764 | */ |
| 765 | stock te_create_gunshot(position[3], receiver = 0, bool:reliable = true) |
| 766 | { |
| 767 | if(receiver && !is_user_connected(receiver)) |
| 768 | return 0; |
| 769 | |
| 770 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 771 | write_byte(TE_GUNSHOT); |
| 772 | write_coord(position[0]); |
| 773 | write_coord(position[1]); |
| 774 | write_coord(position[2]); |
| 775 | message_end(); |
| 776 | |
| 777 | return 1; |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * Creates an explosion. |
| 782 | * |
| 783 | * @note A common sprite to use is "sprites/zerogxplode.spr" |
| 784 | * @note Video preview of this and all other te_ stocks can be found here: |
| 785 | * https://youtu.be/szW-bSMPuyQ?t=43s |
| 786 | * |
| 787 | * @param position Position of the explosion |
| 788 | * @param sprite The additive sprite index to use in the explosion |
| 789 | * @param scale The scale of the sprite in the explosion (0 - 255) |
| 790 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 791 | * @param flags Explosion flags: |
| 792 | * TE_EXPLFLAG_NONE - default Half-Life explosion |
| 793 | * TE_EXPLFLAG_NOADDITIVE - sprite will be drawn opaque |
| 794 | * TE_EXPLFLAG_NODLIGHTS - don't render the dynamic lights |
| 795 | * TE_EXPLFLAG_NOSOUND - don't play the explosion sound |
| 796 | * TE_EXPLFLAG_NOPARTICLES - don't draw the particles |
| 797 | * @param receiver Client index that will be able to see the explosion |
| 798 | * or 0 for all clients |
| 799 | * @param reliable If true, the message will be sent via the reliable |
| 800 | * channel, otherwise it will use the unreliable one |
| 801 | * |
| 802 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 803 | * 1 otherwise |
| 804 | */ |
| 805 | stock te_create_explosion(position[3], sprite, scale = 10, framerate = 30, flags = TE_EXPLFLAG_NONE, receiver = 0, bool:reliable = true) |
| 806 | { |
| 807 | if(receiver && !is_user_connected(receiver)) |
| 808 | return 0; |
| 809 | |
| 810 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 811 | write_byte(TE_EXPLOSION); |
| 812 | write_coord(position[0]); |
| 813 | write_coord(position[1]); |
| 814 | write_coord(position[2]); |
| 815 | write_short(sprite); |
| 816 | write_byte(scale); |
| 817 | write_byte(framerate); |
| 818 | write_byte(flags); |
| 819 | message_end(); |
| 820 | |
| 821 | return 1; |
| 822 | } |
| 823 | |
| 824 | /** |
| 825 | * Creates the Quake "tarbaby" explosion with sound. |
| 826 | * |
| 827 | * @note Video preview of this and all other te_ stocks can be found here: |
| 828 | * https://youtu.be/szW-bSMPuyQ?t=55s |
| 829 | * |
| 830 | * @param position Position of the explosion |
| 831 | * @param receiver Client index that will be able to see the explosion |
| 832 | * or 0 for all clients |
| 833 | * @param reliable If true, the message will be sent via the reliable |
| 834 | * channel, otherwise it will use the unreliable one |
| 835 | * |
| 836 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 837 | * 1 otherwise |
| 838 | */ |
| 839 | stock te_create_tar_explosion(position[3], receiver = 0, bool:reliable = true) |
| 840 | { |
| 841 | if(receiver && !is_user_connected(receiver)) |
| 842 | return 0; |
| 843 | |
| 844 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 845 | write_byte(TE_TAREXPLOSION); |
| 846 | write_coord(position[0]); |
| 847 | write_coord(position[1]); |
| 848 | write_coord(position[2]); |
| 849 | message_end(); |
| 850 | |
| 851 | return 1; |
| 852 | } |
| 853 | |
| 854 | /** |
| 855 | * Creates smoke (a rising alphablend sprite at 30 pps). |
| 856 | * |
| 857 | * @note A common sprite to use is "sprites/steam1.spr" |
| 858 | * @note Video preview of this and all other te_ stocks can be found here: |
| 859 | * https://youtu.be/szW-bSMPuyQ?t=1m2s |
| 860 | * |
| 861 | * @param position Position of the smoke effect |
| 862 | * @param sprite The alphablend sprite index to use for the smoke |
| 863 | * @param scale The scale of the smoke (0 - 255) |
| 864 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 865 | * @param receiver Client index that will be able to see the smoke |
| 866 | * or 0 for all clients |
| 867 | * @param reliable If true, the message will be sent via the reliable |
| 868 | * channel, otherwise it will use the unreliable one |
| 869 | * |
| 870 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 871 | * 1 otherwise |
| 872 | */ |
| 873 | stock te_create_smoke(position[3], sprite, scale = 10, framerate = 30, receiver = 0, bool:reliable = true) |
| 874 | { |
| 875 | if(receiver && !is_user_connected(receiver)) |
| 876 | return 0; |
| 877 | |
| 878 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 879 | write_byte(TE_SMOKE); |
| 880 | write_coord(position[0]); |
| 881 | write_coord(position[1]); |
| 882 | write_coord(position[2]); |
| 883 | write_short(sprite); |
| 884 | write_byte(scale); |
| 885 | write_byte(framerate); |
| 886 | message_end(); |
| 887 | |
| 888 | return 1; |
| 889 | } |
| 890 | |
| 891 | /** |
| 892 | * Creates a tracer effect from one point to another. |
| 893 | * |
| 894 | * @note Video preview of this and all other te_ stocks can be found here: |
| 895 | * https://youtu.be/szW-bSMPuyQ?t=1m12s |
| 896 | * |
| 897 | * @param startpos Starting position of the tracer |
| 898 | * @param endpos Ending position of the tracer |
| 899 | * @param receiver Client index that will be able to see the tracer |
| 900 | * or 0 for all clients |
| 901 | * @param reliable If true, the message will be sent via the reliable |
| 902 | * channel, otherwise it will use the unreliable one |
| 903 | * |
| 904 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 905 | * 1 otherwise |
| 906 | */ |
| 907 | stock te_create_tracer(startpos[3], endpos[3], receiver = 0, bool:reliable = true) |
| 908 | { |
| 909 | if(receiver && !is_user_connected(receiver)) |
| 910 | return 0; |
| 911 | |
| 912 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 913 | write_byte(TE_TRACER); |
| 914 | write_coord(startpos[0]); |
| 915 | write_coord(startpos[1]); |
| 916 | write_coord(startpos[2]); |
| 917 | write_coord(endpos[0]); |
| 918 | write_coord(endpos[1]); |
| 919 | write_coord(endpos[2]); |
| 920 | message_end(); |
| 921 | |
| 922 | return 1; |
| 923 | } |
| 924 | |
| 925 | /** |
| 926 | * Creates a beam between two entities. |
| 927 | * |
| 928 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 929 | * @note Video preview of this and all other te_ stocks can be found here: |
| 930 | * https://youtu.be/szW-bSMPuyQ?t=1m26s |
| 931 | * |
| 932 | * @param startent Primary entity id |
| 933 | * @param endent Secondary entity id |
| 934 | * @param sprite The sprite index to use in the beam |
| 935 | * @param startframe The frame to start with in the sprite (0 - 255) |
| 936 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 937 | * @param life The length of time the beam shall remain (0 - 255) |
| 938 | * @param width The width of the beam (0 - 255) |
| 939 | * @param noise The noise amplitude of the beam, this controls |
| 940 | * the distorsion of the beam (0 - 255) |
| 941 | * @param r Red color amount (0 - 255) |
| 942 | * @param g Green color amount (0 - 255) |
| 943 | * @param b Blue color amount (0 - 255) |
| 944 | * @param a Beam brightness (alpha) (0 - 255) |
| 945 | * @param speed The scroll speed of the beam (0 - 255) |
| 946 | * @param receiver Client index that will be able to see the beam |
| 947 | * or 0 for all clients |
| 948 | * @param reliable If true, the message will be sent via the reliable |
| 949 | * channel, otherwise it will use the unreliable one |
| 950 | * |
| 951 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 952 | * 1 otherwise |
| 953 | */ |
| 954 | stock te_create_beam_between_entities(startent, endent, sprite, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 955 | { |
| 956 | if(receiver && !is_user_connected(receiver)) |
| 957 | return 0; |
| 958 | |
| 959 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 960 | write_byte(TE_BEAMENTS); |
| 961 | write_short(startent); |
| 962 | write_short(endent); |
| 963 | write_short(sprite); |
| 964 | write_byte(startframe); |
| 965 | write_byte(framerate); |
| 966 | write_byte(life); |
| 967 | write_byte(width); |
| 968 | write_byte(noise); |
| 969 | write_byte(r); |
| 970 | write_byte(g); |
| 971 | write_byte(b); |
| 972 | write_byte(a); |
| 973 | write_byte(speed); |
| 974 | message_end(); |
| 975 | |
| 976 | return 1; |
| 977 | } |
| 978 | |
| 979 | /** |
| 980 | * Creates 8 random tracers with gravity and a ricochet sprite. |
| 981 | * |
| 982 | * @note Video preview of this and all other te_ stocks can be found here: |
| 983 | * https://youtu.be/szW-bSMPuyQ?t=1m41s |
| 984 | * |
| 985 | * @param position Position of the effect |
| 986 | * @param receiver Client index that will be able to see the effect |
| 987 | * or 0 for all clients |
| 988 | * @param reliable If true, the message will be sent via the reliable |
| 989 | * channel, otherwise it will use the unreliable one |
| 990 | * |
| 991 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 992 | * 1 otherwise |
| 993 | */ |
| 994 | stock te_create_sparks(position[3], receiver = 0, bool:reliable = true) |
| 995 | { |
| 996 | if(receiver && !is_user_connected(receiver)) |
| 997 | return 0; |
| 998 | |
| 999 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1000 | write_byte(TE_SPARKS); |
| 1001 | write_coord(position[0]); |
| 1002 | write_coord(position[1]); |
| 1003 | write_coord(position[2]); |
| 1004 | message_end(); |
| 1005 | |
| 1006 | return 1; |
| 1007 | } |
| 1008 | |
| 1009 | /** |
| 1010 | * Creates a Quake-style lava splash. |
| 1011 | * |
| 1012 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1013 | * https://youtu.be/szW-bSMPuyQ?t=1m49s |
| 1014 | * |
| 1015 | * @param position Position of the effect |
| 1016 | * @param receiver Client index that will be able to see the effect |
| 1017 | * or 0 for all clients |
| 1018 | * @param reliable If true, the message will be sent via the reliable |
| 1019 | * channel, otherwise it will use the unreliable one |
| 1020 | * |
| 1021 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1022 | * 1 otherwise |
| 1023 | */ |
| 1024 | stock te_create_lava_splash(position[3], receiver = 0, bool:reliable = true) |
| 1025 | { |
| 1026 | if(receiver && !is_user_connected(receiver)) |
| 1027 | return 0; |
| 1028 | |
| 1029 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1030 | write_byte(TE_LAVASPLASH); |
| 1031 | write_coord(position[0]); |
| 1032 | write_coord(position[1]); |
| 1033 | write_coord(position[2]); |
| 1034 | message_end(); |
| 1035 | |
| 1036 | return 1; |
| 1037 | } |
| 1038 | |
| 1039 | /** |
| 1040 | * Creates a Quake-style teleport splash. |
| 1041 | * |
| 1042 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1043 | * https://youtu.be/szW-bSMPuyQ?t=2m6s |
| 1044 | * |
| 1045 | * @param position Position of the effect |
| 1046 | * @param receiver Client index that will be able to see the effect |
| 1047 | * or 0 for all clients |
| 1048 | * @param reliable If true, the message will be sent via the reliable |
| 1049 | * channel, otherwise it will use the unreliable one |
| 1050 | * |
| 1051 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1052 | * 1 otherwise |
| 1053 | */ |
| 1054 | stock te_create_teleport_splash(position[3], receiver = 0, bool:reliable = true) |
| 1055 | { |
| 1056 | if(receiver && !is_user_connected(receiver)) |
| 1057 | return 0; |
| 1058 | |
| 1059 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1060 | write_byte(TE_TELEPORT); |
| 1061 | write_coord(position[0]); |
| 1062 | write_coord(position[1]); |
| 1063 | write_coord(position[2]); |
| 1064 | message_end(); |
| 1065 | |
| 1066 | return 1; |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * Creates a Quake colormapped (base palette) particle explosion with sound. |
| 1071 | * |
| 1072 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1073 | * https://youtu.be/szW-bSMPuyQ?t=2m19s |
| 1074 | * |
| 1075 | * @param position Position of the explosion |
| 1076 | * @param startcolor Starting color (0 - 255) |
| 1077 | * @param numcolors Number of colors (1 - 255) |
| 1078 | * @param receiver Client index that will be able to see the explosion |
| 1079 | * or 0 for all clients |
| 1080 | * @param reliable If true, the message will be sent via the reliable |
| 1081 | * channel, otherwise it will use the unreliable one |
| 1082 | * |
| 1083 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1084 | * 1 otherwise |
| 1085 | */ |
| 1086 | stock te_create_colored_explosion(position[3], startcolor = 0, numcolors = 255, receiver = 0, bool:reliable = true) |
| 1087 | { |
| 1088 | if(receiver && !is_user_connected(receiver)) |
| 1089 | return 0; |
| 1090 | |
| 1091 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1092 | write_byte(TE_EXPLOSION2); |
| 1093 | write_coord(position[0]); |
| 1094 | write_coord(position[1]); |
| 1095 | write_coord(position[2]); |
| 1096 | write_byte(startcolor); |
| 1097 | write_byte(clamp(numcolors, 1)); // 0 will crash the game |
| 1098 | message_end(); |
| 1099 | |
| 1100 | return 1; |
| 1101 | } |
| 1102 | |
| 1103 | /** |
| 1104 | * Places a decal from the .BSP file. |
| 1105 | * |
| 1106 | * @note Using a decal index that doesn't exist will crash the client. |
| 1107 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1108 | * https://youtu.be/szW-bSMPuyQ?t=2m30s |
| 1109 | * |
| 1110 | * @param position Position of the decal (center of texture in world) |
| 1111 | * @param texture Texture index of precached decal texture name |
| 1112 | * @param entity Entity index or 0 for world |
| 1113 | * @param entabove Model index of the entity above (only available if |
| 1114 | * the "entity" argument is non-zero) |
| 1115 | * @param receiver Client index that will be able to see the effect |
| 1116 | * or 0 for all clients |
| 1117 | * @param reliable If true, the message will be sent via the reliable |
| 1118 | * channel, otherwise it will use the unreliable one |
| 1119 | * |
| 1120 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1121 | * 1 otherwise |
| 1122 | */ |
| 1123 | stock te_place_decal_from_bsp_file(position[3], texture, entity = 0, entabove = 0, receiver = 0, bool:reliable = true) |
| 1124 | { |
| 1125 | if(receiver && !is_user_connected(receiver)) |
| 1126 | return 0; |
| 1127 | |
| 1128 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1129 | write_byte(TE_BSPDECAL); |
| 1130 | write_coord(position[0]); |
| 1131 | write_coord(position[1]); |
| 1132 | write_coord(position[2]); |
| 1133 | write_short(texture); |
| 1134 | write_short(entity); |
| 1135 | |
| 1136 | if(entity) |
| 1137 | write_short(entabove); |
| 1138 | |
| 1139 | message_end(); |
| 1140 | |
| 1141 | return 1; |
| 1142 | } |
| 1143 | |
| 1144 | /** |
| 1145 | * Creates tracers moving towards a point. |
| 1146 | * |
| 1147 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1148 | * https://youtu.be/szW-bSMPuyQ?t=2m44s |
| 1149 | * |
| 1150 | * @param position Position of the implosion effect |
| 1151 | * @param radius Implosion radius |
| 1152 | * @param count Number of tracers to generate |
| 1153 | * @param life The length of time the effect shall remain |
| 1154 | * @param receiver Client index that will be able to see the effect |
| 1155 | * or 0 for all clients |
| 1156 | * @param reliable If true, the message will be sent via the reliable |
| 1157 | * channel, otherwise it will use the unreliable one |
| 1158 | * |
| 1159 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1160 | * 1 otherwise |
| 1161 | */ |
| 1162 | stock te_create_implosion(position[3], radius = 64, count = 10, life = 3, receiver = 0, bool:reliable = true) |
| 1163 | { |
| 1164 | if(receiver && !is_user_connected(receiver)) |
| 1165 | return 0; |
| 1166 | |
| 1167 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1168 | write_byte(TE_IMPLOSION); |
| 1169 | write_coord(position[0]); |
| 1170 | write_coord(position[1]); |
| 1171 | write_coord(position[2]); |
| 1172 | write_byte(radius); |
| 1173 | write_byte(count); |
| 1174 | write_byte(life); |
| 1175 | message_end(); |
| 1176 | |
| 1177 | return 1; |
| 1178 | } |
| 1179 | |
| 1180 | /** |
| 1181 | * Creates a line of moving glow sprites or models with gravity, fadeout, |
| 1182 | * and collisions. |
| 1183 | * |
| 1184 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1185 | * https://youtu.be/szW-bSMPuyQ?t=2m58s |
| 1186 | * |
| 1187 | * @param startpos Starting position of the effect |
| 1188 | * @param endpos Ending position of the effect |
| 1189 | * @param sprite Sprite index |
| 1190 | * @param count Number of models/sprites to generate |
| 1191 | * @param life The length of time the effect shall remain |
| 1192 | * @param scale Scale of the effect |
| 1193 | * @param velocity Velocity along vector |
| 1194 | * @param randomness Randomness of the velocity |
| 1195 | * @param receiver Client index that will be able to see the effect |
| 1196 | * or 0 for all clients |
| 1197 | * @param reliable If true, the message will be sent via the reliable |
| 1198 | * channel, otherwise it will use the unreliable one |
| 1199 | * |
| 1200 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1201 | * 1 otherwise |
| 1202 | */ |
| 1203 | stock te_create_model_trail(startpos[3], endpos[3], sprite, count = 1, life = 10, scale = 10, velocity = 10, randomness = 10, receiver = 0, bool:reliable = true) |
| 1204 | { |
| 1205 | if(receiver && !is_user_connected(receiver)) |
| 1206 | return 0; |
| 1207 | |
| 1208 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1209 | write_byte(TE_SPRITETRAIL); |
| 1210 | write_coord(startpos[0]); |
| 1211 | write_coord(startpos[1]); |
| 1212 | write_coord(startpos[2]); |
| 1213 | write_coord(endpos[0]); |
| 1214 | write_coord(endpos[1]); |
| 1215 | write_coord(endpos[2]); |
| 1216 | write_short(sprite); |
| 1217 | write_byte(count); |
| 1218 | write_byte(life); |
| 1219 | write_byte(scale); |
| 1220 | write_byte(velocity); |
| 1221 | write_byte(randomness); |
| 1222 | message_end(); |
| 1223 | |
| 1224 | return 1; |
| 1225 | } |
| 1226 | |
| 1227 | /** |
| 1228 | * Displays an additive sprite that plays one cycle. |
| 1229 | * |
| 1230 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1231 | * https://youtu.be/szW-bSMPuyQ?t=3m7s |
| 1232 | * |
| 1233 | * @param position Sprite position |
| 1234 | * @param sprite Sprite index |
| 1235 | * @param scale Scale of the sprite |
| 1236 | * @param brightness Brightness of the sprite |
| 1237 | * @param receiver Client index that will be able to see the sprite |
| 1238 | * or 0 for all clients |
| 1239 | * @param reliable If true, the message will be sent via the reliable |
| 1240 | * channel, otherwise it will use the unreliable one |
| 1241 | * |
| 1242 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1243 | * 1 otherwise |
| 1244 | */ |
| 1245 | stock te_display_additive_sprite(position[3], sprite, scale = 5, brightness = 255, receiver = 0, bool:reliable = true) |
| 1246 | { |
| 1247 | if(receiver && !is_user_connected(receiver)) |
| 1248 | return 0; |
| 1249 | |
| 1250 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1251 | write_byte(TE_SPRITE); |
| 1252 | write_coord(position[0]); |
| 1253 | write_coord(position[1]); |
| 1254 | write_coord(position[2]); |
| 1255 | write_short(sprite); |
| 1256 | write_byte(scale); |
| 1257 | write_byte(brightness); |
| 1258 | message_end(); |
| 1259 | |
| 1260 | return 1; |
| 1261 | } |
| 1262 | |
| 1263 | /** |
| 1264 | * Creates a beam with a sprite at the end of the beam. |
| 1265 | * |
| 1266 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1267 | * https://youtu.be/szW-bSMPuyQ?t=3m29s |
| 1268 | * |
| 1269 | * @param receiver Client index that will be able to see the beam |
| 1270 | * or 0 for all clients |
| 1271 | * @param startpos Starting position of the beam |
| 1272 | * @param endpos Ending position of the beam |
| 1273 | * @param beamid Sprite index for the beam body |
| 1274 | * @param endid Sprite index for the end of the beam |
| 1275 | * @param receiver Client index that will be able to see the beam |
| 1276 | * or 0 for all clients |
| 1277 | * @param reliable If true, the message will be sent via the reliable |
| 1278 | * channel, otherwise it will use the unreliable one |
| 1279 | * |
| 1280 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1281 | * 1 otherwise |
| 1282 | */ |
| 1283 | stock te_create_beam_sprite(startpos[3], endpos[3], beamid, endid, receiver = 0, bool:reliable = true) |
| 1284 | { |
| 1285 | if(receiver && !is_user_connected(receiver)) |
| 1286 | return 0; |
| 1287 | |
| 1288 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1289 | write_byte(TE_BEAMSPRITE); |
| 1290 | write_coord(startpos[0]); |
| 1291 | write_coord(startpos[1]); |
| 1292 | write_coord(startpos[2]); |
| 1293 | write_coord(endpos[0]); |
| 1294 | write_coord(endpos[1]); |
| 1295 | write_coord(endpos[2]); |
| 1296 | write_short(beamid); |
| 1297 | write_short(endid); |
| 1298 | message_end(); |
| 1299 | |
| 1300 | return 1; |
| 1301 | } |
| 1302 | |
| 1303 | /** |
| 1304 | * Creates a screen aligned beam ring that expands to the maximum radius |
| 1305 | * over lifetime. |
| 1306 | * |
| 1307 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 1308 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1309 | * https://youtu.be/szW-bSMPuyQ?t=3m40s |
| 1310 | * |
| 1311 | * @param position Starting coordinates of the beam |
| 1312 | * @param sprite The sprite index to use in the beam |
| 1313 | * @param axis Beam axis |
| 1314 | * @param startframe The frame to start with in the sprite |
| 1315 | * @param framerate The frame rate to show the sprite at |
| 1316 | * @param life The length of time the beam shall remain |
| 1317 | * @param width The width of the beam |
| 1318 | * @param noise The noise amplitude of the beam, this controls |
| 1319 | * the distorsion of the beam |
| 1320 | * @param r Red color amount (0 - 255) |
| 1321 | * @param g Green color amount (0 - 255) |
| 1322 | * @param b Blue color amount (0 - 255) |
| 1323 | * @param a Beam brightness (alpha) (0 - 255) |
| 1324 | * @param speed The scroll speed of the beam (0 - 255) |
| 1325 | * @param receiver Client index that will be able to see the beam |
| 1326 | * or 0 for all clients |
| 1327 | * @param reliable If true, the message will be sent via the reliable |
| 1328 | * channel, otherwise it will use the unreliable one |
| 1329 | * |
| 1330 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1331 | * 1 otherwise |
| 1332 | */ |
| 1333 | stock te_create_beam_ring(position[3], sprite, axis[3] = {0, 0, 0}, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 1334 | { |
| 1335 | if(receiver && !is_user_connected(receiver)) |
| 1336 | return 0; |
| 1337 | |
| 1338 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1339 | write_byte(TE_BEAMTORUS); |
| 1340 | write_coord(position[0]); |
| 1341 | write_coord(position[1]); |
| 1342 | write_coord(position[2]); |
| 1343 | write_coord(axis[0]); |
| 1344 | write_coord(axis[1]); |
| 1345 | write_coord(axis[2]); |
| 1346 | write_short(sprite); |
| 1347 | write_byte(startframe); |
| 1348 | write_byte(framerate); |
| 1349 | write_byte(life); |
| 1350 | write_byte(width); |
| 1351 | write_byte(noise); |
| 1352 | write_byte(r); |
| 1353 | write_byte(g); |
| 1354 | write_byte(b); |
| 1355 | write_byte(a); |
| 1356 | write_byte(speed); |
| 1357 | message_end(); |
| 1358 | |
| 1359 | return 1; |
| 1360 | } |
| 1361 | |
| 1362 | /** |
| 1363 | * Creates a beam disk that expands to the maximum radius over lifetime. |
| 1364 | * |
| 1365 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 1366 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1367 | * https://youtu.be/szW-bSMPuyQ?t=3m58s |
| 1368 | * |
| 1369 | * @param position Starting coordinates of the beam |
| 1370 | * @param sprite The sprite index to use in the beam |
| 1371 | * @param axis Beam axis |
| 1372 | * @param startframe The frame to start with in the sprite (0 - 255) |
| 1373 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 1374 | * @param life The length of time the beam shall remain (0 - 255) |
| 1375 | * @param width The width of the beam (0 - 255) |
| 1376 | * @param noise The noise amplitude of the beam, this controls |
| 1377 | * the distorsion of the beam (0 - 255) |
| 1378 | * @param r Red color amount (0 - 255) |
| 1379 | * @param g Green color amount (0 - 255) |
| 1380 | * @param b Blue color amount (0 - 255) |
| 1381 | * @param a Beam brightness (alpha) (0 - 255) |
| 1382 | * @param speed The scroll speed of the beam (0 - 255) |
| 1383 | * @param receiver Client index that will be able to see the beam |
| 1384 | * or 0 for all clients |
| 1385 | * @param reliable If true, the message will be sent via the reliable |
| 1386 | * channel, otherwise it will use the unreliable one |
| 1387 | * |
| 1388 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1389 | * 1 otherwise |
| 1390 | */ |
| 1391 | stock te_create_beam_disk(position[3], sprite, axis[3] = {0, 0, 0}, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 1392 | { |
| 1393 | if(receiver && !is_user_connected(receiver)) |
| 1394 | return 0; |
| 1395 | |
| 1396 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1397 | write_byte(TE_BEAMDISK); |
| 1398 | write_coord(position[0]); |
| 1399 | write_coord(position[1]); |
| 1400 | write_coord(position[2]); |
| 1401 | write_coord(axis[0]); |
| 1402 | write_coord(axis[1]); |
| 1403 | write_coord(axis[2]); |
| 1404 | write_short(sprite); |
| 1405 | write_byte(startframe); |
| 1406 | write_byte(framerate); |
| 1407 | write_byte(life); |
| 1408 | write_byte(width); |
| 1409 | write_byte(noise); |
| 1410 | write_byte(r); |
| 1411 | write_byte(g); |
| 1412 | write_byte(b); |
| 1413 | write_byte(a); |
| 1414 | write_byte(speed); |
| 1415 | message_end(); |
| 1416 | |
| 1417 | return 1; |
| 1418 | } |
| 1419 | |
| 1420 | /** |
| 1421 | * Creates a beam cylinder that expands to the maximum radius over lifetime. |
| 1422 | * |
| 1423 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 1424 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1425 | * https://youtu.be/szW-bSMPuyQ?t=4m17s |
| 1426 | * |
| 1427 | * @param position Starting coordinates of the beam |
| 1428 | * @param sprite The sprite index to use in the beam |
| 1429 | * @param axis Beam axis |
| 1430 | * @param startframe The frame to start with in the sprite (0 - 255) |
| 1431 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 1432 | * @param life The length of time the beam shall remain (0 - 255) |
| 1433 | * @param width The width of the beam (0 - 255) |
| 1434 | * @param noise The noise amplitude of the beam, this controls |
| 1435 | * the distorsion of the beam (0 - 255) |
| 1436 | * @param r Red color amount (0 - 255) |
| 1437 | * @param g Green color amount (0 - 255) |
| 1438 | * @param b Blue color amount (0 - 255) |
| 1439 | * @param a Beam brightness (alpha) (0 - 255) |
| 1440 | * @param speed The scroll speed of the beam (0 - 255) |
| 1441 | * @param receiver Client index that will be able to see the beam |
| 1442 | * or 0 for all clients |
| 1443 | * @param reliable If true, the message will be sent via the reliable |
| 1444 | * channel, otherwise it will use the unreliable one |
| 1445 | * |
| 1446 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1447 | * 1 otherwise |
| 1448 | */ |
| 1449 | stock te_create_beam_cylinder(position[3], sprite, axis[3] = {0, 0, 0}, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 1450 | { |
| 1451 | if(receiver && !is_user_connected(receiver)) |
| 1452 | return 0; |
| 1453 | |
| 1454 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1455 | write_byte(TE_BEAMCYLINDER); |
| 1456 | write_coord(position[0]); |
| 1457 | write_coord(position[1]); |
| 1458 | write_coord(position[2]); |
| 1459 | write_coord(axis[0]); |
| 1460 | write_coord(axis[1]); |
| 1461 | write_coord(axis[2]); |
| 1462 | write_short(sprite); |
| 1463 | write_byte(startframe); |
| 1464 | write_byte(framerate); |
| 1465 | write_byte(life); |
| 1466 | write_byte(width); |
| 1467 | write_byte(noise); |
| 1468 | write_byte(r); |
| 1469 | write_byte(g); |
| 1470 | write_byte(b); |
| 1471 | write_byte(a); |
| 1472 | write_byte(speed); |
| 1473 | message_end(); |
| 1474 | |
| 1475 | return 1; |
| 1476 | } |
| 1477 | |
| 1478 | /** |
| 1479 | * Creates a decaying beam that follows the entity until it stops moving. |
| 1480 | * |
| 1481 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 1482 | * @note When the entity stops moving, the beam will become visible again |
| 1483 | * once the entity starts moving. |
| 1484 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1485 | * https://youtu.be/szW-bSMPuyQ?t=4m31s |
| 1486 | * |
| 1487 | * @param entity Entity that the beam will follow |
| 1488 | * @param sprite The sprite index to use in the beam |
| 1489 | * @param life The length of time the beam shall remain (0 - 255) |
| 1490 | * @param width The width of the beam (0 - 255) |
| 1491 | * @param r Red color amount (0 - 255) |
| 1492 | * @param g Green color amount (0 - 255) |
| 1493 | * @param b Blue color amount (0 - 255) |
| 1494 | * @param a Beam brightness (alpha) (0 - 255) |
| 1495 | * @param receiver Client index that will be able to see the beam |
| 1496 | * or 0 for all clients |
| 1497 | * @param reliable If true, the message will be sent via the reliable |
| 1498 | * channel, otherwise it will use the unreliable one |
| 1499 | * |
| 1500 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1501 | * 1 otherwise |
| 1502 | */ |
| 1503 | stock te_create_following_beam(entity, sprite, life = 10, width = 10, r = 0, g = 0, b = 255, a = 75, receiver = 0, bool:reliable = true) |
| 1504 | { |
| 1505 | if(receiver && !is_user_connected(receiver)) |
| 1506 | return 0; |
| 1507 | |
| 1508 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1509 | write_byte(TE_BEAMFOLLOW); |
| 1510 | write_short(entity); |
| 1511 | write_short(sprite); |
| 1512 | write_byte(life); |
| 1513 | write_byte(width); |
| 1514 | write_byte(r); |
| 1515 | write_byte(g); |
| 1516 | write_byte(b); |
| 1517 | write_byte(a); |
| 1518 | message_end(); |
| 1519 | |
| 1520 | return 1; |
| 1521 | } |
| 1522 | |
| 1523 | /** |
| 1524 | * Displays a glowing sprite. |
| 1525 | * |
| 1526 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1527 | * https://youtu.be/szW-bSMPuyQ?t=4m43s |
| 1528 | * |
| 1529 | * @param position Sprite position |
| 1530 | * @param sprite Sprite index |
| 1531 | * @param scale Sprite scale (0 - 255) |
| 1532 | * @param size Sprite size (0 - 255) |
| 1533 | * @param brightness Sprite brightness (0 - 255) |
| 1534 | * @param receiver Client index that will be able to see the sprite |
| 1535 | * or 0 for all clients |
| 1536 | * @param reliable If true, the message will be sent via the reliable |
| 1537 | * channel, otherwise it will use the unreliable one |
| 1538 | * |
| 1539 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1540 | * 1 otherwise |
| 1541 | */ |
| 1542 | stock te_display_glow_sprite(position[3], sprite, scale = 10, size = 10, brightness = 150, receiver = 0, bool:reliable = true) |
| 1543 | { |
| 1544 | if(receiver && !is_user_connected(receiver)) |
| 1545 | return 0; |
| 1546 | |
| 1547 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1548 | write_byte(TE_GLOWSPRITE); |
| 1549 | write_coord(position[0]); |
| 1550 | write_coord(position[1]); |
| 1551 | write_coord(position[2]); |
| 1552 | write_short(sprite); |
| 1553 | write_byte(scale); |
| 1554 | write_byte(size); |
| 1555 | write_byte(brightness); |
| 1556 | message_end(); |
| 1557 | |
| 1558 | return 1; |
| 1559 | } |
| 1560 | |
| 1561 | /** |
| 1562 | * Creates a beam ring between two entities. |
| 1563 | * |
| 1564 | * @note A common sprite to use is "sprites/laserbeam.spr" |
| 1565 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1566 | * https://youtu.be/szW-bSMPuyQ?t=5m10s |
| 1567 | * |
| 1568 | * @param startent Primary entity id |
| 1569 | * @param endent Secondary entity id |
| 1570 | * @param sprite The sprite index to use in the beam |
| 1571 | * @param startframe The frame to start with in the sprite (0 - 255) |
| 1572 | * @param framerate The frame rate to show the sprite at (0 - 255) |
| 1573 | * @param life The length of time the beam shall remain (0 - 255) |
| 1574 | * @param width The width of the beam (0 - 255) |
| 1575 | * @param noise The noise amplitude of the beam, this controls |
| 1576 | * the distorsion of the beam (0 - 255) |
| 1577 | * @param r Red color amount (0 - 255) |
| 1578 | * @param g Green color amount (0 - 255) |
| 1579 | * @param b Blue color amount (0 - 255) |
| 1580 | * @param a Beam brightness (alpha) (0 - 255) |
| 1581 | * @param speed The scroll speed of the beam (0 - 255) |
| 1582 | * @param receiver Client index that will be able to see the beam |
| 1583 | * or 0 for all clients |
| 1584 | * @param reliable If true, the message will be sent via the reliable |
| 1585 | * channel, otherwise it will use the unreliable one |
| 1586 | * |
| 1587 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1588 | * 1 otherwise |
| 1589 | */ |
| 1590 | stock te_create_beam_ring_between_entities(startent, endent, sprite, startframe = 0, framerate = 30, life = 10, width = 10, noise = 0, r = 0, g = 0, b = 255, a = 75, speed = 0, receiver = 0, bool:reliable = true) |
| 1591 | { |
| 1592 | if(receiver && !is_user_connected(receiver)) |
| 1593 | return 0; |
| 1594 | |
| 1595 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1596 | write_byte(TE_BEAMRING); |
| 1597 | write_short(startent); |
| 1598 | write_short(endent); |
| 1599 | write_short(sprite); |
| 1600 | write_byte(startframe); |
| 1601 | write_byte(framerate); |
| 1602 | write_byte(life); |
| 1603 | write_byte(width); |
| 1604 | write_byte(noise); |
| 1605 | write_byte(r); |
| 1606 | write_byte(g); |
| 1607 | write_byte(b); |
| 1608 | write_byte(a); |
| 1609 | write_byte(speed); |
| 1610 | message_end(); |
| 1611 | |
| 1612 | return 1; |
| 1613 | } |
| 1614 | |
| 1615 | /** |
| 1616 | * Creates an oriented shower of tracers. |
| 1617 | * |
| 1618 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1619 | * https://youtu.be/szW-bSMPuyQ?t=5m34s |
| 1620 | * |
| 1621 | * @param position Position of the effect |
| 1622 | * @param direction Effect direction |
| 1623 | * @param color Effect color (https://wiki.alliedmods.net/images/Palette.png) |
| 1624 | * @param count Number of tracers to create |
| 1625 | * @param speed The scroll speed of the effect |
| 1626 | * @param velocity Random velocity |
| 1627 | * @param receiver Client index that will be able to see the tracers |
| 1628 | * or 0 for all clients |
| 1629 | * @param reliable If true, the message will be sent via the reliable |
| 1630 | * channel, otherwise it will use the unreliable one |
| 1631 | * |
| 1632 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1633 | * 1 otherwise |
| 1634 | */ |
| 1635 | stock te_create_tracer_shower(position[3], direction[3] = {0, 0, 0}, color = 12, count = 1, speed = 0, velocity = 10, receiver = 0, bool:reliable = true) |
| 1636 | { |
| 1637 | if(receiver && !is_user_connected(receiver)) |
| 1638 | return 0; |
| 1639 | |
| 1640 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1641 | write_byte(TE_STREAK_SPLASH); |
| 1642 | write_coord(position[0]); |
| 1643 | write_coord(position[1]); |
| 1644 | write_coord(position[2]); |
| 1645 | write_coord(direction[0]); |
| 1646 | write_coord(direction[1]); |
| 1647 | write_coord(direction[2]); |
| 1648 | write_byte(color); |
| 1649 | write_short(count); |
| 1650 | write_short(speed); |
| 1651 | write_short(velocity); |
| 1652 | message_end(); |
| 1653 | |
| 1654 | return 1; |
| 1655 | } |
| 1656 | |
| 1657 | /** |
| 1658 | * Creates a dynamic light with a world effect. |
| 1659 | * |
| 1660 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1661 | * https://youtu.be/szW-bSMPuyQ?t=5m47s |
| 1662 | * |
| 1663 | * @param position Position of the light |
| 1664 | * @param radius Light radius (0 - 255) |
| 1665 | * @param r Red color amount (0 - 255) |
| 1666 | * @param g Green color amount (0 - 255) |
| 1667 | * @param b Blue color amount (0 - 255) |
| 1668 | * @param life The length of time the light shall remain (0 - 255) |
| 1669 | * @param decay Light decay rate (0 - 255) |
| 1670 | * @param receiver Client index that will be able to see the light |
| 1671 | * or 0 for all clients |
| 1672 | * @param reliable If true, the message will be sent via the reliable |
| 1673 | * channel, otherwise it will use the unreliable one |
| 1674 | * |
| 1675 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1676 | * 1 otherwise |
| 1677 | */ |
| 1678 | stock te_create_dynamic_light(position[3], radius = 10, r = 255, g = 255, b = 255, life = 10, decay = 10, receiver = 0, bool:reliable = true) |
| 1679 | { |
| 1680 | if(receiver && !is_user_connected(receiver)) |
| 1681 | return 0; |
| 1682 | |
| 1683 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1684 | write_byte(TE_DLIGHT); |
| 1685 | write_coord(position[0]); |
| 1686 | write_coord(position[1]); |
| 1687 | write_coord(position[2]); |
| 1688 | write_byte(radius); |
| 1689 | write_byte(r); |
| 1690 | write_byte(g); |
| 1691 | write_byte(b); |
| 1692 | write_byte(life); |
| 1693 | write_byte(decay); |
| 1694 | message_end(); |
| 1695 | |
| 1696 | return 1; |
| 1697 | } |
| 1698 | |
| 1699 | /** |
| 1700 | * Creates a point entity light with no world effect. |
| 1701 | * |
| 1702 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1703 | * https://youtu.be/szW-bSMPuyQ?t=6m7s |
| 1704 | * |
| 1705 | * @param entity Entity or client to apply the light on |
| 1706 | * @param position Position of the light |
| 1707 | * @param radius Light radius |
| 1708 | * @param r Red color amount (0 - 255) |
| 1709 | * @param g Green color amount (0 - 255) |
| 1710 | * @param b Blue color amount (0 - 255) |
| 1711 | * @param life The length of time the light shall remain (0 - 255) |
| 1712 | * @param decay Light decay rate |
| 1713 | * @param receiver Client index that will be able to see the light |
| 1714 | * or 0 for all clients |
| 1715 | * @param reliable If true, the message will be sent via the reliable |
| 1716 | * channel, otherwise it will use the unreliable one |
| 1717 | * |
| 1718 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1719 | * 1 otherwise |
| 1720 | */ |
| 1721 | stock te_create_entity_light(entity, position[3] = {0, 0, 0}, radius = 50, r = 255, g = 255, b = 255, life = 10, decay = 10, receiver = 0, bool:reliable = true) |
| 1722 | { |
| 1723 | if(receiver && !is_user_connected(receiver)) |
| 1724 | return 0; |
| 1725 | |
| 1726 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1727 | write_byte(TE_ELIGHT); |
| 1728 | write_short(entity); |
| 1729 | write_coord(position[0]); |
| 1730 | write_coord(position[1]); |
| 1731 | write_coord(position[2]); |
| 1732 | write_coord(radius); |
| 1733 | write_byte(r); |
| 1734 | write_byte(g); |
| 1735 | write_byte(b); |
| 1736 | write_byte(life); |
| 1737 | write_coord(decay); |
| 1738 | message_end(); |
| 1739 | |
| 1740 | return 1; |
| 1741 | } |
| 1742 | |
| 1743 | /** |
| 1744 | * Draws a simple line. |
| 1745 | * |
| 1746 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1747 | * https://youtu.be/szW-bSMPuyQ?t=6m32s |
| 1748 | * |
| 1749 | * @param startpos Starting position of the line |
| 1750 | * @param endpos Ending position of the line |
| 1751 | * @param life Line life |
| 1752 | * @param r Red color amount (0 - 255) |
| 1753 | * @param g Green color amount (0 - 255) |
| 1754 | * @param b Blue color amount (0 - 255) |
| 1755 | * @param receiver Client index that will be able to see the line |
| 1756 | * or 0 for all clients |
| 1757 | * @param reliable If true, the message will be sent via the reliable |
| 1758 | * channel, otherwise it will use the unreliable one |
| 1759 | * |
| 1760 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1761 | * 1 otherwise |
| 1762 | */ |
| 1763 | stock te_draw_line(startpos[3], endpos[3], life = 10, r = 0, g = 0, b = 255, receiver = 0, bool:reliable = true) |
| 1764 | { |
| 1765 | if(receiver && !is_user_connected(receiver)) |
| 1766 | return 0; |
| 1767 | |
| 1768 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1769 | write_byte(TE_LINE); |
| 1770 | write_coord(startpos[0]); |
| 1771 | write_coord(startpos[1]); |
| 1772 | write_coord(startpos[2]); |
| 1773 | write_coord(endpos[0]); |
| 1774 | write_coord(endpos[1]); |
| 1775 | write_coord(endpos[2]); |
| 1776 | write_short(life); |
| 1777 | write_byte(r); |
| 1778 | write_byte(g); |
| 1779 | write_byte(b); |
| 1780 | message_end(); |
| 1781 | |
| 1782 | return 1; |
| 1783 | } |
| 1784 | |
| 1785 | /** |
| 1786 | * Creates a simple box. |
| 1787 | * |
| 1788 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1789 | * https://youtu.be/szW-bSMPuyQ?t=6m45s |
| 1790 | * |
| 1791 | * @param startpos Starting position of the box |
| 1792 | * @param endpos Ending position of the box |
| 1793 | * @param life Box life |
| 1794 | * @param r Red color amount (0 - 255) |
| 1795 | * @param g Green color amount (0 - 255) |
| 1796 | * @param b Blue color amount (0 - 255) |
| 1797 | * @param receiver Client index that will be able to see the box |
| 1798 | * or 0 for all clients |
| 1799 | * @param reliable If true, the message will be sent via the reliable |
| 1800 | * channel, otherwise it will use the unreliable one |
| 1801 | * |
| 1802 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1803 | * 1 otherwise |
| 1804 | */ |
| 1805 | stock te_create_box(startpos[3], endpos[3], life = 10, r = 0, g = 0, b = 255, receiver = 0, bool:reliable = true) |
| 1806 | { |
| 1807 | if(receiver && !is_user_connected(receiver)) |
| 1808 | return 0; |
| 1809 | |
| 1810 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1811 | write_byte(TE_BOX); |
| 1812 | write_coord(startpos[0]); |
| 1813 | write_coord(startpos[1]); |
| 1814 | write_coord(startpos[2]); |
| 1815 | write_coord(endpos[0]); |
| 1816 | write_coord(endpos[1]); |
| 1817 | write_coord(endpos[2]); |
| 1818 | write_short(life); |
| 1819 | write_byte(r); |
| 1820 | write_byte(g); |
| 1821 | write_byte(b); |
| 1822 | message_end(); |
| 1823 | |
| 1824 | return 1; |
| 1825 | } |
| 1826 | |
| 1827 | /** |
| 1828 | * Removes all beams attached to an entity. |
| 1829 | * |
| 1830 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1831 | * https://youtu.be/szW-bSMPuyQ?t=7m7s |
| 1832 | * |
| 1833 | * @param entity Entity id to remove attached beams from |
| 1834 | * @param receiver Client index that will be able to see the changes |
| 1835 | * or 0 for all clients |
| 1836 | * @param reliable If true, the message will be sent via the reliable |
| 1837 | * channel, otherwise it will use the unreliable one |
| 1838 | * |
| 1839 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1840 | * 1 otherwise |
| 1841 | */ |
| 1842 | stock te_remove_all_beams_from_entity(entity, receiver = 0, bool:reliable = true) |
| 1843 | { |
| 1844 | if(receiver && !is_user_connected(receiver)) |
| 1845 | return 0; |
| 1846 | |
| 1847 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1848 | write_byte(TE_KILLBEAM); |
| 1849 | write_short(entity); |
| 1850 | message_end(); |
| 1851 | |
| 1852 | return 1; |
| 1853 | } |
| 1854 | |
| 1855 | /** |
| 1856 | * Flags used in te_create_large_funnel() |
| 1857 | */ |
| 1858 | #define LF_FLOAT_DOWN 0 |
| 1859 | #define LF_FLOAT_UP 1 |
| 1860 | |
| 1861 | /** |
| 1862 | * Creates a large group of sprites or models accompanied by green dots |
| 1863 | * that float up or down until they reach the point set in the "position" argument. |
| 1864 | * |
| 1865 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1866 | * https://youtu.be/szW-bSMPuyQ?t=7m10s |
| 1867 | * |
| 1868 | * @param position Effect position |
| 1869 | * @param sprite Sprite index to use |
| 1870 | * @param flag List of valid flags: |
| 1871 | * LF_FLOAT_DOWN - float downwards and end in the point set in the "position" argument |
| 1872 | * LF_FLOAT_UP - start from the point set in the "position" argument and float upwards |
| 1873 | * @param receiver Client index that will be able to see the effect |
| 1874 | * or 0 for all clients |
| 1875 | * @param reliable If true, the message will be sent via the reliable |
| 1876 | * channel, otherwise it will use the unreliable one |
| 1877 | * |
| 1878 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1879 | * 1 otherwise |
| 1880 | */ |
| 1881 | stock te_create_large_funnel(position[3], sprite, flag = LF_FLOAT_DOWN, receiver = 0, bool:reliable = true) |
| 1882 | { |
| 1883 | if(receiver && !is_user_connected(receiver)) |
| 1884 | return 0; |
| 1885 | |
| 1886 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1887 | write_byte(TE_LARGEFUNNEL); |
| 1888 | write_coord(position[0]); |
| 1889 | write_coord(position[1]); |
| 1890 | write_coord(position[2]); |
| 1891 | write_short(sprite); |
| 1892 | write_short(flag); |
| 1893 | message_end(); |
| 1894 | |
| 1895 | return 1; |
| 1896 | } |
| 1897 | |
| 1898 | /** |
| 1899 | * Creates dripping blood particles. |
| 1900 | * |
| 1901 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1902 | * https://youtu.be/szW-bSMPuyQ?t=7m35s |
| 1903 | * |
| 1904 | * @param position Starting position of the blood |
| 1905 | * @param direction Blood direction |
| 1906 | * @param color Blood color (https://wiki.alliedmods.net/images/Palette.png) |
| 1907 | * @param count Number of blood particles to generate (0 - 255) |
| 1908 | * @param receiver Client index that will be able to see the blood |
| 1909 | * or 0 for all clients |
| 1910 | * @param reliable If true, the message will be sent via the reliable |
| 1911 | * channel, otherwise it will use the unreliable one |
| 1912 | * |
| 1913 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1914 | * 1 otherwise |
| 1915 | */ |
| 1916 | stock te_create_bloodstream(position[3], direction[3] = {0, 0, 0}, color = 78, count = 1, receiver = 0, bool:reliable = true) |
| 1917 | { |
| 1918 | if(receiver && !is_user_connected(receiver)) |
| 1919 | return 0; |
| 1920 | |
| 1921 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1922 | write_byte(TE_BLOODSTREAM); |
| 1923 | write_coord(position[0]); |
| 1924 | write_coord(position[1]); |
| 1925 | write_coord(position[2]); |
| 1926 | write_coord(direction[0]); |
| 1927 | write_coord(direction[1]); |
| 1928 | write_coord(direction[2]); |
| 1929 | write_byte(color); |
| 1930 | write_byte(count); |
| 1931 | message_end(); |
| 1932 | |
| 1933 | return 1; |
| 1934 | } |
| 1935 | |
| 1936 | /** |
| 1937 | * Draws a line of blood particles spread 5 units from each other that |
| 1938 | * disappears after 30 seconds. |
| 1939 | * |
| 1940 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1941 | * https://youtu.be/szW-bSMPuyQ?t=7m53s |
| 1942 | * |
| 1943 | * @param startpos Starting position of the line |
| 1944 | * @param endpos Ending position of the line |
| 1945 | * @param receiver Client index that will be able to see the line |
| 1946 | * or 0 for all clients |
| 1947 | * @param reliable If true, the message will be sent via the reliable |
| 1948 | * channel, otherwise it will use the unreliable one |
| 1949 | * |
| 1950 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1951 | * 1 otherwise |
| 1952 | */ |
| 1953 | stock te_draw_blood_line(startpos[3], endpos[3], receiver = 0, bool:reliable = true) |
| 1954 | { |
| 1955 | if(receiver && !is_user_connected(receiver)) |
| 1956 | return 0; |
| 1957 | |
| 1958 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1959 | write_byte(TE_SHOWLINE); |
| 1960 | write_coord(startpos[0]); |
| 1961 | write_coord(startpos[1]); |
| 1962 | write_coord(startpos[2]); |
| 1963 | write_coord(endpos[0]); |
| 1964 | write_coord(endpos[1]); |
| 1965 | write_coord(endpos[2]); |
| 1966 | message_end(); |
| 1967 | |
| 1968 | return 1; |
| 1969 | } |
| 1970 | |
| 1971 | /** |
| 1972 | * Sprays blood particles from a given point. |
| 1973 | * |
| 1974 | * @note Video preview of this and all other te_ stocks can be found here: |
| 1975 | * https://youtu.be/szW-bSMPuyQ?t=7m59s |
| 1976 | * |
| 1977 | * @param position Position from where the blood will be sprayed |
| 1978 | * @param direction Blood spraying direction |
| 1979 | * @param color Blood color (https://wiki.alliedmods.net/images/Palette.png) |
| 1980 | * @param speed Speed at which the blood particles will be sprayed (0 - 255) |
| 1981 | * @param receiver Client index that will be able to see the particles |
| 1982 | * or 0 for all clients |
| 1983 | * @param reliable If true, the message will be sent via the reliable |
| 1984 | * channel, otherwise it will use the unreliable one |
| 1985 | * |
| 1986 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 1987 | * 1 otherwise |
| 1988 | */ |
| 1989 | stock te_spray_blood(position[3], direction[3] = {0, 0, 0}, color = 78, speed = 30, receiver = 0, bool:reliable = true) |
| 1990 | { |
| 1991 | if(receiver && !is_user_connected(receiver)) |
| 1992 | return 0; |
| 1993 | |
| 1994 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 1995 | write_byte(TE_BLOOD); |
| 1996 | write_coord(position[0]); |
| 1997 | write_coord(position[1]); |
| 1998 | write_coord(position[2]); |
| 1999 | write_coord(direction[0]); |
| 2000 | write_coord(direction[1]); |
| 2001 | write_coord(direction[2]); |
| 2002 | write_byte(color); |
| 2003 | write_byte(speed); |
| 2004 | message_end(); |
| 2005 | |
| 2006 | return 1; |
| 2007 | } |
| 2008 | |
| 2009 | /** |
| 2010 | * Applies a decal to a brush entity (not the world). |
| 2011 | * |
| 2012 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2013 | * https://youtu.be/szW-bSMPuyQ?t=8m12s |
| 2014 | * |
| 2015 | * @param position Position of the decal (center of texture in world) |
| 2016 | * @param texture Texture index of precached decal texture name (0 - 511) |
| 2017 | * @param entity Entity index to apply the decal to |
| 2018 | * @param receiver Client index that will be able to see the effect |
| 2019 | * or 0 for all clients |
| 2020 | * @param reliable If true, the message will be sent via the reliable |
| 2021 | * channel, otherwise it will use the unreliable one |
| 2022 | * |
| 2023 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2024 | * 1 otherwise |
| 2025 | */ |
| 2026 | stock te_place_brush_decal(position[3], texture, entity = 0, receiver = 0, bool:reliable = true) |
| 2027 | { |
| 2028 | if(receiver && !is_user_connected(receiver)) |
| 2029 | return 0; |
| 2030 | |
| 2031 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2032 | write_byte(texture > 256 ? TE_DECALHIGH : TE_DECAL); |
| 2033 | write_coord(position[0]); |
| 2034 | write_coord(position[1]); |
| 2035 | write_coord(position[2]); |
| 2036 | write_byte(texture > 256 ? texture - 256 : texture); |
| 2037 | write_short(entity); |
| 2038 | message_end(); |
| 2039 | |
| 2040 | return 1; |
| 2041 | } |
| 2042 | |
| 2043 | /** |
| 2044 | * Bounce sound types used in te_create_bouncing_model() |
| 2045 | */ |
| 2046 | enum BounceSounds |
| 2047 | { |
| 2048 | BounceSound_Null = 0, |
| 2049 | BounceSound_Shell, |
| 2050 | BounceSound_ShotShell |
| 2051 | } |
| 2052 | |
| 2053 | /** |
| 2054 | * Creates a moving model or sprite that bounces and makes a sound when it hits. |
| 2055 | * |
| 2056 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2057 | * https://youtu.be/szW-bSMPuyQ?t=8m16s |
| 2058 | * |
| 2059 | * @param position Position of the model |
| 2060 | * @param modelid Model index |
| 2061 | * @param velocity Model velocity |
| 2062 | * @param yaw Initial yaw |
| 2063 | * @param bouncesound Bounce sound type: |
| 2064 | * BounceSound_Null |
| 2065 | * BounceSound_Shell |
| 2066 | * BounceSound_ShotShell |
| 2067 | * @param life The length of time the model shall remain (0 - 255) |
| 2068 | * @param receiver Client index that will be able to see the model |
| 2069 | * or 0 for all clients |
| 2070 | * @param reliable If true, the message will be sent via the reliable |
| 2071 | * channel, otherwise it will use the unreliable one |
| 2072 | * |
| 2073 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2074 | * 1 otherwise |
| 2075 | */ |
| 2076 | stock te_create_bouncing_model(position[3], modelid, velocity[3] = {0, 0, 0}, yaw = 0, BounceSounds:bouncesound = BounceSound_Null, life = 10, receiver = 0, bool:reliable = true) |
| 2077 | { |
| 2078 | if(receiver && !is_user_connected(receiver)) |
| 2079 | return 0; |
| 2080 | |
| 2081 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2082 | write_byte(TE_MODEL); |
| 2083 | write_coord(position[0]); |
| 2084 | write_coord(position[1]); |
| 2085 | write_coord(position[2]); |
| 2086 | write_coord(velocity[0]); |
| 2087 | write_coord(velocity[1]); |
| 2088 | write_coord(velocity[2]); |
| 2089 | write_angle(yaw); |
| 2090 | write_short(modelid); |
| 2091 | write_byte(_:bouncesound); |
| 2092 | write_byte(life); |
| 2093 | message_end(); |
| 2094 | |
| 2095 | return 1; |
| 2096 | } |
| 2097 | |
| 2098 | /** |
| 2099 | * Creates model or sprite with a blinking orange aura effect. |
| 2100 | * |
| 2101 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2102 | * https://youtu.be/szW-bSMPuyQ?t=8m28s |
| 2103 | * |
| 2104 | * @param position Position of the model |
| 2105 | * @param modelid Model index |
| 2106 | * @param speed Model speed |
| 2107 | * @param count Number of models to generate |
| 2108 | * @param life The length of time the model shall remain (0 - 255) |
| 2109 | * @param receiver Client index that will be able to see the model |
| 2110 | * or 0 for all clients |
| 2111 | * @param reliable If true, the message will be sent via the reliable |
| 2112 | * channel, otherwise it will use the unreliable one |
| 2113 | * |
| 2114 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2115 | * 1 otherwise |
| 2116 | */ |
| 2117 | stock te_create_explode_model(position[3], modelid, speed = 0, count = 1, life = 10, receiver = 0, bool:reliable = true) |
| 2118 | { |
| 2119 | if(receiver && !is_user_connected(receiver)) |
| 2120 | return 0; |
| 2121 | |
| 2122 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2123 | write_byte(TE_EXPLODEMODEL); |
| 2124 | write_coord(position[0]); |
| 2125 | write_coord(position[1]); |
| 2126 | write_coord(position[2]); |
| 2127 | write_coord(speed); |
| 2128 | write_short(modelid); |
| 2129 | write_short(count); |
| 2130 | write_byte(life); |
| 2131 | message_end(); |
| 2132 | |
| 2133 | return 1; |
| 2134 | } |
| 2135 | |
| 2136 | /** |
| 2137 | * Flags used in te_create_break_model() |
| 2138 | */ |
| 2139 | #define BreakModel_TypeMask 0x4F |
| 2140 | #define BreakModel_Glass 0x01 |
| 2141 | #define BreakModel_Metal 0x02 |
| 2142 | #define BreakModel_Flesh 0x04 |
| 2143 | #define BreakModel_Wood 0x08 |
| 2144 | #define BreakModel_Smoke 0x10 |
| 2145 | #define BreakModel_Trans 0x20 |
| 2146 | #define BreakModel_Concrete 0x40 |
| 2147 | #define BreakModel_2 0x80 |
| 2148 | |
| 2149 | /** |
| 2150 | * Creates a model or sprite entity that slowly disappears until it's gone. |
| 2151 | * |
| 2152 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2153 | * https://youtu.be/szW-bSMPuyQ |
| 2154 | * |
| 2155 | * @param position Position of the model |
| 2156 | * @param size Size of the model |
| 2157 | * @param velocity Model velocity |
| 2158 | * @param modelid Model index |
| 2159 | * @param random Random velocity (0 - 255) |
| 2160 | * @param count Number of model pieces to generate (0 - 255) |
| 2161 | * @param life The length of time the model shall remain (0 - 255) |
| 2162 | * @param flags Break model flags: |
| 2163 | * BreakModel_TypeMask |
| 2164 | * BreakModel_Glass |
| 2165 | * BreakModel_Metal |
| 2166 | * BreakModel_Flesh |
| 2167 | * BreakModel_Wood |
| 2168 | * BreakModel_Smoke |
| 2169 | * BreakModel_Trans |
| 2170 | * BreakModel_Concrete |
| 2171 | * BreakModel_2 |
| 2172 | * @param receiver Client index that will be able to see the model |
| 2173 | * or 0 for all clients |
| 2174 | * @param reliable If true, the message will be sent via the reliable |
| 2175 | * channel, otherwise it will use the unreliable one |
| 2176 | * |
| 2177 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2178 | * 1 otherwise |
| 2179 | */ |
| 2180 | stock te_create_break_model(position[3], modelid, size[3] = {50, 50, 50}, velocity[3] = {0, 0, 0}, random = 0, count = 1, life = 10, flags = 0, receiver = 0, bool:reliable = true) |
| 2181 | { |
| 2182 | if(receiver && !is_user_connected(receiver)) |
| 2183 | return 0; |
| 2184 | |
| 2185 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2186 | write_byte(TE_BREAKMODEL); |
| 2187 | write_coord(position[0]); |
| 2188 | write_coord(position[1]); |
| 2189 | write_coord(position[2]); |
| 2190 | write_coord(size[0]); |
| 2191 | write_coord(size[1]); |
| 2192 | write_coord(size[2]); |
| 2193 | write_coord(velocity[0]); |
| 2194 | write_coord(velocity[1]); |
| 2195 | write_coord(velocity[2]); |
| 2196 | write_byte(random); |
| 2197 | write_short(modelid); |
| 2198 | write_byte(count); |
| 2199 | write_byte(life); |
| 2200 | write_byte(flags); |
| 2201 | message_end(); |
| 2202 | |
| 2203 | return 1; |
| 2204 | } |
| 2205 | |
| 2206 | /** |
| 2207 | * Places a gunshot decal on an entity or the world and plays a ricochet sound. |
| 2208 | * |
| 2209 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2210 | * https://youtu.be/szW-bSMPuyQ?t=8m41s |
| 2211 | * |
| 2212 | * @param position Position of the decal |
| 2213 | * @param decal Decal index (0 - 255) |
| 2214 | * @param entity Entity to apply the decal to or 0 for world |
| 2215 | * @param receiver Client index that will be able to see the model |
| 2216 | * or 0 for all clients |
| 2217 | * @param reliable If true, the message will be sent via the reliable |
| 2218 | * channel, otherwise it will use the unreliable one |
| 2219 | * |
| 2220 | * @noreturn |
| 2221 | * @error If "receiver" is non-zero and the client isn't |
| 2222 | * connected, an error will be thrown. |
| 2223 | */ |
| 2224 | stock te_place_gunshot_decal(position[3], decal = 41, entity = 0, receiver = 0, bool:reliable = true) |
| 2225 | { |
| 2226 | if(receiver && !is_user_connected(receiver)) |
| 2227 | return 0; |
| 2228 | |
| 2229 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2230 | write_byte(TE_GUNSHOTDECAL); |
| 2231 | write_coord(position[0]); |
| 2232 | write_coord(position[1]); |
| 2233 | write_coord(position[2]); |
| 2234 | write_short(entity); |
| 2235 | write_byte(decal); |
| 2236 | message_end(); |
| 2237 | |
| 2238 | return 1; |
| 2239 | } |
| 2240 | |
| 2241 | /** |
| 2242 | * Creates a spray of alpha sprites or models. |
| 2243 | * |
| 2244 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2245 | * https://youtu.be/szW-bSMPuyQ?t=8m52s |
| 2246 | * |
| 2247 | * @param position Position of the effect |
| 2248 | * @param sprite Sprite index |
| 2249 | * @param velocity Spray velocity |
| 2250 | * @param count Number of sprays to generate (0 - 255) |
| 2251 | * @param speed The scroll speed of the effect (0 - 255) |
| 2252 | * @param noise The noise amplitude of the effect - this |
| 2253 | * controls the distorsion of the effect (0 - 255) |
| 2254 | * @param receiver Client index that will be able to see the effect |
| 2255 | * or 0 for all clients |
| 2256 | * @param reliable If true, the message will be sent via the reliable |
| 2257 | * channel, otherwise it will use the unreliable one |
| 2258 | * |
| 2259 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2260 | * 1 otherwise |
| 2261 | */ |
| 2262 | stock te_create_sprite_spray(position[3], sprite, velocity[3] = {0, 0, 0}, count = 1, speed = 0, noise = 0, receiver = 0, bool:reliable = true) |
| 2263 | { |
| 2264 | if(receiver && !is_user_connected(receiver)) |
| 2265 | return 0; |
| 2266 | |
| 2267 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2268 | write_byte(TE_SPRITE_SPRAY); |
| 2269 | write_coord(position[0]); |
| 2270 | write_coord(position[1]); |
| 2271 | write_coord(position[2]); |
| 2272 | write_coord(velocity[0]); |
| 2273 | write_coord(velocity[1]); |
| 2274 | write_coord(velocity[2]); |
| 2275 | write_short(sprite); |
| 2276 | write_byte(count); |
| 2277 | write_byte(speed); |
| 2278 | write_byte(noise); |
| 2279 | message_end(); |
| 2280 | |
| 2281 | return 1; |
| 2282 | } |
| 2283 | |
| 2284 | /** |
| 2285 | * Creates a quick spray sprite with a ricochet sound. |
| 2286 | * |
| 2287 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2288 | * https://youtu.be/szW-bSMPuyQ?t=9m3s |
| 2289 | * |
| 2290 | * @param position Position of the effect |
| 2291 | * @param scale Scale of the effect (0 - 255) |
| 2292 | * @param receiver Client index that will be able to see the effect |
| 2293 | * or 0 for all clients |
| 2294 | * @param reliable If true, the message will be sent via the reliable |
| 2295 | * channel, otherwise it will use the unreliable one |
| 2296 | * |
| 2297 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2298 | * 1 otherwise |
| 2299 | */ |
| 2300 | stock te_create_armor_ricochet(position[3], scale = 10, receiver = 0, bool:reliable = true) |
| 2301 | { |
| 2302 | if(receiver && !is_user_connected(receiver)) |
| 2303 | return 0; |
| 2304 | |
| 2305 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2306 | write_byte(TE_ARMOR_RICOCHET); |
| 2307 | write_coord(position[0]); |
| 2308 | write_coord(position[1]); |
| 2309 | write_coord(position[2]); |
| 2310 | write_byte(scale); |
| 2311 | message_end(); |
| 2312 | |
| 2313 | return 1; |
| 2314 | } |
| 2315 | |
| 2316 | /** |
| 2317 | * Places a player spray on an entity or the world. |
| 2318 | * |
| 2319 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2320 | * https://youtu.be/szW-bSMPuyQ?t=9m16s |
| 2321 | * |
| 2322 | * @param position Position of the decal |
| 2323 | * @param decal Decal index (0 - 255) |
| 2324 | * @param entity Entity to apply the decal to or 0 for world |
| 2325 | * @param receiver Client index that will be able to see the model |
| 2326 | * or 0 for all clients |
| 2327 | * @param reliable If true, the message will be sent via the reliable |
| 2328 | * channel, otherwise it will use the unreliable one |
| 2329 | * |
| 2330 | * @noreturn |
| 2331 | * @error If "receiver" is non-zero and the client isn't |
| 2332 | * connected, an error will be thrown. |
| 2333 | */ |
| 2334 | stock te_place_player_spray(position[3], player, spray = 0, entity = 0, receiver = 0, bool:reliable = true) |
| 2335 | { |
| 2336 | if(receiver && !is_user_connected(receiver)) |
| 2337 | return 0; |
| 2338 | |
| 2339 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2340 | write_byte(TE_PLAYERDECAL); |
| 2341 | write_byte(player); |
| 2342 | write_coord(position[0]); |
| 2343 | write_coord(position[1]); |
| 2344 | write_coord(position[2]); |
| 2345 | write_short(entity); |
| 2346 | write_byte(spray); |
| 2347 | message_end(); |
| 2348 | |
| 2349 | return 1; |
| 2350 | } |
| 2351 | |
| 2352 | /** |
| 2353 | * Creates alpha sprites or models inside of a box that float upwards. |
| 2354 | * |
| 2355 | * @note A common sprite to use is "sprites/bubble.spr" |
| 2356 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2357 | * https://youtu.be/szW-bSMPuyQ?t=9m22s |
| 2358 | * |
| 2359 | * @param startpos Start position |
| 2360 | * @param endpos End position |
| 2361 | * @param sprite Sprite index |
| 2362 | * @param count Number of sprites to generate (0 - 255) |
| 2363 | * @param randomness Randoness of the floating direction |
| 2364 | * @param height Float height |
| 2365 | * @param receiver Client index that will be able to see the effect |
| 2366 | * or 0 for all clients |
| 2367 | * @param reliable If true, the message will be sent via the reliable |
| 2368 | * channel, otherwise it will use the unreliable one |
| 2369 | * |
| 2370 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2371 | * 1 otherwise |
| 2372 | */ |
| 2373 | stock te_create_bubble_box(startpos[3], endpos[3], sprite, count = 3, randomness = 0, height = 50, receiver = 0, bool:reliable = true) |
| 2374 | { |
| 2375 | if(receiver && !is_user_connected(receiver)) |
| 2376 | return 0; |
| 2377 | |
| 2378 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2379 | write_byte(TE_BUBBLES); |
| 2380 | write_coord(startpos[0]); |
| 2381 | write_coord(startpos[1]); |
| 2382 | write_coord(startpos[2]); |
| 2383 | write_coord(endpos[0]); |
| 2384 | write_coord(endpos[1]); |
| 2385 | write_coord(endpos[2]); |
| 2386 | write_coord(height); |
| 2387 | write_short(sprite); |
| 2388 | write_byte(count); |
| 2389 | write_coord(randomness); |
| 2390 | message_end(); |
| 2391 | |
| 2392 | return 1; |
| 2393 | } |
| 2394 | |
| 2395 | /** |
| 2396 | * Creates alpha sprites or models along a line that float upwards. |
| 2397 | * |
| 2398 | * @note A common sprite to use is "sprites/bubble.spr" |
| 2399 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2400 | * https://youtu.be/szW-bSMPuyQ?t=9m37s |
| 2401 | * |
| 2402 | * @param startpos Start position |
| 2403 | * @param endpos End position |
| 2404 | * @param sprite Sprite index |
| 2405 | * @param count Number of sprites to generate (0 - 255) |
| 2406 | * @param randomness Randoness of the floating direction |
| 2407 | * @param height Float height |
| 2408 | * @param receiver Client index that will be able to see the effect |
| 2409 | * or 0 for all clients |
| 2410 | * @param reliable If true, the message will be sent via the reliable |
| 2411 | * channel, otherwise it will use the unreliable one |
| 2412 | * |
| 2413 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2414 | * 1 otherwise |
| 2415 | */ |
| 2416 | stock te_create_bubble_line(startpos[3], endpos[3], sprite, count = 3, randomness = 0, height = 50, receiver = 0, bool:reliable = true) |
| 2417 | { |
| 2418 | if(receiver && !is_user_connected(receiver)) |
| 2419 | return 0; |
| 2420 | |
| 2421 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2422 | write_byte(TE_BUBBLETRAIL); |
| 2423 | write_coord(startpos[0]); |
| 2424 | write_coord(startpos[1]); |
| 2425 | write_coord(startpos[2]); |
| 2426 | write_coord(endpos[0]); |
| 2427 | write_coord(endpos[1]); |
| 2428 | write_coord(endpos[2]); |
| 2429 | write_coord(height); |
| 2430 | write_short(sprite); |
| 2431 | write_byte(count); |
| 2432 | write_coord(randomness); |
| 2433 | message_end(); |
| 2434 | |
| 2435 | return 1; |
| 2436 | } |
| 2437 | |
| 2438 | /** |
| 2439 | * Creates an spray of opaque sprites or models that fall to another sprite or model. |
| 2440 | * |
| 2441 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2442 | * https://youtu.be/szW-bSMPuyQ?t=9m44s |
| 2443 | * |
| 2444 | * @param position Effect position |
| 2445 | * @param sprite1id Primary sprite index |
| 2446 | * @param sprite2id Secondary sprite index |
| 2447 | * @param color Sprite color (https://wiki.alliedmods.net/images/Palette.png) |
| 2448 | * @param scale Sprite scale (0 - 255) |
| 2449 | * @param receiver Client index that will be able to see the sprite |
| 2450 | * or 0 for all clients |
| 2451 | * @param reliable If true, the message will be sent via the reliable |
| 2452 | * channel, otherwise it will use the unreliable one |
| 2453 | * |
| 2454 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2455 | * 1 otherwise |
| 2456 | */ |
| 2457 | stock te_display_falling_sprite(position[3], sprite1id, sprite2id, color = 78, scale = 10, receiver = 0, bool:reliable = true) |
| 2458 | { |
| 2459 | if(receiver && !is_user_connected(receiver)) |
| 2460 | return 0; |
| 2461 | |
| 2462 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2463 | write_byte(TE_BLOODSPRITE); |
| 2464 | write_coord(position[0]); |
| 2465 | write_coord(position[1]); |
| 2466 | write_coord(position[2]); |
| 2467 | write_short(sprite1id); |
| 2468 | write_short(sprite2id); |
| 2469 | write_byte(color); |
| 2470 | write_byte(scale); |
| 2471 | message_end(); |
| 2472 | |
| 2473 | return 1; |
| 2474 | } |
| 2475 | |
| 2476 | /** |
| 2477 | * Applies a decal to the world brush. |
| 2478 | * |
| 2479 | * @note Using a decal index that doesn't exist will crash the client. |
| 2480 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2481 | * https://youtu.be/szW-bSMPuyQ?t=9m56s |
| 2482 | * |
| 2483 | * @param position Decal position (center of texture in world) |
| 2484 | * @param texture Texture index of precached decal texture name (0 - 511) |
| 2485 | * @param receiver Client index that will be able to see the decal |
| 2486 | * or 0 for all clients |
| 2487 | * @param reliable If true, the message will be sent via the reliable |
| 2488 | * channel, otherwise it will use the unreliable one |
| 2489 | * |
| 2490 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2491 | * 1 otherwise |
| 2492 | */ |
| 2493 | stock te_place_world_decal(position[3], texture, receiver = 0, bool:reliable = true) |
| 2494 | { |
| 2495 | if(receiver && !is_user_connected(receiver)) |
| 2496 | return 0; |
| 2497 | |
| 2498 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2499 | write_byte(texture > 256 ? TE_WORLDDECALHIGH : TE_WORLDDECAL); |
| 2500 | write_coord(position[0]); |
| 2501 | write_coord(position[1]); |
| 2502 | write_coord(position[2]); |
| 2503 | write_byte(texture > 256 ? texture - 256 : texture); |
| 2504 | message_end(); |
| 2505 | |
| 2506 | return 1; |
| 2507 | } |
| 2508 | |
| 2509 | /** |
| 2510 | * Creates a nail-like projectile. |
| 2511 | * |
| 2512 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2513 | * https://youtu.be/szW-bSMPuyQ?t=10m12s |
| 2514 | * |
| 2515 | * @param position Projectile position |
| 2516 | * @param velocity Projectile velocity |
| 2517 | * @param model Model index that will be used for the projectile |
| 2518 | * @param life The length of time the projectile shall remain (0 - 255) |
| 2519 | * @param owner The projectile won't collide with the owner, if set to 0, |
| 2520 | * the projectile will hit any client |
| 2521 | * @param receiver Client index that will be able to see the projectile |
| 2522 | * or 0 for all clients |
| 2523 | * @param reliable If true, the message will be sent via the reliable |
| 2524 | * channel, otherwise it will use the unreliable one |
| 2525 | * |
| 2526 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2527 | * 1 otherwise |
| 2528 | */ |
| 2529 | stock te_create_projectile(position[3], velocity[3], model, life = 10, owner = 0, receiver = 0, bool:reliable = true) |
| 2530 | { |
| 2531 | if(receiver && !is_user_connected(receiver)) |
| 2532 | return 0; |
| 2533 | |
| 2534 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2535 | write_byte(TE_PROJECTILE); |
| 2536 | write_coord(position[0]); |
| 2537 | write_coord(position[1]); |
| 2538 | write_coord(position[2]); |
| 2539 | write_coord(velocity[0]); |
| 2540 | write_coord(velocity[1]); |
| 2541 | write_coord(velocity[2]); |
| 2542 | write_short(model); |
| 2543 | write_byte(life); |
| 2544 | write_byte(owner); |
| 2545 | message_end(); |
| 2546 | |
| 2547 | return 1; |
| 2548 | } |
| 2549 | |
| 2550 | /** |
| 2551 | * Creates a shower of sprites or models. |
| 2552 | * |
| 2553 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2554 | * https://youtu.be/szW-bSMPuyQ?t=10m27s |
| 2555 | * |
| 2556 | * @param position Effect position |
| 2557 | * @param model Model index that will be used for the effect |
| 2558 | * @param direction Effect direction |
| 2559 | * @param count Number of sprites/models to generate (0 - 255) |
| 2560 | * @param speed The scroll speed of the effect (0 - 255) |
| 2561 | * @param noise The noise amplitude of the effect - this |
| 2562 | * controls the distorsion of the effect (0 - 255) |
| 2563 | * @param rendermode Render mode - one of kRender* constants |
| 2564 | * @param receiver Client index that will be able to see the effect |
| 2565 | * or 0 for all clients |
| 2566 | * @param reliable If true, the message will be sent via the reliable |
| 2567 | * channel, otherwise it will use the unreliable one |
| 2568 | * |
| 2569 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2570 | * 1 otherwise |
| 2571 | */ |
| 2572 | stock te_create_sprite_shower(position[3], model, direction[3] = {0, 0, 0}, count = 1, speed = 0, noise = 0, rendermode = kRenderNormal, receiver = 0, bool:reliable = true) |
| 2573 | { |
| 2574 | if(receiver && !is_user_connected(receiver)) |
| 2575 | return 0; |
| 2576 | |
| 2577 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2578 | write_byte(TE_SPRAY); |
| 2579 | write_coord(position[0]); |
| 2580 | write_coord(position[1]); |
| 2581 | write_coord(position[2]); |
| 2582 | write_coord(direction[0]); |
| 2583 | write_coord(direction[1]); |
| 2584 | write_coord(direction[2]); |
| 2585 | write_short(model); |
| 2586 | write_byte(count); |
| 2587 | write_byte(speed); |
| 2588 | write_byte(noise); |
| 2589 | write_byte(rendermode); |
| 2590 | message_end(); |
| 2591 | |
| 2592 | return 1; |
| 2593 | } |
| 2594 | |
| 2595 | /** |
| 2596 | * Emits sprites or models from a player's bounding box. |
| 2597 | * |
| 2598 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2599 | * https://youtu.be/szW-bSMPuyQ?t=10m39s |
| 2600 | * |
| 2601 | * @param player Client index to emit the sprites from (can't be 0) |
| 2602 | * @param sprite Sprite index |
| 2603 | * @param count Number of sprites to generate (0 - 255) |
| 2604 | * @param variance Variance in size (0 = no variance; 10 = 10% variance) (0 - 255) |
| 2605 | * @param receiver Client index that will be able to see the effect |
| 2606 | * or 0 for all clients |
| 2607 | * @param reliable If true, the message will be sent via the reliable |
| 2608 | * channel, otherwise it will use the unreliable one |
| 2609 | * |
| 2610 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2611 | * 1 otherwise |
| 2612 | */ |
| 2613 | stock te_emit_sprite_from_player(player, sprite, count = 1, variance = 0, receiver = 0, bool:reliable = true) |
| 2614 | { |
| 2615 | if(receiver && !is_user_connected(receiver)) |
| 2616 | return 0; |
| 2617 | |
| 2618 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2619 | write_byte(TE_PLAYERSPRITES); |
| 2620 | write_short(player); |
| 2621 | write_short(sprite); |
| 2622 | write_byte(count); |
| 2623 | write_byte(variance); |
| 2624 | message_end(); |
| 2625 | |
| 2626 | return 1; |
| 2627 | } |
| 2628 | |
| 2629 | /** |
| 2630 | * Creates a particle burst similar to te_create_lava_splash. |
| 2631 | * |
| 2632 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2633 | * https://youtu.be/szW-bSMPuyQ?t=10m55s |
| 2634 | * |
| 2635 | * @param position Effect position |
| 2636 | * @param radius Effect radius |
| 2637 | * @param color Particle color (https://wiki.alliedmods.net/images/Palette.png) |
| 2638 | * @param duration Duration of the effect (will be randomized a bit) (0 - 255) |
| 2639 | * @param receiver Client index that will be able to see the effect |
| 2640 | * or 0 for all clients |
| 2641 | * @param reliable If true, the message will be sent via the reliable |
| 2642 | * channel, otherwise it will use the unreliable one |
| 2643 | * |
| 2644 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2645 | * 1 otherwise |
| 2646 | */ |
| 2647 | stock te_create_particle_burst(position[3], radius = 30, color = 106, duration = 5, receiver = 0, bool:reliable = true) |
| 2648 | { |
| 2649 | if(receiver && !is_user_connected(receiver)) |
| 2650 | return 0; |
| 2651 | |
| 2652 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2653 | write_byte(TE_PARTICLEBURST); |
| 2654 | write_coord(position[0]); |
| 2655 | write_coord(position[1]); |
| 2656 | write_coord(position[2]); |
| 2657 | write_short(radius); |
| 2658 | write_byte(color); |
| 2659 | write_byte(duration); |
| 2660 | message_end(); |
| 2661 | |
| 2662 | return 1; |
| 2663 | } |
| 2664 | |
| 2665 | /** |
| 2666 | * Creates a field of fire. |
| 2667 | * |
| 2668 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2669 | * https://youtu.be/szW-bSMPuyQ?t=11m7s |
| 2670 | * |
| 2671 | * @param position Effect position |
| 2672 | * @param sprite Sprite or model index to use for the fire |
| 2673 | * @param radius Effect radius |
| 2674 | * @param count Number of fields to generate (0 - 255) |
| 2675 | * @param duration Duration of the effect (will be randomized a bit) (0 - 255) |
| 2676 | * @param flags Available flags: |
| 2677 | * TEFIRE_FLAG_ALLFLOAT - all sprites will drift upwards as they animate |
| 2678 | * TEFIRE_FLAG_SOMEFLOAT - some of the sprites will drift upwards (50% chance) |
| 2679 | * TEFIRE_FLAG_LOOP - if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration |
| 2680 | * TEFIRE_FLAG_ALPHA - if set, sprite is rendered alpha blended at 50% else, opaque |
| 2681 | * TEFIRE_FLAG_PLANAR - if set, all fire sprites have same initial Z instead of randomly filling a cube |
| 2682 | * @param receiver Client index that will be able to see the effect |
| 2683 | * or 0 for all clients |
| 2684 | * @param reliable If true, the message will be sent via the reliable |
| 2685 | * channel, otherwise it will use the unreliable one |
| 2686 | * |
| 2687 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2688 | * 1 otherwise |
| 2689 | */ |
| 2690 | stock te_create_fire_field(position[3], sprite, radius = 5, count = 1, duration = 10, flags = TEFIRE_FLAG_ALLFLOAT, receiver = 0, bool:reliable = true) |
| 2691 | { |
| 2692 | if(receiver && !is_user_connected(receiver)) |
| 2693 | return 0; |
| 2694 | |
| 2695 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2696 | write_byte(TE_FIREFIELD); |
| 2697 | write_coord(position[0]); |
| 2698 | write_coord(position[1]); |
| 2699 | write_coord(position[2]); |
| 2700 | write_short(radius); |
| 2701 | write_short(sprite); |
| 2702 | write_byte(count); |
| 2703 | write_byte(flags); |
| 2704 | write_byte(duration); |
| 2705 | message_end(); |
| 2706 | |
| 2707 | return 1; |
| 2708 | } |
| 2709 | |
| 2710 | /** |
| 2711 | * Attaches a temporary entity model to a client. |
| 2712 | * |
| 2713 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2714 | * https://youtu.be/szW-bSMPuyQ?t=11m16s |
| 2715 | * |
| 2716 | * @param player Client index to attach the model to |
| 2717 | * @param model Model index |
| 2718 | * @param offset Vertical offset (attachment origin.z = player origin.z + vertical offset) |
| 2719 | * @param life The length of time the model shall remain |
| 2720 | * @param receiver Client index that will be able to see the model |
| 2721 | * or 0 for all clients |
| 2722 | * @param reliable If true, the message will be sent via the reliable |
| 2723 | * channel, otherwise it will use the unreliable one |
| 2724 | * |
| 2725 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2726 | * 1 otherwise |
| 2727 | */ |
| 2728 | stock te_attach_model_to_player(player, model, offset = 0, life = 5, receiver = 0, bool:reliable = true) |
| 2729 | { |
| 2730 | if(receiver && !is_user_connected(receiver)) |
| 2731 | return 0; |
| 2732 | |
| 2733 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2734 | write_byte(TE_PLAYERATTACHMENT); |
| 2735 | write_byte(player); |
| 2736 | write_coord(offset); |
| 2737 | write_short(model); |
| 2738 | write_short(life); |
| 2739 | message_end(); |
| 2740 | |
| 2741 | return 1; |
| 2742 | } |
| 2743 | |
| 2744 | /** |
| 2745 | * Kills all temporary entity models attached to a client. |
| 2746 | * |
| 2747 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2748 | * https://youtu.be/szW-bSMPuyQ?t=11m24s |
| 2749 | * |
| 2750 | * @param player Client index to remove the attachments from |
| 2751 | * @param receiver Client index that will be able to see the effect |
| 2752 | * or 0 for all clients |
| 2753 | * @param reliable If true, the message will be sent via the reliable |
| 2754 | * channel, otherwise it will use the unreliable one |
| 2755 | * |
| 2756 | * @noreturn |
| 2757 | * @error If "receiver" is non-zero and the client isn't |
| 2758 | * |
| 2759 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2760 | * 1 otherwise |
| 2761 | */ |
| 2762 | stock te_remove_all_player_attachments(player, receiver = 0, bool:reliable = true) |
| 2763 | { |
| 2764 | if(receiver && !is_user_connected(receiver)) |
| 2765 | return 0; |
| 2766 | |
| 2767 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2768 | write_byte(TE_KILLPLAYERATTACHMENTS); |
| 2769 | write_byte(player); |
| 2770 | message_end(); |
| 2771 | |
| 2772 | return 1; |
| 2773 | } |
| 2774 | |
| 2775 | /** |
| 2776 | * Much more compact shotgun shot stock. |
| 2777 | * |
| 2778 | * @note This stock is used to make a client approximate a 'spray' of gunfire. |
| 2779 | * Any weapon that fires more than one bullet per frame and fires in a bit |
| 2780 | * of a spread is a good candidate for MULTIGUNSHOT use. (shotguns) |
| 2781 | * @note This effect makes the client do traces for each bullet, these client |
| 2782 | * traces ignore entities that have studio models. Traces are 4096 long. |
| 2783 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2784 | * https://youtu.be/szW-bSMPuyQ?t=11m27s |
| 2785 | * |
| 2786 | * @param position Gunshot position |
| 2787 | * @param direction Gunshot direction |
| 2788 | * @param decal Bullethole decal texture index (0 - 255) |
| 2789 | * @param count Number of bulletholes to generate (0 - 255) |
| 2790 | * @param noise_x X noise multiplied by 100 |
| 2791 | * @param noise_y Y noise multiplied by 100 |
| 2792 | * @param receiver Client index that will be able to see the Gunshot |
| 2793 | * or 0 for all clients |
| 2794 | * @param reliable If true, the message will be sent via the reliable |
| 2795 | * channel, otherwise it will use the unreliable one |
| 2796 | * |
| 2797 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2798 | * 1 otherwise |
| 2799 | */ |
| 2800 | stock te_create_multi_gunshot(position[3], direction[3], decal = 105, count = 1, noise_x = 0, noise_y = 0, receiver = 0, bool:reliable = true) |
| 2801 | { |
| 2802 | if(receiver && !is_user_connected(receiver)) |
| 2803 | return 0; |
| 2804 | |
| 2805 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2806 | write_byte(TE_MULTIGUNSHOT); |
| 2807 | write_coord(position[0]); |
| 2808 | write_coord(position[1]); |
| 2809 | write_coord(position[2]); |
| 2810 | write_coord(direction[0]); |
| 2811 | write_coord(direction[1]); |
| 2812 | write_coord(direction[2]); |
| 2813 | write_coord(noise_x); |
| 2814 | write_coord(noise_y); |
| 2815 | write_byte(count); |
| 2816 | write_byte(decal); |
| 2817 | message_end(); |
| 2818 | |
| 2819 | return 1; |
| 2820 | } |
| 2821 | |
| 2822 | /** |
| 2823 | * Creates a tracer effect and allows more customization than te_create_tracer. |
| 2824 | * |
| 2825 | * @note Video preview of this and all other te_ stocks can be found here: |
| 2826 | * https://youtu.be/szW-bSMPuyQ?t=11m36s |
| 2827 | * |
| 2828 | * @param position Effect position |
| 2829 | * @param velocity Effect velocity |
| 2830 | * @param life The length of time the effect shall remain, multiplied by 10 (0 - 255) |
| 2831 | * @param color Tracer color (0 - 12) |
| 2832 | * @param length Length of the tracer (0 - 255) |
| 2833 | * @param receiver Client index that will be able to see the effect |
| 2834 | * or 0 for all clients |
| 2835 | * @param reliable If true, the message will be sent via the reliable |
| 2836 | * channel, otherwise it will use the unreliable one |
| 2837 | * |
| 2838 | * @return 0 if "receiver" is non-zero and the client isn't connected, |
| 2839 | * 1 otherwise |
| 2840 | */ |
| 2841 | stock te_create_user_tracer(position[3], velocity[3], life = 1, color = 106, length = 1, receiver = 0, bool:reliable = true) |
| 2842 | { |
| 2843 | if(receiver && !is_user_connected(receiver)) |
| 2844 | return 0; |
| 2845 | |
| 2846 | message_begin(get_msg_destination(receiver, reliable), SVC_TEMPENTITY, .player = receiver); |
| 2847 | write_byte(TE_USERTRACER); |
| 2848 | write_coord(position[0]); |
| 2849 | write_coord(position[1]); |
| 2850 | write_coord(position[2]); |
| 2851 | write_coord(velocity[0]); |
| 2852 | write_coord(velocity[1]); |
| 2853 | write_coord(velocity[2]); |
| 2854 | write_byte(life); |
| 2855 | write_byte(clamp(color, 0, 12)); |
| 2856 | write_byte(length); |
| 2857 | message_end(); |
| 2858 | |
| 2859 | return 1; |
| 2860 | } |
| 2861 | |
| 2862 | /** |
| 2863 | * @endsection |
| 2864 | */ |
| 2865 | |
| 2866 | /** |
| 2867 | * Used with message stocks. Returns whether or not to use the reliable or |
| 2868 | * unreliable channel when sending a message according to the params used. |
| 2869 | * |
| 2870 | * @param id Client index or 0 for all clients |
| 2871 | * @param reliable If true, the message will be sent via the reliable |
| 2872 | * channel, otherwise it will use the unreliable one |
| 2873 | * |
| 2874 | * @return MSG_ONE if "id" is non-zero and "reliable" is true, |
| 2875 | * MSG_ONE_UNRELIABLE if "id" is non-zero and "reliable" is false, |
| 2876 | * MSG_ALL if "id" is zero and "reliable" is true, |
| 2877 | * MSG_BROADCAST if "id" is zero and "reliable" is false. |
| 2878 | */ |
| 2879 | stock get_msg_destination(id, bool:reliable) |
| 2880 | { |
| 2881 | if(id) |
| 2882 | return reliable ? MSG_ONE : MSG_ONE_UNRELIABLE; |
| 2883 | |
| 2884 | return reliable ? MSG_ALL : MSG_BROADCAST; |
| 2885 | } |
| 2886 | |
| 2887 | /** |
| 2888 | * Converts a float value into a short. |
| 2889 | * |
| 2890 | * @param value Float value to convert |
| 2891 | * |
| 2892 | * @return Value converted to short |
| 2893 | */ |
| 2894 | stock float_to_short(Float:value) |
| 2895 | return clamp(floatround(value * (1<<12)), 0, 0xFFFF); |