class MegaTon expands NaliWeapons;

//1st person
#exec MESH IMPORT MESH=MegaTon ANIVFILE=MODELS\MegaTon_a.3d DATAFILE=MODELS\MegaTon_d.3d X=0 Y=0 Z=0 UNMIRROR=1
#exec MESH LODPARAMS MESH=MegaTon STRENGTH=0
#exec MESH ORIGIN MESH=MegaTon X=0 Y=0 Z=0

//3rd person / pickup
#exec MESH IMPORT MESH=MegaTonM ANIVFILE=MODELS\MegaTon_a.3d DATAFILE=MODELS\MegaTon_d.3d X=0 Y=0 Z=0 UNMIRROR=1
#exec MESH LODPARAMS MESH=MegaTonM STRENGTH=0
#exec MESH ORIGIN MESH=MegaTonM X=0 Y=0 Z=0 YAW=128

#exec MESH SEQUENCE MESH=MegaTon SEQ=All STARTFRAME=0 NUMFRAMES=12
#exec MESH SEQUENCE MESH=MegaTon SEQ=Arming STARTFRAME=0 NUMFRAMES=5 RATE=1.0
#exec MESH SEQUENCE MESH=MegaTon SEQ=Armed STARTFRAME=4 NUMFRAMES=1
#exec MESH SEQUENCE MESH=MegaTon SEQ=Disarming STARTFRAME=4 NUMFRAMES=5 RATE=1.0
#exec MESH SEQUENCE MESH=MegaTon SEQ=Setting STARTFRAME=8 NUMFRAMES=2 RATE=2.0
#exec MESH SEQUENCE MESH=MegaTon SEQ=Down STARTFRAME=9 NUMFRAMES=2 RATE=3.0
#exec MESH SEQUENCE MESH=MegaTon SEQ=Select STARTFRAME=10 NUMFRAMES=2 RATE=3.0

#exec MESH SEQUENCE MESH=MegaTonM SEQ=All STARTFRAME=0 NUMFRAMES=12
#exec MESH SEQUENCE MESH=MegaTonM SEQ=Arming STARTFRAME=0 NUMFRAMES=5 RATE=1.0
#exec MESH SEQUENCE MESH=MegaTonM SEQ=Armed STARTFRAME=4 NUMFRAMES=1
#exec MESH SEQUENCE MESH=MegaTonM SEQ=Disarming STARTFRAME=4 NUMFRAMES=5 RATE=1.0
#exec MESH SEQUENCE MESH=MegaTonM SEQ=Setting STARTFRAME=8 NUMFRAMES=2 RATE=2.0

#exec MESHMAP NEW MESHMAP=MegaTon MESH=MegaTon
#exec MESHMAP SCALE MESHMAP=MegaTon X=0.05 Y=0.05 Z=0.1

#exec MESHMAP NEW MESHMAP=MegaTonM MESH=MegaTonM
#exec MESHMAP SCALE MESHMAP=MegaTonM X=0.05 Y=0.05 Z=0.1

//Skins
#exec TEXTURE IMPORT NAME=Sk_MegaTon_01 FILE=SKINS\Sk_MegaTon_01.bmp GROUP=Skins FLAGS=2 LODSET=2
#exec MESHMAP SETTEXTURE MESHMAP=MegaTon NUM=1 TEXTURE=Sk_MegaTon_01
#exec MESHMAP SETTEXTURE MESHMAP=MegaTonM NUM=1 TEXTURE=Sk_MegaTon_01

#exec TEXTURE IMPORT NAME=Sk_MegaTon_02 FILE=SKINS\Sk_MegaTon_02.bmp GROUP=Skins FLAGS=2 LODSET=2
#exec MESHMAP SETTEXTURE MESHMAP=MegaTon NUM=2 TEXTURE=Sk_MegaTon_02
#exec MESHMAP SETTEXTURE MESHMAP=MegaTonM NUM=2 TEXTURE=Sk_MegaTon_02

#exec TEXTURE IMPORT NAME=DigitalMinDead FILE=SKINS\DigitalMinDead.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec MESHMAP SETTEXTURE MESHMAP=MegaTon NUM=3 TEXTURE=DigitalMinDead
#exec MESHMAP SETTEXTURE MESHMAP=MegaTonM NUM=3 TEXTURE=DigitalMinDead

#exec TEXTURE IMPORT NAME=DigitalSecDead FILE=SKINS\DigitalSecDead.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec MESHMAP SETTEXTURE MESHMAP=MegaTon NUM=4 TEXTURE=DigitalSecDead
#exec MESHMAP SETTEXTURE MESHMAP=MegaTon NUM=5 TEXTURE=DigitalSecDead
#exec MESHMAP SETTEXTURE MESHMAP=MegaTonM NUM=4 TEXTURE=DigitalSecDead
#exec MESHMAP SETTEXTURE MESHMAP=MegaTonM NUM=5 TEXTURE=DigitalSecDead

