From b6e47728afc79748b62ab0f7036b838b09f1a666 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Thu, 22 Oct 2020 15:02:44 -0400 Subject: [PATCH 1/7] Obj instead of Globals --- Classic/scripts/autoexec/Autobalance.cs | 39 ++++++++++++++----------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Classic/scripts/autoexec/Autobalance.cs b/Classic/scripts/autoexec/Autobalance.cs index e1f365f..088ecbb 100644 --- a/Classic/scripts/autoexec/Autobalance.cs +++ b/Classic/scripts/autoexec/Autobalance.cs @@ -60,11 +60,14 @@ function Autobalance( %game ) //Select lower half of team rank as canidates for team change if(!$Autobalance::UseAllMode) { + //Reset clients canidate var + ResetABClients(); + $Autobalance::Max = mFloor($TeamRank[$BigTeam, count]/2); for(%i = $Autobalance::Max; %i < $TeamRank[$BigTeam, count]; %i++) { //echo("[Autobalance]: Selected" SPC $TeamRank[$BigTeam, %i].nameBase @ ", " @ %i); - $Autobalance::Canidate[%i] = $TeamRank[$BigTeam, %i]; + $TeamRank[$BigTeam, %i].abCanidate = true; } %a = " selected"; } @@ -76,18 +79,12 @@ function Autobalance( %game ) messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance will switch the next%3 respawning player%2 on Team %1.', $TeamName[$BigTeam], %s, %a); } -// Return true if client is a canidate -function CheckCanidate(%client) +function ResetABClients() { - if(!$Autobalance::UseAllMode) + for(%i = 0; %i < $TeamRank[$BigTeam, count]; %i++) { - for(%i = $Autobalance::Max; %i < $TeamRank[$BigTeam, count]; %i++) - { - if(%client $= $Autobalance::Canidate[%i]) - return true; - } + $TeamRank[$BigTeam, %i].abCanidate = false; } - return false; } package Autobalance @@ -103,13 +100,13 @@ function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, % if($TeamRank[$BigTeam, count] - $TeamRank[%otherTeam, count] >= 2) { %fallback = 0; - if($Autobalance::CanidateFallbackTime $= "") - $Autobalance::CanidateFallbackTime = getSimTime(); - else if((getSimTime() - $Autobalance::CanidateFallbackTime) < $Autobalance::Fallback) + if($Autobalance::FallbackTime $= "") + $Autobalance::FallbackTime = getSimTime(); + else if((getSimTime() - $Autobalance::FallbackTime) < $Autobalance::Fallback) %fallback = 1; //damageType 0: If someone switches to observer or disconnects - if(%damageType !$= 0 && (CheckCanidate(%clVictim) || $Autobalance::UseAllMode || %fallback)) + if(%damageType !$= 0 && (%clVictim.abCanidate || $Autobalance::UseAllMode || %fallback)) { echo("[Autobalance]" SPC %clVictim.nameBase @ " has been moved to Team " @ %otherTeam @ " for balancing. [AM:" @ $Autobalance::UseAllMode SPC "#BT:" @ ($TeamRank[$BigTeam, count]-1) SPC "#OT:" @ ($TeamRank[%otherTeam, count]+1) SPC "FB:" @ %fallback @ "]"); messageClient(%clVictim, 'MsgTeamBalanceNotify', '\c0You were switched to Team %1 for balancing.~wfx/powered/vehicle_screen_on.wav', $TeamName[%otherTeam]); @@ -120,9 +117,10 @@ function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, % } else { - $BigTeam = ""; + ResetABClients(); ResetTBNStatus(); - deleteVariables("$Autobalace::Canidate*"); + $Autobalance::FallbackTime = ""; + $BigTeam = ""; } } } @@ -133,7 +131,14 @@ function DefaultGame::gameOver(%game) //Reset Autobalance $BigTeam = ""; - deleteVariables("$Autobalace::Canidate*"); + $Autobalance::FallbackTime = ""; + + //Reset all clients canidate var + for (%i = 0; %i < ClientGroup.getCount(); %i++) + { + %client = ClientGroup.getObject(%i); + %client.abCanidate = false; + } } }; From 486aa2d6f6c55e3a12d7b0ea4b44141f5729c719 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Thu, 22 Oct 2020 15:32:41 -0400 Subject: [PATCH 2/7] Moved --- Classic/scripts/autoexec/Autobalance.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classic/scripts/autoexec/Autobalance.cs b/Classic/scripts/autoexec/Autobalance.cs index 088ecbb..fdd1abd 100644 --- a/Classic/scripts/autoexec/Autobalance.cs +++ b/Classic/scripts/autoexec/Autobalance.cs @@ -33,6 +33,7 @@ function Autobalance( %game ) return; $Autobalance::UseAllMode = 0; + $Autobalance::FallbackTime = ""; %otherTeam = $BigTeam == 1 ? 2 : 1; $Autobalance::AMThreshold = mCeil(MissionGroup.CTF_scoreLimit/3) * 100; @@ -119,7 +120,6 @@ function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, % { ResetABClients(); ResetTBNStatus(); - $Autobalance::FallbackTime = ""; $BigTeam = ""; } } @@ -131,7 +131,6 @@ function DefaultGame::gameOver(%game) //Reset Autobalance $BigTeam = ""; - $Autobalance::FallbackTime = ""; //Reset all clients canidate var for (%i = 0; %i < ClientGroup.getCount(); %i++) From 2082b95858c0f58c1c66276c7d3b33b733e96db3 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Thu, 22 Oct 2020 15:58:38 -0400 Subject: [PATCH 3/7] Added cmdArmor patch --- Classic/scripts/autoexec/MemPatches.cs | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Classic/scripts/autoexec/MemPatches.cs b/Classic/scripts/autoexec/MemPatches.cs index db77650..15f3acf 100644 --- a/Classic/scripts/autoexec/MemPatches.cs +++ b/Classic/scripts/autoexec/MemPatches.cs @@ -24,4 +24,36 @@ function suppressTraversalRootPatch() memPatch("56AD8A", "90909090909090909090909090909090909090909090"); memPatch("56D114", "90909090909090909090909090909090909090909090"); $tvpatched = 1; +} + +if (!$CmdArmor::Patched) +{ + $CmdArmor::Patched = true; + //memPatch("6FC746", "66B8000090906683FE017408ACAA84C075FA89D05F5EC3"); + memPatch("6FC746", "83FE017408ACAA84C075FA89D05F5EC3"); + //Removed register size override (cmp si, 1 -> cmp esi, 1) and got rid of + //weird NASM garbage code at the beginning. Had a mov ax, 0 which did nothing + //and wasn't necessary anyways because of xor eax, eax in the original. It also + //generated several NOPs after that for no reason. +} + +function serverCmd(%client) +{ + // Stick your own administrative action code here + messageAll('msgAll',"\c3" @ %client.namebase SPC "is attempting to crash the server!"); + + messageClient(%client, 'onClientBanned', ""); + messageAllExcept( %client, -1, 'MsgClientDrop', "", %client.name, %client ); + + // kill and delete this client + if( isObject(%client.player) ) + %client.player.scriptKill(0); + + if ( isObject( %client ) ) + { + %client.setDisconnectReason("You have been banned for attempting to crash the server."); + %client.schedule(700, "delete"); + } + + BanList::add(%client.guid, %client.getAddress(), $Host::BanTime); } \ No newline at end of file From 90949fb401a3c2b7b882e277ccca455157383184 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Sat, 24 Oct 2020 17:48:20 -0400 Subject: [PATCH 4/7] No Flag Zone added --- Classic/scripts/autoexec/NoFlagZone.cs | 105 +++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Classic/scripts/autoexec/NoFlagZone.cs diff --git a/Classic/scripts/autoexec/NoFlagZone.cs b/Classic/scripts/autoexec/NoFlagZone.cs new file mode 100644 index 0000000..a96b6b4 --- /dev/null +++ b/Classic/scripts/autoexec/NoFlagZone.cs @@ -0,0 +1,105 @@ +//exec("scripts/autoexec/NoFlagZone.cs"); +$TurleCampTime = 10000; //10secs + +function CTFGame::onEnterTrigger(%game, %triggerName, %data, %obj, %colobj) +{ + %client = %colobj.client; + switch$(%obj.type) + { + case NOFLAGZONE: + if(%client.player.holdingFlag !$= "" && $Host::NoBaseRapePlayerCount > $TotalTeamPlayerCount && %obj.team == %client.team) + { + //%colobj.throwObject(%colobj.holdingFlag); + CTFGame::zoneTossFlag(%game, %colobj, %obj); + } + + case TURTLEDAMAGE: + if(%client.player.holdingFlag !$= "") + { + //schedule a warning in 10 seconds + %client = %colobj.client; + %client.turtledamage = 1; + %client.campingThread = %game.schedule($TurleCampTime, "CampingDamage", %client, true); + } + } +} + +function CTFGame::zoneTossFlag(%game, %player, %obj) +{ + // ------------------------------------------------------------------------------ + // z0dd - ZOD - SquirrelOfDeath, 9/27/02. Delay on grabbing flag after tossing it + %player.flagTossWait = true; + %player.schedule(1500, resetFlagTossWait); + // ------------------------------------------------------------------------------ + + %client = %player.client; + %flag = %player.holdingFlag; + %flag.setVelocity("0 0 0"); + %flag.setTransform(%player.getWorldBoxCenter()); + %flag.setCollisionTimeout(%player); + + %held = %game.formatTime(getSimTime() - %game.flagHeldTime[%flag], false); // z0dd - ZOD, 8/15/02. How long did player hold flag? + + if($Host::ClassicEvoStats) + %game.totalFlagHeldTime[%flag] = 0; + + %game.playerDroppedFlag(%player); + + //Need home to be away from the trigger box location + %vec = vectorNormalize(vectorSub(%player.getWorldBoxCenter(),%obj.getWorldBoxCenter())); + + // normalize the vector, scale it, and add an extra "upwards" component + %vecNorm = VectorNormalize(%vec); + %vec = VectorScale(%vecNorm, 1000); + %vec = vectorAdd(%vec, "0 0 300"); + + // z0dd - ZOD, 6/09/02. Remove anti-hover so flag can be thrown properly + %flag.static = false; + + // z0dd - ZOD, 10/02/02. Hack for flag collision bug. + %flag.searchSchedule = %game.schedule(10, "startFlagCollisionSearch", %flag); + + // apply the impulse to the flag object + %flag.applyImpulse(%obj.getWorldBoxCenter(), %vec); + + // z0dd - ZOD 3/30/02. Above message was sending the wrong varible to objective hud. + messageClient(%player.client, 'MsgCTFFlagDropped', '\c1You are not allowed to have the flag in this area. (Held: %4)~wfx/misc/flag_drop.wav', %client.name, 0, %flag.team, %held); // Yogi, 8/18/02. 3rd param changed 0 -> %client.name + logEcho(%player.client.nameBase@" (pl "@%player@"/cl "@%player.client@") lost flag (No flag zone)"@" (Held: "@%held@")"); +} + +function CTFGame::onLeaveTrigger(%game, %triggerName, %data, %obj, %colobj) +{ + %client.turtledamage = 0; + %client = %colobj.client; + cancel(%client.campingThread); +} + +function CTFGame::CampingDamage(%game, %client, %firstWarning) +{ + %player = %client.player; + + if(isEventPending(%client.campingThread)) + cancel(%client.campingThread); + + //make sure we're still alive... + if (!isObject(%player) || %player.getState() $= "Dead") + return; + + //if the match hasn't yet started, don't warn or apply damage yet... + if (!$MatchStarted) + { + %client.campingThread = %game.schedule($TurleCampTime / 2, "CampingDamage", %client, true); + } + else if (%firstWarning) + { + messageClient(%client, 'MsgHuntersNoCampZone', '\c2No turtling inside the base.', 1); + %client.campingThread = %game.schedule($TurleCampTime / 2, "CampingDamage", %client, false); + } + else if(%client.turtledamage) + { + %player.setDamageFlash(0.1); + %player.damage(0, %player.position, 0.05, $DamageType::NexusCamping); + %client.campingThread = %game.schedule(1000, "CampingDamage", %client, false); + } + +} \ No newline at end of file From 7490f4bc300054cf5c4d3ad382fd846bc18176c6 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Sun, 25 Oct 2020 13:46:33 -0400 Subject: [PATCH 5/7] More Time More time for ServerJoin ObserverKick Observer only for missionLoadDone check --- Classic/scripts/defaultGame.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Classic/scripts/defaultGame.cs b/Classic/scripts/defaultGame.cs index bef4749..15c83c7 100644 --- a/Classic/scripts/defaultGame.cs +++ b/Classic/scripts/defaultGame.cs @@ -1824,18 +1824,22 @@ function DefaultGame::clientMissionDropReady(%game, %client) for(%i = 1; %i <= 13; %i++) $stats::weapon_damage[%client, %i] = ""; - if(!%client.isAdmin && !$Host::TournamentMode && $Host::KickObserverTimeout) + if(%client.team $=0) //Observer only { - if(isEventPending(%client.okschedule)) - cancel(%client.okschedule); - - %minutes = $Host::KickObserverTimeout / 60; - //messageClient(%client, 'MsgNoObservers', '\c2You have %1 minutes to join the game or you will be kicked.', %minutes); - - %key = mFloor(getRandom() * 1000); - %client.okkey = %key; - - %client.okschedule = schedule(($Host::KickObserverTimeout * 1000), 0, "cmdAutoKickObserver", %client, %key); + if(!%client.isAdmin && !$Host::TournamentMode && $Host::KickObserverTimeout) + { + if(isEventPending(%client.okschedule)) + cancel(%client.okschedule); + + %time = ($Host::KickObserverTimeout) + ($Host::KickObserverTimeout/2); + //%minutes = %time / 60; + //messageClient(%client, 'MsgNoObservers', '\c2You have %1 minutes to join the game or you will be kicked.', %minutes); + + %key = mFloor(getRandom() * 1000); + %client.okkey = %key; + + %client.okschedule = schedule((%time * 1000), 0, "cmdAutoKickObserver", %client, %key); + } } } From 09c5a104b24bfcaebb29deca0b272c0b677f530c Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Fri, 30 Oct 2020 13:29:59 -0400 Subject: [PATCH 6/7] Lowered Wait Time NFZ --- Classic/scripts/autoexec/NoFlagZone.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classic/scripts/autoexec/NoFlagZone.cs b/Classic/scripts/autoexec/NoFlagZone.cs index a96b6b4..ac81461 100644 --- a/Classic/scripts/autoexec/NoFlagZone.cs +++ b/Classic/scripts/autoexec/NoFlagZone.cs @@ -13,6 +13,7 @@ function CTFGame::onEnterTrigger(%game, %triggerName, %data, %obj, %colobj) CTFGame::zoneTossFlag(%game, %colobj, %obj); } + //Has issues case TURTLEDAMAGE: if(%client.player.holdingFlag !$= "") { @@ -29,7 +30,7 @@ function CTFGame::zoneTossFlag(%game, %player, %obj) // ------------------------------------------------------------------------------ // z0dd - ZOD - SquirrelOfDeath, 9/27/02. Delay on grabbing flag after tossing it %player.flagTossWait = true; - %player.schedule(1500, resetFlagTossWait); + %player.schedule(1000, resetFlagTossWait); // ------------------------------------------------------------------------------ %client = %player.client; From 407667aaeaa3687c930834e76e8c55955c4f3a68 Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Sat, 31 Oct 2020 12:10:05 -0400 Subject: [PATCH 7/7] NFZ Mempatch Collision MemPatch to fix collision with item thru zones --- Classic/scripts/autoexec/NoFlagZone.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Classic/scripts/autoexec/NoFlagZone.cs b/Classic/scripts/autoexec/NoFlagZone.cs index ac81461..29adcab 100644 --- a/Classic/scripts/autoexec/NoFlagZone.cs +++ b/Classic/scripts/autoexec/NoFlagZone.cs @@ -1,6 +1,11 @@ //exec("scripts/autoexec/NoFlagZone.cs"); $TurleCampTime = 10000; //10secs +//Trigger Zone Collision Patch +//MemPatch so mines, grenades, and flags +//Dont interact with the trigger zone +memPatch("604358","0C"); + function CTFGame::onEnterTrigger(%game, %triggerName, %data, %obj, %colobj) { %client = %colobj.client;