The truth about xCoop v1.92
Posted: Tue Jan 01, 2008 9:38 am
-
forums, downloads, community, support and development for Unreal, UnrealTournament and other UnrealEngine 1/2 based games
https://www.oldunreal.com/phpBB3/
Code: Select all
var bool bIsReallyWalking; //Different Walk flag.
var bool bCrouchStep; //To prevent telefragging from crouching.
var bool bWalkingStep; //Switch walking speed and vice versa.
var bool bCrouchChanging; //Changes the collision stuff, duh.
var float OldGroundSpeed,OldJumpZ,OldAccelRate,OldWaterSpeed,OldAirSpeed; //Old movement, used in walk changes.
Code: Select all
//==============
// Encroachment
event bool EncroachingOn( actor Other )
{
if ( bCrouchStep )
return true;
if ( (Other.Brush != None) || (Brush(Other) != None) )
return true;
if ( (!bIsPlayer || bWarping) && (Pawn(Other) != None))
return true;
return false;
}
function RemoteHandleCrouch()
{
local float CrouchHeight;
local vector CrouchLocation; //Defineing this because Sweeny made errors when using a simple float as a value in a vect() FUCK YOU SWEENY!
if( Level.NetMode != NM_Standalone )
return;
CrouchHeight = Default.CollisionHeight * 0.65;
CrouchLocation.X = 0.000000;
CrouchLocation.Y = 0.000000;
CrouchLocation.Z = Default.CollisionHeight - CrouchHeight;
if( (bIsCrouching) && !bCrouchChanging )
{
PrePivot = vect(0,0,1) * (Default.CollisionHeight - CrouchHeight);
SetCollisionSize(0.000000, 0.000000);
SetCollision(false,false,false);
bCollideWorld = false;
bCrouchStep = true;
SetLocation(Location-CrouchLocation);
bCrouchStep = false;
SetCollisionSize(Default.CollisionRadius, CrouchHeight);
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bCrouchChanging = true;
}
else if( (!bIsCrouching) && bCrouchChanging )
{
PrePivot = Default.PrePivot;
SetCollisionSize(0.000000, 0.000000);
SetCollision(false,false,false);
bCollideWorld = false;
bCrouchStep = true;
SetLocation(Location+CrouchLocation);
bCrouchStep = false;
SetCollisionSize(Default.CollisionRadius, Default.CollisionHeight);
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bCrouchChanging = False;
}
}
function HandleCrouch()
{
local float CrouchHeight;
local vector CrouchLocation; //Defineing this because Sweeny made errors when using a simple float as a value in a vect() FUCK YOU SWEENY!
if( (Role < ROLE_Authority) || (Level.NetMode != NM_DedicatedServer) )
return;
CrouchHeight = Default.CollisionHeight * 0.65;
CrouchLocation.X = 0.000000;
CrouchLocation.Y = 0.000000;
CrouchLocation.Z = Default.CollisionHeight - CrouchHeight;
if( (bIsCrouching) && !bCrouchChanging )
{
PrePivot = vect(0,0,1) * (Default.CollisionHeight - CrouchHeight);
SetCollisionSize(0.000000, 0.000000);
SetCollision(false,false,false);
bCollideWorld = false;
bCrouchStep = true;
SetLocation(Location-CrouchLocation);
bCrouchStep = false;
SetCollisionSize(Default.CollisionRadius, CrouchHeight);
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bCrouchChanging = true;
}
else if( (!bIsCrouching) && bCrouchChanging )
{
PrePivot = Default.PrePivot;
SetCollisionSize(0.000000, 0.000000);
SetCollision(false,false,false);
bCollideWorld = false;
bCrouchStep = true;
SetLocation(Location+CrouchLocation);
bCrouchStep = false;
SetCollisionSize(Default.CollisionRadius, Default.CollisionHeight);
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bCrouchChanging = False;
}
}
simulated function ClientHandleCrouch()
{
local float CrouchHeight;
local vector CrouchLocation; //Defineing this because Sweeny made errors when using a simple float as a value in a vect() FUCK YOU SWEENY!
if( (Role >= ROLE_Authority) || (Level.NetMode != NM_Client) )
return;
CrouchHeight = Default.CollisionHeight * 0.65;
CrouchLocation.X = 0.000000;
CrouchLocation.Y = 0.000000;
CrouchLocation.Z = Default.CollisionHeight - CrouchHeight;
if( (bIsCrouching) && !bCrouchChanging )
{
PrePivot = vect(0,0,1) * (Default.CollisionHeight - CrouchHeight);
SetCollisionSize(0.000000, 0.000000);
SetCollision(false,false,false);
bCollideWorld = false;
bCrouchStep = true;
SetLocation(Location-CrouchLocation);
bCrouchStep = false;
SetCollisionSize(Default.CollisionRadius, CrouchHeight);
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bCrouchChanging = true;
}
else if( (!bIsCrouching) && bCrouchChanging )
{
PrePivot = Default.PrePivot;
SetCollisionSize(0.000000, 0.000000);
SetCollision(false,false,false);
bCollideWorld = false;
bCrouchStep = true;
SetLocation(Location+CrouchLocation);
bCrouchStep = false;
SetCollisionSize(Default.CollisionRadius, Default.CollisionHeight);
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bCrouchChanging = False;
}
}
//To bad Epic never had a hint from Valve and their Half-Life game.
// DUCK JUMPING!
//Player Jumped
function DoJump( optional float F )
{
if ( CarriedDecoration != None )
return;
if ( Physics == PHYS_Walking )
{
if ( Role == ROLE_Authority )
PlaySound(JumpSound, SLOT_Talk, 1.5, true, 1200, 1.0 );
if ( (Level.Game != None) && (Level.Game.Difficulty > 0) )
MakeNoise(0.1 * Level.Game.Difficulty);
PlayInAir();
if ( bCountJumps && (Role == ROLE_Authority) )
Inventory.OwnerJumped();
Velocity.Z = JumpZ;
if ( Base != Level )
Velocity.Z += Base.Velocity.Z;
SetPhysics(PHYS_Falling);
}
}
Code: Select all
// Physics Changes.
function HandleWalking()
{
local rotator carried;
//Bla blah bla. BLAH BBLABH BLAH Blah BLAH blah!! NO BLAH BLAH BLAH!
Default.bAvoidLedges = false;
Default.bStopAtLedges = false;
bAvoidLedges = false;
bStopAtLedges = false;
Default.bIsWalking = false;
bIsWalking = false; //Never do this, screw this!
bIsReallyWalking = ((bRun != 0) || (bDuck != 0)) && !Region.Zone.IsA('WarpZoneInfo');
// HERE IS THE BIG PART!
if( (bIsReallyWalking) && !bWalkingStep )
{
OldGroundSpeed = GroundSpeed;
OldJumpZ = JumpZ;
OldAccelRate = AccelRate;
OldWaterSpeed = WaterSpeed;
OldAirSpeed = AirSpeed;
// Cut everything in half!
GroundSpeed = GroundSpeed * 0.25;
JumpZ = JumpZ * 0.75; //Exception.
AccelRate = AccelRate * 0.25;
WaterSpeed = WaterSpeed * 0.25;
AirSpeed = AirSpeed * 0.25;
bWalkingStep = true;
}
else if( (!bIsReallyWalking) && bWalkingStep )
{
// I don't know why it would be less than or equal to 0 but just in case.
if( OldGroundSpeed 0.1) )
PlayDuck();
}
}
}
event PlayerTick( float DeltaTime )
{
if( Level.NetMode == NM_Standalone )
RemoteHandleCrouch();
else if( Level.NetMode == NM_DedicatedServer )
HandleCrouch();
else if( Level.NetMode == NM_Client )
ClientHandleCrouch();
if ( bUpdatePosition )
ClientUpdatePosition();
PlayerMove(DeltaTime);
}
function PlayerMove( float DeltaTime )
{
local vector X,Y,Z, NewAccel;
local EDodgeDir OldDodge;
local eDodgeDir DodgeMove;
local rotator OldRotation;
local float Speed2D;
local bool bSaveJump;
local name AnimGroupName;
if( Level.NetMode == NM_Standalone )
RemoteHandleCrouch();
else if( Level.NetMode == NM_DedicatedServer )
HandleCrouch();
else if( Level.NetMode == NM_Client )
ClientHandleCrouch();
GetAxes(Rotation,X,Y,Z);
aForward *= 0.4;
aStrafe *= 0.4;
aLookup *= 0.24;
aTurn *= 0.24;
// Update acceleration.
NewAccel = aForward*X + aStrafe*Y;
NewAccel.Z = 0;
// Check for Dodge move
if ( DodgeDir == DODGE_Active )
DodgeMove = DODGE_Active;
else
DodgeMove = DODGE_None;
if (DodgeClickTime > 0.0)
{
if ( DodgeDir < DODGE_Active )
{
OldDodge = DodgeDir;
DodgeDir = DODGE_None;
if (bEdgeForward && bWasForward)
DodgeDir = DODGE_Forward;
if (bEdgeBack && bWasBack)
DodgeDir = DODGE_Back;
if (bEdgeLeft && bWasLeft)
DodgeDir = DODGE_Left;
if (bEdgeRight && bWasRight)
DodgeDir = DODGE_Right;
if ( DodgeDir == DODGE_None)
DodgeDir = OldDodge;
else if ( DodgeDir != OldDodge )
DodgeClickTimer = DodgeClickTime + 0.5 * DeltaTime;
else
DodgeMove = DodgeDir;
}
if (DodgeDir == DODGE_Done)
{
DodgeClickTimer -= DeltaTime;
if (DodgeClickTimer < -0.35)
{
DodgeDir = DODGE_None;
DodgeClickTimer = DodgeClickTime;
}
}
else if ((DodgeDir != DODGE_None) && (DodgeDir != DODGE_Active))
{
DodgeClickTimer -= DeltaTime;
if (DodgeClickTimer < 0)
{
DodgeDir = DODGE_None;
DodgeClickTimer = DodgeClickTime;
}
}
}
AnimGroupName = GetAnimGroup(AnimSequence);
if ( (Physics == PHYS_Walking) && (AnimGroupName != 'Dodge') )
{
//if walking, look up/down stairs - unless player is rotating view
if ( !bKeyboardLook && (bLook == 0) )
{
if ( bLookUpStairs )
ViewRotation.Pitch = FindStairRotation(deltaTime);
else if ( bCenterView )
{
ViewRotation.Pitch = ViewRotation.Pitch & 65535;
if (ViewRotation.Pitch > 32768)
ViewRotation.Pitch -= 65536;
ViewRotation.Pitch = ViewRotation.Pitch * (1 - 12 * FMin(0.0833, deltaTime));
if ( Abs(ViewRotation.Pitch) < 1000 )
ViewRotation.Pitch = 0;
}
}
Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
//add bobbing when walking
if ( !bShowMenu )
{
if ( Speed2D < 10 )
BobTime += 0.2 * DeltaTime;
else
BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/GroundSpeed);
WalkBob = Y * 0.65 * Bob * Speed2D * sin(6.0 * BobTime);
if ( Speed2D < 10 )
WalkBob.Z = Bob * 30 * sin(12 * BobTime);
else
WalkBob.Z = Bob * Speed2D * sin(12 * BobTime);
}
}
else if ( !bShowMenu )
{
BobTime = 0;
WalkBob = WalkBob * (1 - FMin(1, 8 * deltatime));
}
// Update rotation.
OldRotation = Rotation;
UpdateRotation(DeltaTime, 1);
if ( bPressedJump && (AnimGroupName == 'Dodge') )
{
bSaveJump = true;
bPressedJump = false;
}
else
bSaveJump = false;
if ( Role < ROLE_Authority ) // then save this move and replicate it
ReplicateMove(DeltaTime, NewAccel, DodgeMove, OldRotation - Rotation);
else
ProcessMove(DeltaTime, NewAccel, DodgeMove, OldRotation - Rotation);
bPressedJump = bSaveJump;
}
function BeginState()
{
SetCollisionSize( Default.CollisionRadius, Default.CollisionHeight );
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bProjTarget = Default.bProjTarget;
WalkBob = vect(0,0,0);
DodgeDir = DODGE_None;
bIsCrouching = false;
bIsTurning = false;
bPressedJump = false;
if (Physics != PHYS_Falling) SetPhysics(PHYS_Walking);
if ( !IsAnimating() )
PlayWaiting();
}
function EndState()
{
SetCollisionSize( Default.CollisionRadius, Default.CollisionHeight );
SetCollision( Default.bCollideActors, Default.bBlockActors, Default.bBlockPlayers );
bCollideWorld = Default.bCollideWorld;
bProjTarget = Default.bProjTarget;
WalkBob = vect(0,0,0);
bIsCrouching = false;
}
}Lol, you explain to me, how could that NOT be a compliment?That better be a compliment... If it's sarcasm I'm going to be extremely mad with you...Nice.
-
Yeah... about all that I posted (aside from the code) You can ignore that, I was feeling rather depressed. I should edit it.... I had no idea what I was thinking at the moment so sorry.this is getting more and more interesting every day...
Anyway, I'm no judge in this matter, and I'm obviously not able to tell if this is the truth or not.
So I don't judge and won't judge, because I can't judge.
For my part I won't say anything about that, and will look into this code.
Anyways, If you DO look into the code, I hope you didn't change anything drastic in Unreal's collision system, I saw someone post "Hixboxes?" in the 227 bug reports. That made me think that the crouch code would bust.
Thanks for considering.
- Fenix