|
楼主 |
发表于 2009-1-16 05:29:01
|
显示全部楼层
来自 中国–广东–广州–白云区
38# wangshengzhen
不用下截的 地球冰炸弹-即O5
过测试cs1.5
- /*-------------------
- INCLUDES AND DEFINES
- --------------------*/
- #include <amxmodx>
- #include <fun>
- #include <engine>
- #include <fakemeta>
- #include <cstrike>
- new hasFrostNade[33];
- new isChilled[33];
- new isFrozen[33];
- new novaDisplay[33];
- new Float:oldSpeed[33];
- new glassGibs;
- new trailSpr;
- new smokeSpr;
- new exploSpr;
- #define FROST_RADIUS 240.0
- #define FROST_R 0
- #define FROST_G 206
- #define FROST_B 209
- #define TASK_REMOVE_CHILL 200
- #define TASK_REMOVE_FREEZE 250
- /*----------------
- LOADING FUNCTIONS
- -----------------*/
- // 3, 2, 1: blastoff!
- public plugin_init()
- {
- register_plugin("FrostNades","0.12b","Avalanche");
- register_cvar("fn_on","1");
- register_cvar("fn_hitself","0");
- register_cvar("fn_los","0");
- register_cvar("fn_maxdamage","50.0");
- register_cvar("fn_mindamage","50.0");
- register_cvar("fn_override","1");
- register_cvar("fn_price","150");
- register_cvar("fn_chill_maxchance","1000");
- register_cvar("fn_chill_minchance","1000");
- register_cvar("fn_chill_duration","4");
- register_cvar("fn_chill_speed","60");
- register_cvar("fn_freeze_maxchance","1000");
- register_cvar("fn_freeze_minchance","1000");
- register_cvar("fn_freeze_duration","5");
- register_clcmd("say /fn","buy_frostnade",-1);
- register_clcmd("say_team /fn","buy_frostnade",-1);
- register_clcmd("say /frostnade","buy_frostnade",-1);
- register_clcmd("say_team /frostnade","buy_frostnade",-1);
- register_event("DeathMsg","event_deathmsg","a");
- register_event("CurWeapon","event_curweapon","b","1=1");
- register_forward(FM_SetModel,"fw_setmodel");
- register_think("grenade","think_grenade");
- register_logevent("event_roundend",2,"0=World triggered","1=Round_End");
- }
- // get in the cache and be quiet!!
- public plugin_precache() {
- precache_model("models/sat_globe.mdl");
- glassGibs = precache_model("models/glassgibs.mdl");
- precache_sound("ambience/wolfhowl01.wav"); // grenade explodes
- precache_sound("warcraft3/impalehit.wav"); // player is frozen
- precache_sound("warcraft3/impalelaunch1.wav"); // frozen wears off
- precache_sound("player/pl_duct2.wav"); // player is chilled
- trailSpr = precache_model("sprites/laserbeam.spr");
- smokeSpr = precache_model("sprites/steam1.spr");
- exploSpr = precache_model("sprites/shockwave.spr");
- }
- /*------------
- HOOK HANDLERS
- -------------*/
- // player wants to buy a grenade
- public buy_frostnade(id)
- {
- if(!get_cvar_num("fn_on"))
- return PLUGIN_CONTINUE;
- // can't buy while dead
- if(!is_user_alive(id))
- return PLUGIN_HANDLED;
- // no custom buy needed
- if(get_cvar_num("fn_override"))
- return PLUGIN_HANDLED;
- // not in a buyzone
- if(!cs_get_user_buyzone(id))
- return PLUGIN_HANDLED;
- // not enough money
- new money = cs_get_user_money(id);
- if(money < get_cvar_num("fn_price"))
- {
- client_print(id,print_center,"#Not_Enough_Money");
- return PLUGIN_HANDLED;
- }
- // already have a frost grenade
- if(hasFrostNade[id])
- {
- client_print(id,print_center,"#Cstrike_Already_Own_Weapon");
- return PLUGIN_HANDLED;
- }
- // already have a smoke grenade
- new weapons[32], num, i;
- get_user_weapons(id,weapons,num);
- for(i=0;i<num;i++)
- {
- if(weapons[i] == CSW_SMOKEGRENADE)
- {
- client_print(id,print_center,"You already own a smoke grenade.");
- return PLUGIN_HANDLED;
- }
- }
- // gimme gimme
- hasFrostNade[id] = 1;
- give_item(id,"weapon_smokegrenade");
- cs_set_user_money(id,money - get_cvar_num("fn_price"));
- // display icon
- message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
- write_byte(1); // status (0=hide, 1=show, 2=flash)
- write_string("dmg_cold"); // sprite name
- write_byte(FROST_R); // red
- write_byte(FROST_G); // green
- write_byte(FROST_B); // blue
- message_end();
- return PLUGIN_HANDLED;
- }
- // prethinking
- public client_PreThink(id)
- {
- if(!get_cvar_num("fn_on"))
- return;
- // if they are frozen, make sure they don't move at all
- if(isFrozen[id])
- {
- // stop motion
- entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0});
- new button = get_user_button(id), oldbuttons = entity_get_int(id,EV_INT_oldbuttons);
- new flags = entity_get_int(id,EV_INT_flags);
- // if are on the ground and about to jump, set the gravity too high to really do so
- if((button & IN_JUMP) && !(oldbuttons & IN_JUMP) && (flags & FL_ONGROUND))
- entity_set_float(id,EV_FL_gravity,999999.9); // I CAN'T STAND THE PRESSURE
- // otherwise, set the gravity so low that they don't fall
- else
- entity_set_float(id,EV_FL_gravity,0.000001); // 0.0 doesn't work
- }
- }
- // someone dies
- public event_deathmsg()
- {
- if(!get_cvar_num("fn_on"))
- return;
- new id = read_data(2);
- if(hasFrostNade[id])
- {
- hasFrostNade[id] = 0;
- message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
- write_byte(0); // status (0=hide, 1=show, 2=flash)
- write_string("dmg_cold"); // sprite name
- write_byte(FROST_R); // red
- write_byte(FROST_G); // green
- write_byte(FROST_B); // blue
- message_end();
- }
- if(isChilled[id])
- remove_chill(TASK_REMOVE_CHILL+id);
- if(isFrozen[id])
- remove_freeze(TASK_REMOVE_FREEZE+id);
- }
- // a player changes weapons
- public event_curweapon(id)
- {
- if(!get_cvar_num("fn_on"))
- return;
- // flash icon if frost grenade is out
- if(hasFrostNade[id] && read_data(2) == CSW_SMOKEGRENADE)
- {
- message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
- write_byte(2); // status (0=hide, 1=show, 2=flash)
- write_string("dmg_cold"); // sprite name
- write_byte(FROST_R); // red
- write_byte(FROST_G); // green
- write_byte(FROST_B); // blue
- message_end();
- }
- else if(hasFrostNade[id])
- {
- message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},id);
- write_byte(1); // status (0=hide, 1=show, 2=flash)
- write_string("dmg_cold"); // sprite name
- write_byte(FROST_R); // red
- write_byte(FROST_G); // green
- write_byte(FROST_B); // blue
- message_end();
- }
- if(isChilled[id])
- chill_player(id);
- if(isFrozen[id])
- freeze_player(id);
- }
- // when a model is set
- public fw_setmodel(ent,model[])
- {
- if(get_cvar_num("fn_on") < 1 || !is_valid_ent(ent))
- return FMRES_IGNORED;
- // not a smoke grenade
- if(!equali(model,"models/w_smokegrenade.mdl"))
- return FMRES_IGNORED;
- // not yet thrown
- if(entity_get_float(ent,EV_FL_gravity) == 0.0)
- return FMRES_IGNORED;
- new owner = entity_get_edict(ent,EV_ENT_owner);
- // check to see if this isn't a frost grenade
- if(!get_cvar_num("fn_override") && !hasFrostNade[owner])
- return FMRES_IGNORED;
- // store team in the grenade
- entity_set_int(ent,EV_INT_team,get_user_team(owner));
- // hide icon
- if(hasFrostNade[owner])
- {
- hasFrostNade[owner] = 0;
- message_begin(MSG_ONE,get_user_msgid("StatusIcon"),{0,0,0},owner);
- write_byte(0); // status (0=hide, 1=show, 2=flash)
- write_string("dmg_cold"); // sprite name
- write_byte(FROST_R); // red
- write_byte(FROST_G); // green
- write_byte(FROST_B); // blue
- message_end();
- }
- // give it a blue glow and a blue trail
- set_rendering(ent,kRenderFxGlowShell,FROST_R,FROST_G,FROST_B);
- set_beamfollow(ent,10,10,FROST_R,FROST_G,FROST_B,100);
- // hack? flag to remember to track this grenade's think
- entity_set_int(ent,EV_INT_bInDuck,1);
- // track for when it will explode
- set_task(1.6,"grenade_explode",ent);
- return FMRES_IGNORED;
- }
- // think, grenade. think, damnit!
- public think_grenade(ent)
- {
- if(get_cvar_num("fn_on") < 1 || !is_valid_ent(ent))
- return PLUGIN_CONTINUE;
- // hack? not a smoke grenade, or at least not a popular one
- if(!entity_get_int(ent,EV_INT_bInDuck))
- return PLUGIN_CONTINUE;
- // stop it from exploding
- return PLUGIN_HANDLED;
- }
- // the round ends
- public event_roundend()
- {
- new i;
- for(i=1;i<=32;i++)
- {
- if(isChilled[i])
- remove_chill(TASK_REMOVE_CHILL+i);
- if(isFrozen[i])
- remove_freeze(TASK_REMOVE_FREEZE+i);
- }
- }
- /*-------------------
- OTHER MAIN FUNCTIONS
- --------------------*/
- // and boom goes the dynamite
- public grenade_explode(ent)
- {
- if(get_cvar_num("fn_on") < 1 || !is_valid_ent(ent))
- return;
- // make the smoke
- new origin[3], Float:originF[3];
- entity_get_vector(ent,EV_VEC_origin,originF);
- FVecIVec(originF,origin);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(5); // TE_SMOKE
- write_coord(origin[0]); // x
- write_coord(origin[1]); // y
- write_coord(origin[2]); // z
- write_short(smokeSpr); // sprite
- write_byte(random_num(35,45)); // scale
- write_byte(5); // framerate
- message_end();
- // debug
- //show_xyz(origin,floatround(FROST_RADIUS));
- // explosion
- create_blast(origin);
- emit_sound(ent,CHAN_WEAPON,"ambience/wolfhowl01.wav",1.0,ATTN_NORM,0,PITCH_NORM);
- // get grenade's owner
- new owner = entity_get_edict(ent,EV_ENT_owner);
- // get grenades team
- new nadeTeam = entity_get_int(ent,EV_INT_team);
- // collisions
- new player;
- while((player = find_ent_in_sphere(player,originF,FROST_RADIUS)) != 0)
- {
- // not a player, or a dead one
- if(!is_user_alive(player))
- continue;
复制代码 |
|