Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Asteroids Mini-Game
#1


Quote:Just add this code to any .gsc and then activate the devmap "asteroids"

not sure if it works on PC- not tested

PHP Code:
#include common_scripts\utility;
#include maps\mp\_utility;

main()
{
        
level.WIDTH 800;
        
level.HEIGHT 600;

        
level.xMAX 500 2.2;
        
level.yMAX 375 2.2;

        
level.CAMERA_HEIGHT = ( 002048 );

        
level.ROUND 1;
        
level.LIVES 3;
        
level.FRICTION 0.98;
        
level.RADS 0.0174532925199;

        
level.SHIP_SPEED 200;
        
level.BULLET_SPEED 10;
        
level.BULLET_FUSE 4;
        
level.BULLET_SLOTS_MAX 5;

        
level.BULLETS array_randomizeGetEntArray"bullet""targetname" ) );
        
level.ASTEROIDS_LARGE array_randomizeGetEntArray"asteroid_large""targetname" ) );
        
level.ASTEROIDS_MEDIUM array_randomizeGetEntArray"asteroid_medium""targetname" ) );
        
level.ASTEROIDS_SMALL array_randomizeGetEntArray"asteroid_small""targetname" ) );
        
allAsteroids = [];
        
allAsteroids array_combineallAsteroidslevel.ASTEROIDS_LARGE );
        
allAsteroids array_combineallAsteroidslevel.ASTEROIDS_MEDIUM );
        
allAsteroids array_combineallAsteroidslevel.ASTEROIDS_SMALL );
        
level.ASTEROIDS array_randomizeallAsteroids );

        
level.BTN_HYPERSPACE "reload";
        
level.BTN_FORWARD "forward";
        
level.BTN_LEFT "moveleft";
        
level.BTN_RIGHT "moveright";
        
level.BTN_FIRE "attack";

        
level.SND_LARGE_DESTROYED "asteroid_large";
        
level.SND_MEDIUM_DESTROYED "asteroid_medium";
        
level.SND_SMALL_DESTROYED "asteroid_small";

        
flag_init"alive" );
        
flag_init"hyperspace" );

        
maps\mp\_load::main();

        
flag_wait"all_players_connected" );
        
flag_wait"all_players_spawned" );

        
player get_players()[ ];
        
player DetachAll();
        
player Hide();
        
player TakeAllWeapons();
        
player FreezeControlstrue );

        
player setClientDvars"compass""0",
        
"cg_drawgun""0",
        
"hud_showStance""0",
        
"cg_thirdPerson""0",
        
"cg_fov""65",
        
"cg_thirdPersonAngle""0",
        
"ammoCounterHide""1",
        
"miniscoreboardhide""0" );

        
player AllowCrouchfalse );
        
player AllowPronefalse );
        
player AllowJumpfalse );
        
player AllowLeanfalse );

        
camera GetEnt"player_camera""targetname" );
        
AssertIsDefinedcamera ) );
        
camera.origin += level.CAMERA_HEIGHT;
        
player SetOrigincamera.origin );
        
player LinkTocamera );

        
player SetPlayerAnglescamera.angles );
        
camera RotatePitch890.1 );
        
camera waittill "rotatedone" );
        
camera RotateYaw890.1 );

        
frontEnd();

        
level.player GetEnt"player""targetname" );
        
AssertIsDefinedlevel.player ) );
        
level.player.thrust GetEnt"thrust""script_noteworthy" );
        
AssertIsDefinedlevel.player.thrust ) );
        
level.player.thrust LinkTolevel.player );
        
level.player.muzzle GetEntlevel.player.targetname "_muzzle""targetname" );
        
AssertIsDefinedlevel.player.muzzle ) );
        
level.player.muzzle LinkTolevel.player );
        
level.player RotateYaw( -90 0.1 );
        
level.player.rotation 0;
        
player FreezeControlsfalse );

        
level.player thread initPiece();
        
array_threadlevel.BULLETS, ::initPiecetrue );

        
thread shipControls();
        
thread shipThrustThink();
        
thread shipThink();
        
level.bullet_slots = [];
        for( 
level.BULLET_SLOTS_MAX x++ )
        {
                
level.bullet_slots] = SpawnStruct();
                
level.bullet_slots].isActive false;
        }

        
