class CybotLauncher expands NaliWeapons;

//1st person
#exec MESH IMPORT MESH=CybotLauncher ANIVFILE=MODELS\CybotLauncher_a.3d DATAFILE=MODELS\CybotLauncher_d.3d X=0 Y=0 Z=0
#exec MESH LODPARAMS MESH=CybotLauncher STRENGTH=0
#exec MESH ORIGIN MESH=CybotLauncher X=0 Y=0 Z=0 YAW=128

//1st person right handed
#exec MESH IMPORT MESH=CybotLauncherR ANIVFILE=MODELS\CybotLauncher_a.3d DATAFILE=MODELS\CybotLauncher_d.3d X=0 Y=0 Z=0 UNMIRROR=1 UNMIRRORTEX=2
#exec MESH LODPARAMS MESH=CybotLauncherR STRENGTH=0
#exec MESH ORIGIN MESH=CybotLauncherR X=0 Y=0 Z=0

//Pickup
#exec MESH IMPORT MESH=CybotLauncherPick ANIVFILE=MODELS\CybotLauncher_a.3d DATAFILE=MODELS\CybotLauncher_d.3d X=0 Y=0 Z=0
//#exec MESH LODPARAMS MESH=CybotLauncherPick STRENGTH=0
#exec MESH ORIGIN MESH=CybotLauncherPick X=0 Y=0 Z=0 YAW=128

//3rd person
#exec MESH IMPORT MESH=CybotLauncherM ANIVFILE=MODELS\CybotLauncher_a.3d DATAFILE=MODELS\CybotLauncher_d.3d X=0 Y=0 Z=0
#exec MESH LODPARAMS MESH=CybotLauncherM STRENGTH=0
#exec MESH ORIGIN MESH=CybotLauncherM X=400 Y=0 Z=-60 YAW=128

//-----------------------------------------------------------------------------------

//Animations
#exec MESH SEQUENCE MESH=CybotLauncher SEQ=All STARTFRAME=0 NUMFRAMES=18
#exec MESH SEQUENCE MESH=CybotLauncher SEQ=Still STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=CybotLauncher SEQ=Fire STARTFRAME=0 NUMFRAMES=7 RATE=12.0
#exec MESH SEQUENCE MESH=CybotLauncher SEQ=Select STARTFRAME=7 NUMFRAMES=5 RATE=7.0 GROUP=Select
#exec MESH SEQUENCE MESH=CybotLauncher SEQ=Down STARTFRAME=11 NUMFRAMES=5 RATE=14.0
#exec MESH SEQUENCE MESH=CybotLauncher SEQ=AltFire STARTFRAME=16 NUMFRAMES=2 RATE=3.0

#exec MESH SEQUENCE MESH=CybotLauncherR SEQ=All STARTFRAME=0 NUMFRAMES=18
#exec MESH SEQUENCE MESH=CybotLauncherR SEQ=Still STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=CybotLauncherR SEQ=Fire STARTFRAME=0 NUMFRAMES=7 RATE=12.0
#exec MESH SEQUENCE MESH=CybotLauncherR SEQ=Select STARTFRAME=7 NUMFRAMES=5 RATE=7.0 GROUP=Select
#exec MESH SEQUENCE MESH=CybotLauncherR SEQ=Down STARTFRAME=11 NUMFRAMES=5 RATE=14.0
#exec MESH SEQUENCE MESH=CybotLauncherR SEQ=AltFire STARTFRAME=16 NUMFRAMES=2 RATE=3.0

#exec MESH SEQUENCE MESH=CybotLauncherPick SEQ=Still STARTFRAME=0 NUMFRAMES=1

#exec MESH SEQUENCE MESH=CybotLauncherM SEQ=Still STARTFRAME=0 NUMFRAMES=1

//-----------------------------------------------------------------------------------

//Scale
#exec MESHMAP NEW MESHMAP=CybotLauncher MESH=CybotLauncher
#exec MESHMAP SCALE MESHMAP=CybotLauncher X=0.04125 Y=0.04125 Z=0.0825

#exec MESHMAP NEW MESHMAP=CybotLauncherR MESH=CybotLauncherR
#exec MESHMAP SCALE MESHMAP=CybotLauncherR X=0.04125 Y=0.04125 Z=0.0825

