jacob404 / promod-future

GNU General Public License v3.0
7 stars 1 forks source link

Rewrite Tank slowdown to be based on damage rather than amount of bullets #87

Closed MattNF closed 9 years ago

jacob404 commented 9 years ago

+be fully adjustable per weapon, so we can decide how much slowdown each weapon does.

Attano commented 9 years ago

Summoning @jbzdarkid to provide his opinion. This can be used as base.

jbzdarkid commented 9 years ago

Ok, both water slowdown and tank slowdown in one plugin was confusing me. So I guess this is a pretty straightforward change, hook damage type to split out, and have cvars to control the ratio damage:slowdown per weapon.

Attano commented 9 years ago

I think the idea also includes the amount of damage being inflicted at the moment, e.g. two SMGs firing at once induce a higher slowdown than just one. Or an SMG being fired from a medium distance is inflicting less slowdown than one being fired in close quarters.

jbzdarkid commented 9 years ago

If the code at present works for multiple players shooting tank, then the code change I suggest will work for multiple uzis. The latter issue is I believe the problem this is trying to address.

jbzdarkid commented 9 years ago

This plugin is going to replace l4d_si_slowdown and waterslowdownduringtank.

Attano commented 9 years ago

I'm not very happy with how this plugin was redesigned. In its current state, it disregards completely the fact that there are other configs beside Promod. There should be a cvar to ignore all those per-weapon toggles for EQ, which is known to not use any slowdown. I also haven't checked in-game yet, but I think it even adds slowdown for non-Tank SI?..

if (IsTank(client)) {
        slowdown = 1-modifier*scale*GetConVarFloat(hCvarSdGunfireTank);
    } else {
        slowdown = 1-modifier*scale*GetConVarFloat(hCvarSdGunfireSi);
    }

Any real reason for that? SI slowdown was removed completely since Fresh.

MattNF commented 9 years ago

There are configs other than Promod? Kappa

jbzdarkid commented 9 years ago

If you want to remove all slowdown, set the slowdown CVAR to 0. 1 - modifier x scale x 0 = 1 which is no slowdown. 0 is complete slowdown.

Attano commented 9 years ago

Tested, the things I was worried about worked fine, however water slowdown during tank being set at 1 caused the survivors to be slower than a snail in the water. I'm going to edit the plugin to make it compatible with EQ.

jbzdarkid commented 9 years ago

I thought I had water slowdown off during tank. If not, please commit that change here.

MattNF commented 9 years ago

There should be water slowdown during Tank in Promod (reduced by 5%).

jbzdarkid commented 9 years ago

Well I guess that bit needs rewriting anyways. Probably change the CVAR to be "What is the reduction in water slowdown during tank" or similar.

Attano commented 9 years ago

Tank's speed in the water also got fucked up because there is no adjustment that was made in the ProcessConVar() function. In order to get rid of slowdown now I have to set that cvar to 1 instead of 0.

I'm gonna test a bit more to see if anything else broke, then adjust/fix it.

Edit

