/////////////////////////////////////////////////////////////////////////////////////// // // AMX Mod (X) // // Developed by: // The Amxmodx DoD Community // |BW|.Zor Editor (zor@blackwatch.recongamer.com) // http://www.dodcommunity.net // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at // your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // In addition, as a special exception, the author gives permission to // link the code of this program with the Half-Life Game Engine ("HL // Engine") and Modified Game Libraries ("MODs") developed by Valve, // L.L.C ("Valve"). You must obey the GNU General Public License in all // respects for all of the code used other than the HL Engine and MODs // from Valve. If you modify this file, you may extend this exception // to your version of the file, but you are not obligated to do so. If // you do not wish to do so, delete this exception statement from your // version. // // Name: DoD Bleeding // Author: |BW|.Zor ( Original Concept SidLuke ) // Description: This plugin will make players bleed when hit, depending on the weapon // the hit location it will make them bleed more or less. It will also // kill the players after a period of time. // // Important Information: // // ENSURE TO ADD THIS BEFORE YOUR TK MANAGER!!!! IF NOT TKS WONT GET CAUGHT!!! // // Reference: // // v0.1 - Be! // - Alot of work from the original was ripped out, some things remain. I have // been testing this on my server and it works fine // v0.1a - Added says from original and a bit of fixes so as to show bled out ppl how to patch // - Added a function to allow a user to bind a key using the chat // v0.1b - Fixed the binding using global chat // - Added pausing abilities // // ToDo: // - I need to work on the bleeding by teamates...cant figure out how to throw the // death by teamate, have tried using the message but not working...testing calling the // function directly within the plugin. // - Want to look at having it as a useable weapon type thing // - Look at a menu for binding keys // - Look at droping all weapons, then reload all weapons when patching // /////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////////////// // Version Control // new AUTH[] = "AMXX DoD Community" new PLUGIN_NAME[] = "DoD Bleeding" new VERSION[] = "0.1b" // /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// // Globals // new gObjectSprite[33][64] new gBleeding[33] new gBandaging[33] new gKiller[33] new gDeathByBleeding[33] new gBoundHisKey[33] new gmsgObject new gDamage new gwpnbandage new fileNames[5][] = { "sprites/blood_icon.spr", "sprites/bandage_icon.spr", "player/hit.wav", // I created my own wave that says "I'm hit I'm hit...MEDIC" "player/bouch.wav", // British saying "damnit man you shot me. I spilt my tea" "player/germedic.wav" // German cry for medic after being shot } enum { blood, bandage, ouch, bouch, gouch } // /////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Plugin Initialization - plugin_init // // This function is called by amxmodx upon start of a new map and is the second step in initializing a // plugin // // @step 2 // @access public // @return int PLUGIN_CONTINUE - Let the plugin continue // public plugin_init() { // Register this plugin register_plugin(PLUGIN_NAME, VERSION, AUTH) // Register the client command to stop bleeding register_clcmd("amx_bandage", "bandage_command") register_clcmd("say Help_Bandage", "bleeding_motd") register_clcmd("say", "bleeding_bind") // Register that I want damage register_statsfwd(XMF_DAMAGE) // Register the death message catch register_message(get_user_msgid("DeathMsg"), "death_message") // Register the events register_event("Object", "object", "b") register_event("ResetHUD", "reset_hud", "be") register_event("CurWeapon", "cur_weapon", "be", "1=1", "2!1", "2!2", "2!19") // Register the cvars register_cvar("amx_bleeding", "1") register_cvar("amx_bleed_damage", "8") register_cvar("amx_knife_or_drop", "2") gmsgObject = get_user_msgid("Object") gDamage = get_cvar_num("amx_bleed_damage") gwpnbandage = get_cvar_num("amx_knife_or_drop") } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Plugin Precache - plugin_precache // // This function is called by amxmodx upon start of a new map and is the first step in initializing a // plugin // // @step 1 // @access public // @return int PLUGIN_CONTINUE - Let the plugin continue // public plugin_precache() { precache_model(fileNames[blood]) precache_model(fileNames[bandage]) precache_sound(fileNames[ouch]) //american saying precache_sound(fileNames[bouch]) //british saying precache_sound(fileNames[gouch]) //german cry for medic return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Plugin Pause - plugin_pause // // This function is called by amxmodx upon pausing of the plugin // // @access public // @return int PLUGIN_CONTINUE - Let the plugin continue // public plugin_pause() { set_cvar_num("amx_bleeding", 0) for(new id = 1; id < 33; id++) { remove_task(500+id) remove_task(550+id) } return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Plugin Un-Pause - plugin_unpause // // This function is called by amxmodx upon un-pausing of the plugin // // @access public // @return int PLUGIN_CONTINUE - Let the plugin continue // public plugin_unpause() { set_cvar_num("amx_bleeding", 1) return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Client Put In Server - client_putinserver // // This function is called when a new client has been put into the server, ie they see the MOTD // // @access public // @param int id - The id of the new individual in the server // @return int PLUGIN_CONTINUE - Let the plugin continue // public client_putinserver(id) { if(!get_cvar_num("amx_bleeding")) return PLUGIN_CONTINUE // Set their initial variables to default gBleeding[id] = 0 gBandaging[id] = 0 gKiller[id] = -1 gBoundHisKey[id] = 0 gDeathByBleeding[id] = 0 new param[1] param[0] = id set_task(15.0, "tell_about", 0, param, 1) return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Client Damage - client_damage // // This function is forward from the dodx // // @access public // @param int attacker - The id of the attacker // @param int victim - The id of the attacked // @param int damage - How much damage the attacker did // @param int wpnindex - What weapon the attacker used // @param int hitplace - Where the attacker hit // @param int TA - Was the attacker a teamate // @return int PLUGIN_CONTINUE - Let the plugin continue // public client_damage(attacker, victim, damage, wpnindex, hitplace, TA) { // Check to see that the plugin is enabled and the user is alive, if not keep going if(!get_cvar_num("amx_bleeding") || !is_user_alive(victim)) return PLUGIN_CONTINUE // Check to see that the weapon used was a DoD Weapon and not done by the world if(wpnindex < 1 || wpnindex > DODMAX_WEAPONS) return PLUGIN_CONTINUE // Check to see if they are already bleeding, just reset the attacker if(gBleeding[victim] == 1) { gKiller[victim] = attacker return PLUGIN_CONTINUE } // Show the blood icon message_begin(MSG_ONE, gmsgObject, {0,0,0}, victim) write_string(fileNames[blood]) message_end() // Grunt emit_sound(victim, CHAN_VOICE, fileNames[ouch], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) // Turn on the bleeding and set the other variables gBleeding[victim] = 1 gBandaging[victim] = 0 gKiller[victim] = attacker // Set the task for drawing blood, latter depending on the hit area we will detemine how much blood new param[1] param[0] = victim //param[1] = bloodloss = what area hit and what weapon hit with set_task(1.0, "bloodDamage", 500+victim, param, 1, "b") return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Object - object // // This function is will get the object for a client // // @access public // @param int id - The id of the client // @return int PLUGIN_CONTINUE - Let the plugin continue // public object(id) { read_data(1, gObjectSprite[id], 63) return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Suicide Death Message Catch - suicide_death // // This function is will catch the suicide message that we wish to block so we can call our own // // @access public // @param int id - The id of the message sender // [1] - Killer ID // [2] - Victim ID // [3] - Weapon ID // @unseenparam int[3] - The killer, victim, weapon index // @return int PLUGIN_CONTINUE - Let the plugin continue // public death_message(id) { if(!get_cvar_num("amx_bleeding")) return PLUGIN_CONTINUE new killer = get_msg_arg_int(1) // Should be the same as victim for a bleeding death new victim = get_msg_arg_int(2) // Should be the same as killer for a bleeding death new weapon = get_msg_arg_int(3) // Should be 0 for a world death // Delete the bleeding task and the bandagind tasks remove_task(500+victim) remove_task(550+victim) // Make sure this is a bleeding death if((gBleeding[victim] == 1 || gBandaging[victim] == 1) // Did they die while bleeding or bandaging && gKiller[victim] != -1 // Their Killer is set && killer == victim // It is a world death && weapon == 0) // Weapon that killed them was world { dod_make_deathmsg(gKiller[victim], victim, 0) if(get_user_team(gKiller[victim]) != get_user_team(victim)) dod_set_user_kills(gKiller[victim], dod_get_user_kills(gKiller[victim]) + 1) // Now we reset all the variables back to inititial values gBleeding[victim] = 0 gBandaging[victim] = 0 gKiller[victim] = -1 gDeathByBleeding[victim] = 1 return PLUGIN_HANDLED } // Now we reset all the variables back to inititial values gBleeding[victim] = 0 gBandaging[victim] = 0 gKiller[victim] = -1 return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Reset Hud - reset_hud // // This is called upon the spawning of the individual // // @param int id - The id of the persons HUD that is being reset to default // @return int PLUGIN_CONTINUE - Let the plugin continue // public reset_hud(id) { if(!get_cvar_num("amx_bleeding")) return PLUGIN_CONTINUE if(gDeathByBleeding[id] == 1 && gBoundHisKey[id] == 0) { gDeathByBleeding[id] = 0 new param[1] param[0] = id set_task(1.0, "tell_about", 0, param, 1) } gBleeding[id] = 0 gBandaging[id] = 0 gKiller[id] = -1 remove_task(500+id) remove_task(550+id) return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Current Weapon Catch - cur_weapon // // This is called upon the spawning of the individual // // @param int id - The id of the persons HUD that is being reset to default // @return int PLUGIN_CONTINUE - Let the plugin continue // public cur_weapon(id) { if(gBandaging[id]) switch_wpn(id) return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Repeating function for damaging player - bloodDamage // // here i will attempt to detect the team and apply the correct sound file ...Streamer // // This is called via a task loop against a player // // @param array - [0] = The players id // @return int PLUGIN_CONTINUE - Let the plugin continue // public bloodDamage(param[]) { if(is_user_alive(param[0])) { emit_sound(param[0], CHAN_VOICE, fileNames[ouch], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) set_user_health(param[0], (get_user_health(param[0]) - gDamage)) } else remove_task(500+param[0]) return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Does the bandagin on the player - bandage_command // // This is called via a task loop against a player // // @param int id - The players id // @return int PLUGIN_CONTINUE - Let the plugin continue // public bandage_command(id) { gBoundHisKey[id] = 1 if ( !gBleeding[id] || gBandaging[id] ) return PLUGIN_HANDLED gBandaging[id] = 1 switch_wpn(id) message_begin(MSG_ONE, gmsgObject, {0,0,0}, id) write_string(fileNames[bandage]) message_end() remove_task(500+id) new param[1] param[0] = id set_task(3.0, "stopBleeding", 550+id, param, 1) return PLUGIN_HANDLED } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Ends the patching process - stopBleeding // // This is called by bandage_command via a task 3 seconds after bandage key is hit // // @param array - [0] = The players id // @return int PLUGIN_CONTINUE - Let the plugin continue // public stopBleeding(param[]) { new id = param[0] message_begin(MSG_ONE, gmsgObject, {0,0,0}, id) write_string(gObjectSprite[id]) message_end() gBleeding[id] = 0 gBandaging[id] = 0 gKiller[id] = -1 engclient_cmd(id, "lastinv") return PLUGIN_HANDLED } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Tells players about the plugin - tell_about // // This is called by bandage_command via a task 3 seconds after bandage key is hit // // @param array - [0] = The players id // @return int PLUGIN_CONTINUE - Let the plugin continue // public tell_about(param[]) { new Red = random(256) new Green = random(256) new Blue = random(256) set_hudmessage(Red, Green, Blue) show_hudmessage(param[0], "This server implements DoD Beta 1.3 Bleeding^n^nType ^"Bandage b ^" in global say to bind your bandage to the key B^n or Replace b with any letter you want.") } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Binds a key for player - bleeding_bind // // This will allow a user to bind a given key to patching // // @param int id - The players id // @return int PLUGIN_CONTINUE - Let the plugin continue // public bleeding_bind(id) { if(!get_cvar_num("amx_bleeding")) return PLUGIN_CONTINUE new args[64], cmd[32], key[10] read_args(args, 31) if(contain(args, "Bandage") != -1) //I changed the original line to take out case in sensitivity { remove_quotes(args) // strtolower(args) //I commented this out so i could use a capitol B strtok(args, cmd, 31, key, 9, ' ', 1) if(strlen(key) < 1) format(key, 1, "b") client_print(id, print_chat, "amx_bandage has been bound to key %s", key) client_cmd(id, "bind %s amx_bandage", key) } return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Shows players a motd with info about plugin - bleeding_motd // // This will allow a user to read about the plugin // // @param int id - The players id // @return int PLUGIN_CONTINUE - Let the plugin continue // public bleeding_motd(id) { if(!get_cvar_num("amx_bleeding")) return PLUGIN_CONTINUE new message[1300] new pos = copy(message, 1299,"
")

	pos += format(message[pos], 1299-pos, "To stop bleeding you must bind any key to ^"amx_bandage^".^nIn the global say type Bandage key^n^nExample: Bandage b^n^nThe word Bandage must start with a capitol B ^n^nDo Not Do This in your consol just type it in the global chat^n^nBandaging is important so you will drop your weapon as soon as you hit the bandage key.^n^n YOU WILL DIE IF YOU DO NOT BANDAGE. ^n^n www.dodplugins.net for more help")

	format(message[pos],1299-pos,"
") show_motd(id, message, "Bleeding Help") return PLUGIN_CONTINUE } //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Handles the weapon when bandaging - switch_wpn // // This will switch a users weapon to knife while bandaging if the cvar amx_knife_or_drop is 1 // If the cvar is set to any other number the weapon will be dropped in front of the player while they bandage. // // Next i will research how to make the mg and bazooka and sniper class undeploy drop weapon or switch to knife then bandage // // @param int id - The players id // switch_wpn(id) { if (gwpnbandage==1){ engclient_cmd(id, "weapon_spade") engclient_cmd(id, "weapon_amerknife") engclient_cmd(id, "weapon_gerknife") } else { client_cmd(id,"drop") } }