|
楼主 |
发表于 2011-8-18 11:26:35
|
显示全部楼层
来自 中国–江苏–盐城–建湖县
- public fw_SetModel(entity, const model[])
- {
- if (!pev_valid(entity))
- return FMRES_IGNORED;
-
- new owner
- owner = pev(entity, pev_owner)
-
- if (equal(model[7], "w_weaponbox.mdl"))
- {
- user_drop[owner] = entity;
- return FMRES_IGNORED;
- }
-
- if (user_drop[owner] == entity)
- {
- if (hasp_p90[owner] && equal(model[7], "w_m249.mdl"))
- {
- fm_kill_entity(entity)
-
- drop_p_p90(owner, 0, 1)
-
- drop_time[owner] = get_gametime()
- hasp_p90[owner] = false
- }
- }
-
- user_drop[owner] = -1
-
- return FMRES_IGNORED;
- }
- public fw_Touch(ptr, ptd)
- {
- if (!pev_valid(ptr) || !pev_valid(ptd))
- return FMRES_IGNORED;
-
- new classname[32]
- pev(ptr, pev_classname, classname, charsmax(classname))
-
- if (!equal(classname, "CS_p_p90"))
- return FMRES_IGNORED;
-
- if (has_custom_weapons(ptd, PRIMARY_WEAPONS_BIT_SUM))
- return FMRES_IGNORED;
-
- if (get_gametime() - drop_time[ptd] < 0.5)
- return FMRES_IGNORED;
-
- hasp_p90[ptd] = true
- fm_give_item(ptd, "weapon_m249")
-
- static weap_clip, user_bpammo, weap_ent
- weap_clip = pev(ptr, pev_iuser3)
- user_bpammo = min(cs_get_user_bpammo(ptd, CSW_M249) + pev(ptr, pev_iuser4), 30)
- weap_ent = fm_find_ent_by_owner(-1, "weapon_m249", ptd)
-
- cs_set_weapon_ammo(weap_ent, weap_clip)
- cs_set_user_bpammo(ptd, CSW_M249, user_bpammo)
-
- engfunc(EngFunc_RemoveEntity, ptr)
-
- client_print(ptd, print_chat, "你撿到了一把p_p90.")
-
- return FMRES_IGNORED;
- }
- public event_cur_weapon(id)
- {
- if (!hasp_p90[id])
- return;
-
- new weap_id, weap_clip, weap_bpammo
- weap_id = get_user_weapon(id, weap_clip, weap_bpammo)
-
- if (weap_id != CSW_M249)
- return;
-
- set_p_p90_model(id)
- user_clip[id] = weap_clip
- user_bpammo[id] = weap_bpammo
- user_shoot[id] = false
- }
- public set_p_p90_model(id)
- {
- set_pev(id, pev_viewmodel2, p_p90_V_Model)
- set_pev(id, pev_weaponmodel2, p_p90_P_Model)
- }
- public drop_p_p90(id, store_bpammo, drop_type)
- {
- new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
-
- if (!pev_valid(ent))return 0;
-
- set_pev(ent, pev_classname, "CS_p_p90")
- set_pev(ent, pev_iuser1, 0) // hasn't bounced yet
- set_pev(ent, pev_solid, SOLID_TRIGGER)
- set_pev(ent, pev_movetype, MOVETYPE_TOSS)
-
- new Float:mins[3] = { -16.0, -16.0, -16.0 }
- new Float:maxs[3] = { 16.0, 16.0, 16.0 }
- engfunc(EngFunc_SetSize, ent, mins, maxs)
-
- set_pev(ent, pev_iuser3, user_clip[id])
-
- if (store_bpammo)
- {
- set_pev(ent, pev_iuser4, user_bpammo[id])
- cs_set_user_bpammo(id, CSW_M249, 0)
- }
- else
- {
- set_pev(ent, pev_iuser4, 0)
- }
-
- new Float:angles[3]
- pev(id, pev_angles, angles)
- angles[0] = angles[2] = 0.0
- set_pev(ent, pev_angles, angles)
-
- engfunc(EngFunc_SetModel, ent, p_p90_W_Model)
-
- new Float:origin[3]
- pev(id, pev_origin, origin)
-
- if (drop_type)
- {
- new Float:velocity[3]
- velocity_by_aim(id, 15, velocity)
- origin[0] += velocity[0]
- origin[1] += velocity[1]
- origin[2] += velocity[2]
- set_pev(ent, pev_origin, origin)
- velocity_by_aim(id, 400, velocity)
- set_pev(ent, pev_velocity, velocity)
- }
- else
- {
- new Float:drop_angle = random_float(0.0, 360.0)
- origin[0] += 15.0 * floatcos(drop_angle, degrees)
- origin[1] += 15.0 * floatsin(drop_angle, degrees)
- set_pev(ent, pev_origin, origin)
- }
-
- return 1;
- }
- public client_connect(id)
- {
- hasp_p90[id] = false
- }
- public client_disconnect(id)
- {
- hasp_p90[id] = false
- }
- public reset_p_p90()
- {
- for (new id = 1; id <= g_maxplayers; id++)
- {
- if (is_user_connected(id) && is_user_alive(id) && hasp_p90[id] && !user_has_weapon(id, CSW_M249))
- {
- hasp_p90[id] = false
- }
- }
- }
- stock drop_primary_weapons(id)
- {
- static weapons[32], num, i, weaponid
- num = 0 // reset passed weapons count (bugfix)
- get_user_weapons(id, weapons, num)
-
- for (i = 0; i < num; i++)
- {
- weaponid = weapons[i]
-
- if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
- {
- static wname[32]
- get_weaponname(weaponid, wname, sizeof wname - 1)
- engclient_cmd(id, "drop", wname)
- }
- }
- }
- stock fm_give_item(index, const item[])
- {
- if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
- return 0
-
- new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
- if (!pev_valid(ent))
- return 0
-
- new Float:origin[3]
- pev(index, pev_origin, origin)
- set_pev(ent, pev_origin, origin)
- set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
- dllfunc(DLLFunc_Spawn, ent)
-
- new save = pev(ent, pev_solid)
- dllfunc(DLLFunc_Touch, ent, index)
- if (pev(ent, pev_solid) != save)
- return ent
-
- engfunc(EngFunc_RemoveEntity, ent)
-
- return -1
- }
- stock bool:has_custom_weapons(id, const bitsum)
- {
- static weapons[32], num, i, weaponid
- num = 0 // reset passed weapons count (bugfix)
- get_user_weapons(id, weapons, num)
-
- for (i = 0; i < num; i++)
- {
- weaponid = weapons[i]
-
- if ((1<<weaponid) & bitsum)
- return true;
- }
-
- return false;
- }
- stock fm_find_ent_by_owner(entity, const classname[], owner)
- {
- while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && (pev(entity, pev_owner) != owner)) {}
-
- return entity;
- }
- stock fm_find_ent_by_class(index, const classname[])
- {
- return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
- }
- stock fm_kill_entity(index)
- {
- set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME);
-
- return 1;
- }
- stock Float:get_weapon_next_pri_attack(entity)
- {
- return get_pdata_float(entity, OFFSET_FlNextPrimaryAttack, OFFSET_LINUX_WEAPONS)
- }
- stock set_weapon_next_pri_attack(entity, Float:time)
- {
- set_pdata_float(entity, OFFSET_FlNextPrimaryAttack, time, OFFSET_LINUX_WEAPONS)
- }
- stock fm_get_aim_vector(index, forward_distance, Float:forward_origin[3], Float:view_end_origin[3])
- {
- new Float:start[3], Float:view_ofs[3]
- pev(index, pev_origin, start);
- pev(index, pev_view_ofs, view_ofs);
- xs_vec_add(start, view_ofs, start);
-
- new Float:vector[3], Float:temp[3];
- pev(index, pev_v_angle, vector);
- engfunc(EngFunc_MakeVectors, vector);
- global_get(glb_v_forward, vector);
- xs_vec_mul_scalar(vector, float(forward_distance), temp);
- xs_vec_add(start, temp, forward_origin);
-
- new Float:dest[3]
- xs_vec_mul_scalar(vector, 9999.0, temp);
- xs_vec_add(start, temp, dest);
- engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
- get_tr2(0, TR_vecEndPos, view_end_origin);
-
- return 1;
- }
- #if defined SUPPORT_CZBOT
- // CZBot support
- public client_putinserver(id)
- {
- if (!cvar_botquota || !is_user_bot(id) || BotHasDebug)
- return;
-
- new classname[32]
- pev(id, pev_classname, classname, 31)
-
- if (!equal(classname, "player"))
- set_task(0.1, "_Debug", id)
- }
- public _Debug(id)
- {
- // Make sure it's a CZ bot and it's still connected
- if (!get_pcvar_num(cvar_botquota) || !is_user_connected(id))
- return;
-
- BotHasDebug = true
- RegisterHamFromEntity(Ham_TakeDamage, id, "fw_Player_TakeDamage")
- RegisterHamFromEntity(Ham_TraceAttack, id, "fw_Player_TraceAttack")
- }
复制代码 |
|