X-Git-Url: http://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=76dca4064a07d087c4cfabf0e15adef00bde6cdd;hp=e5157453c2e7229168e924fd4378f3facf67711e;hb=26226159c0b283300257726c80bfe81ade915db8;hpb=328192ad4edba15666acde860838df3501ee268f diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index e5157453..76dca406 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -16,12 +16,15 @@ entity Swallow_player_check() vector vore_w_shotorg, vore_w_shotdir; swallow_range = cvar("g_balance_vore_swallow_range"); - if(self.scale) // we can swallow from further or closer based on our size + if(cvar("g_healthsize")) // we can swallow from further or closer based on our size swallow_range *= self.scale; vore_w_shotorg = self.origin; vore_w_shotdir = v_forward; - WarpZone_traceline_antilag(self, vore_w_shotorg, vore_w_shotorg + vore_w_shotdir * swallow_range, FALSE, self, ANTILAG_LATENCY(self)); + if(self.antilag_debug) + WarpZone_traceline_antilag(self, vore_w_shotorg, vore_w_shotorg + vore_w_shotdir * swallow_range, FALSE, self, self.antilag_debug); + else + WarpZone_traceline_antilag(self, vore_w_shotorg, vore_w_shotorg + vore_w_shotdir * swallow_range, FALSE, self, ANTILAG_LATENCY(self)); if(trace_fraction < 1) if(trace_ent.classname == "player") return trace_ent; @@ -36,7 +39,7 @@ float Swallow_condition_check(entity prey) if(prey.classname == "player" && !prey.stat_eaten && prey.deadflag == DEAD_NO) // we can't swallow someone who's already in someone else's stomach if(self.classname == "player" && !self.stat_eaten && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves if(!self.BUTTON_REGURGITATE && time > self.action_delay) - if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap")) + if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap") / (1 + self.stomach_load)) { string swallow_complain; if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore")) @@ -199,6 +202,64 @@ void Vore_AutoDigest(entity e) e.digesting = TRUE; } +.entity swallow_model; +void Vore_SwallowModel_Think() +{ + //update the position of the swallow model to match our swallow progress + float dist; + dist = (-0.5 + self.owner.swallow_progress_prey) * cvar("g_vore_swallowmodel_range"); // the model is centered at 0.5 progress + if(cvar("g_healthsize")) + dist *= self.scale; + self.view_ofs = '1 0 0' * dist; + + // if our swallow progress is gone or we are dead, the swallow model also goes away + if(!self.owner.swallow_progress_prey || self.owner.deadflag != DEAD_NO || self.owner.classname != "player") + { + remove(self.owner.swallow_model); + self.owner.swallow_model = world; + return; + } + + // properties that should update whenever possible, but when the predator is not available + self.alpha = self.owner.cvar_cl_vore_swallowmodel; + self.nextthink = time; +} + +void Vore_SwallowModel_Update(entity prey, entity pred) +{ + // if we don't have a swallow model already, spawn one + if(!prey.swallow_model) + { + prey.swallow_model = spawn(); + + prey.swallow_model.movetype = MOVETYPE_FOLLOW; + prey.swallow_model.solid = SOLID_NOT; + + // apply the properties of the prey + prey.swallow_model.viewmodelforclient = prey; // use the same system as the weapon model + //prey.swallow_model.effects |= EF_NOGUNBOB; // let it bob + prey.swallow_model.effects |= EF_NODEPTHTEST; // don't hide behind walls + prey.swallow_model.colormap = prey.colormap; // pants and shirt color + prey.swallow_model.glowmod = prey.glowmod; // glow color + + prey.swallow_model.owner = prey; // owned by the prey + prey.swallow_model.think = Vore_SwallowModel_Think; + prey.swallow_model.nextthink = time; + } + + // properties that should update whenever possible, but when the predator is available + string player_swallowmodel; + player_swallowmodel = strcat(substring(pred.playermodel, 0, strlen(pred.playermodel) - 4), "_swallow.md3"); // 4 is the extension length + if(prey.swallow_model.model != player_swallowmodel) // player model can be changed while the predator is active + setmodel(prey.swallow_model, player_swallowmodel); + if(prey.swallow_model.skin != pred.skin) // player skin can be changed while the predator is active + prey.swallow_model.skin = pred.skin; + if(cvar("g_healthsize")) + prey.swallow_model.scale = pred.scale / prey.scale; // player size difference + if(prey.swallow_model.enemy != pred) + prey.swallow_model.enemy = pred; // enemy is the predator +} + .entity pusher; .float pushltime; void Vore_Swallow(entity e) @@ -237,6 +298,7 @@ void Vore_Swallow(entity e) e.predator.stomach_load += 1; e.predator.regurgitate_prepare = 0; e.predator.spawnshieldtime = 0; // lose spawn shield when we vore + e.predator.hitsound += 1; // play this for team mates too, as we could be swallowing them to heal them Vore_WeightApply(e.predator); Vore_AutoDigest(e.predator); @@ -247,6 +309,38 @@ void Vore_Swallow(entity e) e.stomachkick_delay = time + cvar("g_balance_vore_kick_delay"); // don't kick immediately after being swallowed } +void Vore_SwallowStep(entity e) +{ + if(!cvar("g_balance_vore_swallow_speed_fill")) + { + Vore_Swallow(e); + return; + } + + Vore_SwallowModel_Update(e, self); + + // increase the progress value until it reaches 1, then swallow the player + if(e.swallow_progress_prey < 1) + { + float fill; + fill = cvar("g_balance_vore_swallow_speed_fill") * frametime; + if(cvar("g_healthsize") && cvar("g_balance_vore_swallow_speed_fill_scalediff")) // fill rate depends on predator size compared to prey size + fill *= pow(self.scale / e.scale, cvar("g_balance_vore_swallow_speed_fill_scalediff")); + if(cvar("g_balance_vore_swallow_speed_fill_stomachload") && e.stomach_load) // fill rate is influenced by the prey's stomach load + fill /= e.stomach_load; + + e.swallow_progress_prey += fill; + } + else + { + Vore_Swallow(e); + e.swallow_progress_prey = 0; + } + + // the predator's progress is how much the prey got swallowed + self.swallow_progress_pred = e.swallow_progress_prey; +} + void Vore_Regurgitate(entity e) { // this player is being regurgitated by their predator, apply the proper changes @@ -271,9 +365,26 @@ void Vore_Regurgitate(entity e) e.pusher = e.predator; // allows us to frag players by regurgitating them in deadly pits e.pushltime = time + cvar("g_maxpushtime"); + // regurgitated prey is given this amount of swallow progress, to simulate being more vulnerable + if(cvar("g_balance_vore_swallow_speed_fill") && cvar("g_balance_vore_regurgitate_swallowprogress")) + { + e.swallow_progress_prey = cvar("g_balance_vore_regurgitate_swallowprogress"); + Vore_SwallowModel_Update(e, e.predator); + } + + // apply regurgitation damage to the predator + if(cvar("g_balance_vore_regurgitate_damage")) + { + float regurgitate_dmg; + regurgitate_dmg = cvar("g_balance_vore_regurgitate_damage"); + if(cvar("g_healthsize")) + regurgitate_dmg *= e.scale / e.predator.scale; + Damage(e.predator, e.predator, e.predator, regurgitate_dmg, DEATH_REGURGITATION, e.predator.origin, '0 0 0'); + } + 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("regurgitate"), e.predator.origin, '0 0 0', 1); + pointparticles(particleeffectnum("vore_regurgitate"), e.predator.origin, '0 0 0', 1); e.predator.punchangle_x += cvar("g_balance_vore_regurgitate_punchangle"); e.predator.stomach_load -= 1; e.predator.regurgitate_prepare = 0; @@ -382,8 +493,8 @@ void Vore_Digest() damage = cvar("g_balance_vore_digestion_damage") / reduce; // apply player scale to digestion damage - if(cvar("g_balance_vore_digestion_playerscale")) - damage *= self.predator.scale; + if(cvar("g_healthsize") && cvar("g_balance_vore_digestion_scalediff")) + damage *= pow(self.predator.scale / self.scale, cvar("g_balance_vore_digestion_scalediff")); Damage(self, self.predator, self.predator, damage, DEATH_DIGESTION, self.origin, '0 0 0'); if(cvar("g_balance_vore_digestion_vampire") && self.predator.health < cvar("g_balance_vore_digestion_vampire_stable")) @@ -422,30 +533,41 @@ void Vore_Teamheal() } } +.float kick_pressed; void Vore_StomachKick() { // allows prey to kick the predator's stomach and do some damage or attempt to escape - if(time > self.stomachkick_delay) + if(time > self.stomachkick_delay && !self.kick_pressed) { - float damage; + float damage, vol; vector force; - damage = ceil(random() * (cvar("g_balance_vore_kick_damage_max") - cvar("g_balance_vore_kick_damage_min")) + cvar("g_balance_vore_kick_damage_min")); + damage = cvar("g_balance_vore_kick_damage"); force = v_forward * cvar("g_balance_vore_kick_force"); + vol = VOL_BASE; // apply player scale to the damage / force of the kick - if(cvar("g_balance_vore_kick_playerscale")) + if(cvar("g_healthsize") && cvar("g_balance_vore_kick_scalediff")) { - damage *= self.scale; - force *= self.scale; + damage *= pow(self.scale / self.predator.scale, cvar("g_balance_vore_kick_scalediff")); + force *= pow(self.scale / self.predator.scale, cvar("g_balance_vore_kick_scalediff")); + vol *= pow(self.scale / self.predator.scale, cvar("g_balance_vore_kick_scalediff")); // kick sound volume based on the same scale } + vol = bound(0, vol, 1); Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, force); - sound(self.predator, CHAN_PROJECTILE, strcat("weapons/hit", ftos(floor(random() * 8)), ".wav"), VOL_BASE, ATTN_NORM); + sound(self.predator, CHAN_PROJECTILE, strcat("weapons/hit", ftos(floor(random() * 8)), ".wav"), vol, ATTN_NORM); self.predator.punchangle_x -= cvar("g_balance_vore_kick_predator_punchangle"); self.punchangle_x += cvar("g_balance_vore_kick_prey_punchangle"); + // abort the predator's scheduled regurgitation + if(random() < cvar("g_balance_vore_kick_cutregurgitate")) + self.predator.regurgitate_prepare = 0; + self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay"); + if(cvar("g_balance_vore_kick_repress")) + if not(clienttype(self) == CLIENTTYPE_BOT) // not for bots, to prevent an issue + self.kick_pressed = TRUE; } } @@ -510,35 +632,41 @@ void Vore_SetSbarRings() { if(time <= self.stomachkick_delay) { - self.stat_sbring1_type = 2; // ring shows stomach kick delay, empties with progress + self.stat_sbring1_type = 3; // ring shows stomach kick delay, empties with progress self.stat_sbring1_clip = bound(0, (time / self.stomachkick_delay - 1) / ((self.stomachkick_delay - cvar("g_balance_vore_kick_delay")) / self.stomachkick_delay - 1), 1); } } else { - if(time <= self.action_delay) + if(self.swallow_progress_pred) + { + self.stat_sbring1_type = 1; // ring shows predator swallow progress, fills with progress + self.stat_sbring1_clip = bound(0, self.swallow_progress_pred, 1); + } + else if(time <= self.action_delay) { - self.stat_sbring1_type = 1; // ring shows vore action delay, empties with progress + self.stat_sbring1_type = 2; // ring shows vore action delay, empties with progress self.stat_sbring1_clip = bound(0, (time / self.action_delay - 1) / ((self.action_delay - cvar("g_balance_vore_action_delay")) / self.action_delay - 1), 1); } - if(time <= self.regurgitate_prepare) + + if(self.swallow_progress_prey) { - self.stat_sbring2_type = 1; // ring shows regurgitation preparing, fills with progress + self.stat_sbring2_type = 1; // ring shows prey swallow progress, fills with progress + self.stat_sbring2_clip = bound(0, self.swallow_progress_prey, 1); + } + else if(time <= self.regurgitate_prepare) + { + self.stat_sbring2_type = 2; // ring shows regurgitation preparing, fills with progress self.stat_sbring2_clip = 1 - bound(0, (time / self.regurgitate_prepare - 1) / ((self.regurgitate_prepare - cvar("g_balance_vore_regurgitate_delay")) / self.regurgitate_prepare - 1), 1); } } } +.entity prey; void Vore() { // main vore code, this is where it all happens - if(!cvar("g_vore")) // the vore system is disabled - { - Vore_Disconnect(); - return; - } - Vore_AutoTaunt(); // wash the goo away from players once they leave the stomach @@ -600,7 +728,29 @@ void Vore() } } + // the swallow progress of prey and preds idly decrease by this amount + if(cvar("g_balance_vore_swallow_speed_decrease")) + { + if(self.swallow_progress_pred) + { + self.swallow_progress_pred -= cvar("g_balance_vore_swallow_speed_decrease") * frametime; + if(self.swallow_progress_pred < 0) + self.swallow_progress_pred = 0; + } + if(self.swallow_progress_prey) + { + self.swallow_progress_prey -= cvar("g_balance_vore_swallow_speed_decrease") * frametime; + if(self.swallow_progress_prey < 0) + self.swallow_progress_prey = 0; + } + } + // apply delays and skip the vore system under some circumstances + if(!cvar("g_vore")) // the vore system is disabled + { + Vore_Disconnect(); + return; + } if(time < game_starttime || (time < warmup && !inWarmupStage)) // don't allow vore before a round begins { Vore_Disconnect(); @@ -615,23 +765,22 @@ void Vore() // Code that addresses predators: // -------------------------------- - entity prey; - prey = Swallow_player_check(); + self.prey = Swallow_player_check(); // attempt to swallow our new prey if we pressed the attack button, and there's any in range self.stat_canswallow = 0; - if(Swallow_condition_check(prey)) + if(Swallow_condition_check(self.prey)) { // canswallow stat, used by the HUD - if(teams_matter && prey.team == self.team) + if(teams_matter && self.prey.team == self.team) self.stat_canswallow = 2; else self.stat_canswallow = 1; if(self.BUTTON_ATCK) - Vore_Swallow(prey); + Vore_SwallowStep(self.prey); } - else if(prey != world) + else if(self.prey != world) self.stat_canswallow = -1; // toggle digestion, if the player has someone in their stomach @@ -664,6 +813,7 @@ void Vore() { self.regurgitate_prepare = time + cvar("g_balance_vore_regurgitate_delay"); PlayerSound(self, playersound_regurgitate_prepare, CHAN_VOICE, VOICETYPE_PLAYERSOUND); + setanim(self, self.anim_pain2, FALSE, TRUE, TRUE); // looks good for preparing regurgitation self.regurgitate_button_delay_time = time + button_delay_time; } } @@ -700,7 +850,7 @@ void Vore() if(self.predator.deadflag != DEAD_NO) Vore_Regurgitate(self); - else if(vlen(self.predator.velocity) > cvar("g_balance_vore_regurgitate_speedcap")) + else if(vlen(self.predator.velocity) > cvar("g_balance_vore_regurgitate_speedcap") / (1 + self.predator.stomach_load)) Vore_Regurgitate(self); // apply delayed regurgitating if it was scheduled @@ -719,8 +869,13 @@ void Vore() Vore_Teamheal(); // execute prey commands - if(self.BUTTON_ATCK && cvar("g_vore_kick")) - Vore_StomachKick(); + if(self.BUTTON_ATCK) + { + if(cvar("g_vore_kick")) + Vore_StomachKick(); + } + else + self.kick_pressed = FALSE; if(self.BUTTON_JUMP) Vore_StomachLeave();