X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fbuffs%2Fsv_buffs.qc;h=edd970126c5a8ec1c467b1f3a2850c70bb042ce8;hp=d9223b302a13b771f34e11b55c8bb7077e08f01c;hb=6c97577a92244e0c02e0f4319426542dfdcc5a42;hpb=f34fd47ee0a7f283ab60592a17399ec5a500416c diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index d9223b302..edd970126 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -6,11 +6,14 @@ .float buff_time = _STAT(BUFF_TIME); void buffs_DelayedInit(entity this); -REGISTER_MUTATOR(buffs, cvar("g_buffs")) +AUTOCVAR(g_buffs, int, -1, "Enable buffs, -1: enabled but no auto location or replacing powerups, 1: enabled and can replace them"); + +REGISTER_MUTATOR(buffs, autocvar_g_buffs) { MUTATOR_ONADD { - InitializeEntity(NULL, buffs_DelayedInit, INITPRIO_FINDTARGET); + if(autocvar_g_buffs > 0) + InitializeEntity(NULL, buffs_DelayedInit, INITPRIO_FINDTARGET); } } @@ -111,7 +114,7 @@ void buff_SetCooldown(entity this, float cd) void buff_Respawn(entity this) { - if(gameover) { return; } + if(game_stopped) return; vector oldbufforigin = this.origin; this.velocity = '0 0 200'; @@ -146,7 +149,7 @@ void buff_Respawn(entity this) void buff_Touch(entity this, entity toucher) { - if(gameover) { return; } + if(game_stopped) return; if(ITEM_TOUCH_NEEDKILL()) { @@ -216,7 +219,7 @@ void buff_NewType(entity ent, float cb) FOREACH(Buffs, buff_Available(it), LAMBDA( it.buff_seencount += 1; // if it's already been chosen, give it a lower priority - RandomSelection_Add(NULL, it.m_itemid, string_null, 1, max(0.2, 1 / it.buff_seencount)); + RandomSelection_AddFloat(it.m_itemid, 1, max(0.2, 1 / it.buff_seencount)); )); ent.buffs = RandomSelection_chosen_float; } @@ -231,6 +234,7 @@ void buff_Think(entity this) this.skin = buff.m_skin; setmodel(this, MDL_BUFF); + setsize(this, BUFF_MIN, BUFF_MAX); if(this.buff_waypoint) { @@ -244,7 +248,7 @@ void buff_Think(entity this) this.oldbuffs = this.buffs; } - if(!gameover) + if(!game_stopped) if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime) if(!this.buff_activetime_updated) { @@ -265,7 +269,7 @@ void buff_Think(entity this) } if(this.buff_activetime) - if(!gameover) + if(!game_stopped) if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime) { this.buff_activetime = max(0, this.buff_activetime - frametime); @@ -339,12 +343,16 @@ void buff_Init(entity this) entity buff = buff_FirstFromFlags(this.buffs); - if(!this.buffs || buff_Available(buff)) + if(!this.buffs || !buff_Available(buff)) buff_NewType(this, 0); this.classname = "item_buff"; this.solid = SOLID_TRIGGER; this.flags = FL_ITEM; + this.bot_pickup = true; + this.bot_pickupevalfunc = generic_pickupevalfunc; + this.bot_pickupbasevalue = 1000; + IL_PUSH(g_items, this); setthink(this, buff_Think); settouch(this, buff_Touch); this.reset = buff_Reset; @@ -420,9 +428,9 @@ void buff_Medic_Heal(entity this) }); } -float buff_Inferno_CalculateTime(float x, float offset_x, float offset_y, float intersect_x, float intersect_y, float base) +float buff_Inferno_CalculateTime(float damg, float offset_x, float offset_y, float intersect_x, float intersect_y, float base) { - return offset_y + (intersect_y - offset_y) * logn(((x - offset_x) * ((base - 1) / intersect_x)) + 1, base); + return offset_y + (intersect_y - offset_y) * logn(((damg - offset_x) * ((base - 1) / intersect_x)) + 1, base); } // mutator hooks @@ -442,7 +450,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_SplitHealthArmor) } } -MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate) +MUTATOR_HOOKFUNCTION(buffs, Damage_Calculate) { entity frag_attacker = M_ARGV(1, entity); entity frag_target = M_ARGV(2, entity); @@ -620,7 +628,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDies) MUTATOR_HOOKFUNCTION(buffs, PlayerUseKey, CBC_ORDER_FIRST) { - if(MUTATOR_RETURNVALUE || gameover) { return; } + if(MUTATOR_RETURNVALUE || game_stopped) return; entity player = M_ARGV(0, entity); @@ -639,7 +647,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerUseKey, CBC_ORDER_FIRST) MUTATOR_HOOKFUNCTION(buffs, ForbidThrowCurrentWeapon) { - if(MUTATOR_RETURNVALUE || gameover) { return; } + if(MUTATOR_RETURNVALUE || game_stopped) return; entity player = M_ARGV(0, entity); if(player.buffs & BUFF_SWAPPER.m_itemid) @@ -739,6 +747,9 @@ MUTATOR_HOOKFUNCTION(buffs, CustomizeWaypoint) MUTATOR_HOOKFUNCTION(buffs, OnEntityPreSpawn, CBC_ORDER_LAST) { + if(autocvar_g_buffs < 0) + return; // no auto replacing of entities in this mode + entity ent = M_ARGV(0, entity); if(autocvar_g_buffs_replace_powerups) @@ -776,11 +787,24 @@ MUTATOR_HOOKFUNCTION(buffs, WeaponSpeedFactor) M_ARGV(0, float) *= autocvar_g_buffs_disability_weaponspeed; } +.bool buff_flight_crouchheld; + MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) { entity player = M_ARGV(0, entity); - if(gameover || IS_DEAD(player)) { return; } + if(game_stopped || IS_DEAD(player)) return; + + if(player.buffs & BUFF_FLIGHT.m_itemid) + { + if(!PHYS_INPUT_BUTTON_CROUCH(player)) + player.buff_flight_crouchheld = false; + else if(!player.buff_flight_crouchheld) + { + player.buff_flight_crouchheld = true; + player.gravity *= -1; + } + } if(time < player.buff_disability_time) if(time >= player.buff_disability_effect_time) @@ -822,7 +846,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) if(player.buffs & BUFF_MAGNET.m_itemid) { vector pickup_size; - FOREACH_ENTITY_FLAGS(flags, FL_ITEM, + IL_EACH(g_items, it.itemdef, { if(it.buffs) pickup_size = '1 1 1' * autocvar_g_buffs_magnet_range_buff; @@ -838,8 +862,14 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) } if(player.buffs & BUFF_AMMO.m_itemid) - if(player.clip_size) - player.clip_load = player.(weapon_load[PS(player).m_switchweapon.m_id]) = player.clip_size; + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity).clip_size) + player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + } + } if((player.buffs & BUFF_INVISIBLE.m_itemid) && (player.oldbuffs & BUFF_INVISIBLE.m_itemid)) if(player.alpha != autocvar_g_buffs_invisible_alpha) @@ -866,9 +896,17 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_WEAPON_AMMO); player.items |= IT_UNLIMITED_WEAPON_AMMO; - if(player.clip_load) - player.buff_ammo_prev_clipload = player.clip_load; - player.clip_load = player.(weapon_load[PS(player).m_switchweapon.m_id]) = player.clip_size; + if(player.buffs & BUFF_AMMO.m_itemid) + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity).clip_load) + player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load; + if(player.(weaponentity).clip_size) + player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + } + } } BUFF_ONREM(BUFF_AMMO) @@ -878,8 +916,15 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) else player.items &= ~IT_UNLIMITED_WEAPON_AMMO; - if(player.buff_ammo_prev_clipload) - player.clip_load = player.buff_ammo_prev_clipload; + if(player.buffs & BUFF_AMMO.m_itemid) + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity).buff_ammo_prev_clipload) + player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload; + } + } } BUFF_ONADD(BUFF_INVISIBLE) @@ -894,6 +939,16 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) BUFF_ONREM(BUFF_INVISIBLE) player.alpha = player.buff_invisible_prev_alpha; + BUFF_ONADD(BUFF_FLIGHT) + { + player.buff_flight_oldgravity = player.gravity; + if(!player.gravity) + player.gravity = 1; + } + + BUFF_ONREM(BUFF_FLIGHT) + player.gravity = ((player.trigger_gravity_check) ? player.trigger_gravity_check.enemy.gravity : player.buff_flight_oldgravity); + player.oldbuffs = player.buffs; if(player.buffs) { @@ -977,12 +1032,14 @@ REPLICATE(cvar_cl_buffs_autoreplace, bool, "cl_buffs_autoreplace"); MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsString) { - M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Buffs"); + if(autocvar_g_buffs > 0) // only report as a mutator if they're enabled + M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Buffs"); } MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsPrettyString) { - M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Buffs"); + if(autocvar_g_buffs > 0) + M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Buffs"); } void buffs_DelayedInit(entity this)