#exec MESHMAP SETTEXTURE MESHMAP=MegaTon NUM=6 TEXTURE=Yeallow_Over
#exec MESHMAP SETTEXTURE MESHMAP=MegaTonM NUM=6 TEXTURE=Yeallow_Over

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

//Digital skinning import-----------------------------------------------------------------------------
#exec TEXTURE IMPORT NAME=DigitalMin0 FILE=SKINS\DigitalMin0.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin1 FILE=SKINS\DigitalMin1.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin2 FILE=SKINS\DigitalMin2.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin3 FILE=SKINS\DigitalMin3.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin4 FILE=SKINS\DigitalMin4.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin5 FILE=SKINS\DigitalMin5.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin6 FILE=SKINS\DigitalMin6.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin7 FILE=SKINS\DigitalMin7.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin8 FILE=SKINS\DigitalMin8.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalMin9 FILE=SKINS\DigitalMin9.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec0 FILE=SKINS\DigitalSec0.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec1 FILE=SKINS\DigitalSec1.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec2 FILE=SKINS\DigitalSec2.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec3 FILE=SKINS\DigitalSec3.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec4 FILE=SKINS\DigitalSec4.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec5 FILE=SKINS\DigitalSec5.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec6 FILE=SKINS\DigitalSec6.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec7 FILE=SKINS\DigitalSec7.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec8 FILE=SKINS\DigitalSec8.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
#exec TEXTURE IMPORT NAME=DigitalSec9 FILE=SKINS\DigitalSec9.bmp GROUP=Skins FLAGS=2 LODSET=0 MIPS=OFF
//----------------------------------------------------------------------------------------------------

//Sounds
#exec AUDIO IMPORT NAME="MegaTon_Pickup" FILE=SOUNDS\MegaTon_Pickup.wav GROUP="MegaTon"
#exec AUDIO IMPORT NAME="MegaTon_Set" FILE=SOUNDS\MegaTon_Set.wav GROUP="MegaTon"
#exec AUDIO IMPORT NAME="MegaTon_SetDone" FILE=SOUNDS\MegaTon_SetDone.wav GROUP="MegaTon"

var() texture DigitalSeconds[10], DigitalMinutes[10];
var float TimeToBlow;
var byte NukePassword[3];

var byte TweakStage;

replication
{
	reliable if (Role == ROLE_Authority)
		TimeToBlow, NukePassword;
	reliable if (Role == ROLE_Authority && bNetOwner)
		TweakStage;
}


simulated function PostBeginPlay()
{
	if (TimeToBlow > 999)
		TimeToBlow = 999;

	bOwnsCrossHair = True;
}


function Fire( float Value )
{
local MegaTonOMFG MT;

	GotoState('NormalFire');
        bPointing=True;
        bCanClientFire = true;
        ClientFire(Value);

	if (TweakStage == 0)
	{

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

	if (AmmoType.UseAmmo(1))
	{
		GotoState('NormalFire');
		bPointing=True;
		bCanClientFire = true;
		ClientFire(Value);

		MT = MegaTonOMFG(ProjectileFire(Class'MegaTonOMFG', ProjectileSpeed, bWarnTarget));
		MT.TimeToBlow = TimeToBlow;
		MT.NukePassword[0] = NukePassword[0];
		MT.NukePassword[1] = NukePassword[1];
		MT.NukePassword[2] = NukePassword[2];
    	}
	}
	else if (TweakStage > 0)
		SetFireAction();
}

simulated function SetFireAction()
{
	TweakStage++;

	if (TweakStage > 4)
		TweakStage = 0;
}


simulated function PlayFiring()
{
	if (TweakStage == 0)
	{
		PlayAnim('Setting', 5.0, 0.0);
		PlayOwnedSound(SelectSound, SLOT_None, Pawn(Owner).SoundDampening*3.0);
	}
	else
	{
		PlayAnim('Setting', 1.0, 0.0);
		PlayOwnedSound(FireSound, SLOT_None, Pawn(Owner).SoundDampening*3.0);
	}
}

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

	SetAltFireAction();
}


simulated function SetAltFireAction()
{
	if (TweakStage == 0)
		TweakStage = 1;

	if (TweakStage == 1)
	{
		//Available times: 30s / 1min / 2min30s / 5min
		if (TimeToBlow == 30)
			TimeToBlow = 60;
		else if (TimeToBlow == 60)
			TimeToBlow = 150;
		else if (TimeToBlow == 150)
			TimeToBlow = 300;
		else if (TimeToBlow == 300)
			TimeToBlow = 30;
	}
	else if (TweakStage == 2)
	{
		NukePassword[0]++;

		if (NukePassword[0] > 9)
			NukePassword[0] = 0;
	}
	else if (TweakStage == 3)
	{
		NukePassword[1]++;

		if (NukePassword[1] > 9)
			NukePassword[1] = 0;
	}
	else if (TweakStage == 4)
	{
		NukePassword[2]++;

		if (NukePassword[2] > 9)
			NukePassword[2] = 0;
	}
}

