csdm.inc
Original include source with line numbers.
| 1 | /** |
| 2 | * (C)2003-2013 David "BAILOPAN" Anderson |
| 3 | * Counter-Strike Deathmatch (CSDM) 2.1.3 Module Includes |
| 4 | */ |
| 5 | |
| 6 | #if defined _csdm_included |
| 7 | #endinput |
| 8 | #endif |
| 9 | #define _csdm_included |
| 10 | |
| 11 | #if AMXX_VERSION_NUM >= 175 |
| 12 | #pragma reqlib csdm |
| 13 | #if !defined AMXMODX_NOAUTOLOAD |
| 14 | #pragma loadlib csdm |
| 15 | #endif |
| 16 | #else |
| 17 | #pragma library csdm |
| 18 | #endif |
| 19 | |
| 20 | #define CSDM_VERSION "2.1.3d" |
| 21 | |
| 22 | #define CFG_READ 0 //Line is being read normally |
| 23 | #define CFG_RELOAD 1 //Section is being parsed from the start |
| 24 | #define CFG_DONE 2 //Section is done being parsed |
| 25 | |
| 26 | #define DEFAULT_ARMOR 100 |
| 27 | |
| 28 | #define MAX_WEAPONS 32 |
| 29 | #define MAX_SECONDARY 8 |
| 30 | #define MAX_PRIMARY 18 |
| 31 | |
| 32 | #define CSDM_FFA_ENABLE 3 |
| 33 | #define CSDM_FFA_DISABLE 2 |
| 34 | #define CSDM_ENABLE 1 |
| 35 | #define CSDM_DISABLE 0 |
| 36 | |
| 37 | #define CSDM_DROP_CONTINUE 0 //continue normally |
| 38 | #define CSDM_DROP_REMOVE 1 //remove the dropped weapon |
| 39 | #define CSDM_DROP_IGNORE 2 //ignore entirely |
| 40 | |
| 41 | /************ |
| 42 | * FORWARDS * |
| 43 | ************/ |
| 44 | |
| 45 | //Called when CSDM initializes. It passes in a version string, or a blank |
| 46 | // string if some load failure occurred. |
| 47 | //Do pre-config stuff here. |
| 48 | forward csdm_Init(const version[]); |
| 49 | |
| 50 | //Called when CSDM is ready to accept config hooks. |
| 51 | forward csdm_CfgInit(); |
| 52 | |
| 53 | //Called right before a death message is sent. Return value has no effect. |
| 54 | forward csdm_PreDeath(killer, victim, headshot, const weapon[]); |
| 55 | |
| 56 | //Called right after a death message is handled. |
| 57 | //return PLUGIN_HANDLED will block CSDM from doing any physical respawning. |
| 58 | forward csdm_PostDeath(killer, victim, headshot, const weapon[]); |
| 59 | |
| 60 | //Called after a player is physically respawned, |
| 61 | // but before the spawn handler is called. Returning PLUGIN_HANDLED |
| 62 | // will block CSDM from calling the set spawn handler. |
| 63 | //Note! this will only be called if CSDM internally respawns or you use |
| 64 | // csdm_respawn(). |
| 65 | forward csdm_PreSpawn(player, bool:fake); |
| 66 | |
| 67 | //Called after a player is physically respawned, |
| 68 | // and after all spawn handling is completed. |
| 69 | forward csdm_PostSpawn(player, bool:fake); |
| 70 | |
| 71 | //Called right before round is restarted |
| 72 | //The post parameter is set to 1 if the event is post. |
| 73 | //If post is 0, the event is pre, and PLUGIN_HANDLED will block |
| 74 | // CSDM from doing round restart actions (respawning) |
| 75 | forward csdm_RoundRestart(post); |
| 76 | |
| 77 | //Called when a CSDM state is set |
| 78 | forward csdm_StateChange(csdm_state); |
| 79 | |
| 80 | /** |
| 81 | * Called when CSDM is about to remove a weapon. Return PLUGIN_HANDLED to block. |
| 82 | * |
| 83 | * owner - The player who owned this weapon. |
| 84 | * entity_id - The entity index of the weapon. |
| 85 | * box_id - If the weapon is boxed, this will be set to the boxed entity index.. |
| 86 | */ |
| 87 | forward csdm_RemoveWeapon(owner, entity_id, boxed_id); |
| 88 | |
| 89 | //Called by the main plugin right now |
| 90 | //If death is true, the weapon was dropped on death |
| 91 | //if weapon is -1, the weapon is the shield. |
| 92 | forward csdm_HandleDrop(id, weapon, death); |
| 93 | |
| 94 | /*********** |
| 95 | * NATIVES * |
| 96 | ***********/ |
| 97 | |
| 98 | //To retrieve/set angles and v_angles, pass up to two more vectors |
| 99 | native csdm_getpos(player, Float:origin[3], ...); |
| 100 | |
| 101 | native csdm_setpos(player, const Float:origin[3], ...); |
| 102 | |
| 103 | //Returns the number of registered spawn styles |
| 104 | native csdm_spawnstyles(); |
| 105 | |
| 106 | //Retrieves the name of a spawn style by index (indices start at 0) |
| 107 | native csdm_styleinfo(style_index, name[], maxlength); |
| 108 | |
| 109 | //Adds a spawn style handler |
| 110 | native csdm_addstyle(const name[], const function[]); |
| 111 | |
| 112 | //Sets the current spawn style handler by name. |
| 113 | //The handler registered to this name will be called after every spawn. |
| 114 | native csdm_setstyle(const name[]); |
| 115 | |
| 116 | //Returns the current style id |
| 117 | native csdm_curstyle(); |
| 118 | |
| 119 | //Respawns a player correctly under the CSDM spawn system. |
| 120 | native csdm_respawn(player); |
| 121 | |
| 122 | //Forces a "fake" respawn on the player - sort of like a ResetHUD |
| 123 | native csdm_fakespawn(player); |
| 124 | |
| 125 | //Registers a hook on the config reader |
| 126 | //The forward looks like this: |
| 127 | //forward my_cfg_reader(read_mode, const line[], const section[]) |
| 128 | native csdm_reg_cfg(const sectionName[], const handler[]); |
| 129 | |
| 130 | //Gives an item. Same as give_item from fun. |
| 131 | native csdm_give_item(player, const item_name[]); |
| 132 | |
| 133 | //Forces a player to drop a weapon |
| 134 | native csdm_force_drop(player, const weapon[], remove=1); |
| 135 | |
| 136 | //Schedules a weapon for removal. 0 seconds means immediate |
| 137 | //delay specifies whether it should wait 0.1 seconds or not (0 for immediate lookup) |
| 138 | native csdm_remove_weapon(player, const weapon[], seconds, delay); |
| 139 | |
| 140 | //Schedules a weapon for removal. 0 seconds means immediate |
| 141 | //delay specifies whether it should wait 0.1 seconds or not (0 for immediate lookup) |
| 142 | native csdm_remove_weaponbox(player, ent, seconds, delay, shield); |
| 143 | |
| 144 | //Reloads the config file |
| 145 | //If you specify a named file, CSDM auto-prepends the configs dir. |
| 146 | // I.e., passing csdm\mapconfigs\de_dust2.cfg will turn into: |
| 147 | // addons\amxmodx\configs\csdm\mapconfigs\de_dust2.cfg |
| 148 | native csdm_reload_cfg(const file[]=""); |
| 149 | |
| 150 | //Returns whether CSDM is active |
| 151 | native csdm_active(); |
| 152 | //Sets CSDM to active (do not set the cvar!) |
| 153 | native csdm_set_active(on_or_off); |
| 154 | |
| 155 | //Returns/sets the current FFA (free for all) state |
| 156 | native csdm_get_ffa(); |
| 157 | native csdm_set_ffa(on_or_off); |
| 158 | |
| 159 | //Gets/sets the respawn wait time |
| 160 | native Float:csdm_get_spawnwait(); |
| 161 | native csdm_set_spawnwait(Float:time); |
| 162 | |
| 163 | //returns cache information into each array slot |
| 164 | // 0 - number of free items in spawn task cache |
| 165 | // 1 - number of free task in general task cache |
| 166 | // 2 - number of hot tasks (ones in use) |
| 167 | // 3 - number of cached weapon removals in table |
| 168 | // 4 - number of live weapon removals in table |
| 169 | // 5 - number of weapon find tasks in cache |
| 170 | // in general, 0+5+4 should about equal 1+2 |
| 171 | // do not edit the vers parameter. |
| 172 | native csdm_cache(ar[6], vers=2) |
| 173 | |
| 174 | //Quick hack to replace engine dependency and work around a FM bug |
| 175 | //returns 1 if a hull collision is found |
| 176 | native csdm_trace_hull(Float:origin[3], hull_no); |
| 177 | |
| 178 | //Disables the CSDM welcome message |
| 179 | //This is useful if you only use CSDM as an engine |
| 180 | //Returns the old value. Pass -1 to do nothing. |
| 181 | native csdm_set_intromsg(value=-1); |
| 182 | |
| 183 | /** |
| 184 | * Natives defined by csdm_main |
| 185 | */ |
| 186 | |
| 187 | //Returns the handle for the main CSDM menu, letting you modify it. |
| 188 | native csdm_main_menu(); |
| 189 | |
| 190 | //Returns the handle for the settings CSDM menu, letting you modify it. |
| 191 | native csdm_settings_menu(); |
| 192 | |
| 193 | #define CSDM_OPTION_SAYRESPAWN 1 //No extra parameters |
| 194 | #define CSDM_SET_DISABLED -1 |
| 195 | #define CSDM_SET_DEFAULT 0 |
| 196 | #define CSDM_SET_ENABLED 1 |
| 197 | |
| 198 | //Sets an internal option. Options listed above. |
| 199 | native csdm_set_mainoption(option, setting, ...); |
| 200 | |
| 201 | //Runs through the weapon drop deletion algorithm. |
| 202 | //If weapon_id is -1, name should be "weapon_shield" |
| 203 | native csdm_fwd_drop(player, weapon_id, const name[]); |
| 204 | |
| 205 | // Writes the Value of the Setting Parameter in the Section of csdm.cfg |
| 206 | native csdm_write_cfg(id, const section[], const parameter[], const value[]) |
| 207 | |
| 208 | /*** ************ *** |
| 209 | *** HELPER STUFF |
| 210 | ***/ |
| 211 | |
| 212 | #define SLOT_PRIMARY 1 |
| 213 | #define SLOT_SECONDARY 2 |
| 214 | #define SLOT_KNIFE 3 |
| 215 | #define SLOT_GRENADE 4 |
| 216 | #define SLOT_C4 5 |
| 217 | |
| 218 | #define _TEAM_T 1 |
| 219 | #define _TEAM_CT 2 |
| 220 | |
| 221 | //Weapon slot lookup table |
| 222 | stock g_WeaponSlots[] = { |
| 223 | 0, |
| 224 | 2, //CSW_P228 |
| 225 | 0, |
| 226 | 1, //CSW_SCOUT |
| 227 | 4, //CSW_HEGRENADE |
| 228 | 1, //CSW_XM1014 |
| 229 | 5, //CSW_C4 |
| 230 | 1, //CSW_MAC10 |
| 231 | 1, //CSW_AUG |
| 232 | 4, //CSW_SMOKEGRENADE |
| 233 | 2, //CSW_ELITE |
| 234 | 2, //CSW_FIVESEVEN |
| 235 | 1, //CSW_UMP45 |
| 236 | 1, //CSW_SG550 |
| 237 | 1, //CSW_GALIL |
| 238 | 1, //CSW_FAMAS |
| 239 | 2, //CSW_USP |
| 240 | 2, //CSW_GLOCK18 |
| 241 | 1, //CSW_AWP |
| 242 | 1, //CSW_MP5NAVY |
| 243 | 1, //CSW_M249 |
| 244 | 1, //CSW_M3 |
| 245 | 1, //CSW_M4A1 |
| 246 | 1, //CSW_TMP |
| 247 | 1, //CSW_G3SG1 |
| 248 | 4, //CSW_FLASHBANG |
| 249 | 2, //CSW_DEAGLE |
| 250 | 1, //CSW_SG552 |
| 251 | 1, //CSW_AK47 |
| 252 | 3, //CSW_KNIFE |
| 253 | 1 //CSW_P90 |
| 254 | }; |
| 255 | |
| 256 | //Maximum backpack ammo lookup table |
| 257 | stock g_MaxBPAmmo[] = { |
| 258 | 0, |
| 259 | 52, //CSW_P228 |
| 260 | 0, |
| 261 | 90, //CSW_SCOUT |
| 262 | 1, //CSW_HEGRENADE |
| 263 | 32, //CSW_XM1014 |
| 264 | 1, //CSW_C4 |
| 265 | 100,//CSW_MAC10 |
| 266 | 90, //CSW_AUG |
| 267 | 1, //CSW_SMOKEGRENADE |
| 268 | 120,//CSW_ELITE |
| 269 | 100,//CSW_FIVESEVEN |
| 270 | 100,//CSW_UMP45 |
| 271 | 90, //CSW_SG550 |
| 272 | 90, //CSW_GALIL |
| 273 | 90, //CSW_FAMAS |
| 274 | 100,//CSW_USP |
| 275 | 120,//CSW_GLOCK18 |
| 276 | 30, //CSW_AWP |
| 277 | 120,//CSW_MP5NAVY |
| 278 | 200,//CSW_M249 |
| 279 | 32, //CSW_M3 |
| 280 | 90, //CSW_M4A1 |
| 281 | 120,//CSW_TMP |
| 282 | 90, //CSW_G3SG1 |
| 283 | 2, //CSW_FLASHBANG |
| 284 | 35, //CSW_DEAGLE |
| 285 | 90, //CSW_SG552 |
| 286 | 90, //CSW_AK47 |
| 287 | 0, //CSW_KNIFE |
| 288 | 100//CSW_P90 |
| 289 | }; |
| 290 | |
| 291 | #define getWepId(%1) get_weaponid(%1) |
| 292 | |
| 293 | stock bool:IsValidTeam(team) |
| 294 | { |
| 295 | if (team == 1 || team == 2) |
| 296 | return true |
| 297 | return false |
| 298 | } |
| 299 | |
| 300 | stock drop_with_shield(player, weapon_id) |
| 301 | { |
| 302 | new name[32] |
| 303 | get_weaponname(weapon_id, name, 31) |
| 304 | csdm_force_drop(player, "weapon_shield", 0) |
| 305 | csdm_force_drop(player, name, 0) |
| 306 | csdm_fwd_drop(player, -1, "weapon_shield") |
| 307 | csdm_fwd_drop(player, weapon_id, name) |
| 308 | csdm_give_item(player, "weapon_shield") |
| 309 | } |
| 310 | |