This is a vehicle code I'm doing. It's gonna be the first vehicle ever done in Unreal Tournament 1999!
Code: Select all
//=============================================================================
// UT99Vehicle.
//=============================================================================
class UT99Vehicle expands Pickup;
var(Vehicle) Vector DriverOffset;
var(Vehicle) Vector PassengerOffsets[63];
var(Vehicle) float TopSpeed;
var(Vehicle) float VehicleHealth;
var byte PeopleInside;
var Pawn PassengerPawns[63];
var Pawn DriverPawn;
var(Vehicle) bool bTeamGame;
var(Vehicle) float ActorBumpForce;
var(Vehicle) int MyTeam;
var(Vehicle) bool bSetTeamToDriverTeam;
var(Vehicle) int PawnBumpDamage;
var(Vehicle) float Weight;
var(Vehicle) Vector BlastOffset;
var(Vehicle) string KillMessage[3];
var(Vehicle) int MaxPassengers;
var(Vehicle) Texture DestroyedTexture;
var(Vehicle) float Acceleration;
var Texture OldTexture;
static function vector NewVector(float X, float Y, float Z)
{
local Vector V;
V.X = X;
V.Y = Y;
V.Z = Z;
return V;
}
function TakeDamage(int Health, Pawn EventInstigator, vector HitLocation, vector Momentum, name DamageType)
{
if ( DamageType == 'AntiVehicle' )
self.Velocity += Momentum / (Weight / 2);
else self.Velocity += Momentum / Weight;
}
simulated function Touch(Actor Other)
{
if ( Pawn(Other) != None && PeopleInside > 1 )
{
if
(
( Level.Game.IsA(class'TeamGamePlus'.Name)
&& (
(
!bSetTeamToDriverTeam
&& Pawn(Other).PlayerReplicationInfo != None
&& Pawn(Other).PlayerReplicationInfo.Team == MyTeam
)
|| (
bSetTeamToDriverTeam
&& Pawn(Other).PlayerReplicationInfo != None
&& DriverPawn.PlayerReplicationInfo != None
&& Pawn(Other).PlayerReplicationInfo.Team == DriverPawn.PlayerReplicationInfo.Team
)
)
)
&& Pawn(Other).PlayerReplicationInfo.Team != 255
&& PeopleInside <= MaxPassengers
)
{
PassengerPawns[PeopleInside - 1] = Pawn(Other);
PeopleInside++;
}
else
{
Other.TakeDamage(PawnBumpDamage, DriverPawn, Location, Velocity, 'vehiclebump');
Other.Velocity = (Other.Location - Location) * ActorBumpForce;
if ( Pawn(Other).Health < 1 )
{
Pawn(Other).GoToState('Dying');
BroadcastMessage(KillMessage[0] @ DriverPawn.Name @ KillMessage[1] @ Pawn(Other).Name @ KillMessage[2], false, 'deathmessage');
}
}
}
else if ( Projectile(Other) != None )
{
TakeDamage(Projectile(Other).Damage, None, Other.Location, Self.Location - Other.Location, Projectile(Other).MyDamageType);
Projectile(Other).Touch(Self);
}
else if ( Other.bBlockActors )
Other.Velocity = (Other.Location - Location) * ActorBumpForce;
}
function Activate()
{
bHidden = false;
}
function vector AdjustMotion(vector OldLocation, pawn Driver)
{
local Vector result;
local Vector tresult;
local Vector unused;
local Vector halp;
halp = OldLocation - Location * Acceleration;
halp.Z = Location.Z;
Trace(result, unused, halp, OldLocation - Location, false);
if ( VSize(result) > TopSpeed )
result = Normal(result) * TopSpeed;
SetLocation(OldLocation + result);
if ( Location.Z > OldLocation.Z + 64 && !FastTrace(Location, Location + static.NewVector(0, 0, -64)) )
{
Trace(tresult, unused, static.NewVector(Location.X, Location.Y, OldLocation.Z), Location, false);
result = Location - tresult;
}
SetLocation(OldLocation);
return result;
}
function LeaveVehicle(byte Index)
{
local int i;
if ( Index == 0 )
{
DriverPawn = None;
PeopleInside--;
for (i = 0; i < 64; i++)
if ( PassengerPawns[i] != None )
PassengerPawns[i] = None;
}
else if ( Index < 64 )
{
for ( i = Index--; i < 63; i++ )
{
if ( PassengerPawns[i++] != None )
PassengerPawns[i] = PassengerPawns[i++];
else
return;
}
}
}
function PickupFunction(Pawn Other)
{
if ( IsInState('DestroyedVehicle') || IsInState('Activated') )
return;
DriverPawn = Other;
PeopleInside++;
GoToState('Activated');
}
simulated function Tick(float TimeDelta)
{
local vector OldLocation;
local int i;
local Pawn Passenger;
if ( ( DriverPawn == None || DriverPawn.IsInState('Dying') ) && !IsInState('Pickup') )
GoToState('DestroyedVehicle');
if ( PeopleInside < 1 || !IsInState('Activated') )
return;
if ( VehicleHealth < 1 )
{
Spawn(class'ExplosionChain', self, '__vehicle_blast__', Location + (BlastOffset * (VRand() * 2))).Trigger(self, DriverPawn);
GoToState('Destroyed');
}
OldLocation = Location;
if ( DriverPawn != None )
SetLocation(DriverPawn.Location - DriverOffset);
SetLocation(OldLocation + AdjustMotion(OldLocation, DriverPawn));
DriverPawn.SetLocation(Location + DriverOffset);
for ( i = 0; i < 63; i++ )
{
Passenger = PassengerPawns[i];
if ( Passenger != None )
Passenger.SetLocation(Location + PassengerOffsets[i]);
}
}
State DestroyedVehicle
{
function TakeDamage(int Health, Pawn EventInstigator, vector HitLocation, vector Momentum, name DamageType);
function Tick(float TimeDelta);
function PickupFunction(Pawn Other);
function Touch(Actor Other)
{
if ( Pawn(Other) != None )
{
Pawn(Other).Health -= 1;
if ( Pawn(Other).Health < 1 )
Other.GoToState('Dying');
}
}
Begin:
OldTexture = Texture;
Texture = DestroyedTexture;
Sleep(RespawnTime);
Texture = OldTexture;
OldTexture = None;
GoToState('Pickup');
}
State Pickup
{
Begin:
VehicleHealth = default.VehicleHealth;
}
Hello all again!
I'm doing a complete overhaul of VehiclePawn (from the old GusPack) to it's own Vehicles package (and a way of bumping with stuff without bBlockActors, enabling players to get in! ) however I have a very strange error:This is the full code:Code: Select all
Error in UT99Vehicle, line 155: 'state': expecting State, got Function
I tried looking for something in the Wiki, but all I've got is:Code: Select all
//============================================================================= // UT99Vehicle. //============================================================================= class UT99Vehicle expands Pickup; var(Vehicle) Vector DriverOffset; var(Vehicle) Vector PassengerOffsets[63]; var(Vehicle) float TopSpeed; var(Vehicle) float VehicleHealth; var byte PeopleInside; var Pawn PassengerPawns[63]; var Pawn DriverPawn; var(Vehicle) bool bTeamGame; var(Vehicle) float ActorBumpForce; var(Vehicle) int MyTeam; var(Vehicle) bool bSetTeamToDriverTeam; var(Vehicle) int PawnBumpDamage; var(Vehicle) float Weight; var(Vehicle) string KillMessage[3]; var(Vehicle) int MaxPassengers; var(Vehicle) float RespawnTime; var(Vehicle) Texture DestroyedTexture; var Texture OldTexture; simulated function TakeDamage(int Health, Pawn EventInstigator, vector HitLocation, vector Momentum, name DamageType) { if ( DamageType != 'AntiVehicle' ) self.Velocity += Momentum / (Weight / 2); else self.Velocity += Momentum / Weight; } simulated function Touch(Actor Other) { if ( Other.IsA(class'Pawn'.Name) && PeopleInside > 1 ) { if ( ( Level.Game.IsA(class'TeamGamePlus'.Name) && ( ( !bSetTeamToDriverTeam && Pawn(Other).PlayerReplicationInfo.Team == MyTeam ) ^^ ( bSetTeamToDriverTeam && Pawn(Other).PlayerReplicationInfo.Team == DriverPawn.PlayerReplicationInfo.Team ) ) ) && Pawn(Other).PlayerReplicationInfo.Team != 255 && PeopleInside <= MaxPassengers ) { PassengerPawns[PeopleInside - 1] = Pawn(Other); PeopleInside++; } else { Other.TakeDamage(PawnBumpDamage, DriverPawn, Location, Velocity, 'vehiclebump'); Other.Velocity = (Other.Location - Location) * ActorBumpForce; if ( Pawn(Other).Health < 1 ) { Pawn(Other).GoToState('Dying'); BroadcastMessage(KillMessage[0] @ DriverPawn.Name @ KillMessage[1] @ Pawn(Other).Name @ KillMessage[2]); } } } else if ( Other.IsA(class'Projectile'.Name) ) { Projectile(Other).ProcessTouch(self, self.Location); } else if ( Other.bBlockActors ) Other.Velocity = (Other.Location - Location) * ActorBumpForce; } simulated function AdjustMotion(vector OldLocation, pawn Driver) { if ( VSize(OldLocation - Location) > TopSpeed ) { return Normal(OldLocation - Location) * TopSpeed; } } simulated function LeaveVehicle(byte Index) { local int i; if ( Index == 0 ) { DriverPawn == None; PeopleInside--; for (i = 0; i < 64; i++) if ( PassengerPawns[i] != None ) PassengerPawns[i] == None; } elif ( Index < 64 ) { for ( i = Index--; i < 63; i++ ) { if ( PassengerPawns[i++] != None ) PassengerPawns[i] = PassengerPawns[i++]; else return; } } } function PickupFunction(Pawn Other) { if ( IsInState('Destroyed') || IsInState('Activated') ) return; DriverPawn = Other; PeopleInside++; GoToState('Activated'); } simulated function Tick(float TimeDelta) { local vector OldLocation; local int i; if ( PeopleInside < 1 || !IsInState('Activated') ) return; if ( VehicleHealth < 1 ) { Spawn(class'ExplosionChain', self, Location + (BlastOffset * (VRand() * 2 ))).Trigger(self, DriverPawn); GoToState('Destroyed') } OldLocation = Location; if ( DriverPawn != None ) { Self.Location = DriverPawn.Location - DriverOffset; } Move(AdjustMotion(OldLocation, DriverPawn)) DriverPawn.SetLocation(Location + DriverOffset); for ( i = 0; i < 64; i++ ) if ( PassengerPawns[i] != None ) { PassengerPawns[í].SetLocation(Location + PassengerOffsets[i]); } } State() Destroyed { function TakeDamage(); function Tick(); function LeaveVehicle(); function PickupFunction(); function Touch(); simulated function BeginState() { OldTexture = Texture; Texture = DestroyedTexture; Super.Sleep(RespawnTime); Texture = OldTexture GoToState(InitialState); } }
However, I already tried calling sleep() from Global and it didn't work ._.The Wiki: https://wiki.beyondunreal.com/Compiler_errors_overview#States wrote: Error, 'state': expecting State, got Function
This was caused by calling a state sleep where sleep is a function of state. Im guessing any function previously defined can conflict with a state.
And a Google search for the exact terms
only had 3 unuseful results, even with my incredible Google-Fu X1000.Code: Select all
unrealscript "expecting state got function"
I remember having this error once, but I don't recall how did I fix it! Please !
EDIT: Oh, and almost forgetting; I made ##unrealscript1 channel in irc.freenode.net for very quick help