Warning, /frameworks/ktexteditor/autotests/src/test.uc is written in an unsupported language. File is not indexed.
0001 //=============================================================================
0002 // Shield Gun
0003 //=============================================================================
0004 class ShieldGun extends Weapon
0005 config(user);
0006
0007 #EXEC OBJ LOAD FILE=InterfaceContent.utx
0008
0009 var Sound ShieldHitSound;
0010 var String ShieldHitForce;
0011
0012 replication
0013 {
0014 reliable if (Role == ROLE_Authority)
0015 ClientTakeHit;
0016 }
0017
0018 simulated function DoAutoSwitch()
0019 {
0020 }
0021
0022 simulated event RenderOverlays( Canvas Canvas )
0023 {
0024 local int m;
0025
0026 if ((Hand < -1.0) || (Hand > 1.0))
0027 {
0028 for (m = 0; m < NUM_FIRE_MODES; m++)
0029 {
0030 if (FireMode[m] != None)
0031 {
0032 FireMode[m].DrawMuzzleFlash(Canvas);
0033 }
0034 }
0035 }
0036 Super.RenderOverlays(Canvas);
0037 }
0038
0039 // AI Interface
0040 function GiveTo(Pawn Other, optional Pickup Pickup)
0041 {
0042 Super.GiveTo(Other, Pickup);
0043
0044 if ( Bot(Other.Controller) != None )
0045 Bot(Other.Controller).bHasImpactHammer = true;
0046 }
0047
0048 function bool CanAttack(Actor Other)
0049 {
0050 return true;
0051 }
0052
0053 simulated function Timer()
0054 {
0055 local Bot B;
0056
0057 if (ClientState == WS_BringUp)
0058 {
0059 // check if owner is bot waiting to do impact jump
0060 B = Bot(Instigator.Controller);
0061 if ( (B != None) && B.bPreparingMove && (B.ImpactTarget != None) )
0062 {
0063 B.ImpactJump();
0064 B = None;
0065 }
0066 }
0067 Super.Timer();
0068 if ( (B != None) && (B.Enemy != None) )
0069 BotFire(false);
0070 }
0071
0072 function FireHack(byte Mode)
0073 {
0074 if ( Mode == 0 )
0075 {
0076 FireMode[0].PlayFiring();
0077 FireMode[0].FlashMuzzleFlash();
0078 FireMode[0].StartMuzzleSmoke();
0079 IncrementFlashCount(0);
0080 }
0081 }
0082
0083 /* BestMode()
0084 choose between regular or alt-fire
0085 */
0086 function byte BestMode()
0087 {
0088 local float EnemyDist;
0089 local bot B;
0090
0091 B = Bot(Instigator.Controller);
0092 if ( (B == None) || (B.Enemy == None) )
0093 return 1;
0094
0095 EnemyDist = VSize(B.Enemy.Location - Instigator.Location);
0096 if ( EnemyDist > 2 * Instigator.GroundSpeed )
0097 return 1;
0098 if ( (B.MoveTarget != B.Enemy) && ((EnemyDist > 0.5 * Instigator.GroundSpeed)
0099 || (((B.Enemy.Location - Instigator.Location) Dot vector(Instigator.Rotation)) <= 0)) )
0100 return 1;
0101 return 0;
0102 }
0103
0104 // super desireable for bot waiting to impact jump
0105 function float GetAIRating()
0106 {
0107 local Bot B;
0108 local float EnemyDist;
0109
0110 B = Bot(Instigator.Controller);
0111 if ( B == None )
0112 return AIRating;
0113
0114 if ( B.bPreparingMove && (B.ImpactTarget != None) )
0115 return 9;
0116
0117 if ( B.PlayerReplicationInfo.HasFlag != None )
0118 {
0119 if ( Instigator.Health < 50 )
0120 return AIRating + 0.35;
0121 return AIRating + 0.25;
0122 }
0123
0124 if ( B.Enemy == None )
0125 return AIRating;
0126
0127 EnemyDist = VSize(B.Enemy.Location - Instigator.Location);
0128 if ( B.Stopped() && (EnemyDist > 100) )
0129 return 0.1;
0130
0131 if ( (EnemyDist < 750) && (B.Skill <= 2) && !B.Enemy.IsA('Bot') && (ShieldGun(B.Enemy.Weapon) != None) )
0132 return FClamp(300/(EnemyDist + 1), 0.6, 0.75);
0133
0134 if ( EnemyDist > 400 )
0135 return 0.1;
0136 if ( (Instigator.Weapon != self) && (EnemyDist < 120) )
0137 return 0.25;
0138
0139 return ( FMin(0.6, 90/(EnemyDist + 1)) );
0140 }
0141
0142 // End AI interface
0143
0144 function AdjustPlayerDamage( out int Damage, Pawn InstigatedBy, Vector HitLocation,
0145 out Vector Momentum, class<DamageType> DamageType)
0146 {
0147 local int Drain;
0148 local vector Reflect;
0149 local vector HitNormal;
0150 local float DamageMax;
0151
0152 DamageMax = 100.0;
0153 if ( DamageType == class'Fell' )
0154 DamageMax = 20.0;
0155 else if( !DamageType.default.bArmorStops || (DamageType == class'DamTypeShieldImpact' && InstigatedBy == Instigator) )
0156 return;
0157
0158 if ( CheckReflect(HitLocation, HitNormal, 0) )
0159 {
0160 Drain = Min( Ammo[1].AmmoAmount*2, Damage );
0161 Drain = Min(Drain,DamageMax);
0162 Reflect = MirrorVectorByNormal( Normal(Location - HitLocation), Vector(Instigator.Rotation) );
0163 Damage -= Drain;
0164 Momentum *= 1.25;
0165 Ammo[1].UseAmmo(Drain/2);
0166 DoReflectEffect(Drain/2);
0167 }
0168 }
0169
0170 function DoReflectEffect(int Drain)
0171 {
0172 PlaySound(ShieldHitSound, SLOT_None);
0173 ShieldAltFire(FireMode[1]).TakeHit(Drain);
0174 ClientTakeHit(Drain);
0175 }
0176
0177 simulated function ClientTakeHit(int Drain)
0178 {
0179 ClientPlayForceFeedback(ShieldHitForce);
0180 ShieldAltFire(FireMode[1]).TakeHit(Drain);
0181 }
0182
0183 function bool CheckReflect( Vector HitLocation, out Vector RefNormal, int AmmoDrain )
0184 {
0185 local Vector HitDir;
0186 local Vector FaceDir;
0187
0188 if (!FireMode[1].bIsFiring || Ammo[0].AmmoAmount == 0) return false;
0189
0190 FaceDir = Vector(Instigator.Controller.Rotation);
0191 HitDir = Normal(Instigator.Location - HitLocation + Vect(0,0,8));
0192 //Log(self@"HitDir"@(FaceDir dot HitDir));
0193
0194 RefNormal = FaceDir;
0195
0196 if ( FaceDir dot HitDir < -0.37 ) // 68 degree protection arc
0197 {
0198 if (AmmoDrain > 0)
0199 Ammo[0].UseAmmo(AmmoDrain);
0200 return true;
0201 }
0202 return false;
0203 }
0204
0205 function AnimEnd(int channel)
0206 {
0207 if (FireMode[0].bIsFiring)
0208 {
0209 LoopAnim('Charged');
0210 }
0211 else if (!FireMode[1].bIsFiring)
0212 {
0213 Super.AnimEnd(channel);
0214 }
0215 }
0216
0217 function float SuggestAttackStyle()
0218 {
0219 return 0.8;
0220 }
0221
0222 function float SuggestDefenseStyle()
0223 {
0224 return -0.8;
0225 }
0226
0227 simulated function float ChargeBar()
0228 {
0229 return FMin(1,FireMode[0].HoldTime/ShieldFire(FireMode[0]).FullyChargedTime);
0230 }
0231
0232 defaultproperties
0233 {
0234 ItemName="Shield Gun"
0235 IconMaterial=Material'InterfaceContent.Hud.SkinA'
0236 IconCoords=(X1=200,Y1=281,X2=321,Y2=371)
0237
0238 bShowChargingBar=true
0239 bCanThrow=false
0240 FireModeClass(0)=ShieldFire
0241 FireModeClass(1)=ShieldAltFire
0242 InventoryGroup=1
0243 Mesh=mesh'Weapons.ShieldGun_1st'
0244 BobDamping=2.2
0245 PickupClass=class'ShieldGunPickup'
0246 EffectOffset=(X=15.0,Y=6.7,Z=1.2)
0247 bMeleeWeapon=true
0248 ShieldHitSound=Sound'WeaponSounds.ShieldGun.ShieldReflection'
0249 DrawScale=0.4
0250 PutDownAnim=PutDown
0251 DisplayFOV=60
0252 PlayerViewOffset=(X=2,Y=-0.7,Z=-2.7)
0253 PlayerViewPivot=(Pitch=500,Roll=0,Yaw=500)
0254
0255 UV2Texture=Material'XGameShaders.WeaponEnvShader'
0256
0257 AttachmentClass=class'ShieldAttachment'
0258 SelectSound=Sound'WeaponSounds.ShieldGun_change'
0259 SelectForce="ShieldGun_change"
0260 ShieldHitForce="ShieldReflection"
0261
0262 AIRating=0.35
0263 CurrentRating=0.35
0264
0265 DefaultPriority=2
0266 }