📄 gameitems.java
字号:
public String getID() { return "use_envirosuit";} public void use(edict_t ent, gitem_t item) { ent.client.pers.inventory[ITEM_INDEX(item)]--; GameUtil.ValidateSelectedItem(ent); if (ent.client.enviro_framenum > GameBase.level.framenum) ent.client.enviro_framenum += 300; else ent.client.enviro_framenum = GameBase.level.framenum + 300; GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi .soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0); } }; static ItemUseAdapter Use_Silencer = new ItemUseAdapter() { public String getID() { return "use_silencer";} public void use(edict_t ent, gitem_t item) { ent.client.pers.inventory[ITEM_INDEX(item)]--; GameUtil.ValidateSelectedItem(ent); ent.client.silencer_shots += 30; GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi .soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0); } }; static EntInteractAdapter Pickup_Key = new EntInteractAdapter() { public String getID() { return "pickup_key";} public boolean interact(edict_t ent, edict_t other) { if (GameBase.coop.value != 0) { if (Lib.strcmp(ent.classname, "key_power_cube") == 0) { if ((other.client.pers.power_cubes & ((ent.spawnflags & 0x0000ff00) >> 8)) != 0) return false; other.client.pers.inventory[ITEM_INDEX(ent.item)]++; other.client.pers.power_cubes |= ((ent.spawnflags & 0x0000ff00) >> 8); } else { if (other.client.pers.inventory[ITEM_INDEX(ent.item)] != 0) return false; other.client.pers.inventory[ITEM_INDEX(ent.item)] = 1; } return true; } other.client.pers.inventory[ITEM_INDEX(ent.item)]++; return true; } }; public static EntInteractAdapter Pickup_Ammo = new EntInteractAdapter() { public String getID() { return "pickup_ammo";} public boolean interact(edict_t ent, edict_t other) { int oldcount; int count; boolean weapon; weapon = (ent.item.flags & Defines.IT_WEAPON) != 0; if ((weapon) && ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0) count = 1000; else if (ent.count != 0) count = ent.count; else count = ent.item.quantity; oldcount = other.client.pers.inventory[ITEM_INDEX(ent.item)]; if (!Add_Ammo(other, ent.item, count)) return false; if (weapon && 0 == oldcount) { if (other.client.pers.weapon != ent.item && (0 == GameBase.deathmatch.value || other.client.pers.weapon == FindItem("blaster"))) other.client.newweapon = ent.item; } if (0 == (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)) && (GameBase.deathmatch.value != 0)) SetRespawn(ent, 30); return true; } }; public static EntInteractAdapter Pickup_Armor = new EntInteractAdapter() { public String getID() { return "pickup_armor";} public boolean interact(edict_t ent, edict_t other) { int old_armor_index; gitem_armor_t oldinfo; gitem_armor_t newinfo; int newcount; float salvage; int salvagecount; // get info on new armor newinfo = (gitem_armor_t) ent.item.info; old_armor_index = ArmorIndex(other); // handle armor shards specially if (ent.item.tag == Defines.ARMOR_SHARD) { if (0 == old_armor_index) other.client.pers.inventory[jacket_armor_index] = 2; else other.client.pers.inventory[old_armor_index] += 2; } // if player has no armor, just use it else if (0 == old_armor_index) { other.client.pers.inventory[ITEM_INDEX(ent.item)] = newinfo.base_count; } // use the better armor else { // get info on old armor if (old_armor_index == jacket_armor_index) oldinfo = jacketarmor_info; else if (old_armor_index == combat_armor_index) oldinfo = combatarmor_info; else // (old_armor_index == body_armor_index) oldinfo = bodyarmor_info; if (newinfo.normal_protection > oldinfo.normal_protection) { // calc new armor values salvage = oldinfo.normal_protection / newinfo.normal_protection; salvagecount = (int) salvage * other.client.pers.inventory[old_armor_index]; newcount = newinfo.base_count + salvagecount; if (newcount > newinfo.max_count) newcount = newinfo.max_count; // zero count of old armor so it goes away other.client.pers.inventory[old_armor_index] = 0; // change armor to new item with computed value other.client.pers.inventory[ITEM_INDEX(ent.item)] = newcount; } else { // calc new armor values salvage = newinfo.normal_protection / oldinfo.normal_protection; salvagecount = (int) salvage * newinfo.base_count; newcount = other.client.pers.inventory[old_armor_index] + salvagecount; if (newcount > oldinfo.max_count) newcount = oldinfo.max_count; // if we're already maxed out then we don't need the new // armor if (other.client.pers.inventory[old_armor_index] >= newcount) return false; // update current armor value other.client.pers.inventory[old_armor_index] = newcount; } } if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) SetRespawn(ent, 20); return true; } }; public static EntInteractAdapter Pickup_PowerArmor = new EntInteractAdapter() { public String getID() { return "pickup_powerarmor";} public boolean interact(edict_t ent, edict_t other) { int quantity; quantity = other.client.pers.inventory[ITEM_INDEX(ent.item)]; other.client.pers.inventory[ITEM_INDEX(ent.item)]++; if (GameBase.deathmatch.value != 0) { if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)) SetRespawn(ent, ent.item.quantity); // auto-use for DM only if we didn't already have one if (0 == quantity) ent.item.use.use(other, ent.item); } return true; } }; public static EntInteractAdapter Pickup_Powerup = new EntInteractAdapter() { public String getID() { return "pickup_powerup";} public boolean interact(edict_t ent, edict_t other) { int quantity; quantity = other.client.pers.inventory[ITEM_INDEX(ent.item)]; if ((GameBase.skill.value == 1 && quantity >= 2) || (GameBase.skill.value >= 2 && quantity >= 1)) return false; if ((GameBase.coop.value != 0) && (ent.item.flags & Defines.IT_STAY_COOP) != 0 && (quantity > 0)) return false; other.client.pers.inventory[ITEM_INDEX(ent.item)]++; if (GameBase.deathmatch.value != 0) { if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)) SetRespawn(ent, ent.item.quantity); if (((int) GameBase.dmflags.value & Defines.DF_INSTANT_ITEMS) != 0 || ((ent.item.use == Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))) { if ((ent.item.use == Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM)) quad_drop_timeout_hack = (int) ((ent.nextthink - GameBase.level.time) / Defines.FRAMETIME); ent.item.use.use(other, ent.item); } } return true; } }; public static EntInteractAdapter Pickup_Adrenaline = new EntInteractAdapter() { public String getID() { return "pickup_adrenaline";} public boolean interact(edict_t ent, edict_t other) { if (GameBase.deathmatch.value == 0) other.max_health += 1; if (other.health < other.max_health) other.health = other.max_health; if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) SetRespawn(ent, ent.item.quantity); return true; } }; public static EntInteractAdapter Pickup_AncientHead = new EntInteractAdapter() { public String getID() { return "pickup_ancienthead";} public boolean interact(edict_t ent, edict_t other) { other.max_health += 2; if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) SetRespawn(ent, ent.item.quantity); return true; } }; public static EntInteractAdapter Pickup_Bandolier = new EntInteractAdapter() { public String getID() { return "pickup_bandolier";} public boolean interact(edict_t ent, edict_t other) { gitem_t item; int index; if (other.client.pers.max_bullets < 250) other.client.pers.max_bullets = 250; if (other.client.pers.max_shells < 150) other.client.pers.max_shells = 150; if (other.client.pers.max_cells < 250) other.client.pers.max_cells = 250; if (other.client.pers.max_slugs < 75) other.client.pers.max_slugs = 75; item = FindItem("Bullets"); if (item != null) { index = ITEM_INDEX(item); other.client.pers.inventory[index] += item.quantity; if (other.client.pers.inventory[index] > other.client.pers.max_bullets) other.client.pers.inventory[index] = other.client.pers.max_bullets; } item = FindItem("Shells"); if (item != null) { index = ITEM_INDEX(item); other.client.pers.inventory[index] += item.quantity; if (other.client.pers.inventory[index] > other.client.pers.max_shells) other.client.pers.inventory[index] = other.client.pers.max_shells; } if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) SetRespawn(ent, ent.item.quantity); return true; } }; public static ItemDropAdapter Drop_Ammo = new ItemDropAdapter() { public String getID() { return "drop_ammo";} public void drop(edict_t ent, gitem_t item) { edict_t dropped; int index; index = ITEM_INDEX(item); dropped = Drop_Item(ent, item); if (ent.client.pers.inventory[index] >= item.quantity) dropped.count = item.quantity; else dropped.count = ent.client.pers.inventory[index]; if (ent.client.pers.weapon != null && ent.client.pers.weapon.tag == Defines.AMMO_GRENADES && item.tag == Defines.AMMO_GRENADES && ent.client.pers.inventory[index] - dropped.count <= 0) { GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Can't drop current weapon\n"); GameUtil.G_FreeEdict(dropped); return; } ent.client.pers.inventory[index] -= dropped.count; Cmd.ValidateSelectedItem(ent); } }; public static ItemDropAdapter Drop_General = new ItemDropAdapter() { public String getID() { return "drop_general";} public void drop(edict_t ent, gitem_t item) { Drop_Item(ent, item); ent.client.pers.inventory[ITEM_INDEX(item)]--; Cmd.ValidateSelectedItem(ent); } }; public static ItemDropAdapter Drop_PowerArmor = new ItemDropAdapter() { public String getID() { return "drop_powerarmor";} public void drop(edict_t ent, gitem_t item) { if (0 != (ent.flags & Defines.FL_POWER_ARMOR) && (ent.client.pers.inventory[ITEM_INDEX(item)] == 1)) Use_PowerArmor.use(ent, item); Drop_General.drop(ent, item); } }; public static EntThinkAdapter droptofloor = new EntThinkAdapter() { public String getID() { return "drop_to_floor";} public boolean think(edict_t ent) { trace_t tr; float[] dest = { 0, 0, 0 }; //float v[]; //v = Lib.tv(-15, -15, -15); //Math3D.VectorCopy(v, ent.mins); ent.mins[0] = ent.mins[1] = ent.mins[2] = -15;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -