hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.05.06. 04:50



Jelenlévő felhasználók

Jelenleg 361 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 360 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Bad camper színesen
HozzászólásElküldve: 2013.05.18. 19:01 
Offline
Őskövület
Avatar

Csatlakozott: 2011.12.28. 00:35
Hozzászólások: 2736
Megköszönt másnak: 56 alkalommal
Megköszönték neki: 275 alkalommal
Hali.

Valaki ebbe bele tudná úgy írni amit a chatbe ír az színes legyen:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <cstrike> // don't worry if you're not running cstrike, it's all good
  6. #include <csx> // don't worry if you're not running cstrike, it's all good
  7.  
  8. #pragma semicolon 1
  9.  
  10. #define TASKID_CHECK_CAMPING 85809473
  11.  
  12. #define DBG_METER_ON_1 1
  13.  
  14. #define SND_STOP (1<<5)
  15.  
  16. #define TEAM1 1
  17. #define TEAM2 2
  18.  
  19. // Player Flags
  20. #define METER_PAUSE 1
  21. #define METER_IGNORE 2
  22. #define PLAYER_BLIND 4
  23. #define PLAYER_SOUND 8
  24. #define CAMPER_ANNOUNCED 16
  25.  
  26. #define FADE_IN (1<<0)
  27. #define FADE_OUT (1<<1)
  28. #define FADE_HOLD (1<<2)
  29.  
  30. #define FADE_LENGTH_PERM (1<<0)
  31.  
  32. #define PUNISH_SLAP 1
  33. #define PUNISH_HEALTH 2
  34. #define PUNISH_SOUND 4
  35. #define PUNISH_BLIND 8
  36. #define PUNISH_MONEY 16
  37. #define PUNISH_SNARKS 32
  38.  
  39. #define ANNOUNCE_CHAT 1
  40. #define ANNOUNCE_HUD 2
  41.  
  42. #define SOUNDTYPE_SNORE 1
  43. #define SOUNDTYPE_HEARTBEAT 2
  44.  
  45. #define DMG_RESET_DEFENDER 1
  46. #define DMG_RESET_ATTACKER 2
  47.  
  48. #define TOLERANCE_DEFENDING 180
  49. #define TOLERANCE_ATTACKING 220
  50.  
  51. #define MAX_PLAYER_CNT 32
  52. #define MAX_COORDTYPE_CNT 2
  53. #define MAX_VECTOR_CNT 4
  54. #define MAX_COORD_CNT 3
  55.  
  56. #define COORDTYPE_BODY 0
  57. #define COORDTYPE_EYES 1
  58.  
  59. new g_coordsBody[MAX_PLAYER_CNT + 1][MAX_VECTOR_CNT][MAX_COORD_CNT];
  60. new g_coordsEyes[MAX_PLAYER_CNT + 1][MAX_VECTOR_CNT][MAX_COORD_CNT];
  61. new g_meter[MAX_PLAYER_CNT + 1], g_playerFlags[MAX_PLAYER_CNT + 1], g_snarkCnt[MAX_PLAYER_CNT + 1];
  62. new g_bombPlanter, bool:g_bombPlanted;
  63. new g_bombDefuser;
  64. new g_msgFade, g_mapHasBomb;
  65. new g_cstrike;
  66. new g_immunityFlags[32];
  67. new g_maxPlayers;
  68. new g_campMeterMsgSync, g_isCampingMsgSync;
  69.  
  70. // declare CVAR pointers
  71. new g_cvarDebug, g_cvarPunish, g_cvarLimit, g_cvarDisplay, g_cvarCheckAll, g_cvarShowSpec;
  72. new g_cvarStart, g_cvarDamageReset, g_cvarDamageRestart, g_cvarHealth, g_cvarMoney;
  73. new g_cvarMinPlayers, g_cvarAllow, g_cvarAnnounce, g_cvarSound, g_cvarImmunityFlags;
  74.  
  75. public plugin_natives()
  76. {
  77. set_module_filter("filter_module");
  78. set_native_filter("filter_native");
  79. }
  80.  
  81. public filter_module(const module[])
  82. {
  83. return (equal(module, "cstrike") || equal(module, "csx")) ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
  84. }
  85.  
  86. public filter_native(const name[], index, trap)
  87. {
  88. return (!trap) ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
  89. }
  90.  
  91. public plugin_precache()
  92. {
  93. if (get_cvar_num("badcamper_sound") & SOUNDTYPE_SNORE) precache_sound("misc/snore.wav");
  94. precache_sound("player/heartbeat1.wav");
  95.  
  96. return PLUGIN_CONTINUE;
  97. }
  98.  
  99. public plugin_init()
  100. {
  101. new pluginVersion[] = "1.4 beta";
  102.  
  103. register_plugin("Bad Camper", pluginVersion, "Brad Jones");
  104.  
  105. register_cvar("badcamper_version", pluginVersion, FCVAR_SERVER|FCVAR_SPONLY);
  106. g_cvarDebug = register_cvar("badcamper_debug", "0");
  107.  
  108. register_dictionary("bad_camper.txt");
  109.  
  110. register_concmd("badcamper", "cmd_list", ADMIN_CVAR, "- lists available punishments and indicates which are active");
  111.  
  112. g_cvarPunish = register_cvar("badcamper_punish", "12"); // is camping to be punished and if so, how
  113. g_cvarLimit = register_cvar("badcamper_limit", "35"); // seconds allowed to camp
  114. g_cvarDisplay = register_cvar("badcamper_display", "1"); // at what percentage to display meter
  115. g_cvarCheckAll = register_cvar("badcamper_check_all", "1"); // check both teams or just team with primary objective
  116. g_cvarStart = register_cvar("badcamper_start", "4.0"); // number of seconds after the start of a round that the meter starts
  117. g_cvarDamageReset = register_cvar("badcamper_damage_reset", "3"); // flag that indicates which meter(s) get reset upon a player attack
  118. g_cvarDamageRestart = register_cvar("badcamper_damage_restart", "4.0"); // number of seconds after giving or taking damage that the meter restarts
  119. g_cvarHealth = register_cvar("badcamper_health", "10"); // health taken if 'health reduction' punishment flag set (at 100% camp meter)
  120. g_cvarMoney = register_cvar("badcamper_money", "10"); // percentage of player's money taken if 'money reduction' punishment flag set (at 100% camp meter)
  121. g_cvarMinPlayers = register_cvar("badcamper_min_players", "0"); // minimum players before camping is allowed
  122. g_cvarAllow = register_cvar("badcamper_allow", "0"); // when is camping allowed
  123. g_cvarAnnounce = register_cvar("badcamper_announce", "3"); // announce a player's camping status
  124. g_cvarSound = register_cvar("badcamper_sound", "1"); // type of sound to play when "badcamper_punish" includes the sound punishment
  125. g_cvarImmunityFlags = register_cvar("badcamper_immunity_flags", ""); // which access levels have immunity
  126. g_cvarShowSpec = register_cvar("badcamper_show_spec", "1"); // let spectators see a player's meter?
  127. }
  128.  
  129. public plugin_cfg()
  130. {
  131. g_msgFade = get_user_msgid("ScreenFade");
  132. g_maxPlayers = get_maxplayers();
  133. g_isCampingMsgSync = CreateHudSyncObj();
  134. g_campMeterMsgSync = CreateHudSyncObj();
  135.  
  136. get_pcvar_string(g_cvarImmunityFlags, g_immunityFlags, 31);
  137.  
  138. if (module_exists("cstrike"))
  139. {
  140. g_cstrike = true;
  141.  
  142. // register_event("StatusValue","set_spec_target","bd","1=2"); // from Kost
  143. register_event("SpecHealth2", "meter_display_spec_clear", "bd");
  144. register_event("BarTime", "event_bartime", "b");
  145. register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
  146. register_logevent("event_round_start", 2, "1=Round_Start");
  147. register_logevent("event_round_end", 2, "1=Round_End");
  148. register_logevent("event_round_end", 2, "1&Restart_Round_");
  149.  
  150. g_mapHasBomb = engfunc(EngFunc_FindEntityByString,-1, "classname", "func_bomb_target");
  151. }
  152. else if (module_exists("dodx"))
  153. {
  154. register_event("RoundState", "event_round_start", "a", "1=1");
  155. register_event("RoundState", "event_round_end", "a", "1>2");
  156. register_event("ResetSens", "flags_reset", "b");
  157. }
  158. }
  159.  
  160. public cmd_list(id, level, cid)
  161. {
  162. if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED;
  163.  
  164. new punishmentFlags = get_pcvar_num(g_cvarPunish);
  165. new punishSlap[32], punishHealth[32], punishSound[32], punishBlind[32], punishMoney[32], punishSnarks[32];
  166.  
  167. // List each of the punishments available and indicate which of them are currently active.
  168. formatex(punishSlap, 31, "%5i %-1.1s%L", 1, (punishmentFlags & PUNISH_SLAP) ? "*" : "", LANG_SERVER, "PUNISH_SLAP") ;
  169. formatex(punishHealth, 31, "%5i %-1.1s%L", 2, (punishmentFlags & PUNISH_HEALTH) ? "*" : "", LANG_SERVER, "PUNISH_HEALTH");
  170. formatex(punishSound, 31, "%5i %-1.1s%L (%L)", 4, (punishmentFlags & PUNISH_SOUND) ? "*" : "", LANG_SERVER, "PUNISH_SOUND", LANG_SERVER, (get_pcvar_num(g_cvarSound) & SOUNDTYPE_SNORE) ? "SOUND_SNORE" : "SOUND_HEART");
  171. formatex(punishBlind, 31, "%5i %-1.1s%L", 8, (punishmentFlags & PUNISH_BLIND) ? "*" : "", LANG_SERVER, "PUNISH_BLIND");
  172. formatex(punishMoney, 31, "%5i %-1.1s%L", 16, (punishmentFlags & PUNISH_MONEY) ? "*" : "", LANG_SERVER, "PUNISH_MONEY");
  173. formatex(punishSnarks, 31, "%5i %-1.1s%L", 32, (punishmentFlags & PUNISH_SNARKS) ? "*" : "", LANG_SERVER, "PUNISH_SNARKS");
  174.  
  175. if (id)
  176. {
  177. client_print(id, print_console, "%s", punishSlap);
  178. client_print(id, print_console, "%s", punishHealth);
  179. client_print(id, print_console, "%s", punishSound);
  180. client_print(id, print_console, "%s", punishBlind);
  181. client_print(id, print_console, "%s", punishMoney);
  182. client_print(id, print_console, "%s", punishSnarks);
  183. }
  184. else
  185. {
  186. server_print("%s", punishSlap);
  187. server_print("%s", punishHealth);
  188. server_print("%s", punishSound);
  189. server_print("%s", punishBlind);
  190. server_print("%s", punishMoney);
  191. server_print("%s", punishSnarks);
  192. }
  193. return PLUGIN_HANDLED;
  194. }
  195.  
  196. public check_camping()
  197. {
  198. /* don't check, if the plugin is disabled */
  199. new punishmentFlags = get_pcvar_num(g_cvarPunish);
  200. if (punishmentFlags == 0) return;
  201.  
  202. /* don't check, if there is only one player on server */
  203. new players[32], playerCnt;
  204. get_players(players, playerCnt, "ch"); // don't include bots or hltv
  205. if (playerCnt == 1 && !(get_pcvar_num(g_cvarDebug) && DBG_METER_ON_1)) return;
  206.  
  207. /* determine acceptable camping values */
  208. new allowCampValue = get_pcvar_num(g_cvarAllow);
  209. new s_allowCampValue[8];
  210. new bool:allowCampByRatio;
  211.  
  212. if (allowCampValue > 0)
  213. {
  214. get_pcvar_string(g_cvarAllow, s_allowCampValue, 7);
  215. allowCampByRatio = (contain(s_allowCampValue, "%") ==-1) ? false : true;
  216. allowCampValue = (allowCampByRatio) ? clamp(allowCampValue, 1, 100) : clamp(allowCampValue, 1, 32);
  217. }
  218.  
  219. /* determine if either team is allowed to camp */
  220. new bool:allowTeamCamp[3] = {false, ...}; // using elements 1 and 2 to correspond to the values for TEAM1 and TEAM2
  221. new playerCnt_team1, playerCnt_team2, teamID, id;
  222.  
  223. get_players(players, playerCnt, "h"); // don't include hltv
  224. if (playerCnt >= get_pcvar_num(g_cvarMinPlayers))
  225. {
  226. // based on their objective ...
  227. if (!get_pcvar_num(g_cvarCheckAll) && g_cstrike)
  228. {
  229. if (!g_mapHasBomb)
  230. allowTeamCamp[TEAM1] = true;
  231. else if (g_bombPlanted)
  232. allowTeamCamp[TEAM1] = true;
  233. else
  234. allowTeamCamp[TEAM2] = true;
  235. }
  236.  
  237. // ... and based on calculated camp allowance
  238. if (allowCampValue > 0)
  239. {
  240. // get living player counts for each team
  241. get_players(players, playerCnt, "ah"); // skip dead players and hltv
  242. for (new playerIdx = 0; playerIdx < playerCnt; ++playerIdx)
  243. {
  244. id = players[playerIdx];
  245. teamID = get_user_team(id);
  246. if (teamID == TEAM1)
  247. playerCnt_team1++;
  248. else if (teamID == TEAM2)
  249. playerCnt_team2++;
  250. }
  251.  
  252. if (allowCampByRatio)
  253. {
  254. // allow camp per ratio of players on player's team to players on other team
  255. if (!allowTeamCamp[TEAM1]) allowTeamCamp[TEAM1] = allowCampValue >= percent(playerCnt_team1, playerCnt_team2);
  256. if (!allowTeamCamp[TEAM2]) allowTeamCamp[TEAM2] = allowCampValue >= percent(playerCnt_team2, playerCnt_team1);
  257. }
  258. else
  259. {
  260. // allow camp per straight player count
  261. if (!allowTeamCamp[TEAM1]) allowTeamCamp[TEAM1] = (allowCampValue >= playerCnt_team1);
  262. if (!allowTeamCamp[TEAM2]) allowTeamCamp[TEAM2] = (allowCampValue >= playerCnt_team2);
  263. }
  264. }
  265. }
  266.  
  267. /* handle each player's camping needs */
  268. new stdDev, campTolerance;
  269. new prevMeter, bool:punishCamper, Float:punishPercentage;
  270. new announceCampStatus = get_pcvar_num(g_cvarAnnounce);
  271.  
  272. get_players(players, playerCnt, "ah"); // skip dead players and hltv
  273. for (new playerIdx = 0; playerIdx < playerCnt; ++playerIdx)
  274. {
  275. id = players[playerIdx];
  276.  
  277. // pause the meter (don't cycle coords) if needed
  278. if (g_playerFlags[id] & METER_PAUSE) continue;
  279.  
  280. // insert the current location of the player
  281. coords_insert(id, COORDTYPE_BODY);
  282.  
  283. // ignore the meter if the player can legally camp or the player's meter is being ignored
  284. teamID = get_user_team(id);
  285. if (allowTeamCamp[teamID] || g_playerFlags[id] & METER_IGNORE) continue;
  286.  
  287. // ignore if this player meets the immunity requirements
  288. if (has_flag(id, g_immunityFlags))
  289. {
  290. // insert the current coords of where the player's shot would hit, i.e. where the player is looking
  291. coords_insert(id, COORDTYPE_EYES);
  292.  
  293. if (standing_still(id) && !looking_around(id) && g_meter[id] >= 65 && g_meter[id] < 80) continue;
  294. }
  295.  
  296. // grab the standard deviation from the player coords
  297. stdDev = coords_stdv(id);
  298.  
  299. // grab the camping tolerance based on current objective
  300. campTolerance = (!g_mapHasBomb || g_bombPlanted) ? TOLERANCE_ATTACKING : TOLERANCE_DEFENDING;
  301.  
  302. // grab the current meter percentage
  303. prevMeter = g_meter[id];
  304.  
  305. // add new percentage points to the meter
  306. g_meter[id] += (campTolerance- stdDev) / get_pcvar_num(g_cvarLimit);
  307.  
  308. // ensure the meter falls within bounds
  309. g_meter[id] = clamp(g_meter[id], 0, 100);
  310.  
  311. // if the meter is trending down, give the player some love
  312. if (g_meter[id] < prevMeter)
  313. {
  314. if (g_meter[id] < 80)
  315. {
  316. // help the meter find it's way down
  317. g_meter[id]-= (prevMeter- g_meter[id]) / 3;
  318.  
  319. if (prevMeter >= 80)
  320. {
  321. // ensure player isn't still being punished
  322. punish_stop_all(id);
  323.  
  324. // announce that the player is no longer camping
  325. if (announceCampStatus && g_playerFlags[id] & CAMPER_ANNOUNCED) camper_announcement(id, false);
  326. }
  327. }
  328. }
  329.  
  330. // determine how severe the punishment should be, if at all
  331. punishCamper = true; // now prove me wrong
  332. if (g_meter[id] == 100) punishPercentage = 1.00;
  333. else if (g_meter[id] >= 90) punishPercentage = 0.50;
  334. else if (g_meter[id] >= 80) punishPercentage = 0.10;
  335. else punishCamper = false;
  336.  
  337. // punish the vile camper
  338. if (punishCamper)
  339. {
  340. if (punishmentFlags & PUNISH_SLAP) punish_slap(id, punishPercentage);
  341. if (punishmentFlags & PUNISH_HEALTH) punish_health_reduction(id, punishPercentage);
  342. if (punishmentFlags & PUNISH_BLIND) punish_blind(id, punishPercentage);
  343. if (punishmentFlags & PUNISH_SOUND) punish_sound(id, punishPercentage);
  344. if (punishmentFlags & PUNISH_MONEY) punish_money_reduction(id, punishPercentage);
  345. if (punishmentFlags & PUNISH_SNARKS) punish_snark_attack(id, punishPercentage);
  346.  
  347. // announce that the player is camping
  348. if (g_meter[id] >= 90 && !(g_playerFlags[id] & CAMPER_ANNOUNCED)) camper_announcement(id, true);
  349. }
  350.  
  351. // let them know how long they've camped
  352. meter_display(id);
  353. }
  354. }
  355.  
  356. camper_announcement(id, bool:isCamping)
  357. {
  358. // announce to the opposite team this player's camping status
  359. new camperName[32];
  360. get_user_name(id, camperName, 31);
  361.  
  362. new camperTeam = get_user_team(id);
  363.  
  364. new announcementType = get_pcvar_num(g_cvarAnnounce);
  365. if (announcementType)
  366. {
  367. new msgAnnouncement[16];
  368. copy(msgAnnouncement, 15, (isCamping) ? "CAMPING_STARTED" : "CAMPING_STOPPED");
  369.  
  370. new playerId, announcement[64];
  371.  
  372. for (playerId = 1; playerId <= g_maxPlayers; playerId++)
  373. {
  374. if (is_user_connected(playerId) && get_user_team(playerId) != camperTeam)
  375. {
  376. formatex(announcement, 63, "%L", playerId, msgAnnouncement, camperName);
  377.  
  378. if (announcementType & ANNOUNCE_CHAT)
  379. client_print(playerId, print_chat, "[BADCAMPER] %s", announcement);
  380.  
  381. if (announcementType & ANNOUNCE_HUD)
  382. {
  383. set_hudmessage(100, 100, 255,-1.0, 0.88, 0, 1.0, 6.0, 0.1, 0.1,-1);
  384. ShowSyncHudMsg(playerId, g_isCampingMsgSync, "%s", announcement);
  385. }
  386. }
  387. }
  388. g_playerFlags[id] += (isCamping) ? CAMPER_ANNOUNCED :-CAMPER_ANNOUNCED;
  389. }
  390. }
  391.  
  392. punish_health_reduction(id, Float:punishPercentage)
  393. {
  394. set_pev(id, pev_dmg_inflictor, id);
  395. // set_pev(id, pev_health, get_user_health(id)- floatround(get_pcvar_float(g_cvarHealth) * punishPercentage)); <-- apparently this does bad things
  396. set_user_health(id, get_user_health(id)- floatround(get_pcvar_float(g_cvarHealth) * punishPercentage));
  397. }
  398.  
  399. punish_sound(id, Float:punishPercentage)
  400. {
  401. new soundFile[32];
  402. formatex(soundFile, 31, (get_pcvar_num(g_cvarSound) & SOUNDTYPE_SNORE) ? "misc/snore.wav" : "player/heartbeat1.wav");
  403.  
  404. emit_sound(id, CHAN_VOICE, soundFile, punishPercentage, ATTN_NORM, 0, PITCH_NORM);
  405. if (!(g_playerFlags[id] & PLAYER_SOUND)) g_playerFlags[id] += PLAYER_SOUND;
  406. }
  407.  
  408. punish_sound_stop(id)
  409. {
  410. new soundFile[32];
  411. formatex(soundFile, 31, (get_pcvar_num(g_cvarSound) & SOUNDTYPE_SNORE) ? "misc/snore.wav" : "player/heartbeat1.wav");
  412.  
  413. emit_sound(id, CHAN_VOICE, soundFile, 0.0, ATTN_NORM, 0, PITCH_NORM);
  414. if (g_playerFlags[id] & PLAYER_SOUND) g_playerFlags[id]-= PLAYER_SOUND;
  415. }
  416.  
  417. punish_slap(id, Float:punishPercentage)
  418. {
  419. for (new slapCnt = 1; slapCnt <= floatround(3.0 * punishPercentage, floatround_ceil); slapCnt++)
  420. user_slap(id, 0);
  421. }
  422.  
  423. punish_money_reduction(id, Float:punishPercentage)
  424. {
  425. if (g_cstrike)
  426. {
  427. new Float:lossPercentage = (get_pcvar_float(g_cvarMoney) / 100.0) * punishPercentage;
  428. new Float:currentMoney = float(cs_get_user_money(id));
  429. new reducedMoney = floatround(currentMoney- (currentMoney * lossPercentage));
  430. cs_set_user_money(id, reducedMoney);
  431. }
  432. }
  433.  
  434. public meter_display(id)
  435. {
  436. new displayMeter = get_pcvar_num(g_cvarDisplay);
  437.  
  438. if (displayMeter > 0 && g_meter[id] >= displayMeter)
  439. {
  440. new r, g, b;
  441.  
  442. if (g_meter[id] > 90)
  443. r = 255;
  444. else if (g_meter[id] > 80)
  445. {
  446. r = 255;
  447. g = 100;
  448. }
  449. else if (g_meter[id] > 50)
  450. {
  451. r = 255;
  452. g = 255;
  453. }
  454. else if (g_meter[id] > 20)
  455. g = 255;
  456. else
  457. b = 255;
  458.  
  459. set_hudmessage(r, g, b,-1.0, 0.85, 0, 1.0, 2.0, 0.1, 0.1,-1);
  460. ShowSyncHudMsg(id, g_campMeterMsgSync, "%L", id, "CAMP_METER", g_meter[id]);
  461.  
  462. // if allowed and there's anyone specing this player, go ahead and show them the meter too
  463. if (g_cvarShowSpec)
  464. {
  465. new playerCnt, players[MAX_PLAYER_CNT], id_spectator;
  466. get_players(players, playerCnt, "bch"); // skip alive players, bots, and hltv
  467. for (new playerIdx = 0; playerIdx < playerCnt; ++playerIdx)
  468. {
  469. id_spectator = players[playerIdx];
  470.  
  471. if (pev(id_spectator, pev_iuser2) == id)
  472. {
  473. ShowSyncHudMsg(id_spectator, g_campMeterMsgSync, "%L", id_spectator, "CAMP_METER", g_meter[id]);
  474. }
  475. }
  476. }
  477. }
  478. }
  479.  
  480. public standing_still(id)
  481. {
  482. return vectors_same(id, COORDTYPE_BODY);
  483. }
  484.  
  485. public looking_around(id)
  486. {
  487. return !vectors_same(id, COORDTYPE_EYES);
  488. }
  489.  
  490. public vectors_same(id, coordType)
  491. {
  492. new curCoords[MAX_COORD_CNT], coordIdx;
  493.  
  494. // grab the current coordinates
  495. for (coordIdx = 0; coordIdx < MAX_COORD_CNT; ++coordIdx)
  496. curCoords[coordIdx] = (coordType == COORDTYPE_BODY) ? g_coordsBody[id][0][coordIdx] : g_coordsEyes[id][0][coordIdx];
  497.  
  498. for (new vectorIdx = 1; vectorIdx < MAX_VECTOR_CNT; ++vectorIdx)
  499. for (coordIdx = 0; coordIdx < MAX_COORD_CNT; ++coordIdx)
  500. if (curCoords[coordIdx] != ((coordType == COORDTYPE_BODY) ? g_coordsBody[id][vectorIdx][coordIdx] : g_coordsEyes[id][vectorIdx][coordIdx]))
  501. return false;
  502.  
  503. return true;
  504. }
  505.  
  506. public coords_stdv(id)
  507. {
  508. // get the total variance of all the coords
  509. new sum, avg, variance, varianceTot;
  510. new coordIdx, vectorIdx;
  511.  
  512. for (coordIdx = 0; coordIdx < MAX_COORD_CNT; ++coordIdx)
  513. {
  514. // initialize our working variables
  515. sum = 0;
  516. variance = 0;
  517.  
  518. // get the average of the coordinate
  519. for (vectorIdx = 0; vectorIdx < MAX_VECTOR_CNT; ++vectorIdx)
  520. sum += g_coordsBody[id][vectorIdx][coordIdx];
  521.  
  522. avg = sum / MAX_VECTOR_CNT;
  523.  
  524. // get the variance of the coordinate
  525. for (vectorIdx = 0; vectorIdx < MAX_VECTOR_CNT; ++vectorIdx)
  526. variance += power(g_coordsBody[id][vectorIdx][coordIdx]- avg, 2);
  527.  
  528. variance = variance / (MAX_VECTOR_CNT- 1);
  529.  
  530. // increment the total variance of all coordinates
  531. varianceTot += variance;
  532. }
  533.  
  534. // return the standard deviation (std dev = the square root of the variance)
  535. return sqroot(varianceTot);
  536. }
  537.  
  538. public coords_insert(id, coordType)
  539. {
  540. // move each vector up one level, making room at the bottom for the new coords
  541. for (new vectorIdx = MAX_VECTOR_CNT- 1; vectorIdx > 0;--vectorIdx)
  542. {
  543. for (new coordIdx = 0; coordIdx < MAX_COORD_CNT; ++coordIdx)
  544. {
  545. if (coordType == COORDTYPE_BODY)
  546. g_coordsBody[id][vectorIdx][coordIdx] = g_coordsBody[id][vectorIdx- 1][coordIdx];
  547. else
  548. g_coordsEyes[id][vectorIdx][coordIdx] = g_coordsEyes[id][vectorIdx- 1][coordIdx];
  549. }
  550. }
  551.  
  552. // now that space is cleared for them, insert the current coords into the lowest vector
  553. if (is_user_connected(id))
  554. {
  555. if (coordType == COORDTYPE_BODY)
  556. get_user_origin(id, g_coordsBody[id][0], 0);
  557. else
  558. get_user_origin(id, g_coordsEyes[id][0], 3);
  559. }
  560. }
  561.  
  562. public punish_snark_attack(id, Float:punishPercentage)
  563. {
  564. new maxSnarkCnt = floatround(punishPercentage * 16.0);
  565.  
  566. if (g_snarkCnt[id] < maxSnarkCnt)
  567. {
  568. // send the snarks out, two at a time
  569. server_cmd("monster snark #%i", id);
  570. server_cmd("monster snark #%i", id);
  571.  
  572. g_snarkCnt[id] += 2;
  573. }
  574. }
  575.  
  576. public punish_blind(id, Float:punishPercentage)
  577. {
  578. new duration = (punishPercentage == 1.0) ? FADE_LENGTH_PERM : 1<<12;
  579. new holdTime = (punishPercentage == 1.0) ? FADE_LENGTH_PERM : 1<<8;
  580. new fadeType = (punishPercentage == 1.0) ? FADE_HOLD : FADE_IN;
  581. new blindness = 127 + floatround(128.0 * punishPercentage);
  582.  
  583. if (is_user_alive(id))
  584. {
  585. if (!(g_playerFlags[id] & PLAYER_BLIND)) g_playerFlags[id] += PLAYER_BLIND;
  586.  
  587. message_begin(MSG_ONE, g_msgFade, {0,0,0}, id); // use the magic #1 for "one client"
  588. write_short(duration); // fade lasts this long duration
  589. write_short(holdTime); // fade lasts this long hold time
  590. write_short(fadeType); // fade type
  591. write_byte(0); // fade red
  592. write_byte(0); // fade green
  593. write_byte(0); // fade blue
  594. write_byte(blindness); // fade alpha
  595. message_end();
  596. }
  597. }
  598.  
  599. public punish_blind_stop(id)
  600. {
  601. if (g_playerFlags[id] & PLAYER_BLIND) g_playerFlags[id]-= PLAYER_BLIND;
  602.  
  603. message_begin(MSG_ONE, g_msgFade, {0,0,0}, id); // use the magic #1 for "one client"
  604. write_short(1<<12); // fade lasts this long duration
  605. write_short(1<<8); // fade lasts this long hold time
  606. write_short(FADE_OUT); // fade type
  607. write_byte(0); // fade red
  608. write_byte(0); // fade green
  609. write_byte(0); // fade blue
  610. write_byte(255); // fade alpha
  611. message_end();
  612. }
  613.  
  614. public meter_dmg_reset(id)
  615. {
  616. // forgive previous camping transgressions
  617. punish_stop_all(id);
  618. g_meter[id] = 0;
  619. g_playerFlags[id] = 0;
  620.  
  621. // the player has been through enough trauma (getting or giving damage)
  622. // so let's just ignore the camp meter for awhile
  623. meter_ignore(id);
  624.  
  625. remove_task(id);
  626. set_task(get_pcvar_float(g_cvarDamageRestart), "meter_unignore", id);
  627. }
  628.  
  629. public meter_pause(id)
  630. {
  631. if (!(g_playerFlags[id] & METER_PAUSE)) g_playerFlags[id] += METER_PAUSE;
  632. }
  633.  
  634. public meter_ignore(id)
  635. {
  636. if (!(g_playerFlags[id] & METER_IGNORE)) g_playerFlags[id] += METER_IGNORE;
  637. }
  638.  
  639. public meter_unpause(id)
  640. {
  641. if (g_playerFlags[id] & METER_PAUSE) g_playerFlags[id]-= METER_PAUSE;
  642. }
  643.  
  644. public meter_unignore(id)
  645. {
  646. if (g_playerFlags[id] & METER_IGNORE) g_playerFlags[id]-= METER_IGNORE;
  647. }
  648.  
  649. public start_checking()
  650. {
  651. for (new id = 1; id <= 32; id++)
  652. meter_unignore(id);
  653. }
  654.  
  655. public bomb_planting(planter)
  656. {
  657. g_bombPlanter = planter;
  658. meter_pause(planter);
  659. }
  660.  
  661. public event_bartime(id)
  662. {
  663. if (read_data(1) == 0)
  664. {
  665. if (id == g_bombPlanter)
  666. g_bombPlanter = 0;
  667. else if (id == g_bombDefuser)
  668. g_bombDefuser = 0;
  669. else
  670. return;
  671.  
  672. meter_unpause(id);
  673. }
  674. }
  675.  
  676. public bomb_planted(planter)
  677. {
  678. g_bombPlanter = 0;
  679. g_bombPlanted = true;
  680. meter_unpause(planter);
  681. }
  682.  
  683. public bomb_defusing(defuser)
  684. {
  685. g_bombDefuser = defuser;
  686. meter_pause(defuser);
  687. }
  688.  
  689. public bomb_defused(defuser)
  690. {
  691. g_bombDefuser = 0;
  692. meter_unpause(defuser);
  693. }
  694.  
  695. public client_damage(attacker, victim, damage, wpnindex, hitplace, TA)
  696. {
  697. if (attacker && victim && attacker != victim && !TA)
  698. {
  699. new damageResetFlag = get_pcvar_num(g_cvarDamageReset);
  700. if (damageResetFlag & DMG_RESET_DEFENDER)
  701. meter_dmg_reset(victim);
  702. if (damageResetFlag & DMG_RESET_ATTACKER)
  703. meter_dmg_reset(attacker);
  704. }
  705. }
  706.  
  707. public event_round_end()
  708. {
  709. // stop checking for camping
  710. remove_task(TASKID_CHECK_CAMPING);
  711. }
  712.  
  713. public event_new_round()
  714. {
  715. // make sure any straggling monsters are sent away to a better place
  716. if (get_pcvar_num(g_cvarPunish) & PUNISH_SNARKS)
  717. {
  718. monsters_kill();
  719. }
  720. }
  721.  
  722. public event_round_start()
  723. {
  724. g_bombPlanted = false;
  725.  
  726. if (get_pcvar_num(g_cvarPunish))
  727. {
  728. // reset all the flags
  729. for (new id = 1; id <= 32; id++)
  730. {
  731. flags_reset(id);
  732. meter_ignore(id);
  733. }
  734. set_task(get_pcvar_float(g_cvarStart), "start_checking");
  735. set_task(2.0, "check_camping", TASKID_CHECK_CAMPING, _, _, "b");
  736. }
  737. }
  738.  
  739. monsters_kill()
  740. {
  741. // this function will kill ALL monsters on the map, it doesn't make a distinction
  742. // between monsters spawned by THIS plugin and monsters spawned some other way.
  743. // if it's a monster, it'll be killed.
  744. new Float:health;
  745. new maxEntities = global_get(glb_maxEntities);
  746. for (new entity = 1; entity < maxEntities; ++entity)
  747. {
  748. if (pev_valid(entity) && pev(entity, pev_flags) & FL_MONSTER)
  749. {
  750. set_pev(entity, pev_dmg_inflictor, 0); // set the damage inflictor to "world"
  751. pev(entity, pev_health, health); // grab the monster's current health
  752. set_pev(entity, pev_health, 0.0); // kill the monster by taking away all it's health //pev_fuser4
  753. }
  754. }
  755. }
  756.  
  757. public flags_reset(id)
  758. {
  759. g_meter[id] = 0;
  760. g_playerFlags[id] = 0;
  761. g_snarkCnt[id] = 0;
  762. coords_reset(id);
  763. }
  764.  
  765. public coords_reset(id)
  766. {
  767. for (new vectorIdx = 0; vectorIdx < MAX_VECTOR_CNT; vectorIdx++)
  768. coords_insert(id, COORDTYPE_BODY);
  769. }
  770.  
  771. public punish_stop_all(id)
  772. {
  773. if (g_playerFlags[id] & PLAYER_BLIND) punish_blind_stop(id);
  774. if (g_playerFlags[id] & PLAYER_SOUND) punish_sound_stop(id);
  775. g_snarkCnt[id] = 0;
  776. }
  777.  
  778. percent(is, of)
  779. {
  780. return (of != 0) ? floatround(floatmul(float(is)/float(of), 100.0)) : 0;
  781. }
  782.  
  783. /*
  784. stock debug_log(const textID[] = "", const text[] = "", {Float,Sql,Result,_}:...)
  785. {
  786. new debugger = get_cvar_num("badcamper_debug");
  787. if (debugger || debugger ==-1)
  788. {
  789. // format the text as needed
  790. new formattedText[1024];
  791. format_args(formattedText, 1023, 1);
  792. // if there's a text identifier, add it
  793. if (textID[0])
  794. format(formattedText, 1023, "[%s] %s", textID, formattedText);
  795. // log text to file
  796. log_to_file("_badcamper.log", formattedText);
  797. // if there's someone to show text to, do so
  798. if (debugger && is_user_connected(debugger))
  799. client_print(debugger, print_chat, formattedText);
  800. }
  801. // not needed but gets rid of stupid compiler error
  802. if (text[0] == 0) return;
  803. }
  804. */
  805.  
  806. /*
  807. stock has_flag(id, flags[])
  808. {
  809. return (get_user_flags(id) & read_flags(flags));
  810. }
  811. */
  812.  
  813. public meter_display_spec_clear(id)
  814. {
  815. ClearSyncHud(id, g_campMeterMsgSync);
  816. }

_________________
****


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 27 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole