Page 1 of 1

Dodging

Posted: Wed Mar 14, 2007 12:44 pm
by lord_kungai
Hi people. Long time no write...



I'm trying to make a mutator...


Again...


Which changes the dodging dynamics of the player. Can someone just help me out here. I've got the function ready and waiting. However, i don't know which class to put it in or how to load that class as a mut.

Plz help. Thanks!

Posted: Thu Mar 15, 2007 1:20 pm
by jb
Whats the name of the function you are adding/changing? It sounds like it needs to be a playercontroller class that your mut will want to swap in....

Posted: Fri Mar 16, 2007 12:40 pm
by lord_kungai
I intend to alter the bool Dodge and/or the bool PerformDodge functions, so as to make the playyer dodge in the X,Y AND Z directions that the player is aiming at, after pressing front-front. IE: if the player is aiming upwards and presses FF, the player does not just dodge forward, but upwards as well.

This guess that I can do this by simply altering the methods so as to encompass the Z axis as well as the X and Y

I made a mutator extension and a gamerules extension to do this.

here's the code for my gamerules extension, with reference to the UnrealPawn class:

Code: Select all

class Dodge1GameRules extends GameRules

function bool Dodge(eDoubleClickDir DoubleClickMove)
{
	local vector X,Y,Z;

	if ( bIsCrouched || bWantsToCrouch || (Physics != PHYS_Walking) )
		return false;

    GetAxes(Rotation,X,Y,Z);
	if (DoubleClickMove == DCLICK_Forward)
		Velocity = 1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
	else if (DoubleClickMove == DCLICK_Back)
		Velocity = -1.5*GroundSpeed*X + (Velocity Dot Y)*Y;
	else if (DoubleClickMove == DCLICK_Left)
		Velocity = 1.5*GroundSpeed*Y + (Velocity Dot X)*X;
	else if (DoubleClickMove == DCLICK_Right)
		Velocity = -1.5*GroundSpeed*Y + (Velocity Dot X)*X;

	Velocity.Z = 210;
	CurrentDir = DoubleClickMove;
	SetPhysics(PHYS_Falling);
	return true;
}

defaultproperties
{
}
And here's the code for my gamerules extension, with reference to the xPawn class:

Code: Select all

class Dadge2GameRules extends GameRules

function bool Dodge(eDoubleClickDir DoubleClickMove)
{
    local vector X,Y,Z, TraceStart, TraceEnd, Dir, Cross, HitLocation, HitNormal;
    local Actor HitActor;
	local rotator TurnRot;

    if ( bIsCrouched || bWantsToCrouch || (Physics != PHYS_Walking && Physics != PHYS_Falling) )
        return false;

	TurnRot.Yaw = Rotation.Yaw;
    GetAxes(TurnRot,X,Y,Z);

    if ( Physics == PHYS_Falling )
    {
		if ( !bCanWallDodge )
			return false;
        if (DoubleClickMove == DCLICK_Forward)
            TraceEnd = -X;
        else if (DoubleClickMove == DCLICK_Back)
            TraceEnd = X;
        else if (DoubleClickMove == DCLICK_Left)
            TraceEnd = Y;
        else if (DoubleClickMove == DCLICK_Right)
            TraceEnd = -Y;
        TraceStart = Location - CollisionHeight*Vect(0,0,1) + TraceEnd*CollisionRadius;
        TraceEnd = TraceStart + TraceEnd*32.0;
        HitActor = Trace(HitLocation, HitNormal, TraceEnd, TraceStart, false, vect(1,1,1));
        if ( (HitActor == None) || (!HitActor.bWorldGeometry && (Mover(HitActor) == None)) )
             return false;
	}
    if (DoubleClickMove == DCLICK_Forward)
    {
		Dir = vect(X,Y,Z);
		Cross = vect(0,0,0);
	}
    else if (DoubleClickMove == DCLICK_Back)
    {
		Dir = -1 * X;
		Cross = Y;
	}
    else if (DoubleClickMove == DCLICK_Left)
    {
		Dir = -1 * Y;
		Cross = X;
	}
    else if (DoubleClickMove == DCLICK_Right)
    {
		Dir = Y;
		Cross = X;
	}
	if ( AIController(Controller) != None )
		Cross = vect(0,0,0);
	return PerformDodge(DoubleClickMove, Dir,Cross);
}

function bool PerformDodge(eDoubleClickDir DoubleClickMove, vector Dir, vector Cross)
{
    local float VelocityZ;
    local name Anim;

    if ( Physics == PHYS_Falling )
    {
        if (DoubleClickMove == DCLICK_Forward)
            Anim = WallDodgeAnims[0];
        else if (DoubleClickMove == DCLICK_Back)
            Anim = WallDodgeAnims[1];
        else if (DoubleClickMove == DCLICK_Left)
            Anim = WallDodgeAnims[2];
        else if (DoubleClickMove == DCLICK_Right)
            Anim = WallDodgeAnims[3];

        if ( PlayAnim(Anim, 1.0, 0.1) )
            bWaitForAnim = true;
            AnimAction = Anim;
            
		TakeFallingDamage();
        if (Velocity.Z < -DodgeSpeedZ*0.5)
			Velocity.Z += DodgeSpeedZ*0.5;
    }

    VelocityZ = Velocity.Z;
    Velocity = DodgeSpeedFactor*GroundSpeed*Dir + (Velocity Dot Cross)*Cross;

	if ( !bCanDodgeDoubleJump )
		MultiJumpRemaining = 0;
	if ( bCanBoostDodge || (Velocity.Z < -100) )
		Velocity.Z = VelocityZ + DodgeSpeedZ;
	else
		Velocity.Z = DodgeSpeedZ;

    CurrentDir = DoubleClickMove;
    SetPhysics(PHYS_Falling);
    PlayOwnedSound(GetSound(EST_Dodge), SLOT_Pain, GruntVolume,,80);
    return true;
}

defaultproperties
{
}


Now I'm not sure if what I've done is going to work or is going to cause my computer to erupt in fountain of lava. Nor do I know where I am supposed to put all of this. So please help... :)

Posted: Fri Mar 16, 2007 4:02 pm
by lord_kungai
Hmmm...



Aparently, this is not the way it works...



Ok, so what happens if I make a custom xPawn class, or an extension of it like in the Mutant gametype, then I can somehow implement/force/whatever this class onto all players, via a mut...


help plz...

Posted: Fri Mar 16, 2007 8:07 pm
by jb
Well its probably not going to work as that dodge/PerformDodge function does NOT exist in the gamerules class so there is no way it can get called.

From what I could tell your are going to have to create a new pawn calss and then override the Dodge/PerformDodge functions in that new pawn class :(

Posted: Sat Mar 17, 2007 11:26 am
by lord_kungai
That is, in a way good...


Cause it means that I can kill three cicadas with one flack cannon... or is that birds with stones? Whatever...


What I mean is, I wanted to disable the speed adrenaline combo as well, so as to allow the player to generate his/her/its own 'speed'; IE: the player should be able to dodge/fly. So I'm also going to try and get the player to:

1) Use up a little adreneline while dodging (forward only)
2) Regenerate a little adrenaline passively (via the mutator directly)
3) Not be capable of performing speed and booster (or maybe I'll only cut down the effects of booster so that the player slowly regenerates lost health only until 100 health is reached)
4) Make the player capable of activating any adreneline combo at any time, even if another combo is alread happening. IE: the player can switch combos


What i intend to achieve from this mutator: Not sure... will get back to you on that... :P

Posted: Sat Mar 17, 2007 6:17 pm
by jb
Ok let me know what I can do to help!