thread shipFirethink();

        
getAsteroid"large" thread asteroidThinksinRandomFloat6.28318530718 ) ), cosRandomFloat6.28318530718 ) ) );
}

frontEnd()
{
        
title                                                   NewHudElemlevel );
        
title.alignX                    "center";
        
title.alignY                    "middle";
        
title.horzAlign         "center";
        
title.vertAlign         "middle";
        
title.foreground        true;
        
title.fontScale         4;
        
title.y                                  -= 130;
        
title.alpha                     0;
        
title SetText"ASTEROIDS" );
        
title FadeOverTime);
        
title.alpha 1;
        
title.hidewheninmenu true;

        
subtitle                                                        NewHudElemlevel );
        
subtitle.alignX                         "center";
        
subtitle.alignY                         "middle";
        
subtitle.horzAlign      "center";
        
subtitle.vertAlign      "middle";
        
subtitle.foreground     true;
        
subtitle.fontScale      2;
        
subtitle.y                               += 130;
        
subtitle.alpha                  0;
        
subtitle SetText"PLAY GAME" );
        
subtitle FadeOverTime);
        
subtitle.alpha 1;
        
subtitle.hidewheninmenu true;

        
highscore undefined;

        if( 
GetDvarInt"erocshgih_sdioretsa" ) > )
        {
                
highscore                                                       NewHudElemlevel );
                
highscore.alignX                        "center";
                
highscore.alignY                        "middle";
                
highscore.horzAlign     "center";
                
highscore.vertAlign     "middle";
                
highscore.foreground    true;
                
highscore.fontScale     1.5;
                
highscore.y                              += 170;
                
highscore.alpha                         0;
                
highscore.label "HIGH SCORE: ";
                
highscore SetTextGetDvarInt"erocshgih_sdioretsa" ) );
                
subtitle FadeOverTime);
                
highscore.alpha 1;
                
highscore.hidewheninmenu true;
        }

        
frontEndPlay();

        
title Destroy();
        
subtitle Destroy();

        if( 
IsDefinedhighscore ) )
        {
                
highscore Destroy();
        }
        
        
wait );
}

frontEndPlay()
{
        
player get_players()[ ];

        while( !
player AttackButtonPressed() )
        {
                
wait 0.05 );
        }
}

shipControls()
{
        
ship_controllevel.BTN_FORWARDlevel.SHIP_SPEED20);
        
ship_controllevel.BTN_LEFT1010);
        
ship_controllevel.BTN_RIGHT, -1010);
        
ship_controllevel.BTN_FIRE11);
        
ship_controllevel.BTN_HYPERSPACE11);
}

shipThink()
{
        
rotation 0;
        
rotateX undefined;
        
rotateY undefined;
        
frictionX level.player.origin];
        
frictionY level.player.origin];

        while( 
)
        {
                if( 
paused() )
                {
                        continue;
                }

                
rotation 0;

                if( 
hyperKeyPress() )
                {
                        
level.player hyperSpace();
                }

                if( 
leftKeyPress() )
                {
                        
rotation rotation leftKeyValue();
                }

                if( 
rightKeyPress() )
                {
                        
rotation rotation rightKeyValue();
                }

                
rotateX sinrotation level.RADS );
                
rotateY cosrotation level.RADS );

                if( 
forwardKeyPress() )
                {
                        
frictionX frictionX rotateX 4;
                        
frictionY frictionY rotateY 4;
                }

                
frictionX frictionX level.FRICTION;
                
frictionY frictionY level.FRICTION;

                
level.player wrapPos();

                
level.player RotateYawrotation0.1 );
                
level.player MoveTo( ( level.player.origin] + frictionXlevel.player.origin] + frictionYlevel.player.origin] ), 0.1 );

                
get_players()[ thread shipControlsCheck();

                
wait 0.05 );
        }
}

ship_controlcommandmaxchange_ratereset_rate )
{
        if( !
IsDefinedlevel.controls ) )
        {
                
level.controls = [];
        }

        
button SpawnStruct();
        
button.pressed false;
        
button.held false;
        
button.max max;
        
button.change_rate change_rate;
        
button.reset_rate reset_rate;
        
button.value 0;
        
button.name command;

        
level.controlscommand ] = button;

        
get_players()[ thread shipControlsThreadcommand );
}

