X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Ft_items.qc;h=6b2428bf7803b4719d304a231d3e8a3525f1a2c1;hb=d45e593ef8cfffe645ee76e566e1da938491baf2;hp=d6cae53efcb1457bba295ca2973c99ddb5009725;hpb=ab6d636137b9a111030d0463baaead10a1421477;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index d6cae53ef..6b2428bf7 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -510,7 +510,7 @@ void Item_Respawn (entity this) sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM); // play respawn sound setorigin(this, this.origin); - if (Item_ItemsTime_Allow(this.itemdef) || this.weapons & WEPSET_SUPERWEAPONS) + if (Item_ItemsTime_Allow(this.itemdef) || (this.weapons & WEPSET_SUPERWEAPONS)) { float t = Item_ItemsTime_UpdateTime(this, 0); Item_ItemsTime_SetTime(this, t); @@ -538,7 +538,6 @@ void Item_RespawnCountdown (entity this) this.count += 1; if(this.count == 1) { - MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0'); do { { entity wi = Weapons_from(this.weapon); @@ -557,10 +556,11 @@ void Item_RespawnCountdown (entity this) } } } while (0); + bool mutator_returnvalue = MUTATOR_CALLHOOK(Item_RespawnCountdown, this); if(this.waypointsprite_attached) { GameItem def = this.itemdef; - if (Item_ItemsTime_SpectatorOnly(def)) + if (Item_ItemsTime_SpectatorOnly(def) && !mutator_returnvalue) WaypointSprite_UpdateRule(this.waypointsprite_attached, 0, SPRITERULE_SPECTATOR); WaypointSprite_UpdateBuildFinished(this.waypointsprite_attached, time + ITEM_RESPAWN_TICKS); } @@ -595,15 +595,18 @@ void Item_RespawnThink(entity this) void Item_ScheduleRespawnIn(entity e, float t) { // if the respawn time is longer than 10 seconds, show a waypoint, otherwise, just respawn normally - if ((Item_ItemsTime_Allow(e.itemdef) || e.weapons & WEPSET_SUPERWEAPONS) && (t - ITEM_RESPAWN_TICKS) > 0) + if ((Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0) { setthink(e, Item_RespawnCountdown); e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS); e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS; e.count = 0; - t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime); - Item_ItemsTime_SetTime(e, t); - Item_ItemsTime_SetTimesForAllPlayers(); + if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS)) + { + t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime); + Item_ItemsTime_SetTime(e, t); + Item_ItemsTime_SetTimesForAllPlayers(); + } } else { @@ -611,6 +614,13 @@ void Item_ScheduleRespawnIn(entity e, float t) e.nextthink = time; e.scheduledrespawntime = time + t; e.wait = time + t; + + if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS)) + { + t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime); + Item_ItemsTime_SetTime(e, t); + Item_ItemsTime_SetTimesForAllPlayers(); + } } } @@ -628,7 +638,70 @@ void Item_ScheduleRespawn(entity e) void Item_ScheduleInitialRespawn(entity e) { Item_Show(e, 0); - Item_ScheduleRespawnIn(e, game_starttime - time + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e))); + Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e))); +} + +void GivePlayerHealth(entity player, float amount) +{ + if (amount == 0) + { + return; + } + player.health = bound(player.health, player.health + amount, + g_pickup_healthmega_max); + player.pauserothealth_finished = max(player.pauserothealth_finished, time + + autocvar_g_balance_pause_health_rot); +} + +void GivePlayerArmor(entity player, float amount) +{ + if (amount == 0) + { + return; + } + player.armorvalue = bound(player.armorvalue, player.armorvalue + amount, + g_pickup_armormega_max); + player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + + autocvar_g_balance_pause_armor_rot); +} + +void GivePlayerAmmo(entity player, .float ammotype, float amount) +{ + float maxvalue = 999; + switch (ammotype) + { + case ammo_shells: + { + maxvalue = g_pickup_shells_max; + break; + } + case ammo_cells: + { + maxvalue = g_pickup_cells_max; + break; + } + case ammo_rockets: + { + maxvalue = g_pickup_rockets_max; + break; + } + case ammo_plasma: + { + maxvalue = g_pickup_plasma_max; + break; + } + case ammo_nails: + { + maxvalue = g_pickup_nails_max; + break; + } + case ammo_fuel: + { + maxvalue = g_pickup_fuel_max; + break; + } + } + player.(ammotype) = min(player.(ammotype) + amount, maxvalue); } float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode) @@ -874,7 +947,7 @@ LABEL(pickup) } }); e = RandomSelection_chosen_ent; - + Item_Show(e, 1); // reset its state so it is visible (extra sendflags doesn't matter, this happens anyway) } else e = this; @@ -1047,16 +1120,17 @@ float healtharmor_pickupevalfunc(entity player, entity item) float itemarmor = item.armorvalue; float itemhealth = item.health; + if(item.item_group) { itemarmor *= min(4, item.item_group_count); itemhealth *= min(4, item.item_group_count); } - if (itemarmor) - if (player.armorvalue < item.max_armorvalue) + + if (itemarmor && (player.armorvalue < item.max_armorvalue)) c = itemarmor / max(1, player.armorvalue * 2/3 + player.health * 1/3); - if (itemhealth) - if (player.health < item.max_health) + + if (itemhealth && (player.health < item.max_health)) c = itemhealth / max(1, player.health); rating *= min(2, c); @@ -1353,9 +1427,8 @@ spawnfunc(item_rockets) spawnfunc(item_bullets) { - if(!weaponswapping) - if(autocvar_sv_q3acompat_machineshotgunswap) - if(this.classname != "droppedweapon") + if(!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap && + (this.classname != "droppedweapon")) { weaponswapping = true; spawnfunc_item_shells(this); @@ -1378,9 +1451,8 @@ spawnfunc(item_plasma) spawnfunc(item_shells) { - if(!weaponswapping) - if(autocvar_sv_q3acompat_machineshotgunswap) - if(this.classname != "droppedweapon") + if(!weaponswapping && autocvar_sv_q3acompat_machineshotgunswap && + (this.classname != "droppedweapon")) { weaponswapping = true; spawnfunc_item_bullets(this); @@ -1462,10 +1534,9 @@ void target_items_use(entity this, entity actor, entity trigger) return; } - if (!IS_PLAYER(actor)) - return; - if(IS_DEAD(actor)) + if (!IS_PLAYER(actor) || IS_DEAD(actor)) return; + if(trigger.solid == SOLID_TRIGGER) { EXACTTRIGGER_TOUCH(this, trigger); @@ -1482,7 +1553,7 @@ void target_items_use(entity this, entity actor, entity trigger) spawnfunc(target_items) { - int n, j; + int n; string s; this.use = target_items_use; @@ -1500,7 +1571,7 @@ spawnfunc(target_items) } else { - for(j = 0; j < n; ++j) + for(int j = 0; j < n; ++j) { if (argv(j) == "unlimited_ammo") this.items |= IT_UNLIMITED_AMMO; else if(argv(j) == "unlimited_weapon_ammo") this.items |= IT_UNLIMITED_WEAPON_AMMO; @@ -1584,7 +1655,7 @@ spawnfunc(target_items) //print(this.netname, "\n"); n = tokenize_console(this.netname); - for(j = 0; j < n; ++j) + for(int j = 0; j < n; ++j) { FOREACH(Weapons, it != WEP_Null && W_UndeprecateName(argv(j)) == it.netname, { it.wr_init(it); @@ -1909,7 +1980,11 @@ float GiveItems(entity e, float beginarg, float endarg) { .entity weaponentity = weaponentities[slot]; if(_switchweapon & BIT(slot)) - W_SwitchWeapon_Force(e, w_getbestweapon(e, weaponentity), weaponentity); + { + Weapon wep = w_getbestweapon(e, weaponentity); + if(wep != e.(weaponentity).m_switchweapon) + W_SwitchWeapon_Force(e, wep, weaponentity); + } } }