#exec MESHMAP NEW MESHMAP=CybotLauncherPick MESH=CybotLauncherPick
#exec MESHMAP SCALE MESHMAP=CybotLauncherPick X=0.04125 Y=0.04125 Z=0.0825

#exec MESHMAP NEW MESHMAP=CybotLauncherM MESH=CybotLauncherM
#exec MESHMAP SCALE MESHMAP=CybotLauncherM X=0.04125 Y=0.04125 Z=0.0825

//-----------------------------------------------------------------------------------

//Skins
#exec TEXTURE IMPORT NAME=Sk_CybotLauncher_01 FILE=SKINS\Sk_CybotLauncher_01.bmp GROUP=Skins FLAGS=2 LODSET=2
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncher NUM=1 TEXTURE=Sk_CybotLauncher_01
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherR NUM=1 TEXTURE=Sk_CybotLauncher_01
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherPick NUM=1 TEXTURE=Sk_CybotLauncher_01
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherM NUM=1 TEXTURE=Sk_CybotLauncher_01

#exec TEXTURE IMPORT NAME=DisplayZTrue FILE=SCREENS\DisplayZTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncher NUM=2 TEXTURE=DisplayZTrue
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherR NUM=2 TEXTURE=DisplayZTrue
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherPick NUM=2 TEXTURE=DisplayZTrue
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherM NUM=2 TEXTURE=DisplayZTrue

#exec TEXTURE IMPORT NAME=Sk_CybotLauncher_02 FILE=SKINS\Sk_CybotLauncher_02.bmp GROUP=Skins FLAGS=2 LODSET=2
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncher NUM=3 TEXTURE=Sk_CybotLauncher_02
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherR NUM=3 TEXTURE=Sk_CybotLauncher_02
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherPick NUM=3 TEXTURE=Sk_CybotLauncher_02
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherM NUM=3 TEXTURE=Sk_CybotLauncher_02

#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncher NUM=4 TEXTURE=UnrealShare.Belt_fx.ShieldBelt.RedShield
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherR NUM=4 TEXTURE=UnrealShare.Belt_fx.ShieldBelt.RedShield
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherPick NUM=4 TEXTURE=UnrealShare.Belt_fx.ShieldBelt.RedShield
#exec MESHMAP SETTEXTURE MESHMAP=CybotLauncherM NUM=4 TEXTURE=UnrealShare.Belt_fx.ShieldBelt.RedShield

//-----------------------------------------------------------------------------------

//Screens
#exec TEXTURE IMPORT NAME=DisplayZFalse FILE=SCREENS\DisplayZFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayYFalse FILE=SCREENS\DisplayYFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayYTrue FILE=SCREENS\DisplayYTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplaySYFalse FILE=SCREENS\DisplaySYFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplaySYTrue FILE=SCREENS\DisplaySYTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplaySZFalse FILE=SCREENS\DisplaySZFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplaySZTrue FILE=SCREENS\DisplaySZTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayAXFalse FILE=SCREENS\DisplayAXFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayAXTrue FILE=SCREENS\DisplayAXTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayFXFalse FILE=SCREENS\DisplayFXFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayFXTrue FILE=SCREENS\DisplayFXTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayHXFalse FILE=SCREENS\DisplayHXFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayHXTrue FILE=SCREENS\DisplayHXTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayKXFalse FILE=SCREENS\DisplayKXFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayKXTrue FILE=SCREENS\DisplayKXTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayTXFalse FILE=SCREENS\DisplayTXFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayTXTrue FILE=SCREENS\DisplayTXTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayVXFalse FILE=SCREENS\DisplayVXFalse.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DisplayVXTrue FILE=SCREENS\DisplayVXTrue.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF


//--------------------------------------------------------------

//Icons
#exec TEXTURE IMPORT NAME=CybotIcon FILE=ICONS\CybotIcon.bmp GROUP=Icons MIPS=OFF

#exec OBJ LOAD FILE=Textures\NaliIcons.utx PACKAGE=NaliWeaponsII.Icons

//--------------------------------------------------------------

