Advertisement
snake5

SB3D - robot.sgs + player.sgs

Nov 5th, 2014
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///////////////////////// robot.sgs //////////////////////////////
  2.  
  3. // ROBOT COMPONENT
  4. // - physics
  5. // - rendering
  6. // - attachments
  7.  
  8. function Robot_init( core_mesh, pos )
  9. {
  10.     this.
  11.     {
  12.         attachments = [],
  13.         inventory = [],
  14.         position = vec3(pos.x,pos.y,pos.z),
  15.         matrix = mat4(),
  16.        
  17.         movedir = vec2(0,0),
  18.         turndir = vec2(1,0),
  19.         elevation = 0.5,
  20.        
  21.         mi_core = mi_core = gSGR_Scene.createMeshInstance(),
  22.         body = null,
  23.     };
  24.    
  25.     this.matrix.scale(0.5,0.5,0.5).translate_v3( this.position );
  26.     mi_core.matrix = this.matrix;
  27.     mi_core.mesh = gSGR_GetMesh( core_mesh );
  28.    
  29.     sh_capsuleZ = Bullet_CreateSphereShape( 0.5 );
  30.     rbci = Bullet_CreateRigidBodyCreationInfo();
  31.     rbci.collisionShape = sh_capsuleZ;
  32.     rbci.position = this.position;
  33.     rbci.mass = 120;
  34.     rbci.localInertia = sh_capsuleZ.calculateLocalInertia( 120 ) * vec3(0,0,1);
  35.     rbci.friction = 0.1;
  36.     this.body = body = Bullet_CreateRigidBody( rbci );
  37.     body.activationState = Bullet_DISABLE_DEACTIVATION;
  38.     body.linearDamping = 0.5;
  39.     gSGR_BulletWorld.addRigidBody( body, 0x04 );
  40. }
  41.  
  42. function Robot_destroy()
  43. {
  44.     gSGR_BulletWorld.removeRigidBody( this.body );
  45. }
  46.  
  47. function Robot_tick( dt )
  48. {
  49.     movedir = this.movedir;
  50.     this.body.clearForces();
  51.     this.body.applyCentralImpulse( vec3(movedir.x,movedir.y,0) * 50 );
  52.    
  53.     this.position = this.body.position;
  54.     this.mi_core.matrix = this.matrix = mat4().scale(0.5,0.5,0.5).rotate_quat( this.body.orientation.invert() ).translate_v3( this.position );
  55.     foreach( atch : this.attachments )
  56.     {
  57.         atch.tick( this, dt );
  58.     }
  59. }
  60.  
  61. function Robot_setMoveDir( movedir ){ this.movedir = movedir; }
  62. function Robot_setTurnDir( turndir ){ this.turndir = turndir; }
  63. function Robot_setElevation( elev ){ this.elevation = elev; }
  64.  
  65. function Robot_addAttachment( code )
  66. {
  67.     atch_func = Robot_Attachments.(code);
  68.     atch = this!atch_func();
  69.     this.attachments.push( atch );
  70. }
  71.  
  72. function Robot_dropAttachments( type )
  73. {
  74.     foreach( i, atch : this.attachments )
  75.     {
  76.         if( atch.type == type )
  77.         {
  78.         //  this!Robot_createAttachmentEntity( atch ); // TODO
  79.             this.attachments[ i ] = null;
  80.         }
  81.     }
  82.     this.attachments = array_filter( this.attachments );
  83. }
  84.  
  85. function Robot_setAttachment( code )
  86. {
  87.     if( code.length > 0 )
  88.         this!Robot_dropAttachments( code[0] );
  89.     if( code.length > 1 )
  90.         this!Robot_addAttachment( code );
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97. global Robot_Attachments = {};
  98.  
  99. function Robot_Attachments.EP1()
  100. {
  101.     EP1 =
  102.     {
  103.         type = "E",
  104.         name = "EP1",
  105.         fullname = "Elevation, propeller-based, v1",
  106.        
  107.         mi_stat = mi_stat = gSGR_Scene.createMeshInstance(),
  108.         mi_rot = mi_rot = gSGR_Scene.createMeshInstance(),
  109.     };
  110.    
  111.     mi_stat.mesh = gSGR_GetMesh( "sb_EP1_stat" );
  112.     mi_rot.mesh = gSGR_GetMesh( "sb_EP1_rot" );
  113.    
  114.     function EP1.transform( mtx )
  115.     {
  116.         this.mi_stat.matrix = mat4().translate( 0, 0, -0.67 ).multiply( mtx );
  117.         this.mi_rot.matrix = mat4().rotateZ( ftime() ).translate( 0, 0, -0.67 ).multiply( mtx );
  118.     }
  119.    
  120.     global Robot_EP1_offsets = [ vec3( 0, 0, 0 ), vec3( -1, 0, 0 ), vec3( 1, 0, 0 ), vec3( 0, -1, 0 ), vec3( 0, 1, 0 ) ];
  121.     function EP1.tick( robot, dt )
  122.     {
  123.         this.transform( robot.matrix );
  124.        
  125.         pow_dir = vec3( 0, 0, -5 -15 * robot.elevation );
  126.         pow_pos = robot.position + vec3( 0, 0, -0.17 );
  127.         avgdist = 0;
  128.         foreach( off : Robot_EP1_offsets )
  129.         {
  130.             (rr,cs,rn,rp) = gSGR_BulletWorld.rayTestClosest( pow_pos, pow_pos + pow_dir, 0x01, 0x01 );
  131.             avgdist += rr ?? 1.0;
  132.         }
  133.         powermul = 0.2 - avgdist / Robot_EP1_offsets.size;
  134.        
  135.     //  htdiff = 5 - robot.body.position.z;
  136.     //  robot.body.applyCentralImpulse( vec3(0,0,htdiff) * 50 - robot.body.linearVelocity * 0.9 );
  137.        
  138.         if( powermul > 0 )
  139.             robot.body.applyCentralImpulse( -pow_dir * powermul * 2000 * dt - robot.body.linearVelocity * 0.99 );
  140.     //  if( powermul > 0 )
  141.     //      robot.body.applyCentralForce( -pow_dir * ( 120 + powermul * 50 ) );
  142.     }
  143.    
  144.     return EP1;
  145. }
  146.  
  147. function Robot_Attachments.SP1()
  148. {
  149.     SP1 =
  150.     {
  151.         type = "S",
  152.         name = "SP1",
  153.         fullname = "Steering, propeller-based, v1",
  154.        
  155.         mi_statL = mi_statL = gSGR_Scene.createMeshInstance(),
  156.         mi_statR = mi_statR = gSGR_Scene.createMeshInstance(),
  157.         mi_rotL = mi_rotL = gSGR_Scene.createMeshInstance(),
  158.         mi_rotR = mi_rotR = gSGR_Scene.createMeshInstance(),
  159.     };
  160.    
  161.     mi_statL.mesh = gSGR_GetMesh( "sb_SP1_lft" );
  162.     mi_statR.mesh = gSGR_GetMesh( "sb_SP1_rgt" );
  163.     mi_rotR.mesh = mi_rotL.mesh = gSGR_GetMesh( "sb_SP1_rot" );
  164.    
  165.     function SP1.transform( mtx )
  166.     {
  167.         this.mi_statL.matrix = mat4().translate( 1.90796, 0.12344, 0.04181 ).multiply( mtx );
  168.         this.mi_rotL.matrix = mat4().rotateY( ftime() ).translate( 1.96693, 0.12344, 0.04181 ).multiply( mtx );
  169.         this.mi_statR.matrix = mat4().translate( -1.90796, 0.12344, 0.04181 ).multiply( mtx );
  170.         this.mi_rotR.matrix = mat4().rotateY( ftime() ).translate( -1.90796, 0.12344, 0.04181 ).multiply( mtx );
  171.     }
  172.    
  173.     function SP1.tick( robot, dt )
  174.     {
  175.         this.transform( robot.matrix );
  176.        
  177.         vcur = vec2( robot.body.orientation.invert().mat3.transform( vec3(0,-1,0) ) );
  178.         vtgt = robot.turndir;
  179.         powermul = acos( min( 1, vec2_dot( vcur, vtgt ) ) ) * if( vcur.x * vtgt.y - vtgt.x * vcur.y > 0, 1, -1 );
  180.         robot.body.applyTorqueImpulse( vec3(0,0,powermul*3 - robot.body.angularVelocity.z * 0.99) );
  181.     }
  182.    
  183.     return SP1;
  184. }
  185.  
  186. function Robot_Attachments.WT1()
  187. {
  188.     WT1 =
  189.     {
  190.         type = "W",
  191.         name = "WT1",
  192.         fullname = "Weapon, turret, v1",
  193.        
  194.         mi_stat = mi_stat = gSGR_Scene.createMeshInstance(),
  195.         mi_rot = mi_rot = gSGR_Scene.createMeshInstance(),
  196.     };
  197.    
  198.     mi_stat.mesh = gSGR_GetMesh( "sb_WT1_stat" );
  199.     mi_rot.mesh = gSGR_GetMesh( "sb_WT1_rot" );
  200.    
  201.     function WT1.transform( mtx )
  202.     {
  203.         this.mi_stat.matrix = mat4().translate( 0, -0.40267, 0.63235 ).multiply( mtx );
  204.         this.mi_rot.matrix = mat4().translate( 0, -0.22267, 1.03222 ).multiply( mtx );
  205.     }
  206.    
  207.     function WT1.tick( robot, dt )
  208.     {
  209.         this.transform( robot.matrix );
  210.     }
  211.    
  212.     return WT1;
  213. }
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228. ///////////////////////// player.sgs //////////////////////////
  229.  
  230. function ENTITY_CREATE_player( params )
  231. {
  232.     Player =
  233.     {
  234.         direction = @params.direction.normalized || vec3( 0, 1, 0 ),
  235.         camera = null,
  236.         cam_angle = 0.0,
  237.         cam_zangle = 0.0,
  238.         cam_ignoreOnce = true,
  239.         move_noclip = false,
  240.        
  241.         health = 20,
  242.        
  243.         hint_text = null,
  244.         hint_time = 0,
  245.         use_info = [],
  246.         use_index = null,
  247.        
  248.         tgt_elevation = 0.5,
  249.         elev_change_timeout = 0,
  250.     };
  251.     Player.cam_angle = vec2(Player.direction.x,Player.direction.y).angle;
  252.    
  253.     Player!Robot_init( "sb_core", params.position );
  254.     Player!Robot_addAttachment( "EP1" );
  255.     Player!Robot_addAttachment( "SP1" );
  256.     Player!Robot_addAttachment( "WT1" );
  257.    
  258.     gSGR_Actions.add_action( "move_fwd" );
  259.     gSGR_Actions.add_action( "move_lft" );
  260.     gSGR_Actions.add_action( "move_bwd" );
  261.     gSGR_Actions.add_action( "move_rgt" );
  262.     gSGR_Actions.add_action( "enable_noclip" );
  263.     gSGR_Actions.add_action( "elev_raise" );
  264.     gSGR_Actions.add_action( "elev_lower" );
  265.     gSGR_Actions.add_action( "use" );
  266.    
  267.     gSGR_Actions.add_default_binding( "move_fwd", SDLK_W );
  268.     gSGR_Actions.add_default_binding( "move_lft", SDLK_A );
  269.     gSGR_Actions.add_default_binding( "move_bwd", SDLK_S );
  270.     gSGR_Actions.add_default_binding( "move_rgt", SDLK_D );
  271. //  gSGR_Actions.add_default_binding( "elev_raise", "scrollup" );
  272. //  gSGR_Actions.add_default_binding( "elev_lower", "scrolldown" );
  273.     gSGR_Actions.add_default_binding( "elev_raise", SDLK_UP );
  274.     gSGR_Actions.add_default_binding( "elev_lower", SDLK_DOWN );
  275.     gSGR_Actions.add_default_binding( "use", SDLK_E );
  276.     gSGR_Actions.add_default_binding( "enable_noclip", SDLK_N );
  277.    
  278.     Player.ui_font = SS_CreateFont( "fonts/gauge-heavy.ttf", gSGR_Window.height / 30 );
  279.     Player.ui_font_2 = SS_CreateFont( "fonts/gauge-heavy.ttf", gSGR_Window.height / 50 );
  280.    
  281.     function Player.added()
  282.     {
  283.         this.camera = camera = SS3D_CreateCamera();
  284.         gSGR_Scene.camera = camera;
  285.         global PLAYER = this;
  286.        
  287.         this.camera.angle = 90;
  288.         this.camera.znear = 0.01;
  289.         this.camera.zfar = 1000;
  290.     }
  291.    
  292.     function Player.removed()
  293.     {
  294.         global PLAYER = null;
  295.         this!Robot_destroy();
  296.     }
  297.    
  298.     function Player.serialize()
  299.     {
  300.         innerdata =
  301.         {
  302.             cam_angle = this.cam_angle,
  303.             cam_zangle = this.cam_zangle,
  304.             cam_ignoreOnce = this.cam_ignoreOnce,
  305.             move_noclip = this.move_noclip,
  306.            
  307.             health = this.health,
  308.         };
  309.         p = this.position;
  310.         return "player", { x = p.x, y = p.y, z = p.z, direction = this.direction }, innerdata;
  311.     }
  312.    
  313.     function Player.can_reuse( type, params, data )
  314.     {
  315.         return type == "player";
  316.     }
  317.    
  318.     function Player.unserialize( data )
  319.     {
  320.         this.
  321.         {
  322.             cam_angle = data.cam_angle,
  323.             cam_zangle = data.cam_zangle,
  324.             cam_ignoreOnce = data.cam_ignoreOnce,
  325.             move_noclip = data.move_noclip,
  326.            
  327.             health = data.health,
  328.         };
  329.     }
  330.    
  331.     function Player.updateHint( text )
  332.     {
  333.         this.hint_text = text;
  334.         this.hint_time = 2.1;
  335.     }
  336.    
  337.     function Player.updateDirection( mmspeed )
  338.     {
  339.         joyviewaxis = vec2( toreal( @gSGR_Keys[ "joyaxis2" ] ), toreal( @gSGR_Keys[ "joyaxis4" ] ) );
  340.         viewmove = gSGR_MouseMove + joyviewaxis * 5;
  341.        
  342.         if( viewmove.length && !current_cutscene )
  343.         {
  344.             if( !this.cam_ignoreOnce && !Game.PrevPaused )
  345.             {
  346.                 this.cam_angle -= viewmove.x * mmspeed;
  347.                 this.cam_zangle -= viewmove.y * mmspeed;
  348.             }
  349.             else this.cam_ignoreOnce = false;
  350.         }
  351.        
  352.        
  353.         this.cam_zangle = clamp( this.cam_zangle, -M_PI*0.49, M_PI*0.49 );
  354.        
  355.         cos_angle = cos( this.cam_angle );
  356.         sin_angle = sin( this.cam_angle );
  357.         cos_zangle = cos( this.cam_zangle );
  358.         sin_zangle = sin( this.cam_zangle );
  359.         this.direction = vec3( cos_angle * cos_zangle, sin_angle * cos_zangle, sin_zangle );
  360.     }
  361.    
  362.     function Player.updateNoclip( dt )
  363.     {
  364.         this.updateDirection( 0.02 );
  365.         cos_angle = cos( this.cam_angle );
  366.         sin_angle = sin( this.cam_angle );
  367.         cos_zangle = cos( this.cam_zangle );
  368.         sin_zangle = sin( this.cam_zangle );
  369.         dir = this.direction;
  370.         right = vec3( sin_angle, -cos_angle, 0 );
  371.         speed = 10;
  372.     //  if( gSGR_Actions.get( "move_faster" ) ) speed *= 5;
  373.         if( gSGR_Actions.get( "move_fwd" ) ) this.position += dir * dt * speed;
  374.         if( gSGR_Actions.get( "move_bwd" ) ) this.position -= dir * dt * speed;
  375.         if( gSGR_Actions.get( "move_rgt" ) ) this.position += right * dt * speed;
  376.         if( gSGR_Actions.get( "move_lft" ) ) this.position -= right * dt * speed;
  377.     }
  378.    
  379.     function Player.updateMovement( dt )
  380.     {
  381.         if( this.health <= 0 )
  382.             return;
  383.        
  384.         this.updateDirection( 0.01 );
  385.        
  386.         this!Robot_setTurnDir( vec2(this.direction.x,this.direction.y) );
  387.        
  388.         speed = 2000;
  389.        
  390.         cos_angle = cos( this.cam_angle );
  391.         sin_angle = sin( this.cam_angle );
  392.         fwdir = vec2( cos_angle, sin_angle );
  393.         right = vec2( sin_angle, -cos_angle );
  394.        
  395.         if( !current_cutscene )
  396.         {
  397.             movedir = vec2(0,0);
  398.             if( gSGR_Actions.get( "move_fwd" ) ) movedir += fwdir;
  399.             if( gSGR_Actions.get( "move_bwd" ) ) movedir -= fwdir;
  400.             if( gSGR_Actions.get( "move_rgt" ) ) movedir += right;
  401.             if( gSGR_Actions.get( "move_lft" ) ) movedir -= right;
  402.             if( @gSGR_Keys[ "joyaxis0" ] ) movedir += right * gSGR_Keys[ "joyaxis0" ];
  403.             if( @gSGR_Keys[ "joyaxis1" ] ) movedir -= fwdir * gSGR_Keys[ "joyaxis1" ];
  404.             movedir = movedir.normalized;
  405.            
  406.             this!Robot_setMoveDir( movedir );
  407.         }
  408.     }
  409.    
  410.     function Player.updateCamera()
  411.     {
  412.         if( current_cutscene )
  413.             return;
  414.        
  415.         this.camera.position = this.position - this.direction * 2 + vec3(0,0,0.3);
  416.         this.camera.direction = this.direction;
  417.         this.camera.aspect = gSGR_Window.width / gSGR_Window.height;
  418.     }
  419.    
  420.     function Player.hit()
  421.     {
  422.         this.health -= 2;
  423.     }
  424.    
  425.     function Player.isInAction()
  426.     {
  427.         foreach( osc : Game.OverlayScreens )
  428.             if( @osc.wdi )
  429.                 return true;
  430.         return false;
  431.     }
  432.    
  433.     function Player.updateUseInfo()
  434.     {
  435.         this.use_info = use_info = QueryInteractive( 10 );
  436.         best_idx = null;
  437.         best_q = 99999;
  438.         foreach( i, ui_item : use_info )
  439.         {
  440.             dist = ( ui_item.pos - this.position ).length;
  441.             if( dist < 2 )
  442.             {
  443.                 cur_q = ui_item.area + ui_item.dist + dist;
  444.                 if( cur_q < best_q )
  445.                 {
  446.                     best_q = cur_q;
  447.                     best_idx = i;
  448.                 }
  449.             }
  450.         }
  451.         this.use_index = best_idx;
  452.     }
  453.    
  454.     function Player.tick( dt )
  455.     {
  456.         this!Robot_tick( dt );
  457.        
  458.         if( this.health > 0 )
  459.             this.updateUseInfo();
  460.        
  461.         in_action = this.isInAction();
  462.         if( !in_action )
  463.         {
  464.             if( gSGR_Actions.is_pressed( "enable_noclip" ) )
  465.                 this.move_noclip = !this.move_noclip;
  466.            
  467.             if( gSGR_Actions.is_pressed( "use" ) || ( (@gSGR_Keys[ "joybtn0" ]) && !(@gSGR_PrevKeys[ "joybtn0" ]) ) )
  468.             {
  469.                 if( this.use_index !== null )
  470.                 {
  471.                     ent = this.use_info[ this.use_index ].ent;
  472.                     if( @ent.interact )
  473.                         ent.interact();
  474.                 }
  475.             }
  476.         }
  477.        
  478.         if( this.elev_change_timeout > 0 )
  479.             this.elev_change_timeout -= dt;
  480.         else if( !in_action )
  481.         {
  482.             if( gSGR_Actions.get( "elev_raise" ) || gSGR_Actions.get( "elev_lower" ) || @gSGR_Keys[ "joyhatup" ] || @gSGR_Keys[ "joyhatdn" ] )
  483.             {
  484.                 this.tgt_elevation += 0.05 * ( !!gSGR_Actions.get( "elev_raise" ) - !!gSGR_Actions.get( "elev_lower" ) + !!(@gSGR_Keys[ "joyhatup" ]) - !!(@gSGR_Keys[ "joyhatdn" ]) );
  485.                 this.elev_change_timeout = 0.2;
  486.             }
  487.             this!Robot_setElevation( this.tgt_elevation );
  488.         }
  489.        
  490.         if( !in_action )
  491.         {
  492.             if( this.move_noclip )
  493.                 this.updateNoclip( dt );
  494.             else
  495.                 this.updateMovement( dt );
  496.         }
  497.        
  498.         p = this.position;
  499.        
  500.         if( @gSGR_Keys[ SDLK_0 ] )
  501.             this.health = 0;
  502.        
  503.         if( this.health <= 0 )
  504.         {
  505.             this.death_timeout -= dt;
  506.             if( this.death_timeout <= 0 )
  507.             {
  508.                 Game.SetPaused( true );
  509.                 Game.OverlayScreens.push( PauseScreen );
  510.             }
  511.         }
  512.        
  513.         this.updateCamera();
  514.        
  515.         if( this.hint_time > 0 )
  516.             this.hint_time -= dt;
  517.     }
  518.    
  519.     function Player.draw_ui()
  520.     {
  521.         W = gSGR_Window.width;
  522.         H = gSGR_Window.height;
  523.        
  524.         if( current_cutscene || mission_complete )
  525.             return;
  526.        
  527.         if( this.hint_time > 0 )
  528.         {
  529.             SS_DrawTextRect( this.hint_text, this.ui_font, color(1,clamp(this.hint_time,0,1)), DT_CENTER | DT_VCENTER, W*1/4, W*3/4, H*2/4, H*3/4 );
  530.         }
  531.        
  532.         if( intlist = this.use_info )
  533.         {
  534.             bsz = ceil( min( W, H ) / 60 );
  535.             sqsz = ceil( min( W, H ) / 300 );
  536.             hsqsz = sqsz / 2;
  537.             foreach( idx, intitem : intlist )
  538.             {
  539.                 aabb = intitem.aabb;
  540.                
  541.                 if( this.use_index === idx ){ cr = 0.9; cg = 0.1; cb = 0.0; ca = 0.8; }
  542.                 else { cr = 0.3; cg = 0.7; cb = 0.9; ca = 0.8; }
  543.                
  544.                 SS_DrawColorRect( aabb.x1 - hsqsz + 1, aabb.y1 - hsqsz + 1, aabb.x1 + bsz + hsqsz + 1, aabb.y1 + hsqsz + 1, 0.1, 0.1, 0.1, 0.8 );
  545.                 SS_DrawColorRect( aabb.x1 - hsqsz + 1, aabb.y1 + hsqsz + 1, aabb.x1 + hsqsz + 1, aabb.y1 + bsz + hsqsz + 1, 0.1, 0.1, 0.1, 0.8 );
  546.                 SS_DrawColorRect( aabb.x2 - bsz - hsqsz + 1, aabb.y2 - hsqsz + 1, aabb.x2 + hsqsz + 1, aabb.y2 + hsqsz + 1, 0.1, 0.1, 0.1, 0.8 );
  547.                 SS_DrawColorRect( aabb.x2 - hsqsz + 1, aabb.y2 - bsz - hsqsz + 1, aabb.x2 + hsqsz + 1, aabb.y2 - hsqsz + 1, 0.1, 0.1, 0.1, 0.8 );
  548.                 SS_DrawTextLine_BL( intitem.name, this.ui_font_2, aabb.x1 + 1, aabb.y1 - 1, color(0.1,0.1,0.1,0.8) );
  549.                
  550.                 text = intitem.name;
  551.                 if( this.use_index === idx )
  552.                 {
  553.                     SS_DrawColorRect( aabb.x1, aabb.y1, aabb.x2, aabb.y2, cr, cg, cb, 0.3 );
  554.                     text = "[Press Button 1] " $ text;
  555.                 }
  556.                 SS_DrawColorRect( aabb.x1 - hsqsz, aabb.y1 - hsqsz, aabb.x1 + bsz + hsqsz, aabb.y1 + hsqsz, cr, cg, cb, ca );
  557.                 SS_DrawColorRect( aabb.x1 - hsqsz, aabb.y1 + hsqsz, aabb.x1 + hsqsz, aabb.y1 + bsz + hsqsz, cr, cg, cb, ca );
  558.                 SS_DrawColorRect( aabb.x2 - bsz - hsqsz, aabb.y2 - hsqsz, aabb.x2 + hsqsz, aabb.y2 + hsqsz, cr, cg, cb, ca );
  559.                 SS_DrawColorRect( aabb.x2 - hsqsz, aabb.y2 - bsz - hsqsz, aabb.x2 + hsqsz, aabb.y2 - hsqsz, cr, cg, cb, ca );
  560.                
  561.                 SS_DrawTextLine_BL( text, this.ui_font_2, aabb.x1, aabb.y1 - 2, color(0.9,0.9,0.9,0.8) );
  562.                
  563.         //      SS_DrawColorRect( aabb.x1, aabb.y1, aabb.x2, aabb.y2, 0.2, 0.4, 0.6, 0.5 );
  564.             }
  565.     //      SS_DrawTextLine( "Press E to "$act, this.ui_font, W - unit*20, unit*3, color(1,1) );
  566.         }
  567.        
  568.         unit = H / 30;
  569.         SS_DrawTextLine( "HEALTH: " $ string_repeat( "|", max( 0, this.health ) ), this.ui_font, unit*3, unit*3, color(1,1) );
  570.        
  571.         SS_DrawTextLine( "ELEVATION: " $ string_repeat( "|", 20 ), this.ui_font, unit*3, unit*5, color(0.1,1) );
  572.         SS_DrawTextLine( "ELEVATION: " $ string_repeat( "|", max( 0, this.tgt_elevation * 20 ) ), this.ui_font, unit*3, unit*5, color(0.3,0.6,0.9,1) );
  573.        
  574.     //  rr = gSGR_BulletWorld.rayTestClosest( this.position, this.position + this.direction * 5 );
  575.     //  SS_DrawTextLine( "RAYCAST: "$rr, gSGR_DefaultFont, 100, 100, color(1,1) );
  576.        
  577.         if( time_since_saved < 3 )
  578.         {
  579.             SS_DrawTextLine( "Game saved!", this.ui_font, W / 3, unit, color(1,1-time_since_saved/3) );
  580.         }
  581.        
  582.         if( max_see_time > 0 )
  583.         {
  584.             text = if( max_see_time >= 1, "TURRET ALERT!", "TURRET ALERT" );
  585.             SS_DrawTextLine( text, this.ui_font, W / 2 - unit * 4, unit * 3, color(1,0.1,0.05,1) );
  586.         }
  587.     }
  588.    
  589.     return Player;
  590. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement