X-Git-Url: http://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=531f95d0b010784d7d112bf6f6eec44c07bc4979;hp=6c7e0c2c2cdca8c435fc00b224a23876a43e86e5;hb=c096eccb4414934a5c99f69550591f772ed6e6b4;hpb=284013c0eaf7ee8a382cb76b2172b211b5d51492 diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 6c7e0c2c..531f95d0 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -1,5 +1,5 @@ .float regurgitate_prepare; -.float system_delay, swallow_delay, digest_button_delay_time, regurgitate_button_delay_time; +.float stomachkick_delay, system_delay, action_delay, digest_button_delay_time, regurgitate_button_delay_time; .float complain_vore; .float vore_oldmovetype, vore_oldsolid, vore_oldstomachload; @@ -33,57 +33,33 @@ float Swallow_condition_check(entity prey) // checks the necessary conditions for swallowing a player if(prey != self) - if(prey.classname == "player" && prey.predator.classname != "player" && prey.deadflag == DEAD_NO) // we can't swallow someone who's already in someone else's stomach - if(self.classname == "player" && self.predator.classname != "player" && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves - if(!self.BUTTON_REGURGITATE && self.swallow_delay < time) + 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")) { + string swallow_complain; if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore")) + swallow_complain = "You cannot swallow your team mates\n"; + else if(!cvar("g_vore_spawnshield") && prey.spawnshieldtime > time) + swallow_complain = "You cannot swallow someone protected by the spawn shield\n"; + else if(self.stomach_load >= g_balance_vore_swallow_limit) + swallow_complain = strcat("You cannot swallow more than ^2", ftos(g_balance_vore_swallow_limit), "^7 players at a time\n"); + else if(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load) + swallow_complain = "You cannot swallow someone with a bigger stomach than yours\n"; + else if(cvar("g_vore_biggersize") && prey.scale > self.scale) + swallow_complain = "You cannot swallow someone larger than you\n"; + + if(swallow_complain != "") { if(time > self.complain_vore && self.BUTTON_ATCK) { play2(self, "misc/forbidden.wav"); - sprint(self, "You cannot swallow your team mates\n"); + sprint(self, swallow_complain); self.complain_vore = time + complain_delay_time; } return FALSE; } - - if(self.stomach_load >= cvar("g_balance_vore_swallow_limit")) - { - if(time > self.complain_vore && self.BUTTON_ATCK) - { - play2(self, "misc/forbidden.wav"); - sprint(self, strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n")); - self.complain_vore = time + complain_delay_time; - } - return FALSE; - } - - if(cvar("g_vore_biggergut")) - if(prey.stomach_load > self.stomach_load) - { - if(time > self.complain_vore && self.BUTTON_ATCK) - { - play2(self, "misc/forbidden.wav"); - sprint(self, "You cannot swallow someone with a bigger stomach than yours\n"); - self.complain_vore = time + complain_delay_time; - } - return FALSE; - } - - if(!cvar("g_vore_spawnshield")) - if(prey.spawnshieldtime > time) - { - if(time > self.complain_vore && self.BUTTON_ATCK) - { - play2(self, "misc/forbidden.wav"); - sprint(self, "You cannot swallow someone protected by the spawn shield\n"); - self.complain_vore = time + complain_delay_time; - } - return FALSE; - } - return TRUE; } return FALSE; @@ -107,7 +83,7 @@ float Stomach_TeamMates_check(entity pred) float Vore_CanLeave() { - if(self.predator.classname == "player") + if(self.stat_eaten) { if(!cvar("g_vore_kick")) // you are defenseless in the stomach if you can't kick, so allow leaving return TRUE; @@ -120,19 +96,67 @@ float Vore_CanLeave() } // position the camera properly for prey -void Vore_SetCamera() +void Vore_SetPreyPositions() { - if not(self.predator.classname == "player" || self.fakeprey > 1) - return; + // self is the predator and head is the prey - self.view_ofs = PL_PREY_VIEW_OFS; + local entity head; + local vector origin_apply; + local float position_counter; - float prey_height; - if(self.fakeprey > 1) - prey_height = (self.scale - self.fakepredator.scale) * cvar("g_healthsize_vore_pos"); - else - prey_height = (self.scale - self.predator.scale) * cvar("g_healthsize_vore_pos"); - self.view_ofs_z += prey_height; + // In order to allow prey to see each other in the stomach, we must position each occupant differently, + // else all players overlap in the center. To do this, we run a loop on all players in the same stomach. + // For each player, the origin is updated, then a new origin is used for the next player. + // This requires that no more than 9 players may be in the stomach at a time! + FOR_EACH_PLAYER(head) + { + if(head.predator == self) + { + switch(position_counter) + { + case 0: + origin_apply = '0 0 0'; // first occupant sits in the middle + break; + case 1: + origin_apply = '1 0 0'; // second occupant sits in the front + break; + case 2: + origin_apply = '-1 0 0'; // third occupant sits in the back + break; + case 3: + origin_apply = '0 1 0'; // fourth occupant sits in the right + break; + case 4: + origin_apply = '0 -1 0'; // fifth occupant sits in the left + break; + case 5: + origin_apply = '1 1 0'; // sixth occupant sits in the front-right + break; + case 6: + origin_apply = '-1 1 0'; // seventh occupant sits in the back-right + break; + case 7: + origin_apply = '1 -1 0'; // eigth occupant sits in the front-left + break; + case 8: + origin_apply = '-1 -1 0'; // ninth occupant sits in the back-left + break; + default: + break; + } + + // since prey have their predators set as an aiment, view_ofs will specify the real origin of prey, not just the view offset + head.view_ofs = PL_PREY_VIEW_OFS + origin_apply * cvar("g_vore_neighborprey_distance"); + head.view_ofs_z *= self.scale; // stomach center depends on predator scale + + // change prey height based on scale + float prey_height; + prey_height = (head.scale - self.scale) * cvar("g_healthsize_vore_pos"); + head.view_ofs_z += prey_height; + + position_counter += 1; + } + } } .float gurgle_oldstomachload; @@ -175,6 +199,63 @@ 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.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) @@ -207,7 +288,7 @@ void Vore_Swallow(entity e) centerprint(e.predator, "^3You have swallowed a team mate, don't digest!"); } - PlayerSound(e.predator, playersound_swallow, CHAN_PAIN, VOICETYPE_PLAYERSOUND); + PlayerSound(e.predator, playersound_swallow, CHAN_VOICE, VOICETYPE_PLAYERSOUND); setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating e.predator.punchangle_x -= cvar("g_balance_vore_swallow_punchangle"); e.predator.stomach_load += 1; @@ -218,8 +299,41 @@ void Vore_Swallow(entity e) // block firing for a small amount of time, or we'll be firing the next frame after we swallow e.predator.weapon_delay = time + button_delay_time; - e.predator.swallow_delay = time + cvar("g_balance_vore_swallow_delay"); + e.predator.action_delay = time + cvar("g_balance_vore_action_delay"); e.system_delay = e.predator.system_delay = time + system_delay_time; + 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_balance_vore_swallow_speed_fill_scalediff")) // fill rate depends on predator size compared to prey size + fill *= (self.scale / e.scale); + 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) @@ -246,13 +360,20 @@ 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"); - PlayerSound(e.predator, playersound_regurgitate, CHAN_PAIN, VOICETYPE_PLAYERSOUND); + // 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); + } + + 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); e.predator.punchangle_x += cvar("g_balance_vore_regurgitate_punchangle"); e.predator.stomach_load -= 1; e.predator.regurgitate_prepare = 0; - e.predator.swallow_delay = time + cvar("g_balance_vore_swallow_delay"); + e.predator.action_delay = time + cvar("g_balance_vore_action_delay"); Vore_WeightApply(e.predator); // block firing for a small amount of time, or we'll be firing the next frame @@ -265,12 +386,12 @@ void Vore_DeadPrey_Configure(entity e) { // ran when the keepdeadprey feature is enabled and prey stays inside the stomach after dying - if(e.fakeprey || e.predator.classname != "player") // already configured + if(e.fakeprey || !e.stat_eaten) // we already configured everything return; // this entity is like e.predator but for dead prey, to avoid conflicts e.fakepredator = e.predator; - e.fakeprey = 2; // is fakeprey in a stomach + e.fakeprey = TRUE; // first release the prey from the predator, as dead prey needs to be attached differently // the predator's stomach load is also decreased, as dead prey doesn't count any more @@ -294,7 +415,8 @@ void Vore_DeadPrey_Detach(entity e) return; e.fakepredator = world; - e.fakeprey = 1; // was fakeprey but is now detached + e.fakeprey = TRUE; // keep fakeprey status + e.stat_eaten = 0; e.aiment = world; e.movetype = MOVETYPE_TOSS; } @@ -303,12 +425,12 @@ void Vore_PreyRelease(entity e, float pred_disconnect) { if(pred_disconnect) { - if(e.fakeprey > 1) + if(e.fakeprey) Vore_DeadPrey_Detach(e); else Vore_Regurgitate(e); } - else + else if(self.stat_eaten && !self.fakeprey) { // if the keepdeadprey feature is on, don't spit a dead prey's carcass out if(e.deadflag != DEAD_NO && random() < cvar("g_vore_keepdeadprey")) @@ -323,7 +445,7 @@ void Vore_Disconnect() // frees prey from their predators when someone disconnects or goes spectating, or in other circumstances // prey disconnects or goes spectating while inside someone's belly - if(self.predator.classname == "player") + if(self.stat_eaten) Vore_PreyRelease(self, TRUE); // pred disconnects or goes spectating with players in their belly @@ -343,18 +465,32 @@ void Vore_Digest() { // apply digestion to prey - if(time > self.predator.digestion_step) + if(time > self.digestion_step) { - Damage(self, self.predator, self.predator, cvar("g_balance_vore_digestion_damage"), DEATH_DIGESTION, self.origin, '0 0 0'); + // if distributed digestion is enabled, reduce digestion strength by the number of prey in our stomach + float reduce; + if(cvar("g_balance_vore_digestion_distribute")) + reduce = self.predator.stomach_load; + else + reduce = 1; + + float damage; + damage = cvar("g_balance_vore_digestion_damage") / reduce; + + // apply player scale to digestion damage + if(cvar("g_balance_vore_digestion_scalediff")) + damage *= (self.predator.scale / self.scale); + + 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")) - self.predator.health += cvar("g_balance_vore_digestion_vampire"); + self.predator.health += cvar("g_balance_vore_digestion_vampire") / reduce; if (self.predator.digestsound_finished < time) { PlayerSound (self.predator, playersound_digest, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); self.predator.digestsound_finished = time + 0.5; } - self.predator.digestion_step = time + steptime; + self.digestion_step = time + steptime; } if(self.deadflag != DEAD_NO) @@ -382,25 +518,37 @@ void Vore_Teamheal() } } -.float stomachkick_delay; +.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; + 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")); + force = v_forward * cvar("g_balance_vore_kick_force"); + + // apply player scale to the damage / force of the kick + if(cvar("g_balance_vore_kick_scalediff")) + { + damage *= (self.scale / self.predator.scale); + force *= (self.scale / self.predator.scale); + } - Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, v_forward * cvar("g_balance_vore_kick_force")); - sound(self.predator, CHAN_PROJECTILE, "weapons/stomachkick.wav", VOL_BASE, ATTN_NORM); + 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); self.predator.punchangle_x -= cvar("g_balance_vore_kick_predator_punchangle"); self.punchangle_x += cvar("g_balance_vore_kick_prey_punchangle"); - if(random() < cvar("g_balance_vore_kick_escapeprobability")) - Vore_Regurgitate(self); + // 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")) + self.kick_pressed = TRUE; } } @@ -440,7 +588,7 @@ void Vore_AutoTaunt() } // prey taunts - if(self.predator.classname == "player" && !(teams_matter && self.team == self.predator.team)) + if(self.stat_eaten && !(teams_matter && self.team == self.predator.team)) { if(!self.taunt_soundtime) // taunt_soundtime becomes 0 once the taunt has played { @@ -455,6 +603,46 @@ void Vore_AutoTaunt() } } +void Vore_SetSbarRings() +{ + // first clear the ring stats, then configure them if needed + self.stat_sbring1_type = self.stat_sbring1_clip = 0; + self.stat_sbring2_type = self.stat_sbring2_clip = 0; + + if(self.stat_eaten) + { + if(time <= self.stomachkick_delay) + { + 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(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 = 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(self.swallow_progress_prey) + { + 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); + } + } +} + void Vore() { // main vore code, this is where it all happens @@ -468,7 +656,7 @@ void Vore() Vore_AutoTaunt(); // wash the goo away from players once they leave the stomach - if(self.predator.classname != "player") + if(!self.stat_eaten) if(stov(cvar_string("g_vore_regurgitatecolor_release"))) if(self.colormod) if(cvar("g_vore_regurgitatecolor_release_fade")) @@ -485,7 +673,8 @@ void Vore() } // set all vore stats - if(self.fakeprey > 1) + Vore_SetSbarRings(); + if(self.fakepredator.classname == "player") self.stat_eaten = num_for_edict(self.fakepredator); else if(self.predator.classname == "player") { @@ -504,7 +693,7 @@ void Vore() // don't allow a player inside a player inside another player :) // prevent this by checking if such has happened, and taking the proper measures // this code has a high priority and must not be stopped by any delay, so run it here - if(self.predator.predator.classname == "player") + if(self.predator.stat_eaten) { entity target_predator, target_predator_predator, oldself; target_predator = self.predator; @@ -525,6 +714,23 @@ 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(time < game_starttime || (time < warmup && !inWarmupStage)) // don't allow vore before a round begins { @@ -554,7 +760,7 @@ void Vore() self.stat_canswallow = 1; if(self.BUTTON_ATCK) - Vore_Swallow(prey); + Vore_SwallowStep(prey); } else if(prey != world) self.stat_canswallow = -1; @@ -581,7 +787,7 @@ void Vore() self.digesting = FALSE; // predator wishes to regurgitate his prey - if(self.BUTTON_REGURGITATE) + if(self.BUTTON_REGURGITATE && time > self.action_delay) { if(self.stomach_load) { @@ -607,14 +813,14 @@ void Vore() // Code that addresses the prey: // -------------------------------- - Vore_SetCamera(); + Vore_SetPreyPositions(); // keepdeadprey - detach dead prey if their predator died or got swallowed - if(self.fakepredator.classname == "player") - if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.predator.classname == "player") + if(self.fakeprey) + if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.stat_eaten) Vore_DeadPrey_Detach(self); - if(self.predator.classname != "player") + if(!self.stat_eaten) return; if(self.deadflag != DEAD_NO) @@ -644,8 +850,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();