PHP Code:
class CarPLayer extends UTVehicle_Scorpion_Content;
var config vector PlayerLocation;
var float CurTime;
var float CurSpeed;
struct SCollisionsList
{
var int RandNumber;
var float position;
var float curTime;
var int nHits;
};
var int lap;
var array< SCollisionsList> CollisionsList;
var() string MessageHud;
var bool ShowMessageHud;
var int nRand;
var int nHits;
var vector StartPosition;
var bool xPath;
//filewriter vars
var FileWriter FW;
var string html;
var SCollisionsList rec;
simulated event PostBeginPlay(){
super.PostBeginPlay();
LockWheels();
EnableFullSteering();
//this means that the car is moving through the Y axis, so i read the X change
xPath=false;
FW = spawn(class'FileWriter');
FW.OpenFile("results",FWFT_HTML );
html="";
FW.Logf("<html><body><table width='200' border='1'>");
//sTmp=this.Velocity;
}
event tick(float DeltaTime)
{
// WorldInfo.Game.Broadcast(self,"XXX POS:"$GetALocalPlayerController().Pawn.Location.X);
// WorldInfo.Game.Broadcast(self,"YYY POS:"$GetALocalPlayerController().Pawn.Location.Y);
//WorldInfo.Game.Broadcast(self,"XXX POS:"$WorldInfo.TimeSeconds);
CurTime=WorldInfo.TimeSeconds;
if(ShowMessageHud)
{
// local SCollisionsList newRecord;
rec.RandNumber=nRand;
if(xPath)
rec.position=StartPosition.Y-GetALocalPlayerController().Pawn.Location.Y;
else
rec.position=StartPosition.X-GetALocalPlayerController().Pawn.Location.X;
rec.curTime=CurTime;
rec.nHits=nHits;
LogToHtml(rec);
}
}
function LogToHtml(SCollisionsList cRec)
{
html="<tr><td>"$cRec.RandNumber$"</td>";
html=html$"<td>"$cRec.position$"</td>";
html=html$"<td>"$cRec.curTime$"</td>";
html=html$"<td>"$cRec.nHits$"</td>";
html=html$"</tr>";
FW.Logf(html);
}
function PassIn()
{
ShowMessageHud=true;
StartPosition=GetALocalPlayerController().Pawn.Location;
nRand=GenerateRandomNumber(lap);
MessageHud=string(nRand);
}
function PassOut()
{
ShowMessageHud=false;
}
function ChangePath()
{
if(xPath)
xPath=false;
else
xPath=true;
}
event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
{
local string MetaName;
if(lap==0)lap=1;
MetaName=string(Other);
// GetALocalPlayerController().ClientMessage(MetaName);//this works
// `Log(MetaName);
switch(MetaName)
{
case ("TriggerVolume_0"):
PassIn();
break;
case ("TriggerVolume_1"):
PassOut();
break;
case ("TriggerVolume_11"):
PassIn();
break;
case ("TriggerVolume_12"):
ChangePath();
PassOut();
break;
case ("TriggerVolume_2"):
PassIn();
break;
case ("TriggerVolume_3"):
PassOut();
break;
case ("TriggerVolume_13"):
PassIn();
break;
case ("TriggerVolume_14"):
ChangePath();
PassOut();
break;
case ("TriggerVolume_15"):
PassIn();
break;
case ("TriggerVolume_16"):
PassOut();
break;
case ("TriggerVolume_4"):
PassIn();
break;
case ("TriggerVolume_5"):
ChangePath();
PassOut();
break;
case ("TriggerVolume_6"):
PassIn();
break;
case ("TriggerVolume_7"):
PassOut();
break;
case ("TriggerVolume_17"):
PassIn();
break;
case ("TriggerVolume_18"):
ChangePath();
PassOut();
break;
case ("TriggerVolume_8"):
lap++;
ShowMessageHud=true;
MessageHud="Vuelta Numero "$lap;
if(lap>1)
{
MessageHud="Fin";
EndGame();
}
break;
case ("TriggerVolume_9"):
ChangePath();
PassOut();
break;
}
}
//this function saves all when the game is over
function EndGame()
{
FW.Logf("</table></body></html>");
FW.CloseFile();
ConsoleCommand("exit");
}
//this function generates a random number. eery lap the game increase the number lenght by one
simulated function int GenerateRandomNumber(int nLap)
{
local int sRandomNumber;
local int nBase;
local int Range1;
local int Range2;
nBase=5;
Range1=10**(nLap+nBase-1);
Range2=(10**(nLap+nBase))-1;
sRandomNumber=int( RandRange(Range1,Range2));
return sRandomNumber;
}
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
local vector X, Y, Z;
//this makes the camera stay with the vehicle
GetActorEyesViewPoint( out_CamLoc, out_CamRot );
GetAxes(Rotation,X,Y,Z);
// a bit behind
out_CamLoc = Location - 40 * X;
//up a bit
out_CamLoc.Z = Location.Z + 25;
//camera rotation yaw = vehicle rotation yaw
out_CamRot.Yaw = Rotation.Yaw;
// look down a bit
out_CamRot.Pitch = (-0.0f *DegToRad) * RadToUnrRot;
//delete this line if you want the cam to roll with the vehicle
out_CamRot.Roll = 0;
return true;
}
simulated function DrawHUD( HUD H )
{
super.DrawHUD(H);
if(ShowMessageHud)
{
H.Canvas.SetPos(H.Canvas.ClipX/2,H.Canvas.ClipY/2-200);
H.Canvas.SetDrawColor(255, 255, 255);
H.Canvas.Font = class'Engine'.static.GetLargeFont();
H.Canvas.DrawText(MessageHud);
}
}
function collidedWith(Actor a)
{ // both RigidBodyCollision and RanInto end up here
// My code here
nHits++;
}
simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
{
super.RigidBodyCollision(hitcomponent, othercomponent, Collision, ContactIndex);
collidedWith(OtherComponent.owner);
}
event RanInto( Actor Other ) // called for encroaching actors which successfully moved the other actor out of the way
{
super.RanInto(other);
collidedWith(other);
}
simulated event PlayTakeHitEffects ()
{
GetALocalPlayerController().ClientMessage("PLayHIt effects:");
}
event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
{
WorldInfo.Game.Broadcast(self,"Driver Bumped");
WorldInfo.Game.Broadcast(self,Other);
}
event HitWall(Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
{
WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Get driver hitwall!");
}
event EncroachedBy(Actor Other)
{
GetALocalPlayerController().ClientMessage("EncroachedBy");
}
simulated event SuspensionHeavyShift (float Delta)
{
GetALocalPlayerController().ClientMessage("SuspensionHeavyShift");
}
simulated event TornOff()
{
GetALocalPlayerController().ClientMessage("TornOff:");
}
defaultproperties
{
GroundSpeed=50000
MaxSpeed=50000;
bDirectHitWall=True;
Begin Object Class=UDKVehicleSimCar Name=MySimObject
WheelSuspensionStiffness=100.f
WheelSuspensionDamping=3.f
WheelSuspensionBias=0.1f
ChassisTorqueScale=0.f
MaxBrakeTorque=5.f
StopThreshold=100
MaxSteerAngleCurve=(Points=((InVal=0.f,OutVal=45.f),(InVal=600.f,OutVal=15.f),(InVal=1100.f,OutVal=10.f),(InVal=1300.f,OutVal=6.f),(InVal=1600.f,OutVal=1.f)))
SteerSpeed=110
LSDFactor=0.f
TorqueVSpeedCurve=(Points=((InVal=-500.000000),(InVal=-300.000000,OutVal=60.000000),(OutVal=21200.000000),(InVal=24000.000000,OutVal=120.000000),(InVal=28000.000000,OutVal=2150.000000),(InVal=29200.000000)))
EngineRPMCurve=(Points=((InVal=-500.f,OutVal=2500.f),(InVal=0.f,OutVal=500.f),(InVal=549.f,OutVal=3500.f),(InVal=550.f,OutVal=1000.f),(InVal=849.f,OutVal=4500.f),(InVal=850.f,OutVal=1500.f),(InVal=1100.f,OutVal=5000.f)))
EngineBrakeFactor=0.f25f
ThrottleSpeed=0.02f
WheelInertia=0.2f
NumWheelsForFullSteering=4
SteeringReductionFactor=0.f
SteeringReductionMinSpeed=1100.f
SteeringReductionSpeed=1400.f
bAutoHandbrake=true
bClampedFrictionModel=true
FrontalCollisionGripFactor=0.18f
ConsoleHardTurnGripFactor=1.f
HardTurnMotorTorque=0.7f
SpeedBasedTurnDamping=20.f
AirControlTurnTorque=40.f
InAirUprightMaxTorque=15.f
InAirUprightTorqueFactor=-30.f
WheelLongExtremumSlip=0.1f
WheelLongExtremumValue=1.f
WheelLongAsymptoteSlip=2.f
WheelLongAsymptoteValue=0.6f
WheelLatExtremumSlip=0.35f
WheelLatExtremumValue=0.9f
WheelLatAsymptoteSlip=1.4f
WheelLatAsymptoteValue=0.9f
bAutoDrive=false
AutoDriveSteer=0.3f
End Object
SimObj=MySimObject
Components.Add(MySimObject)
}
later i added a hud modification so i can see the current speed
PHP Code:
class MyGamePlayerController extends GamePlayerController ;
var BaseGame cBaseGame;
simulated event PostBeginPlay(){
super.PostBeginPlay();
cBaseGame=spawn(class'BaseGame');
}
simulated function DrawHUD( HUD H )
{ local String tmp;
local Pawn P;
local string sText;
super.DrawHUD(H);
if(cBaseGame.bShowCountDown)
{
sText=cBaseGame.sMessage;
H.Canvas.SetPos(H.Canvas.ClipX/2,H.Canvas.ClipY/2-200);
H.Canvas.SetDrawColor(255, 255, 255);
H.Canvas.Font = class'Engine'.static.GetLargeFont();
H.Canvas.DrawText(sText);
}
P = GetALocalPlayerController().Pawn;
if (P != None)
{
tmp=String(P.Velocity);
}
H.Canvas.SetPos(0,0);
H.Canvas.SetDrawColor(255, 255, 255);
H.Canvas.Font = class'Engine'.static.GetLargeFont();
H.Canvas.DrawText("Speed:"$tmp);
//GetALocalPlayerController().ClientMessage("Speed:"$tmp);
}
state PlayerDriving
{
function PlayerMove( float DeltaTime )
{
local float Forward, Strafe;
local bool bState;
bState=cBaseGame.Move;
//if the counter gets to start! in BaseGame.uc send a message for debugging purposses
//this is not working. its not capturing the BaseGame.Move variable value
if(bState==true)
{
UpdateRotation(DeltaTime);
// Get the forward input information
Forward = PlayerInput.aForward;
// Get the strafe input information
Strafe = PlayerInput.aStrafe;
// Remap raw x-axis movement.
Strafe += PlayerInput.aBaseX * 7.5 + PlayerInput.aMouseX;
if (PlayerInput != None)
{
Forward = (((PlayerInput.aTilt.X * UnrRotToDeg) - 30.f) / 50.f) * -1.f;
}
// Clamp the forward to within -1.f and 1.f
Forward = FClamp(Forward, -1.f, 1.f);
ProcessDrive(Forward, Strafe, PlayerInput.aUp, bPressedJump);
bPressedJump = false;
}
else
{
ProcessDrive(0, 0, PlayerInput.aUp, bPressedJump);
}
}
}
defaultproperties{
}
so i compile i can't see any effect on speed. watching the hud indicator of speed, it always tops to 1100 so i cant find a real way of increasing this value.
Bookmarks