shipControlsThreadcommand )
{

        
self endon"death" );

        while( 
)
        {
                
wait0.05 );

                
any_pressed false;
                
binding GetKeyBinding"+" command );
                if( 
binding["count"] > )
                {
                        for( 
1binding["count"] + 1i++ )
                        {
                                
bind binding["key" i];
                                
SetDvarcommand "_bind"bind );

                                
bind GetDvarcommand "_bind" );
                                
tokens StrTokbind"key_" );

                                if( 
tokens.size )
                                {
                                        
bind tokens[1];
                                }
                                else
                                {
                                        
bind tokens[0];
                                }

                                if( 
self ButtonPressedtolowerbind ) ) )
                                {
                                        
any_pressed true;
                                }
                        }
                }

                if( 
any_pressed )
                {
                        if( 
level.controls[command].pressed )
                        {
                                
level.controls[command].held true;
                        }

                        
level.controls[command].pressed true;
                        
self thread button_resetcommand );
                }
        }
}

button_resetcommand )
{

        
self endon"death" );

        
self notifycommand "_done" );
        
self endoncommand "_done" );

        
wait0.1 );

        
level.controlscommand ].pressed false;
        
level.controlscommand ].held false;
}

shipControlsCheck()
{
        
self endon "disconnect" );
        
self endon "death" );

        
keys GetArrayKeyslevel.controls );
        for( 
0keys.sizei++ )
        {
                
button level.controlskeys] ];

                if( 
button.pressed )
                {
                        if( 
button.max )
                        {
                                
button.value += button.change_rate;
                        }
                        else
                        {
                                
button.value -= button.change_rate;
                        }
                }
                else if( 
button.value != )
                {
                        if( 
button.value )
                        {
                                
button.value -= button.reset_rate;
                        }
                        else
                        {
                                
button.value += button.reset_rate;
                        }

                        if( 
absbutton.value ) < button.reset_rate )
                        {
                                
button.value 0;
                        }
                }

                if( 
button.max )
                {
                        if( 
button.value button.max )
                        {
                                
button.value button.max;
                        }
                }
                else
                {
                        if( 
button.value button.max )
                        {
                                
button.value button.max;
                        }
                }
        }
}

shipThrustThink()
{
        
flag_set"alive" );

        
thrustFlickerDelay 0.05;

        while( 
)
        {
                while( 
forwardKeyPress() && flag"alive" ) && !flag"hyperspace" ) )
                {
                        
level.player.thrust Show();

                        
wait thrustFlickerDelay );

                        
level.player.thrust Hide();

                        
wait thrustFlickerDelay );
                }

                
level.player.thrust Hide();

                
wait 0.05 );
        }
}

shipFirethink()
{
        while( 
)
        {
                while( 
level.controlslevel.BTN_FIRE ].pressed == true && flag"alive" ) )
                {
                        
slot ShipFireFindSlot();

                        if( 
IsDefinedslot ) )
                        {
                                
level.player thread bulletThinkslot );
                        }

                        
wait );

                        while( ( 
level.controlslevel.BTN_FIRE ].pressed == true || level.controlslevel.BTN_FIRE ].held == true ) && flag"alive" ) )
                        {
                                
slot ShipFireFindSlot();

                                if( 
IsDefinedslot ) )
                                {
                                        
level.player thread bulletThinkslot );
                                }

                                
wait 0.5 );
                        }
                }

                
wait 0.05 );
        }
}

shipFireFindSlot()
{
        for( 
level.bullet_slots.size x++ )
        {
                
slot level.bullet_slots];

                if( 
IsDefinedslot.isActive ) && !slot.isActive )
                {
                        
slot.isActive true;

                        return 
slot;
                }
        }
}

wrapPos()
{
        if( 
self.origin] > ( level.xMAX level.WIDTH ) )
        {
                if( 
IsDefinedself.name ) && self.name == "saucer" )
                {
                        
self resetPiece();
                }
                else
                {
                        
self.origin = ( ( self.origin] - ( level.xMAX level.WIDTH ) ), self.origin], self.origin] );
                }
        }

        if( 
self.origin] > ( level.yMAX level.WIDTH ) )
        {
                
self.origin = ( self.origin], self.origin] - ( level.yMAX level.HEIGHT ), self.origin] );
        }

        if( 
self.origin] < ( ( level.WIDTH  ) / ) )
        {
                if( 
IsDefinedself.name ) && self.name == "saucer" )
                {
                        
self resetPiece();
                }
                else
                {
                        
self.origin = ( self.origin] + ( level.xMAX level.WIDTH ), self.origin], self.origin] );
                }
        }

        if( 
self.origin] < ( ( level.HEIGHT ) / ) )
        {       
                
self.origin = ( self.origin], self.origin] + ( level.yMAX level.HEIGHT ), self.origin] );
        }
}