//Sounds
#exec AUDIO IMPORT NAME="Cybot_AltFire" FILE=SOUNDS\Cybot_AltFire.wav GROUP="Cybot"
#exec AUDIO IMPORT NAME="Cybot_Fire" FILE=SOUNDS\Cybot_Fire.wav GROUP="Cybot"
#exec AUDIO IMPORT NAME="Cybot_Pickup" FILE=SOUNDS\Cybot_Pickup.wav GROUP="Cybot"
#exec AUDIO IMPORT NAME="Cybot_Select" FILE=SOUNDS\Cybot_Select.wav GROUP="Cybot"


var() texture ScreenOK[10], ScreenFault[10];
var() int AmmoUsage[10];
var() Class<projectile> CProj[10];
var byte SelectedM;


replication
{
	reliable if(ROLE == Role_Authority && bNetOwner)
		SelectedM;
}


function PreBeginPlay()
{
	Super.PreBeginPlay();
	if ((Level.Game.IsA('MonsterHunt') && Class'NWMutator'.Default.EnableMonsterHuntMode && Class'NWMutator'.Default.MonsterHuntOnly) || (Class'NWMutator'.Default.EnableMonsterHuntMode && !Class'NWMutator'.Default.MonsterHuntOnly))
	{
		PickupAmmoCount *= Class'NWMutator'.default.ammo_Cybot;
	}
}


function setHand(float Hand)
{
	Super.SetHand(Hand);
	if ( Hand == 1 )
		Mesh = mesh'CybotLauncher';
	else
		Mesh = mesh'CybotLauncherR';
}


function Fire( float Value )
{
local Projectile pj;

    if ( (AmmoType == None) && (AmmoName != None) )
    {
        // ammocheck
        GiveAmmo(Pawn(Owner));
    }

	if (AmmoType.UseAmmo(AmmoUsage[SelectedM]))
    {
        GotoState('NormalFire');
        bPointing=True;
        bCanClientFire = true;
        ClientFire(Value);

	if (AmmoType.AmmoAmount < AmmoUsage[SelectedM])
		MultiSkins[4] = ScreenFault[SelectedM];

	pj = ProjectileFire(CProj[SelectedM], ProjectileSpeed, bWarnTarget);
    }
	else
		PlayFiring();
}


simulated function PlayFiring()
{
	PlayAnim('Fire', 1.0, 0.0);
	PlayOwnedSound(FireSound, SLOT_None, Pawn(Owner).SoundDampening*8.0);
}


function AltFire( float Value )
{
        GotoState('AltFiring');
        bPointing=True;
        bCanClientFire = true;
        ClientAltFire(Value);
}


simulated function PlayAltFiring()
{
	PlayAnim('AltFire', 1.0, 0.0);

	SelectedM++;

	if (SelectedM >= 10)
		SelectedM = 0;

	PlayOwnedSound(AltFireSound, SLOT_None, Pawn(Owner).SoundDampening*3.0);
}



simulated function Tick( float DeltaTime)
{

	If (AmmoType != None)
	{
	if (AmmoType.AmmoAmount >= AmmoUsage[SelectedM] && MultiSkins[2] != ScreenOK[SelectedM])
		MultiSkins[2] = ScreenOK[SelectedM];
	else if (AmmoType.AmmoAmount < AmmoUsage[SelectedM] && MultiSkins[2] != ScreenFault[SelectedM])
		MultiSkins[2] = ScreenFault[SelectedM];
	}

	if ( (SelectedM == 0 || SelectedM == 1) && MultiSkins[4] != None)
		MultiSkins[4] = None;
	else if ( (SelectedM == 2 || SelectedM == 3) && MultiSkins[4] != Texture'UnrealShare.Belt_fx.ShieldBelt.N_Shield')
		MultiSkins[4] = Texture'UnrealShare.Belt_fx.ShieldBelt.N_Shield';
	else if ( SelectedM > 3 && MultiSkins[4] != Texture'PurpleN_Over')
		MultiSkins[4] = Texture'PurpleN_Over';

}


function float RateSelf( out int bUseAltMode )
{
	local float EnemyDist, Rating;
	local bool bRetreating;
	local vector EnemyDir;
	local Pawn P;

	P = Pawn(Owner);

	//No enemy, ready to fire
	if ( P.Enemy == None )
        	return AIRating;

	//Don't recommend self if out of ammo
	if ( AmmoType.AmmoAmount <=0 )
        	return -2;

	//Choose missile
	if (AmmoType.AmmoAmount < AmmoUsage[SelectedM])
		bUseAltMode = 1;
	else if (AmmoUsage[SelectedM] == 5)
		bUseAltMode = 0;
	else if (AmmoUsage[SelectedM] < 5)
		bUseAltMode = int(FRand() + 0.5);

	return (AIRating + FRand() * 0.05);
}



