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);
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)) && (t - ITEM_RESPAWN_TICKS) > 0)
{
setthink(e, Item_RespawnCountdown);
e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
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();
+ }
}
}
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)));
}
float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
}
});
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;
this.item_model_ent = itemmodel;
this.item_pickupsound_ent = pickupsound;
+ if(def.m_iteminit)
+ def.m_iteminit(this);
+
if(!this.respawntime) // both need to be set
{
this.respawntime = defaultrespawntime;
{
int grY = it.item_group;
// move all items of item_group Y to item_group X
- FOREACH_ENTITY(IS_SMALL(it.itemdef),
+ IL_EACH(g_items, IS_SMALL(it.itemdef),
{
if(it.item_group == grY)
it.item_group = this.item_group;
for (int k = 1; k <= group_count; k++)
{
int count = 0;
- FOREACH_ENTITY(IS_SMALL(it.itemdef) && it.item_group == k, { count++; });
+ IL_EACH(g_items, IS_SMALL(it.itemdef) && it.item_group == k, { count++; });
if (count)
- FOREACH_ENTITY(IS_SMALL(it.itemdef) && it.item_group == k, { it.item_group_count = count; });
+ IL_EACH(g_items, IS_SMALL(it.itemdef) && it.item_group == k, { it.item_group_count = count; });
}
}
spawnfunc(item_rockets)
{
- if(!this.ammo_rockets)
- this.ammo_rockets = g_pickup_rockets;
StartItem(this, ITEM_Rockets);
}
return;
}
- if(!this.ammo_nails)
- this.ammo_nails = g_pickup_nails;
StartItem(this, ITEM_Bullets);
}
spawnfunc(item_cells)
{
- if(!this.ammo_cells)
- this.ammo_cells = g_pickup_cells;
StartItem(this, ITEM_Cells);
}
spawnfunc(item_plasma)
{
- if(!this.ammo_plasma)
- this.ammo_plasma = g_pickup_plasma;
StartItem(this, ITEM_Plasma);
}
return;
}
- if(!this.ammo_shells)
- this.ammo_shells = g_pickup_shells;
StartItem(this, ITEM_Shells);
}
spawnfunc(item_armor_small)
{
- if(!this.armorvalue)
- this.armorvalue = g_pickup_armorsmall;
- if(!this.max_armorvalue)
- this.max_armorvalue = g_pickup_armorsmall_max;
StartItem(this, ITEM_ArmorSmall);
}
spawnfunc(item_armor_medium)
{
- if(!this.armorvalue)
- this.armorvalue = g_pickup_armormedium;
- if(!this.max_armorvalue)
- this.max_armorvalue = g_pickup_armormedium_max;
StartItem(this, ITEM_ArmorMedium);
}
spawnfunc(item_armor_big)
{
- if(!this.armorvalue)
- this.armorvalue = g_pickup_armorbig;
- if(!this.max_armorvalue)
- this.max_armorvalue = g_pickup_armorbig_max;
StartItem(this, ITEM_ArmorBig);
}
spawnfunc(item_armor_mega)
{
- if(!this.armorvalue)
- this.armorvalue = g_pickup_armormega;
- if(!this.max_armorvalue)
- this.max_armorvalue = g_pickup_armormega_max;
StartItem(this, ITEM_ArmorMega);
}
spawnfunc(item_health_small)
{
- if(!this.max_health)
- this.max_health = g_pickup_healthsmall_max;
- if(!this.health)
- this.health = g_pickup_healthsmall;
StartItem(this, ITEM_HealthSmall);
}
spawnfunc(item_health_medium)
{
- if(!this.max_health)
- this.max_health = g_pickup_healthmedium_max;
- if(!this.health)
- this.health = g_pickup_healthmedium;
StartItem(this, ITEM_HealthMedium);
}
spawnfunc(item_health_big)
{
- if(!this.max_health)
- this.max_health = g_pickup_healthbig_max;
- if(!this.health)
- this.health = g_pickup_healthbig;
StartItem(this, ITEM_HealthBig);
}
spawnfunc(item_health_mega)
{
- if(!this.max_health)
- this.max_health = g_pickup_healthmega_max;
- if(!this.health)
- this.health = g_pickup_healthmega;
StartItem(this, ITEM_HealthMega);
}
spawnfunc(item_strength)
{
- if(!this.strength_finished)
- this.strength_finished = autocvar_g_balance_powerup_strength_time;
- StartItem(this, ITEM_Strength);
+ StartItem(this, ITEM_Strength);
}
spawnfunc(item_invincible)
{
- if(!this.invincible_finished)
- this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
- StartItem(this, ITEM_Shield);
+ StartItem(this, ITEM_Shield);
}
// compatibility:
spawnfunc(item_fuel)
{
- if(!this.ammo_fuel)
- this.ammo_fuel = g_pickup_fuel;
StartItem(this, ITEM_JetpackFuel);
}
spawnfunc(item_jetpack)
{
- if(!this.ammo_fuel)
- this.ammo_fuel = g_pickup_fuel_jetpack;
if(start_items & ITEM_Jetpack.m_itemid)
{
spawnfunc_item_fuel(this);
{
.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);
+ }
}
}