Code:

CreateCannon(pos)
{
center = spawn("script_origin", bullettrace(self gettagorigin("j_head"), self gettagorigin("j_head")+anglestoforward(self getplayerangles())*20000000, 0, self)["position"]);
org = center.origin;
level.artillery = [];
level.artillery[0] = cbox(org+(41.25,0,0));
level.artillery[1] = cbox(org+(96.25,0,0));
level.artillery[2] = cbox(org+(-41.25,0,0));
level.artillery[3] = cbox(org+(-96.25,0,0));
level.artillery[4] = cbox(org+(0,41.25,0));
level.artillery[5] = cbox(org+(0,96.25,0));
level.artillery[6] = cbox(org+(0,-41.25,0));
level.artillery[7] = cbox(org+(0,-96.25,0));
level.swivel = [];
level.swivel[0] = cbox(org-(0,0,14));
level.swivel[0].angles = (90,0,0);
level.swivel[1] = cbox(org+(0,0,28));
level.swivel[2] = cbox(org+(41.25,0,69));
level.swivel[2].angles = (90,0,0);
level.swivel[3] = cbox(org+(-41.25,0,69));
level.swivel[3].angles = (-90,0,0);
level.swivel[4] = cbox(org+(-41.25,0,29));
level.swivel[4].angles = (0,90,0);
level.swivel[5] = cbox(org+(41.25,0,29));
level.swivel[5].angles = (0,-90,0);
level.swivel[6] = cbox(org+(-41.25,0,110));
level.swivel[6].angles = (0,90,0);
level.swivel[7] = cbox(org+(41.25,0,110));
level.swivel[7].angles = (0,-90,0);
level.barrel = [];
for(i=0;i<=6;i++)
{
level.barrel[i] = cbox(org+(0,i*55-110,110));
level.barrel[i].angles = (0,90,0);
}
level.barrel[7] = cbox(org+(0,0,109.99));
for(i=4;i<=7;i++)
level.artillery[i].angles = (0,90,0);
level.gunpos = spawn("script_origin", org+(0,245,110));
level.gunpos.angles = (0,90,0);
level.pitch = spawn("script_origin", org+(0,0,110));
foreach(barrel in level.barrel)
barrel linkto(level.pitch);
level.gunpos linkto(level.pitch);
level.turn = spawn("script_origin", org);
foreach(swivel in level.swivel)
swivel linkto(level.turn);
level.turn linkto(level.pitch);
level.computer = cbox(org+(-165,-165,14));
level.computer.angles = (0,-45,0);
level.pc = spawn("script_model", level.computer.origin+(0,0,14 ));
level.pc setModel( "com_laptop_2_open" );
level.pc.angles = (0,-135,0);
level.pctrig = spawn("trigger_radius", level.computer.origin,0,70,70);
level.pctrig thread CannonUse();
}
cbox(location)
{
box = spawn("script_model", location);
box setModel( "com_plasticcase_enemy" );
box CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
return box;
}
CannonUse()
{
player = "fsf";
if(level.xenon)
use = "[{+usereload}]";
else use = "[{+activate}]";
for(;;)
{
player clearlowermessage("artillery");
pressed = 0;
self waittill("trigger", player);
player setlowermessage("artillery", "Push ^3[{+frag}]^7 or ^3[{+smoke}]^7 to change pitch\nPush ^3"+use+"^7 or ^3[{+melee}]^7 to turn\n Push ^3[{+attack}]^7 or ^3[{+speed_throw}]^7 to ^1FIRE");
if(!pressed)
while(player fragbuttonpressed())
{
pressed = 1;
level.turn unlink();
if(level.pitch.angles[2] <= 37.5)
level.pitch rotateto(level.pitch.angles+(0,0,2), 0.2);
wait 0.2;
}
if(!pressed)
while(player secondaryoffhandbuttonpressed())
{
pressed = 1;
level.turn unlink();
if(level.pitch.angles[2] >= -22)
level.pitch rotateto(level.pitch.angles-(0,0,2), 0.2);
wait 0.2;
}
if(!pressed)
while(player meleebuttonpressed())
{
pressed = 1;
level.pitch rotateto(level.pitch.angles-(0,2,0), 0.2);
wait 0.2;
}
if(!pressed)
while(player usebuttonpressed())
{
pressed = 1;
level.pitch rotateto(level.pitch.angles+(0,2,0), 0.2);
wait 0.2;
}
if(!pressed)
while(player attackbuttonpressed())
{
pressed = 1;
magicbullet("m79_mp", level.gunpos.origin, level.gunpos.origin+anglestoforward(level.gunpos.angles)*10000);
wait 0.5;
}
if(!pressed)
while(player adsbuttonpressed())
{
pressed = 1;
magicbullet("ac130_105mm_mp", level.gunpos.origin, level.gunpos.origin+anglestoforward(level.gunpos.angles)*10000);
earthquake( 0.5, 0.75, level.turn.origin, 800 );
player playSound( "exp_airstrike_bomb" );
playfx(level.chopper_fx["explode"]["medium"], level.gunpos.origin);
for(i=0;i<=6;i++)
{
level.barrel[i] unlink();
level.barrel[i] moveto(level.barrel[i].origin-anglestoforward(level.barrel[i].angles)*50, 0.05);
}
wait 0.1;
for(i=0;i<=6;i++)
level.barrel[i] moveto(level.barrel[i].origin-anglestoforward(level.barrel[i].angles)*-50, 0.5, 0.4, 0.1);
wait 2;
}
foreach(swivel in level.swivel)
swivel linkto(level.turn);
level.turn linkto(level.pitch);
foreach(barrel in level.barrel)
barrel linkto(level.pitch);
wait 0.05;
}
}