/src/weapons.c

http://github.com/Jermuk/custom_cs2dsrv · C · 67 lines · 57 code · 3 blank · 7 comment · 7 complexity · 15b48f9d4ef344a3896118975192d2ad MD5 · raw file

  1. /*
  2. * Published under GPLv3.
  3. * For more information take a look at the Readme
  4. * Copyright (c) by the authors of this file
  5. *
  6. * Author/s of this file: Jermuk
  7. */
  8. #include "../include/weapons.h"
  9. void AddWeapon(short id, char name[], short wpndmg, short wpndmg_z1,
  10. short wpndmg_z2, short freq, short speed, short slot, short price,
  11. short range, short accuracy, short ammo1, short ammo2, int reloadtime,
  12. short special, short team)
  13. {
  14. if (name != NULL)
  15. {
  16. weapons[id].name = malloc(strlen(name) + 1);
  17. if (weapons[id].name == NULL)
  18. error_exit("Memory Error in AddWeapon()\n");
  19. strncpy(weapons[id].name, name, strlen(name) + 1);
  20. }
  21. else
  22. {
  23. weapons[id].name = NULL;
  24. }
  25. weapons[id].weapondamage = wpndmg;
  26. weapons[id].weapondamage_z1 = wpndmg_z1;
  27. weapons[id].weapondamage_z2 = wpndmg_z2;
  28. if (freq != 0)
  29. weapons[id].freq = (short) (1 / freq) * 60 * 1000;
  30. else
  31. weapons[id].freq = 1000;
  32. weapons[id].speed = speed;
  33. weapons[id].slot = slot;
  34. weapons[id].price = price;
  35. weapons[id].range = range;
  36. weapons[id].accuracy = accuracy;
  37. weapons[id].ammo1 = ammo1;
  38. weapons[id].ammo2 = ammo2;
  39. weapons[id].reloadtime = reloadtime;
  40. weapons[id].special = special;
  41. weapons[id].team = team;
  42. }
  43. void WeaponInit()
  44. {
  45. int i;
  46. for (i = 0; i <= 99; i++)
  47. {
  48. AddWeapon(i, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  49. }
  50. AddWeapon(1, "USP", 24, 0, 0, 166, 1, 2, 500, 300, 0, 12, 100, 1000, 1, 0);
  51. AddWeapon(2, "Glock", 21, 0, 0, 166, 1, 2, 400, 250, 0, 20, 120, 1000, 2, 0);
  52. AddWeapon(3, "Deagle", 34, 0, 0, 100, 1, 2, 550, 300, 0, 7, 35, 1000, 0, 0);
  53. AddWeapon(4, "P228", 22, 0, 0, 166, 1, 2, 600, 300, 0, 13, 35, 1000, 0, 0);
  54. AddWeapon(5, "Elite", 22, 0, 0, 187, 1, 2, 1000, 300, 0, 13, 120, 1000, 0,
  55. 0);
  56. AddWeapon(6, "Five-Seven", 21, 0, 0, 187, 1, 2, 750, 300, 0, 20, 100, 2000,
  57. 0, 0);
  58. AddWeapon(20, "MP5", 13, 0, 0, 500, 1, 1, 1500, 300, 2, 30, 120, 1000, 0, 0);
  59. AddWeapon(21, "TMP", 9, 0, 0, 750, 1, 1, 1250, 100, 4, 30, 120, 1000, 0, 2);
  60. AddWeapon(22, "P90", 11, 0, 0, 750, 1, 1, 2350, 300, 3, 50, 100, 1000, 0, 2);
  61. AddWeapon(35, "AWP", 50, 65, 150, 23, 3, 1, 4750, 400, 0, 10, 30, 2000, 5,
  62. 0);
  63. AddWeapon(50, "Knife", 50, 100, 0, 1, 1, 2, 0, 8, 0, -1, -1, 0, 3, 0);
  64. }