myindex = 0;
owner = 0;
currenttime = 0;
itexists = nil
stage2time = nil
stage1 = nil
larpa = nil
larpatime = nil
larpaexists = nil
larpatimed = nil
larpadeath = nil

function onInit()
	_SWEPSetSound(myindex, "single_shot", "weapon_physcannon.launch");
end

function onThink()
	local pos = _PlayerGetShootPos(owner);
	local ang = _PlayerGetShootAng(owner);
	if (_EntExists(stage1) == false) then
		itexists = 0
	end
	if (_EntExists(larpa) == false) then
		larpaexists = 0
	end
	if (stage2time == nil) then return; end
	if (stage2time < _CurTime()) and (itexists == 1) then
		itexists = 0;
		local moopos = _EntGetPos(stage1);
		local newpos1x = moopos.x + 30;
		local newpos1y = moopos.y + 30;
		local newpos1z = moopos.z + 30;
		local newpos2x = moopos.x - 30;
		local newpos2y = moopos.y - 30;
		local newpos2z = moopos.z - 30;
		local child1 = _EntCreate("Prop_Physics");
		local child2 = _EntCreate("Prop_Physics");
		local child3 = _EntCreate("Prop_Physics");
		local child4 = _EntCreate("Prop_Physics");
		local child5 = _EntCreate("Prop_Physics");
		local child6 = _EntCreate("Prop_Physics");
		_EntPrecacheModel("models/props_junk/gascan001a.mdl");
		_EntSetModel(child1, "models/props_junk/gascan001a.mdl");
		_EntSetModel(child2, "models/props_junk/gascan001a.mdl");
		_EntSetModel(child3, "models/props_junk/gascan001a.mdl");
		_EntSetModel(child4, "models/props_junk/gascan001a.mdl");
		_EntSetModel(child5, "models/props_junk/gascan001a.mdl");
		_EntSetModel(child6, "models/props_junk/gascan001a.mdl");
		_EntSetKeyValue(child1, "damage", "100");
		_EntSetKeyValue(child2, "damage", "100");
		_EntSetKeyValue(child3, "damage", "100");
		_EntSetKeyValue(child4, "damage", "100");
		_EntSetKeyValue(child5, "damage", "100");
		_EntSetKeyValue(child6, "damage", "100");
		_EntSetPos(child1, vector3(moopos.x, moopos.y, newpos1z));
		_EntSetPos(child2, vector3(moopos.x, newpos1y, moopos.z));
		_EntSetPos(child3, vector3(newpos1x, moopos.y, moopos.z));
		_EntSetPos(child4, vector3(moopos.x, moopos.y, newpos2z));
		_EntSetPos(child5, vector3(moopos.x, newpos2y, moopos.z));
		_EntSetPos(child6, vector3(newpos2x, moopos.y, moopos.z));
		_EntSpawn(child1);
		_EntSpawn(child2);
		_EntSpawn(child3);
		_EntSpawn(child4)
		_EntSpawn(child5);
		_EntSpawn(child6);
		_EntFire(stage1, "Sethealth", "1", " ");
		_EntFire(stage1, "ignite", " ", "3");
		_EntFire(child1, "ignite", " ", " ");
		_EntFire(child2, "ignite", " ", " ");
		_EntFire(child3, "ignite", " ", " ");
		_EntFire(child4, "ignite", " ", " ");
		_EntFire(child5, "ignite", " ", " ");
		_EntFire(child6, "ignite", " ", " ");
	end
	if (larpatime < _CurTime()) and (larpaexists == 1) then
		larpatime = _CurTime() + 0.3
		local larpachild = _EntCreate("Prop_Physics");
		local larpapos = _EntGetPos(larpa);
		local larpaposz = larpapos.z - 30;
		_EntSetPos(larpachild, vector3(larpapos.x, larpapos.y, larpaposz));
		_EntPrecacheModel("models/props_junk/gascan001a.mdl");
		_EntSetModel(larpachild, "models/props_junk/gascan001a.mdl");
		_EntSetKeyValue(larpachild, "damage", "100");
		_EntSpawn(larpachild);
		_EntFire(larpachild, "ignite", " ", " ");
	end
	if (larpadeath < _CurTime()) and (larpaexists == 1) then
		larpaexists = 0
		_EntFire(larpa, "ignite", " ", " ");
	end