hyperSpace()
{
        if( 
paused() )
        {
                return 
0;
        }

        
flag_set"hyperspace" );

        
self Hide();
        
level.player.thrust Hide();

        
self.origin = ( RandomFloatlevel.xMAX level.WIDTH ) + level.WIDTHRandomFloatlevel.yMAX level.HEIGHT ) + level.HEIGHTself.origin] );

        
wait );

        
self Show();

        
flag_clear"hyperspace" );
}

getAsteroidtype )
{
        
AssertIsDefinedtype ) );
        
        
asteroids undefined;
        
        switch( 
type )
        {
                case 
"large":
                        
asteroids level.ASTEROIDS_LARGE;
                        break;
                case 
"medium":
                        
asteroids level.ASTEROIDS_MEDIUM;
                        break;
                case 
"small":
                        
asteroids level.ASTEROIDS_SMALL;
                        break;
        }
        
        
asteroids array_randomizeasteroids );
        
        for( 
asteroids.size x++ )
        {
                        
asteroids].isActive true;
                        return 
asteroids];
        }

        
AssertMsg"Not Enough Asteroids Free." );
}

asteroidThinkvelocityXvelocityY )
{
        
self endon "death" );
        
        
self.velocityX velocityX;
        
self.velocityY velocityY;

        
canCollideWith = [];
        for( 
level.BULLETS.size x++ )
        {
                
canCollideWith array_addcanCollideWithlevel.BULLETS] );
        }

        while( 
)
        {
                if( 
paused() )
                {
                        continue;
                }

                
self.origin = ( self.origin] + self.velocityXself.origin] + self.velocityYself.origin] );

                
self wrapPos();

                if( 
self isHitcanCollideWith ) )
                {
                        if( 
IsDefinedself.name ) )
                        {
                                if( 
self.name == "large" )
                                {
                                        
play_sound_in_spacelevel.SND_LARGE_DESTROYEDself.origin );

                                        if( 
IsDefinedself.attacker ) && self.attacker == level.player )
                                        {
                                                
level.player.score += 20;
                                        }
                                }
                                else if( 
self.name == "medium" )
                                {
                                        
play_sound_in_spacelevel.SND_MEDIUM_DESTROYEDself.origin );

                                        if( 
IsDefinedself.attacker ) && self.attacker == level.player )
                                        {
                                                
level.player.score += 50;
                                        }
                                }
                                else if( 
self.name == "small" )
                                {
                                        
play_sound_in_spacelevel.SND_SMALL_DESTROYEDself.origin );

                                        if( 
IsDefinedself.attacker ) && self.attacker == level.player )
                                        {
                                                
level.player.score += 100;
                                        }
                                }
                        }
                }

                
wait 0.05 );
        }
}

bulletThinkslot )
{
        
bullet getBullet();
        
bullet.attacker self;
        
bullet.origin self.muzzle.origin;
        
direction AnglesToForwardself.angles );

        
fuse GetTime() + ( level.BULLET_FUSE 1000 );

        
wait 0.05 );

        
bullet Show();

        while( 
)
        {
                
forward direction * ( 20482048);
                
dist Distancebullet.originbullet.origin forward );

                
bullet wrapPos();

                
bullet moveTobullet.origin forwarddist / ( level.SHIP_SPEED 0.9 ) );

                if( 
GetTime() >= fuse )
                {
                        
bullet notify "movedone" );

                        
bullet resetPiece();

                        if( 
IsDefinedslot ) )
                        {
                                
slot.isActive false;
                        }

                        break;
                }

                
wait 0.05 );
        }
}

getBullet()
{
        for( 
level.BULLETS.size x++ )
        {
                if( 
IsDefinedlevel.BULLETS] ) && IsDefinedlevel.BULLETS].isActive ) && !level.BULLETS].isActive )
                {
                        
level.BULLETS].isActive true;
                        return 
