Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Onslaught.ONSMineLayer


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
//-----------------------------------------------------------
//
//-----------------------------------------------------------
class ONSMineLayer extends Weapon
	config(User);

#exec OBJ LOAD FILE=HudContent.utx

const NUM_BARRELS = 4;
const BARREL_ROTATION_RATE = 2.0;

var()   float   ReloadDelay;
var     float   BarrelRotation;
var     float   FinalRotation;
var     bool    bRotateBarrel;

var array<Projectile> Mines;
var int CurrentMines, MaxMines;
var color FadedColor;

replication
{
	reliable if (bNetOwner && bNetDirty && Role == ROLE_Authority)
		CurrentMines;
}

simulated function DrawWeaponInfo(Canvas Canvas)
{
	NewDrawWeaponInfo(Canvas, 0.705*Canvas.ClipY);
}

simulated function NewDrawWeaponInfo(Canvas Canvas, float YPos)
{
	local int i, Half;
	local float ScaleFactor;

	ScaleFactor = 99 * Canvas.ClipX/3200;
	Half = (MaxMines + 1) / 2;
	Canvas.Style = ERenderStyle.STY_Alpha;
	Canvas.DrawColor = class'HUD'.Default.WhiteColor;
	for (i = 0; i < Half; i++)
	{
		if (i >= CurrentMines)
			Canvas.DrawColor = FadedColor;
		Canvas.SetPos(Canvas.ClipX - (i+1) * ScaleFactor * 1.25, YPos);
		Canvas.DrawTile(Material'HudContent.Generic.HUD', ScaleFactor, ScaleFactor, 391, 383, 44, 49);
	}
	for (i = Half; i < MaxMines; i++)
	{
		if (i >= CurrentMines)
			Canvas.DrawColor = FadedColor;
		Canvas.SetPos(Canvas.ClipX - (i-Half+1) * ScaleFactor * 1.25, YPos - ScaleFactor);
		Canvas.DrawTile(Material'HudContent.Generic.HUD', ScaleFactor, ScaleFactor, 391, 383, 44, 49);
	}
}

simulated function bool HasAmmo()
{
    if (CurrentMines > 0)
    	return true;

    return (FireMode[0] != None && AmmoAmount(0) >= FireMode[0].AmmoPerFire);
}

simulated function bool CanThrow()
{
	if ( AmmoAmount(0) <= 0 )
		return false;

	return Super.CanThrow();
}

simulated function Destroyed()
{
	local int x;

	if (Role == ROLE_Authority)
		for (x = 0; x < Mines.Length; x++)
			if (Mines[x] != None)
				Mines[x].Explode(Mines[x].Location, vect(0,0,1));

	Super.Destroyed();
}

// AI Interface
function float GetAIRating()
{
	local Bot B;
	local float EnemyDist;
	local vector EnemyDir;

	if ( AmmoAmount(0) <= 0 )
		return 0;

	B = Bot(Instigator.Controller);
	if (B == None)
		return AIRating;
	if (B.Enemy == None)
	{
		if (B.Formation() && B.Squad.SquadObjective != None && B.Squad.SquadObjective.BotNearObjective(B))
		{
			if ( DestroyableObjective(B.Squad.SquadObjective) != None && B.Squad.SquadObjective.TeamLink(B.Squad.Team.TeamIndex)
			     && DestroyableObjective(B.Squad.SquadObjective).Health < DestroyableObjective(B.Squad.SquadObjective).DamageCapacity )
				return 1.1; //hackish - don't want higher priority than anything that can heal objective

			return 1.5;
		}

		return AIRating;
	}

	// if retreating, favor this weapon
	EnemyDir = B.Enemy.Location - Instigator.Location;
	EnemyDist = VSize(EnemyDir);
	if ( EnemyDist > 1500 )
		return 0.1;
	if ( B.IsRetreating() )
		return (AIRating + 0.4);
	if ( -1 * EnemyDir.Z > EnemyDist )
		return AIRating + 0.1;
	if ( (B.Enemy.Weapon != None) && B.Enemy.Weapon.bMeleeWeapon )
		return (AIRating + 0.3);
	if ( EnemyDist > 1000 )
		return 0.35;
	return AIRating;
}

/* BestMode()
choose between regular or alt-fire
*/
function byte BestMode()
{
	local AIController C;

	C = AIController(Instigator.Controller);
	if (C == None || C.Enemy == None)
		return 0;

	if (CurrentMines < 2 || VSize(C.Enemy.Location - Instigator.Location) < 2500 || FRand() < 0.5)
		return 0;

	return 1;
}