defaultproperties
{
	DrawType=DT_Mesh
	Mesh=CybotLauncherPick
	CollisionHeight=7.000000
	CollisionRadius=15.000000
	AutoSwitchPriority=10
	Icon=CybotIcon
	InventoryGroup=10
	ItemArticle="a"
	ItemName="CyBot Launcher"
	MaxDesireability=1.000000
	PickupMessage="You got the CyBot Launcher."
	PickupSound=Cybot_Pickup
	PickupViewMesh=CybotLauncherPick
	PickupViewScale=1.000000
	PlayerViewMesh=CybotLauncherR
	PlayerViewOffset=(X=32.000000,Y=-10.000000,Z=-12.000000)
	PlayerViewScale=1.000000
	RespawnTime=120.000000
	StatusIcon=CybotIcon
	ThirdPersonMesh=CybotLauncherM
	ThirdPersonScale=0.750000
	AltDamageType=None
	AltFireSound=Cybot_AltFire
	AltProjectileClass=None
	AmmoName=Class'CybotAmmo'
	bInstantHit=False
	bRapidFire=False
	DeathMessage="%o was fragged by %k's cybot."
	FireOffset=(X=0.000000,Y=-4.000000,Z=0.000000)
	FireSound=Cybot_Fire
	FiringSpeed=1.000000
	MaxTargetRange=4096.000000
	MyDamageType=None
	NameColor=(R=32,G=32,B=0)
	PickupAmmoCount=3
	ProjectileClass=None
	SelectSound=Cybot_Select
	shakemag=0.000000
	shaketime=0.000000
	shakevert=0.000000
	AIRating=1.500000
	AltRefireRate=1.000000
	bAltWarnTarget=False
	bRecommendAltSplashDamage=False
	bRecommendSplashDamage=True
	bSplashDamage=True
	bWarnTarget=False
	RefireRate=0.600000
	Mass=30.000000
	bNoSmooth=False
	bOwnsCrossHair=True
	CustomCross=CybotCross
	CrossHairSize=64
	CrossHairScale=0.800000
	bMegaWeapon=True
	ScreenOK(0)=DisplayZTrue
	ScreenOK(1)=DisplaySZTrue
	ScreenOK(2)=DisplayYTrue
	ScreenOK(3)=DisplaySYTrue
	ScreenOK(4)=DisplayAXTrue
	ScreenOK(5)=DisplayFXTrue
	ScreenOK(6)=DisplayHXTrue
	ScreenOK(7)=DisplayKXTrue
	ScreenOK(8)=DisplayTXTrue
	ScreenOK(9)=DisplayVXTrue
	ScreenFault(0)=DisplayZFalse
	ScreenFault(1)=DisplaySZFalse
	ScreenFault(2)=DisplayYFalse
	ScreenFault(3)=DisplaySYFalse
	ScreenFault(4)=DisplayAXFalse
	ScreenFault(5)=DisplayFXFalse
	ScreenFault(6)=DisplayHXFalse
	ScreenFault(7)=DisplayKXFalse
	ScreenFault(8)=DisplayTXFalse
	ScreenFault(9)=DisplayVXFalse
	AmmoUsage(0)=1
	AmmoUsage(1)=2
	AmmoUsage(2)=2
	AmmoUsage(3)=3
	AmmoUsage(4)=3
	AmmoUsage(5)=4
	AmmoUsage(6)=4
	AmmoUsage(7)=4
	AmmoUsage(8)=4
	AmmoUsage(9)=5
	CProj(0)=Class'CyBotProjZ'
	CProj(1)=Class'CyBotProjSZ'
	CProj(2)=Class'CyBotProjY'
	CProj(3)=Class'CyBotProjSY'
	CProj(4)=Class'CyBotProjAX'
	CProj(5)=Class'CyBotProjFX'
	CProj(6)=Class'CyBotProjHX'
	CProj(7)=Class'CyBotProjKX'
	CProj(8)=Class'CyBotProjTX'
	CProj(9)=Class'CyBotProjVX'
}