level.BULLETS];
                }
        }

        
AssertMsg"Not Enough Bullets Free." );
}

isHitcanCollideWith )
{
        
AssertIsDefinedself ) );

        if( 
isDefinedcanCollideWith ) && canCollideWith.size )
        {
                for( 
canCollideWith.size x++ )
                {
                        
ent canCollideWith];

                        if( 
IsDefinedent ) && self != ent )
                        {
                        }
                }
        }

        return 
false;
}

initPiecebHide )
{
        
AssertIsDefinedself ) );

        if( 
IsDefinedbHide) && bHide )
        {
                
self Hide();
        }

        
self.isActive false;
        
self.home_origin self.origin;
        
self.home_angles self.angles;
}

resetPiece()
{
        
AssertIsDefinedself ) );

        
self Hide();
        
self.isActive false;
        
self.origin self.home_origin;
        
self.angles self.home_angles;
}

paused()
{
        if( 
GetDvarInt"cl_paused" ) > )
        {
                return 
true;
        }

        return 
false;
}

hyperKeyPress()
{
        return ( 
level.controlslevel.BTN_HYPERSPACE ].pressed || level.controlslevel.BTN_HYPERSPACE ].held );
}

forwardKeyPress()
{
        return ( 
level.controlslevel.BTN_FORWARD ].pressed || level.controlslevel.BTN_FORWARD ].held );
}

leftKeyPress()
{
        return ( 
level.controlslevel.BTN_LEFT ].pressed || level.controlslevel.BTN_LEFT ].held );
}

rightKeyPress()
{
        return ( 
level.controlslevel.BTN_RIGHT ].pressed || level.controlslevel.BTN_RIGHT ].held );
}

leftKeyValue()
{
        return 
level.controlslevel.BTN_LEFT ].value;
}

rightKeyValue()
{
        return 
level.controlslevel.BTN_RIGHT ].value;



Credits:
SparkyMcSparks
Reply

#2
nice and cool
Reply

#3
OKAY What is happening?
[Image: wyipjqo9qon7rc2v1lo.jpg]
Reply

#4
(02-17-2011, 12:39)alistair3149 Wrote: OKAY What is happening?

it a retro style arcade game for black ops that needs to be converted to PC and tested
Reply

#5
What the
YouTube 1:Azumikkel- Modding
YouTube 2:DerpShark- Gaming Entertainment
Website:Jensby.me
Contact: im[at]jensby.me
Reply

#6
(02-17-2011, 12:39)alistair3149 Wrote: OKAY What is happening?

it is a little ingame mini game Wink
Reply

#7
(02-17-2011, 12:48)AZUMIKKEL Wrote: What the
Same here
[Image: wyipjqo9qon7rc2v1lo.jpg]
Reply

#8
Multiplayer support?
[Image: wyipjqo9qon7rc2v1lo.jpg]
Reply

#9
muhahahah, lol
Reply

#10
wtf ?
--
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  What game have you bought in the last week? RaZ 12 8,103 12-05-2013, 16:29
Last Post: Nekochan
  [GAME]The Letter Game Bandarigoda123 65 30,414 08-08-2013, 21:05
Last Post: AZUMIKKEL
  [Release] AntiRage for Infected Game Mode yokai134 17 14,324 08-04-2013, 22:22
Last Post: yokai134
  [Release] [Mini Map] Where Is She SgtLegend 21 10,965 08-04-2013, 06:04
Last Post: SgtLegend
  ESTRANGED best indie game I've seen so far Arteq 0 2,580 08-03-2013, 14:03
Last Post: Arteq
  [HELP] bo2 - FD1 - dis-attach the console from the game masis 8 5,918 07-17-2013, 23:01
Last Post: surtek
Smile [Release] Map & Game Type Changer Plugin (Fixed) 30mba 31 22,049 07-10-2013, 16:27
Last Post: 26hz
  Selling steam account for a game! Strentin 3 4,125 06-18-2013, 07:49
Last Post: xfxtroll
  Help Using chat outside in game Bandarigoda123 1 3,051 06-09-2013, 12:46
Last Post: Nekochan
  Help Game Not Reading Mod? Killjoy 6 5,503 06-08-2013, 14:49
Last Post: Killjoy

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.