function float SuggestAttackStyle()
{
	local Bot B;
	local float EnemyDist;

	B = Bot(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return 0.4;

	EnemyDist = VSize(B.Enemy.Location - Instigator.Location);
	if ( EnemyDist > 1500 )
		return 1.0;
	if ( EnemyDist > 1000 )
		return 0.4;
	return -0.4;
}

function float SuggestDefenseStyle()
{
	local Bot B;

	B = Bot(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return 0;

	if ( VSize(B.Enemy.Location - Instigator.Location) < 1600 )
		return -0.6;
	return 0;
}

function bool ShouldFireWithoutTarget()
{
	local ONSPowerCore OPC;
	if ( ShootTarget(Instigator.Controller.Target) != None )
	{
		OPC = ONSPowerCore(Instigator.Controller.Target.Owner);
		if ( (OPC != None) && !OPC.Shield.bHidden )
		{
			Instigator.Controller.Target = OPC.PathList[Rand(OPC.PathList.Length)].End;
			return ( Instigator.Controller.Target != None );
		}
	}
	if (CurrentMines < MaxMines)
		return true;

	return false;
}

// End AI Interface

simulated function PlayFiring(bool plunge)
{
    GotoState('AnimateLoad', 'Begin');
}

simulated function RotateBarrel()
{
    FinalRotation -= 65535.0 / NUM_BARRELS;
    if (FinalRotation <= 0.0)
    {
        FinalRotation += 65535.0;
        BarrelRotation += 65535.0;
    }
    bRotateBarrel = True;
}

simulated function UpdateBarrel(float dt)
{
    local Rotator R;

    BarrelRotation -= dt * 65535.0 * BARREL_ROTATION_RATE / NUM_BARRELS;
    if (BarrelRotation < FinalRotation)
    {
        BarrelRotation = FinalRotation;
        bRotateBarrel = False;
        GotoState('');
    }

    R.Roll = BarrelRotation;
    SetBoneRotation('drum', R, 0, 1);
}

simulated state AnimateLoad
{
    simulated function Tick(float dt)
    {
        if (bRotateBarrel)
            UpdateBarrel(dt);
    }

Begin:
    sleep(ReloadDelay);
    RotateBarrel();
    PlaySound(sound'PickupSounds.FlakAmmoPickup', SLOT_Misc);
    ClientPlayForceFeedback("FlakAmmoPickup");
}

defaultproperties
{
    ItemName="Mine Layer"
    Description="The Spider Mine Layer is used for deploying spider mines, autonomous mobile mines that are highly effective against both foot soldiers and vehicles."
    IconMaterial=Material'HudContent.Generic.HUD'
    IconCoords=(X1=229,Y1=258,X2=296,Y2=307)

    FireModeClass(0)=ONSMineThrowFire
    FireModeClass(1)=ONSMineLayerAltFire
    InventoryGroup=3
	GroupOffset=1

    Mesh=Mesh'ONSWeapons-A.MineLayer_1st'

    BobDamping=2.2
    PickupClass=class'ONSMineLayerPickup'
    EffectOffset=(X=100.0,Y=32.0,Z=-20.0)
    AttachmentClass=class'ONSMineLayerAttachment'
    PutDownAnim=PutDown
    ReloadDelay=0.4;
    BringUpTime=0.35
    PutDownTime=0.40
    PutDownAnimRate=4.0
    SelectAnimRate=2.0

    DisplayFOV=45
	AmbientGlow=64.0
    DrawScale=1.0
    PlayerViewOffset=(X=100,Y=35.5,Z=-32.5)
    SmallViewOffset=(X=116,Y=43.5,Z=-40.5)
    PlayerViewPivot=(Pitch=0,Roll=0,Yaw=0)
    SelectSound=Sound'WeaponSounds.FlakCannon.SwitchToFlakCannon'
	SelectForce="SwitchToFlakCannon"

	AIRating=+0.55
	CurrentRating=+0.55
    HudColor=(r=0,g=0,b=255,a=255)
	Priority=5
	CustomCrosshair=14
	CustomCrosshairTextureName="ONSInterface-TX.MineLayerReticle"
	CustomCrosshairColor=(r=255,g=255,b=255,a=255)

	MaxMines=8
	FadedColor=(R=128,G=128,B=128,A=160)
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:31:48.000 - Creation time: Do 14.8.2014 09:58:46.743 - Created with UnCodeX