simulated function Tick( float DeltaTime)
{
local float Min, SecD, SecU;

	if (Pawn(Owner) != None)
	{
	if (TweakStage == 0 || TweakStage == 1)
	{
		Min = Int(TimeToBlow / 60);
		SecD = Int(((TimeToBlow / 60) - Min) * 6);
		SecU = Int(((TimeToBlow / 60) - Min) * 60 - 10*SecD);

		MultiSkins[3] = DigitalMinutes[Int(Min)];
		MultiSkins[4] = DigitalSeconds[Int(SecD)];
		MultiSkins[5] = DigitalSeconds[Int(SecU)];
	}
	else if (TweakStage == 2)
	{
		MultiSkins[3] = DigitalMinutes[NukePassword[0]];
		MultiSkins[4] = None;
		MultiSkins[5] = None;
	}
	else if (TweakStage == 3)
	{
		MultiSkins[3] = None;
		MultiSkins[4] = DigitalSeconds[NukePassword[1]];
		MultiSkins[5] = None;
	}
	else if (TweakStage == 4)
	{
		MultiSkins[3] = None;
		MultiSkins[4] = None;
		MultiSkins[5] = DigitalSeconds[NukePassword[2]];
	}
	}
	else
	{
		MultiSkins[3] = None;
		MultiSkins[4] = None;
		MultiSkins[5] = None;
	}
}


simulated function PlayAltFiring()
{
	PlayAnim('Setting', 2.0, 0.0);
	PlayOwnedSound(AltFireSound, SLOT_None, Pawn(Owner).SoundDampening*3.0);
}

simulated function TweenDown()
{
    if ( IsAnimating() && (AnimSequence != '') && (GetAnimGroup(AnimSequence) == 'Select') )
        TweenAnim( AnimSequence, AnimFrame * 0.4 );
    else if (AmmoType.AmmoAmount > 0)
        PlayAnim('Down', 1.0, 0.05);
    else
	PlayAnim('Down', 5.0, 0.05);
}


defaultproperties
{
	DrawType=DT_Mesh
	Mesh=MegaTonM
	CollisionRadius=15.000000
	CollisionHeight=16.000000
	AutoSwitchPriority=10
	Icon=MegaTonIcon
	InventoryGroup=10
	ItemArticle="a"
	ItemName="MegaTon"
	MaxDesireability=2.000000
	PickupMessage="You got a MegaTon."
	PickupSound=MegaTon_Pickup
	PickupViewMesh=MegaTonM
	PickupViewScale=1.000000
	PlayerViewMesh=MegaTon
	PlayerViewOffset=(X=35.000000,Y=0.000000,Z=-10.000000)
	PlayerViewScale=1.000000
	RespawnTime=300.000000
	StatusIcon=MegaTonIcon
	ThirdPersonMesh=MegaTonM
	ThirdPersonScale=1.000000
	AltDamageType=None
	AltFireSound=MegaTon_Set
	AltProjectileClass=None
	bInstantHit=False
	AmmoName=Class'MegaTonAmmo'
	DeathMessage="%o's existence right was denied by %k's %w."
	FireOffset=(X=0.000000,Y=0.000000,Z=0.000000)
	FireSound=MegaTon_SetDone
	FiringSpeed=1.000000
	MaxTargetRange=4096.000000
	MyDamageType=MushroomNuke
	NameColor=(R=64,G=0,B=0)
	PickupAmmoCount=1
	ProjectileClass=MegaTonOMFG
	SelectSound=MegaTon_Pickup
	shakemag=0.000000
	shaketime=0.200000
	shakevert=0.000000
	AIRating=2.000000
	AltRefireRate=1.000000
	bAltWarnTarget=False
	bRecommendAltSplashDamage=False
	bRecommendSplashDamage=False
	bSplashDamage=False
	bWarnTarget=False
	RefireRate=1.200000
	Mass=150.000000
	bNoSmooth=False
	bOwnsCrossHair=True
	CustomCross=None
	CrossHairSize=64
	bMegaWeapon=True
	DigitalSeconds(0)=DigitalSec0
	DigitalSeconds(1)=DigitalSec1
	DigitalSeconds(2)=DigitalSec2
	DigitalSeconds(3)=DigitalSec3
	DigitalSeconds(4)=DigitalSec4
	DigitalSeconds(5)=DigitalSec5
	DigitalSeconds(6)=DigitalSec6
	DigitalSeconds(7)=DigitalSec7
	DigitalSeconds(8)=DigitalSec8
	DigitalSeconds(9)=DigitalSec9
	DigitalMinutes(0)=DigitalMin0
	DigitalMinutes(1)=DigitalMin1
	DigitalMinutes(2)=DigitalMin2
	DigitalMinutes(3)=DigitalMin3
	DigitalMinutes(4)=DigitalMin4
	DigitalMinutes(5)=DigitalMin5
	DigitalMinutes(6)=DigitalMin6
	DigitalMinutes(7)=DigitalMin7
	DigitalMinutes(8)=DigitalMin8
	DigitalMinutes(9)=DigitalMin9
	TimeToBlow=30.000000
	bRotatingPickup=False
}
