Core.Object | +--Engine.Actor | +--Engine.Projectile | +--Botpack.PBolt | +--Botpack.StarterBolt
StartError,
AimError
rotator
AimRotation
float
AnimTime
simulated
PostBeginPlay()
Tick(float DeltaTime)
00001 //============================================================================= 00002 // starterbolt. 00003 //============================================================================= 00004 class StarterBolt extends pbolt; 00005 00006 #exec TEXTURE IMPORT NAME=sbolt0 FILE=Textures\Bolt2a_00.bmp GROUP=Skins //Translucent 00007 #exec TEXTURE IMPORT NAME=sbolt1 FILE=Textures\Bolt2a_01.bmp GROUP=Skins //Translucent 00008 #exec TEXTURE IMPORT NAME=sbolt2 FILE=Textures\Bolt2a_02.bmp GROUP=Skins //Translucent 00009 #exec TEXTURE IMPORT NAME=sbolt3 FILE=Textures\Bolt2a_03.bmp GROUP=Skins //Translucent 00010 #exec TEXTURE IMPORT NAME=sbolt4 FILE=Textures\Bolt2a_04.bmp GROUP=Skins //Translucent 00011 #exec MESHMAP SETTEXTURE MESHMAP=pbolt NUM=0 TEXTURE=pbolt0 00012 00013 var float OldError, NewError, StartError, AimError; //used for bot aiming 00014 var rotator AimRotation; 00015 var float AnimTime; 00016 00017 replication 00018 { 00019 // Things the server should send to the client. 00020 unreliable if( Role==ROLE_Authority ) 00021 AimError, NewError, AimRotation; 00022 } 00023 00024 simulated function PostBeginPlay() 00025 { 00026 Super.PostBeginPlay(); 00027 00028 if ( instigator == None ) 00029 return; 00030 if ( Instigator.IsA('Bot') && Bot(Instigator).bNovice ) 00031 aimerror = 2200 + (3 - instigator.skill) * 300; 00032 else 00033 aimerror = 1000 + (3 - instigator.skill) * 400; 00034 00035 if ( FRand() < 0.5 ) 00036 aimerror *= -1; 00037 } 00038 00039 simulated function Tick(float DeltaTime) 00040 { 00041 local vector X,Y,Z, AimSpot, DrawOffset, AimStart; 00042 local int YawErr; 00043 local float dAdjust; 00044 local Bot MyBot; 00045 00046 AnimTime += DeltaTime; 00047 if ( AnimTime > 0.05 ) 00048 { 00049 AnimTime -= 0.05; 00050 SpriteFrame++; 00051 if ( SpriteFrame == ArrayCount(SpriteAnim) ) 00052 SpriteFrame = 0; 00053 Skin = SpriteAnim[SpriteFrame]; 00054 } 00055 00056 // orient with respect to instigator 00057 if ( Instigator != None ) 00058 { 00059 if ( (Level.NetMode == NM_Client) && (!Instigator.IsA('PlayerPawn') || (PlayerPawn(Instigator).Player == None)) ) 00060 { 00061 SetRotation(AimRotation); 00062 Instigator.ViewRotation = AimRotation; 00063 DrawOffset = ((0.01 * class'PulseGun'.Default.PlayerViewOffset) >> Rotation); 00064 DrawOffset += (Instigator.EyeHeight * vect(0,0,1)); 00065 } 00066 else 00067 { 00068 MyBot = Bot(instigator); 00069 if ( MyBot != None ) 00070 { 00071 if ( Instigator.Target == None ) 00072 Instigator.Target = Instigator.Enemy; 00073 if ( Instigator.Target == Instigator.Enemy ) 00074 { 00075 if (MyBot.bNovice ) 00076 dAdjust = DeltaTime * (4 + instigator.Skill) * 0.075; 00077 else 00078 dAdjust = DeltaTime * (4 + instigator.Skill) * 0.12; 00079 if ( OldError > NewError ) 00080 OldError = FMax(OldError - dAdjust, NewError); 00081 else 00082 OldError = FMin(OldError + dAdjust, NewError); 00083 00084 if ( OldError == NewError ) 00085 NewError = FRand() - 0.5; 00086 if ( StartError > 0 ) 00087 StartError -= DeltaTime; 00088 else if ( MyBot.bNovice && (Level.TimeSeconds - MyBot.LastPainTime < 0.2) ) 00089 StartError = MyBot.LastPainTime; 00090 else 00091 StartError = 0; 00092 AimSpot = 1.25 * Instigator.Target.Velocity + 0.75 * Instigator.Velocity; 00093 if ( Abs(AimSpot.Z) < 120 ) 00094 AimSpot.Z *= 0.25; 00095 else 00096 AimSpot.Z *= 0.5; 00097 if ( Instigator.Target.Physics == PHYS_Falling ) 00098 AimSpot = Instigator.Target.Location - 0.0007 * AimError * OldError * AimSpot; 00099 else 00100 AimSpot = Instigator.Target.Location - 0.0005 * AimError * OldError * AimSpot; 00101 if ( (Instigator.Physics == PHYS_Falling) && (Instigator.Velocity.Z > 0) ) 00102 AimSpot = AimSpot - 0.0003 * AimError * OldError * AimSpot; 00103 00104 AimStart = Instigator.Location + FireOffset.X * X + FireOffset.Y * Y + (1.2 * FireOffset.Z - 2) * Z; 00105 if ( FastTrace(AimSpot - vect(0,0,10), AimStart) ) 00106 AimSpot = AimSpot - vect(0,0,10); 00107 GetAxes(Instigator.Rotation,X,Y,Z); 00108 AimRotation = Rotator(AimSpot - AimStart); 00109 AimRotation.Yaw = AimRotation.Yaw + (OldError + StartError) * 0.75 * aimerror; 00110 YawErr = (AimRotation.Yaw - (Instigator.Rotation.Yaw & 65535)) & 65535; 00111 if ( (YawErr > 3000) && (YawErr < 62535) ) 00112 { 00113 if ( YawErr < 32768 ) 00114 AimRotation.Yaw = Instigator.Rotation.Yaw + 3000; 00115 else 00116 AimRotation.Yaw = Instigator.Rotation.Yaw - 3000; 00117 } 00118 } 00119 else if ( Instigator.Target != None ) 00120 AimRotation = Rotator(Instigator.Target.Location - Instigator.Location); 00121 else 00122 AimRotation = Instigator.ViewRotation; 00123 Instigator.ViewRotation = AimRotation; 00124 SetRotation(AimRotation); 00125 } 00126 else 00127 { 00128 AimRotation = Instigator.ViewRotation; 00129 SetRotation(AimRotation); 00130 } 00131 Drawoffset = Instigator.Weapon.CalcDrawOffset(); 00132 } 00133 GetAxes(Instigator.ViewRotation,X,Y,Z); 00134 00135 if ( bCenter ) 00136 { 00137 FireOffset.Z = Default.FireOffset.Z * 1.5; 00138 FireOffset.Y = 0; 00139 } 00140 else 00141 { 00142 FireOffset.Z = Default.FireOffset.Z; 00143 if ( bRight ) 00144 FireOffset.Y = Default.FireOffset.Y; 00145 else 00146 FireOffset.Y = -1 * Default.FireOffset.Y; 00147 } 00148 SetLocation(Instigator.Location + DrawOffset + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z); 00149 } 00150 else 00151 GetAxes(Rotation,X,Y,Z); 00152 00153 CheckBeam(X, DeltaTime); 00154 } 00155 00156 defaultproperties 00157 { 00158 StartError=0.500000 00159 SpriteAnim(0)=Texture'Botpack.Skins.sbolt0' 00160 SpriteAnim(1)=Texture'Botpack.Skins.sbolt1' 00161 SpriteAnim(2)=Texture'Botpack.Skins.sbolt2' 00162 SpriteAnim(3)=Texture'Botpack.Skins.sbolt3' 00163 SpriteAnim(4)=Texture'Botpack.Skins.sbolt4' 00164 RemoteRole=ROLE_SimulatedProxy 00165 LightType=LT_Steady 00166 LightEffect=LE_NonIncidence 00167 LightBrightness=255 00168 LightHue=83 00169 LightSaturation=50 00170 LightRadius=5 00171 }