ZERO
06-26-2012, 11:07 PM
I am looking over the sourcecode for the core of the original wcs mod so that I can better understand the differences between that one and ours. This will allow me to possibly find things that may need to be fixed that we are not doing correctly.
So here is the findings:
// after this time (plus freezetime), ultimates can be used
"wcs_cfg_ulti_warmup" "10"
We currently do not have any default limit such as this...
// help for new players, give that levels
"wcs_cfg_newplayerbonus" "5"
We do not currently give free levels for first time players
// shotgun penalty, give that value in % less chance to activate player_hurt skills
"wcs_cfg_shotgunchance" "30"
This does not exist and should not be needed b/c of the way the OB update fucked shotguns
// take XP on using "resetskills", number in percent of current level XP
"wcs_cfg_resetskillspenalty" "10"
As the ranking uses xp we try to avoid at all costs taking xp from a player. Perhaps some sort of decrease on xp awards for the next X kills or something would balance it out? Could reduce xp awarded for the next 20 kills by 10% or something...
Here is the exact longjump code from the original:
if (server_var(wcs_longjump) != "0") do
{
if (server_var(wcs_longjump) < 1) then es_xset wcs_longjump 1
// calculate the new velocy for jumping
es_getplayerprop wcs_tmp event_var(userid) CCSPlayer.baseclass.localdata.m_vecVelocity[0]
es_math wcs_tmp * server_var(wcs_longjump)
es_getplayerprop wcs_tmp1 event_var(userid) CCSPlayer.baseclass.localdata.m_vecVelocity[1]
es_math wcs_tmp1 * server_var(wcs_longjump)
es_format wcs_tmp "%1,%2,0" server_var(wcs_tmp) server_var(wcs_tmp1)
es_setplayerprop event_var(userid) CBasePlayer.localdata.m_vecBaseVelocity server_var(wcs_tmp)
}
}
}
This is exactly what our races do now but we divide the multiplier effect by 2 first. However I have now found many sm plugins that use long jump multiplying by .25 instead of dividing by 2 like I do. This is the equlivlant of dividing by 4 which is similar to the divider value for the python jack. Solution is to change to multiply by .25 to correct the issue.
The following method runs every .1 second to process weapon restrections. Optimizations to this method may correct some bugs: (from War3Source_Engine_Weapon)
public Action:DeciSecondTimer(Handle:h,any:a){
timerskip--;
if(timerskip<1){
timerskip=10;
for(new client=1;client<=MaxClients;client++){
/*if(true){ //test
new wpnent = GetCurrentWeaponEnt(client);
if(FindSendPropOffs("CWeaponUSP","m_bSilencerOn")>0){
SetEntData(wpnent,FindSendPropOffs("CWeaponUSP","m_bSilencerOn"),true,true);
}
}*/
if(hasAnyRestriction[client]&&ValidPlayer(client,true)){
new String:name[32];
GetClientName(client,name,sizeof(name));
//PrintToChatAll("ValidPlayer %d",client);
new wpnent = GetCurrentWeaponEnt(client);
//PrintIfDebug(client," weapon ent %d %d",client,wpnent);
//new String:WeaponName[32];
//if(IsValidEdict(wpnent)){
// }
//PrintIfDebug(client," %s res: (%s) weapon: %s",name,weaponsAllowed[client],WeaponName);
// if(strlen(weaponsAllowed[client])>0){
if(wpnent>0&&IsValidEdict(wpnent)){
if (CheckCanUseWeapon(client,wpnent)){
//allow
}
else
{
//RemovePlayerItem(client,wpnent);
//PrintIfDebug(client," drop");
SDKCall(hSDKWeaponDrop, client, wpnent, false, false);
AcceptEntityInput(wpnent, "Kill");
//UTIL_Remove(wpnent);
}
}
else{
//PrintIfDebug(client,"no weapon");
//PrintToChatAll("no weapon");
}
// }
}
}
}
}
Here it is again with the code cleaned:
public Action:DeciSecondTimer(Handle:h,any:a)
{
timerskip--;
if(timerskip<1)
{
timerskip=10;
for(new client=1;client<=MaxClients;client++)
{
if(hasAnyRestriction[client]&&ValidPlayer(client,true))
{
new String:name[32];
GetClientName(client,name,sizeof(name));
new wpnent = GetCurrentWeaponEnt(client);
if(wpnent>0&&IsValidEdict(wpnent))
{
if(CheckCanUseWeapon(client,wpnent)){
//allow
}
else
{
SDKCall(hSDKWeaponDrop, client, wpnent, false, false);
AcceptEntityInput(wpnent, "Kill");
}
}
}
}
}
}
So here is the clusterfuck of wtf programing we have today. First part of the issue here is we have code that is designed to run on mutiple games which logically leads to errors. Sorry but it is best to use the best code for each game even if it takes more time. We already know that the code used above is not ideal for weapon removal. This is why we always try to remove the weapon before this code can activate b/c if it does it creates a glitch/crash. The ultimate solution would be to implement the correct weapon removal code here to correct the issue.
Next we have the issue of the timerskip--; part. Holy lazy fucking shit! So as we know this code runs every .1 seconds but you will see that this is here to make it so that it will skip 9 times and then run. So we get this:
0.0 seconds = run timerskip=10
0.1 seconds = skip timerskip=9
0.2 seconds = skip timerskip=8
0.3 seconds = skip timerskip=7
0.4 seconds = skip timerskip=6
0.5 seconds = skip timerskip=5
0.6 seconds = skip timerskip=4
0.7 seconds = skip timerskip=3
0.8 seconds = skip timerskip=2
0.9 seconds = skip timerskip=1
1.0 seconds = run timerskip=10
So how often does the program run? EVERY SECOND! So why they fuck not set the timer to 1 second. I will now tell you and I hope your sitting down. The programer decided this while working on the method but was too lazy to go back to the timer to change 0.1 to 1.0! YES that is the high qualtity programing we got here! Now I do not know who worked on this part of war3 if I remember correctly there was some other programers before Ownz took over everything b/c I doubt he would have done this as I know he is better than this.
So we will be fixing that shit.
Now onto order of fucking operations... yes we are reading from an array hasAnyRestriction[] beofre checking if the dam client we are checking for IS EVEN VALID while we are INSIDE OF A LOOP!!!!!!!
BUT IT GETS BETTER! We also have:
new String:name[32];
GetClientName(client,name,sizeof(name));
Which does, you guessed it NOTING. Not only is the string not being initilized as decl but it is totally worthless. WE ARE CREATING 32 slot arrays for every player in the server and storing their names in them every second for NO REASON. So that shit will be deleted!
One thing that is clear from reading over the sourcecode now that I actually know how to program. This shit is fucked up all over the pace. So here is the plan, after all the races get reprogramed I will then update to the latest war3 release. I will then go though every single line of all the war3 programes and reprogram every single one of them until 100% of all the code is fucking logicall and correct.
As I do not have any idea how to use the svn shit I will then just package my modified source and post it over on war3 for them to use to fix it for everyone. Hopefully they use it. If not at least our server will be really fucking stable.
So here is the findings:
// after this time (plus freezetime), ultimates can be used
"wcs_cfg_ulti_warmup" "10"
We currently do not have any default limit such as this...
// help for new players, give that levels
"wcs_cfg_newplayerbonus" "5"
We do not currently give free levels for first time players
// shotgun penalty, give that value in % less chance to activate player_hurt skills
"wcs_cfg_shotgunchance" "30"
This does not exist and should not be needed b/c of the way the OB update fucked shotguns
// take XP on using "resetskills", number in percent of current level XP
"wcs_cfg_resetskillspenalty" "10"
As the ranking uses xp we try to avoid at all costs taking xp from a player. Perhaps some sort of decrease on xp awards for the next X kills or something would balance it out? Could reduce xp awarded for the next 20 kills by 10% or something...
Here is the exact longjump code from the original:
if (server_var(wcs_longjump) != "0") do
{
if (server_var(wcs_longjump) < 1) then es_xset wcs_longjump 1
// calculate the new velocy for jumping
es_getplayerprop wcs_tmp event_var(userid) CCSPlayer.baseclass.localdata.m_vecVelocity[0]
es_math wcs_tmp * server_var(wcs_longjump)
es_getplayerprop wcs_tmp1 event_var(userid) CCSPlayer.baseclass.localdata.m_vecVelocity[1]
es_math wcs_tmp1 * server_var(wcs_longjump)
es_format wcs_tmp "%1,%2,0" server_var(wcs_tmp) server_var(wcs_tmp1)
es_setplayerprop event_var(userid) CBasePlayer.localdata.m_vecBaseVelocity server_var(wcs_tmp)
}
}
}
This is exactly what our races do now but we divide the multiplier effect by 2 first. However I have now found many sm plugins that use long jump multiplying by .25 instead of dividing by 2 like I do. This is the equlivlant of dividing by 4 which is similar to the divider value for the python jack. Solution is to change to multiply by .25 to correct the issue.
The following method runs every .1 second to process weapon restrections. Optimizations to this method may correct some bugs: (from War3Source_Engine_Weapon)
public Action:DeciSecondTimer(Handle:h,any:a){
timerskip--;
if(timerskip<1){
timerskip=10;
for(new client=1;client<=MaxClients;client++){
/*if(true){ //test
new wpnent = GetCurrentWeaponEnt(client);
if(FindSendPropOffs("CWeaponUSP","m_bSilencerOn")>0){
SetEntData(wpnent,FindSendPropOffs("CWeaponUSP","m_bSilencerOn"),true,true);
}
}*/
if(hasAnyRestriction[client]&&ValidPlayer(client,true)){
new String:name[32];
GetClientName(client,name,sizeof(name));
//PrintToChatAll("ValidPlayer %d",client);
new wpnent = GetCurrentWeaponEnt(client);
//PrintIfDebug(client," weapon ent %d %d",client,wpnent);
//new String:WeaponName[32];
//if(IsValidEdict(wpnent)){
// }
//PrintIfDebug(client," %s res: (%s) weapon: %s",name,weaponsAllowed[client],WeaponName);
// if(strlen(weaponsAllowed[client])>0){
if(wpnent>0&&IsValidEdict(wpnent)){
if (CheckCanUseWeapon(client,wpnent)){
//allow
}
else
{
//RemovePlayerItem(client,wpnent);
//PrintIfDebug(client," drop");
SDKCall(hSDKWeaponDrop, client, wpnent, false, false);
AcceptEntityInput(wpnent, "Kill");
//UTIL_Remove(wpnent);
}
}
else{
//PrintIfDebug(client,"no weapon");
//PrintToChatAll("no weapon");
}
// }
}
}
}
}
Here it is again with the code cleaned:
public Action:DeciSecondTimer(Handle:h,any:a)
{
timerskip--;
if(timerskip<1)
{
timerskip=10;
for(new client=1;client<=MaxClients;client++)
{
if(hasAnyRestriction[client]&&ValidPlayer(client,true))
{
new String:name[32];
GetClientName(client,name,sizeof(name));
new wpnent = GetCurrentWeaponEnt(client);
if(wpnent>0&&IsValidEdict(wpnent))
{
if(CheckCanUseWeapon(client,wpnent)){
//allow
}
else
{
SDKCall(hSDKWeaponDrop, client, wpnent, false, false);
AcceptEntityInput(wpnent, "Kill");
}
}
}
}
}
}
So here is the clusterfuck of wtf programing we have today. First part of the issue here is we have code that is designed to run on mutiple games which logically leads to errors. Sorry but it is best to use the best code for each game even if it takes more time. We already know that the code used above is not ideal for weapon removal. This is why we always try to remove the weapon before this code can activate b/c if it does it creates a glitch/crash. The ultimate solution would be to implement the correct weapon removal code here to correct the issue.
Next we have the issue of the timerskip--; part. Holy lazy fucking shit! So as we know this code runs every .1 seconds but you will see that this is here to make it so that it will skip 9 times and then run. So we get this:
0.0 seconds = run timerskip=10
0.1 seconds = skip timerskip=9
0.2 seconds = skip timerskip=8
0.3 seconds = skip timerskip=7
0.4 seconds = skip timerskip=6
0.5 seconds = skip timerskip=5
0.6 seconds = skip timerskip=4
0.7 seconds = skip timerskip=3
0.8 seconds = skip timerskip=2
0.9 seconds = skip timerskip=1
1.0 seconds = run timerskip=10
So how often does the program run? EVERY SECOND! So why they fuck not set the timer to 1 second. I will now tell you and I hope your sitting down. The programer decided this while working on the method but was too lazy to go back to the timer to change 0.1 to 1.0! YES that is the high qualtity programing we got here! Now I do not know who worked on this part of war3 if I remember correctly there was some other programers before Ownz took over everything b/c I doubt he would have done this as I know he is better than this.
So we will be fixing that shit.
Now onto order of fucking operations... yes we are reading from an array hasAnyRestriction[] beofre checking if the dam client we are checking for IS EVEN VALID while we are INSIDE OF A LOOP!!!!!!!
BUT IT GETS BETTER! We also have:
new String:name[32];
GetClientName(client,name,sizeof(name));
Which does, you guessed it NOTING. Not only is the string not being initilized as decl but it is totally worthless. WE ARE CREATING 32 slot arrays for every player in the server and storing their names in them every second for NO REASON. So that shit will be deleted!
One thing that is clear from reading over the sourcecode now that I actually know how to program. This shit is fucked up all over the pace. So here is the plan, after all the races get reprogramed I will then update to the latest war3 release. I will then go though every single line of all the war3 programes and reprogram every single one of them until 100% of all the code is fucking logicall and correct.
As I do not have any idea how to use the svn shit I will then just package my modified source and post it over on war3 for them to use to fix it for everyone. Hopefully they use it. If not at least our server will be really fucking stable.