X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Ft_items.qc;h=4f24cec237cc351c93408fa4bb0dd52916a62fd9;hb=d707dc2acd582bb64eb63a9bc64adc5e3c050e67;hp=18c74be311d08a2ca7561c5345dcda9c0ba9ea0a;hpb=cc148bf19700d380a18d7f51a706f9bbe959811b;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index 18c74be3..4f24cec2 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -67,7 +67,7 @@ void Item_Show (entity e, float mode) e.model = e.mdl; e.solid = SOLID_TRIGGER; e.colormod = '0 0 0'; - self.glowmod = self.colormod; + e.glowmod = e.colormod; e.alpha = 0; e.customizeentityforclient = func_null; @@ -79,7 +79,7 @@ void Item_Show (entity e, float mode) e.model = string_null; e.solid = SOLID_NOT; e.colormod = '0 0 0'; - self.glowmod = self.colormod; + e.glowmod = e.colormod; e.alpha = 0; e.customizeentityforclient = func_null; @@ -91,7 +91,7 @@ void Item_Show (entity e, float mode) e.model = e.mdl; e.solid = SOLID_TRIGGER; // can STILL be picked up! e.colormod = '0 0 0'; - self.glowmod = self.colormod; + e.glowmod = e.colormod; e.effects |= EF_STARDUST; e.customizeentityforclient = Item_Customize; @@ -103,7 +103,7 @@ void Item_Show (entity e, float mode) e.model = e.mdl; e.solid = SOLID_NOT; e.colormod = stov(cvar_string("g_ghost_items_color")); - self.glowmod = self.colormod; + e.glowmod = e.colormod; e.alpha = g_ghost_items; e.customizeentityforclient = func_null; @@ -115,7 +115,7 @@ void Item_Show (entity e, float mode) e.model = string_null; e.solid = SOLID_NOT; e.colormod = stov(cvar_string("g_ghost_items_color")); - self.glowmod = self.colormod; + e.glowmod = e.colormod; e.alpha = 0; e.customizeentityforclient = func_null; @@ -144,7 +144,6 @@ void Item_Respawn (void) sound (self, CHAN_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTN_NORM); // play respawn sound setorigin (self, self.origin); - //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1); pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1); } @@ -175,7 +174,7 @@ void Item_RespawnCountdown (void) WaypointSprite_Spawn(name, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE); if(self.waypointsprite_attached) { - WaypointSprite_UpdateTeamRadar(self.waypointsprite_attached, RADARICON_POWERUP, rgb); + WaypointSprite_UpdateRadar(self.waypointsprite_attached, RADARICON_POWERUP, rgb); //WaypointSprite_UpdateMaxHealth(self.waypointsprite_attached, ITEM_RESPAWN_TICKS + 1); WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS); } @@ -208,7 +207,10 @@ void Item_ScheduleRespawnIn(entity e, float t) void Item_ScheduleRespawn(entity e) { Item_Show(e, 0); - Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e)); + if(e.respawntime > 0) // if respawntime is -1, this item does not respawn + Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e)); + else + remove(e); } void Item_ScheduleInitialRespawn(entity e) @@ -217,6 +219,241 @@ void Item_ScheduleInitialRespawn(entity e) Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e)); } +.float inithealth, initdmg; +.float item_digestion_step; +void Item_Consumable_Think() +{ + if(self.predator.regurgitate_prepare && time > self.predator.regurgitate_prepare) + { + self.predator.regurgitate_prepare = 0; + self.predator.complain_vore = time + complain_delay_time; // prevent complaining the next frame if this empties our stomach + Item_Consumable_Remove(self, TRUE); + return; + } + if(self.predator.stat_eaten) + { + // prey can't hold consumable items + Item_Consumable_Remove(self, TRUE); + return; + } + + self.scale = self.health / self.inithealth; // scale matches the item's digestion progress + self.dmg = self.initdmg * self.scale; + if(self.health <= 0) + { + // this item is done + Item_Consumable_Remove(self, FALSE); + return; + } + + if(self.predator.digesting) + { + if(time > self.item_digestion_step) + { + // if distributed digestion is enabled, reduce digestion strength by the amount of prey in our stomach + float damage, damage_offset; + + damage_offset = 1; + if(cvar("g_balance_vore_digestion_distribute")) // apply distributed digestion damage + damage_offset /= (1 - (self.predator.stomach_load / self.predator.stomach_maxload) * bound(0, cvar("g_balance_vore_digestion_distribute"), 1)); + damage = ceil(cvar("g_balance_vore_digestion_damage_item") / damage_offset); + + self.health -= damage; + if(self.predator.health + damage <= self.max_health) + self.predator.health += damage; + else if(self.predator.health < self.max_health) + self.predator.health = self.max_health; + self.predator.pauserothealth_finished = max(self.predator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot")); + + self.item_digestion_step = time + vore_steptime; + } + + if(stov(cvar_string("g_vore_regurgitatecolor_color_digest"))) + self.colormod = stov(cvar_string("g_vore_regurgitatecolor_color_digest")); + } + + self.nextthink = time; +} + +float Item_Consumable_Customizeentityforclient() +{ + if(cvar("g_vore_neighborprey_distance_item") && self.predator == other.predator && !(other.cvar_chase_active || other.classname == "observer")) + { + self.alpha = default_player_alpha; // allow seeing neighboring items + self.effects |= EF_NODEPTHTEST; // don't hide behind the stomach's own EF_NODEPTHTEST + } + else + self.alpha = -1; // hide item + return TRUE; +} + +void Item_DroppedConsumable_Spawn(entity e); +void Item_Consumable_Remove(entity e, float regurgitate) +{ + if(regurgitate) + { + float scalediff, sz; + sz = e.scale ? e.scale : 1; // the line below does not work if I define this directly (fteqcc bug?) + scalediff = cvar("g_healthsize") ? sz / e.predator.scale : sz; // the tighter the gut, the greater the velocity + + // predator effects, some common to those in Vore_Regurgitate + PlayerSound(e.predator, playersound_regurgitate, CHAN_VOICE, VOICETYPE_PLAYERSOUND); + setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating + pointparticles(particleeffectnum("vore_regurgitate"), e.predator.origin, '0 0 0', floor(scalediff * PARTICLE_MULTIPLIER)); + e.predator.punchangle_x = crandom() * cvar("g_balance_vore_regurgitate_predator_punchangle_item") * scalediff; + e.predator.punchangle_y = crandom() * cvar("g_balance_vore_regurgitate_predator_punchangle_item") * scalediff; + e.predator.punchangle_z = crandom() * cvar("g_balance_vore_regurgitate_predator_punchangle_item") * scalediff; + e.predator.regurgitate_prepare = 0; + e.predator.action_delay = time + cvar("g_balance_vore_action_delay"); + + Item_DroppedConsumable_Spawn(e); + } + + e.nextthink = 0; + remove(e); + e = world; +} + +void Item_Consumable_Spawn(entity e, entity pl) +{ + entity item; + + item = spawn(); + item.owner = e; + item.classname = "consumable"; + item.movetype = MOVETYPE_FOLLOW; + item.solid = SOLID_NOT; + setmodel(item, e.model); + item.health = e.health; + if(e.inithealth) + { + item.inithealth = e.inithealth; + item.initdmg = e.initdmg; + } + else + { + item.inithealth = e.health; + item.initdmg = e.dmg; + } + item.max_health = e.max_health; + + item.predator = pl; + item.aiment = pl; + item.view_ofs_x = CONSUMABLE_VIEW_OFS_x + crandom() * cvar("g_vore_neighborprey_distance_item"); + item.view_ofs_y = CONSUMABLE_VIEW_OFS_y + crandom() * cvar("g_vore_neighborprey_distance_item"); + item.view_ofs_z = CONSUMABLE_VIEW_OFS_z + crandom() * cvar("g_vore_neighborprey_distance_item"); + item.angles = randomvec() * 360; + + item.customizeentityforclient = Item_Consumable_Customizeentityforclient; + item.think = Item_Consumable_Think; + item.nextthink = time; + + if(stov(cvar_string("g_vore_regurgitatecolor_color_normal"))) + item.colormod = stov(cvar_string("g_vore_regurgitatecolor_color_normal")); + + float scalediff, sz; + sz = e.scale ? e.scale : 1; // the line below does not work if I define this directly (fteqcc bug?) + scalediff = cvar("g_healthsize") ? sz / pl.scale : sz; // the tighter the gut, the greater the velocity + + // predator effects, some common to those in Vore_Swallow + PlayerSound(pl, playersound_swallow, CHAN_VOICE, VOICETYPE_PLAYERSOUND); + setanim(pl, pl.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating + pl.punchangle_x = crandom() * cvar("g_balance_vore_swallow_predator_punchangle_item") * scalediff; + pl.punchangle_y = crandom() * cvar("g_balance_vore_swallow_predator_punchangle_item") * scalediff; + pl.punchangle_z = crandom() * cvar("g_balance_vore_swallow_predator_punchangle_item") * scalediff; + pl.regurgitate_prepare = 0; + pl.action_delay = time + cvar("g_balance_vore_action_delay"); + pl.last_pickup = time; +} + +float Item_Swallow(entity item, entity player); +void Item_DroppedConsumable_Touch() +{ + if(time < self.cnt) + return; + + // give the consumable item to the player touching it + if(Item_Swallow(self, other)) + { + remove(self); + self = world; + } +} + +void Item_DroppedConsumable_Spawn(entity e) +{ + entity item; + item = spawn(); + item.owner = world; + item.classname = "droppedconsumable"; + item.movetype = MOVETYPE_TOSS; + item.solid = SOLID_TRIGGER; + setmodel(item, e.model); + item.health = e.health; + item.inithealth = e.inithealth; + item.dmg = e.dmg; + item.initdmg = e.initdmg; + item.max_health = e.max_health; + item.scale = e.scale; + item.colormod = e.colormod; + + if(cvar("g_nodepthtestitems")) + item.effects |= EF_NODEPTHTEST; + + float scalediff, sz; + sz = e.scale ? e.scale : 1; // the line below does not work if I define this directly (fteqcc bug?) + scalediff = cvar("g_healthsize") ? sz / e.predator.scale : sz; // the tighter the gut, the greater the velocity + + setorigin(item, e.predator.origin); + item.angles_y = e.predator.angles_y; + makevectors(e.predator.v_angle); + item.velocity = v_forward * cvar("g_balance_vore_regurgitate_force") * scalediff; + e.predator.velocity += -v_forward * cvar("g_balance_vore_regurgitate_predatorforce") * scalediff; + item.touch = Item_DroppedConsumable_Touch; + item.cnt = time + 1; // 1 second delay + SUB_SetFade(item, time + 20, 1); +} + +float Item_Swallow(entity item, entity player) +{ + float pickedup, usage; + if(item.dmg && cvar("g_vore")) + { + if(player.stomach_load + item.dmg <= player.stomach_maxload) + if not(!cvar("g_balance_health_consumable_alwayspickup") && player.health >= item.max_health) + usage = 2; // consumable item, only if the vore system is enabled + } + else if (player.health < item.max_health) + usage = 1; // normal item + if(!usage) + return FALSE; + + // since map items don't have a scale, calculate one based on player size center and the item's health, in order to determine swallowing speed + float scalediff; + scalediff = pow((item.health / cvar("g_healthsize_center")) / player.scale, cvar("g_balance_vore_swallow_speed_fill_scalediff_item")); + + item.swallow_progress_prey += cvar("g_balance_vore_swallow_speed_fill_item") / scalediff; + player.swallow_progress_pred = item.swallow_progress_prey; + if(item.swallow_progress_prey < 1 && cvar("g_balance_vore_swallow_speed_fill_item")) + return FALSE; // swallow progress not full yet, or slow swallowing of items is disabled + + if(usage > 1) + { + pickedup = TRUE; + item.swallow_progress_prey = player.swallow_progress_pred = 0; + Item_Consumable_Spawn(item, player); + } + else + { + pickedup = TRUE; + item.swallow_progress_prey = player.swallow_progress_pred = 0; + player.health = min(player.health + item.health, item.max_health); + player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot")); + } + + return pickedup; +} + float Item_GiveTo(entity item, entity player) { float _switchweapon; @@ -299,12 +536,7 @@ float Item_GiveTo(entity item, entity player) } if (item.health) - if (player.health < item.max_health) - { - pickedup = TRUE; - player.health = min(player.health + item.health, item.max_health); - player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot")); - } + pickedup = Item_Swallow(item, player); if (item.armorvalue) if (player.armorvalue < item.max_armorvalue) { @@ -330,6 +562,17 @@ float Item_GiveTo(entity item, entity player) return 1; } +void Item_Think() +{ + self.nextthink = time; + + if(!self.swallow_progress_prey) + return; + + self.swallow_progress_prey = max(0, self.swallow_progress_prey - 0.01); + self.alpha = 1 - self.swallow_progress_prey; +} + void Item_Touch (void) { entity e, head; @@ -352,6 +595,8 @@ void Item_Touch (void) if(!Item_GiveTo(self, other)) return; + other.last_pickup = time; + pointparticles(particleeffectnum("item_pickup"), self.origin, '0 0 0', 1); if (self.classname == "droppedweapon") @@ -512,7 +757,6 @@ float commodity_pickupevalfunc(entity player, entity item) return item.bot_pickupbasevalue * c; }; - .float is_item; void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue) { @@ -622,7 +866,7 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, weaponsInMap |= weaponid; - if(g_lms || g_ca) + if(g_lms) { startitem_failed = TRUE; remove(self); @@ -665,6 +909,8 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, self.weapons = weaponid; self.flags = FL_ITEM | itemflags; self.touch = Item_Touch; + self.think = Item_Think; + self.nextthink = time; setmodel (self, self.mdl); // precision set below self.effects |= EF_LOWPRECISION; if((itemflags & FL_POWERUP) || self.health || self.armorvalue) @@ -814,6 +1060,13 @@ void weapon_defaultspawnfunc(float wpn) if(self.team) self.flags |= FL_NO_WEAPON_STAY; + if(g_weapon_stay == 2 && self.classname != "droppedweapon") + { + self.ammo_fuel = 0; + // weapon stay 2: don't use ammo on weapon pickups; instead + // initialize all ammo types to the pickup ammo unless set by g_start_ammo_* + } + StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, e.bot_pickupbasevalue); if (self.modelindex) // don't precache if self was removed weapon_action(e.weapon, WR_PRECACHE); @@ -856,6 +1109,7 @@ void spawnfunc_item_health_small (void) { self.max_health = g_pickup_healthsmall_max; if(!self.health) self.health = g_pickup_healthsmall; + self.dmg = g_pickup_healthsmall_consumable; StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW); } @@ -864,6 +1118,7 @@ void spawnfunc_item_health_medium (void) { self.max_health = g_pickup_healthmedium_max; if(!self.health) self.health = g_pickup_healthmedium; + self.dmg = g_pickup_healthmedium_consumable; StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID); } @@ -872,20 +1127,16 @@ void spawnfunc_item_health_large (void) { self.max_health = g_pickup_healthlarge_max; if(!self.health) self.health = g_pickup_healthlarge; - StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID); + self.dmg = g_pickup_healthlarge_consumable; + StartItem ("models/items/g_h50.md3", "misc/largehealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID); } void spawnfunc_item_health_mega (void) { - if(!cvar("g_powerup_superhealth")) - return; - - if((g_arena || g_ca) && !cvar("g_arena_powerups")) - return; - if(!self.max_health) self.max_health = g_pickup_healthmega_max; if(!self.health) self.health = g_pickup_healthmega; + self.dmg = g_pickup_healthmega_consumable; StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH); } @@ -1318,9 +1569,9 @@ float GiveItems(entity e, float beginarg, float endarg) } POSTGIVE_VALUE(e, strength_finished, 1, "misc/powerup.wav", "misc/poweroff.wav"); POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", "misc/poweroff.wav"); - POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, cvar("g_balance_pause_fuel_rot"), pauseregen_finished, cvar("g_balance_pause_fuel_regen"), "misc/itempickup.wav", string_null); - POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, cvar("g_balance_pause_armor_rot"), pauseregen_finished, cvar("g_balance_pause_health_regen"), "misc/armor25.wav", string_null); - POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, cvar("g_balance_pause_health_rot"), pauseregen_finished, cvar("g_balance_pause_health_regen"), "misc/megahealth.wav", string_null); + POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, cvar("g_balance_pause_fuel_rot"), pauseregenhealth_finished, cvar("g_balance_pause_fuel_regen"), "misc/itempickup.wav", string_null); + POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, cvar("g_balance_pause_armor_rot"), pauseregenarmor_finished, cvar("g_balance_pause_armor_regen"), "misc/armor25.wav", string_null); + POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, cvar("g_balance_pause_health_rot"), pauseregenhealth_finished, cvar("g_balance_pause_health_regen"), "misc/megahealth.wav", string_null); if(e.strength_finished <= 0) e.strength_finished = 0;