if (GetConVarBool(hCvarSdInwaterDuringTank) && tankInPlay) {
                ApplySlowdown(client, 0.0);

You actually have this in code and it causes the survivors to literally stop in the water... So it's not a cvar conflict, it's a mistake in code.

jbzdarkid commented 9 years ago

Oops, sorry. I'm busy atm, but I'll fix this one once I'm done with what I'm doing.

Attano commented 9 years ago

I got this, almost finished anyway, just need to test.

Attano commented 9 years ago

I have uploaded the source of the fixed version, but no binary(because I don't have this repo forked). Someone please compile and update: https://github.com/jacob404/promod-future/blob/master/addons/sourcemod/scripting/l4d2_slowdown_control.sp

l4d2_slowdown_water_survivors_during_tank is now a slowdown modifier cvar as well.

jbzdarkid commented 9 years ago

Why did you re-add GetActualValue? iirc, the way I had it was that 0.0 meant no slowdown, and 1.0 meant full slowdown. If you change what 0.0 does, then there's trouble.

Attano commented 9 years ago

I re-added it to keep the cvars intuitive. Otherwise it would be hard to know what -1, 0, 1 and 0.456 do without checking the code, which is problematic for those who can't do that.

-1: do nothing 0: no slowdown as in modifier 1.0 0.01-1.00: modifier

This isn't applied to weapon cvars, only to the main ones, because the weapon ones are ignored anyway if the main ones are -1 or 0.

If I did something wrong(haven't tested everything 100%), feel free to correct it, but check it twice this time so that we don't keep correcting each other in an endless loop.

jbzdarkid commented 9 years ago

Here's how I picture it works, and how I wrote my code:

No issues, just I feel like you're adding unneeded complexity by changing the cvar's value.

Edits because formatting is hard.

Attano commented 9 years ago

Well let's look at it this way then.

new Float:scale = 1.0;
new Float:modifier = 0.0;
...
decl Float:slowdown;
if (IsTank(client)) {
    slowdown = 1-modifier*scale*GetConVarFloat(hCvarSdGunfireTank);
} else {
    slowdown = 1-modifier*scale*GetConVarFloat(hCvarSdGunfireSi);
}
if (slowdown <= 1.0) { // If the cvar is set to -1, then the slowdown is > 1, and we should take no action.
    ApplySlowdown(client, slowdown);
}

Even if l4d2_slowdown_gunfire_tank is -1, any weapon cvar set at 0 will cause the slowdown variable to be 1.0 (-x * 0 = 0), and will thus remove any slowdown(instead of keeping it at the native level as it's supposed to).

Next, if the tank in water cvar is set to 0, then it will function differently from how its counterpart from the gunfire slowdown section does.

else if (IsInfected(client) && IsTank(client)) {
            ApplySlowdown(client, GetConVarFloat(hCvarSdInwaterTank));
        }

Tank stops in the water and dies there. Same for the survivor cvar.

I want no slowdown from bullets and no slowdown in the water for everyone.

How I do it with my version:

confogl_addcvar l4d2_slowdown_gunfire_si 0
confogl_addcvar l4d2_slowdown_gunfire_tank 0
confogl_addcvar l4d2_slowdown_water_tank 0
confogl_addcvar l4d2_slowdown_water_survivors 1.294 // *170=220, normal survivor speed
confogl_addcvar l4d2_slowdown_water_survivors_during_tank 0

How I would do it with your version:

confogl_addcvar l4d2_slowdown_gunfire_si 0
confogl_addcvar l4d2_slowdown_gunfire_tank 0
confogl_addcvar l4d2_slowdown_water_tank 1
confogl_addcvar l4d2_slowdown_water_survivors 1.294 // *170=220, normal survivor speed
confogl_addcvar l4d2_no_slowdown_during_tank 0

I guess this illustrates it pretty well.

jbzdarkid commented 9 years ago

I didn't realize those interactions; those changes seem fine. I'd rather that you not re-index the variable and just check its original value, though.

By which I mean, remove the GetActualValue and change if (slowdown == 1.0) to if (slowdown == 0.0).

Attano commented 9 years ago

Then I would have to do the same thing in the water function as well. I would actually have to do that no less than four different times, which is exactly the reason why I came up with this function.

jbzdarkid commented 9 years ago

I see what you're saying, do you see why I'm saying it makes the code harder to read? For cleanliness' sake the value should be changed within ApplySlowdown, though that leads to problems if we do ever want to apply 100% slowdown.

The problem being that looking at lines 152 and 156 it's not obvious why they're different functions.

Attano commented 9 years ago

I wouldn't say it makes it harder. At least for me. But to each his own.

The problem being that looking at lines 152 and 156 it's not obvious why they're different functions.

Well, think about it: l4d2_slowdown_water_survivors_during_tank is Promod's own meta. What sense does it make for it to accept both -1 and 0? With -1 it would do nothing, and with 0 it would... do nothing? And with anything above 0 it would finally do something. But if we let it go through GetActualValue() with 0, it will return 1.00, overriding l4d2_slowdown_water_survivors and breaking other configs.

So why not reduce it to just 0 and 0.01-1.00 and get rid of -1? Having to adjust the code a bit because of this is not a big price to pay. That's why comments exist! We put a // HACK HACK alert and sort out the confusion. Simple!