end

function onPrimaryAttack()
	if (_PlayerInfo(Owner, "alive") == false) then return; end
	if (itexists == 1) then return; end 
	stage1 = _EntCreate( "prop_physics" );
	_EntPrecacheModel( "models/props_c17/oildrum001_explosive.mdl" );
	_EntSetModel(stage1, "models/props_c17/oildrum001_explosive.mdl");
	_EntSetPos(stage1, vecAdd(_PlayerGetShootPos(Owner),vector3(0,0,32)));
	_EntSetAng(stage1, _PlayerGetShootAng(Owner));
	_EntSetKeyValue(stage1, "damage", "100");
	local power = 9999999;
	local fireforce = vecMul(_PlayerGetShootAng(Owner), vector3(power, power, power));
	stage2time = _CurTime() + 1;
	_EntSetGravity ( stage1, 0 )
	_EntSpawn(stage1);
	_PhysApplyForce(stage1, fireforce);
	_EntSetGravity ( stage1, 0 )
	_SWEPUseAmmo(MyIndex, 0, 1);
	itexists = 1
end

function onSecondaryAttack()		
	if (_PlayerInfo(Owner, "alive") == false) then return; end
	if (larpaexists == 1) then return; end 
	larpa = _EntCreate( "prop_physics" );
	_EntPrecacheModel( "models/props_c17/oildrum001_explosive.mdl" );
	_EntSetModel(larpa, "models/props_c17/oildrum001_explosive.mdl");
	_EntSetPos(larpa, vecAdd(_PlayerGetShootPos(Owner),vector3(0,0,32)));
	_EntSetAng(larpa, _PlayerGetShootAng(Owner));
	_EntSetKeyValue(larpa, "damage", "100");
	local power = 9999999;
	local fireforce = vecMul(_PlayerGetShootAng(Owner), vector3(power, power, power));
	larpatime = _CurTime() + 0.3;
	_EntSpawn(larpa);
	_PhysApplyForce(larpa, fireforce);
	_SWEPUseAmmo(MyIndex, 0, 1);
	larpaexists = 1
	larpatimed = 1
	larpadeath = _CurTime() + 3
end

function onReload( )
	return true;
end

function getWeaponSwapHands()
	return false;	
end

function getWeaponFOV()
	return 60;	
end


function getWeaponSlot()
	return 1;	
end

function getWeaponSlotPos()
	return 4;	
end

function getFiresUnderwater()
	return true;
end

function getReloadsSingly()
	return true;
end

function getDamage()
	return 0;
end

function getPrimaryShotDelay()
	return 0.5;
end

function getSecondaryShotDelay()
	return 0.3;
end

function getPrimaryIsAutomatic()
	return true;
end

function getSecondaryIsAutomatic()
	return false;
end

function getPrimaryAmmoType()
	return "pistol";
end

function getSecondaryAmmoType()
	return "none";
end

function getMaxClipPrimary()
	return 500;
end

function getMaxClipSecondary()
	return -1;
end

function getDefClipPrimary()
	return 500;
end


function getDefClipSecondary()
	return -1;
end

function getPrimaryScriptOverride()
	return 2;
end

function getSecondaryScriptOverride()
	return 3;
end

function getBulletSpread()
	return vector3( 0.0, 0.0, 0.0 );
end

function getViewKick()
	return vector3( 0, 0.0, 0.0);
end

function getViewKickRandom()
	return vector3( 0.0, 0.0, 0.0 );
end

function getViewModel( )
	return "models/weapons/v_rpg.mdl";
end

function getWorldModel( )
	return "models/weapons/w_rocket_launcher.mdl";
end

function getClassName()
	return "ultimate_clusterfuck";
end

function getAnimPrefix()
	return "rpg";
end

function getPrintName()
	return "Clusterfuck missile";
end
