adjusted position of strings in hud and cockpit; made fadings work in OGL; made radar scale in cockpit mode; mede normal reticle default again and scaled it to current resolution for OGL; reformatted code to make it A BIT MORE readable

This commit is contained in:
zicodxx 2006-09-08 23:31:06 +00:00
parent 1b11900e30
commit aec4c6ea28
8 changed files with 1310 additions and 2903 deletions

View file

@ -6,8 +6,6 @@
#ifdef __WINDOWS__
#include <windows.h>
#endif
//#include <GL/gl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -24,16 +22,13 @@
#include "palette.h"
#include "u_mem.h"
#include "error.h"
#include "inferno.h"
#include "screens.h"
#include "strutil.h"
#include "mono.h"
#include "args.h"
#include "key.h"
#include "u_mem.h"
#include "gamefont.h"
#define DECLARE_VARS
@ -41,14 +36,10 @@
#include <GL/glu.h>
int ogl_voodoohack=0;
int gr_installed = 0;
void gr_palette_clear(); // Function prototype for gr_init;
int gl_initialized=0;
int gl_reticle=1;
int gl_reticle=0;
int ogl_fullscreen=0;
int gr_check_fullscreen(void){
@ -56,10 +47,10 @@ int gr_check_fullscreen(void){
}
void gr_do_fullscreen(int f){
if (ogl_voodoohack)
if (ogl_voodoohack)
ogl_fullscreen=1;//force fullscreen mode on voodoos.
else
ogl_fullscreen=f;
else
ogl_fullscreen=f;
if (gl_initialized){
ogl_do_fullscreen_internal();
}
@ -67,9 +58,7 @@ void gr_do_fullscreen(int f){
int gr_toggle_fullscreen(void){
gr_do_fullscreen(!ogl_fullscreen);
// grd_curscreen->sc_mode=0;//hack to get it to reset screen mode
glFlush(); // ZICO - prevents black screen, screen glitches etc.
return ogl_fullscreen;
}
@ -85,12 +74,10 @@ int arch_toggle_fullscreen_menu(void){
gr_do_fullscreen(!ogl_fullscreen);
if (ogl_readpixels_ok){
// glWritePixels(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
glRasterPos2f(0,0);
glDrawPixels(grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
free(buf);
}
// grd_curscreen->sc_mode=0;//hack to get it to reset screen mode
return ogl_fullscreen;
}
@ -116,7 +103,6 @@ void ogl_set_screen_mode(void){
if (last_screen_mode==Screen_mode)
return;
OGL_VIEWPORT(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h);
// OGL_VIEWPORT(grd_curcanv->cv_bitmap.bm_x,grd_curcanv->cv_bitmap.bm_y,grd_curcanv->cv_bitmap.bm_w,grd_curcanv->cv_bitmap.bm_h);
if (Screen_mode==SCREEN_GAME){
glDrawBuffer(GL_BACK);
}else{
@ -218,19 +204,14 @@ int gr_set_mode(u_int32_t mode)
int i, argnum = INT_MAX;
#ifdef NOGRAPH
return 0;
return 0;
#endif
// mode=0;
if (mode<=0)
return 0;
w=SM_W(mode);
h=SM_H(mode);
//if (screen != NULL) gr_palette_clear();
// ogl_init_state();
if ((i=FindResArg("aspect", &ah, &aw)) && (i < argnum)) { argnum = i; awidth=aw; aheight=ah; }
gr_bm_data=grd_curscreen->sc_canvas.cv_bitmap.bm_data;//since we use realloc, we want to keep this pointer around.
@ -243,23 +224,14 @@ return 0;
grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0;
grd_curscreen->sc_canvas.cv_bitmap.bm_w = w;
grd_curscreen->sc_canvas.cv_bitmap.bm_h = h;
//grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = screen->pitch;
grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = w;
grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_OGL;
//grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels;
// mprintf((0,"ogl/gr.c: reallocing %p to %i\n",grd_curscreen->sc_canvas.cv_bitmap.bm_data,w*h));
grd_curscreen->sc_canvas.cv_bitmap.bm_data = realloc(gr_bm_data,w*h);
gr_set_current_canvas(NULL);
//gr_enable_default_palette_loading();
ogl_init_window(w,h);//platform specific code
ogl_get_verinfo();
OGL_VIEWPORT(0,0,w,h);
ogl_set_screen_mode();
gamefont_choose_game_font(w,h);
return 0;
@ -276,8 +248,8 @@ int ogl_atotexfilti(char *a,int min){
GLstrcmptestr(a,LINEAR_MIPMAP_LINEAR);
}
Error("unknown/invalid texture filter %s\n",a);
// return GL_NEAREST;
}
int ogl_testneedmipmaps(int i){
switch (i){
case GL_NEAREST:
@ -290,7 +262,7 @@ int ogl_testneedmipmaps(int i){
return 1;
}
Error("unknown texture filter %x\n",i);
// return -1;
}
#ifdef OGL_RUNTIME_LOAD
#ifdef __WINDOWS__
@ -345,8 +317,7 @@ int gr_init(int mode)
ogl_voodoohack=1;
gr_toggle_fullscreen();
}
// if (FindArg("-fullscreen"))
if (!(FindArg("-window"))) // ZICO - from window to fullscreen
if (!(FindArg("-window")))
gr_toggle_fullscreen();
#endif
if ((glt=FindArg("-gl_alttexmerge")))
@ -362,7 +333,7 @@ int gr_init(int mode)
GL_texmagfilt=GL_LINEAR;
GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST;
}
if ((glt=FindArg("-gl_trilinear")))
if ((glt=FindArg("-gl_trilinear")))
{
GL_texmagfilt = GL_LINEAR;
GL_texminfilt = GL_LINEAR_MIPMAP_LINEAR;
@ -391,7 +362,6 @@ int gr_init(int mode)
if ((t=FindArg("-gl_reticle"))){
gl_reticle=atoi(Args[t+1]);
}
//printf("ogl_mem_target=%i\n",ogl_mem_target);
ogl_init();//platform specific initialization
@ -422,8 +392,6 @@ int gr_init(int mode)
void gr_close()
{
// mprintf((0,"ogl init: %s %s %s - %s\n",glGetString(GL_VENDOR),glGetString(GL_RENDERER),glGetString(GL_VERSION),glGetString,(GL_EXTENSIONS)));
ogl_close();//platform specific code
if (grd_curscreen){
if (grd_curscreen->sc_canvas.cv_bitmap.bm_data)
@ -438,33 +406,28 @@ void gr_close()
extern int r_upixelc;
void ogl_upixelc(int x, int y, int c){
r_upixelc++;
// printf("gr_upixelc(%i,%i,%i)%i\n",x,y,c,Function_mode==FMODE_GAME);
// if(Function_mode != FMODE_GAME){
// grd_curcanv->cv_bitmap.bm_data[y*grd_curscreen->sc_canvas.cv_bitmap.bm_w+x]=c;
// }else{
OGL_DISABLE(TEXTURE_2D);
glPointSize(1.0);
glBegin(GL_POINTS);
// glBegin(GL_LINES);
// ogl_pal=gr_current_pal;
glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
// ogl_pal=gr_palette;
glVertex2f((x+grd_curcanv->cv_bitmap.bm_x)/(float)last_width,1.0-(y+grd_curcanv->cv_bitmap.bm_y)/(float)last_height);
// glVertex2f(x/((float)last_width+1),1.0-y/((float)last_height+1));
glEnd();
// }
OGL_DISABLE(TEXTURE_2D);
glPointSize(1.0);
glBegin(GL_POINTS);
glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
glVertex2f((x+grd_curcanv->cv_bitmap.bm_x)/(float)last_width,1.0-(y+grd_curcanv->cv_bitmap.bm_y)/(float)last_height);
glEnd();
}
void ogl_urect(int left,int top,int right,int bot){
GLfloat xo,yo,xf,yf;
int c=COLOR;
xo=(left+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
xf=(right+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
xf = (right + 1 + grd_curcanv->cv_bitmap.bm_x) / (float)last_width;
yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
yf = 1.0 - (bot + 1 + grd_curcanv->cv_bitmap.bm_y) / (float)last_height;
OGL_DISABLE(TEXTURE_2D);
glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
if (Gr_scanline_darkening_level >= GR_FADE_LEVELS)
glColor3f(CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c));
else
glColor4f(CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0));
glBegin(GL_QUADS);
glVertex2f(xo,yo);
glVertex2f(xo,yf);
@ -472,6 +435,7 @@ void ogl_urect(int left,int top,int right,int bot){
glVertex2f(xf,yo);
glEnd();
}
void ogl_ulinec(int left,int top,int right,int bot,int c){
GLfloat xo,yo,xf,yf;
@ -491,21 +455,16 @@ void ogl_ulinec(int left,int top,int right,int bot,int c){
GLfloat last_r=0, last_g=0, last_b=0;
int do_pal_step=0;
void ogl_do_palfx(void){
// GLfloat r,g,b,a;
OGL_DISABLE(TEXTURE_2D);
if (gr_palette_faded_out){
/* glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
glColor3f(0,0,0);
// r=g=b=0.0;a=1.0;
}else{
if (do_pal_step){
//glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_ONE);
glColor3f(last_r,last_g,last_b);
// r=f2fl(last_r);g=f2fl(last_g);b=f2fl(last_b);a=0.5;
}else
return;
}
@ -517,7 +476,6 @@ void ogl_do_palfx(void){
glVertex2f(1,1);
glVertex2f(1,0);
glEnd();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
@ -532,13 +490,6 @@ void gr_palette_step_up( int r, int g, int b )
{
if (gr_palette_faded_out) return;
// if ( (r==last_r) && (g==last_g) && (b==last_b) ) return;
/* last_r = r/63.0;
last_g = g/63.0;
last_b = b/63.0;
do_pal_step=(r || g || b);*/
last_r = (r+gr_palette_gamma)/63.0;
last_g = (g+gr_palette_gamma)/63.0;
last_b = (b+gr_palette_gamma)/63.0;
@ -547,45 +498,34 @@ void gr_palette_step_up( int r, int g, int b )
}
//added on 980913 by adb to fix palette problems
// need a min without side effects...
#undef min
static inline int min(int x, int y) { return x < y ? x : y; }
//end changes by adb
void gr_palette_load( ubyte *pal )
{
int i;//, j;
int i;//, j;
for (i=0; i<768; i++ ) {
gr_current_pal[i] = pal[i];
if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
}
for (i=0; i<768; i++ ) {
gr_current_pal[i] = pal[i];
if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
}
//palette = screen->format->palette;
gr_palette_faded_out=0;
init_computed_colors();
gr_palette_faded_out=0;
init_computed_colors();
}
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys)
{
gr_palette_faded_out=1;
return 0;
}
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)
{
gr_palette_faded_out=0;
return 0;
}
void gr_palette_read(ubyte * pal)
{
int i;
@ -646,7 +586,6 @@ void write_bmp(char *savename,int w,int h,unsigned char *buf){ // ZICO - modifie
void save_screen_shot(int automap_flag)
{
// fix t1;
char message[100];
static int savenum=0;
char savename[13];
@ -660,7 +599,6 @@ void save_screen_shot(int automap_flag)
stop_time();
//added/changed on 10/31/98 by Victor Rachels to fix overwrite each new game
if ( savenum == 9999 ) savenum = 0;
sprintf(savename,"scrn%04d.tga",savenum++);
@ -670,19 +608,15 @@ void save_screen_shot(int automap_flag)
sprintf(savename,"scrn%04d.tga",savenum++);
}
sprintf( message, "%s '%s'", TXT_DUMPING_SCREEN, savename );
//end this section addition/change - Victor Rachels
if (automap_flag) {
} else {
if (!automap_flag) {
hud_message(MSGC_GAME_FEEDBACK,message);
}
buf = malloc(grd_curscreen->sc_w*grd_curscreen->sc_h*3);
glReadBuffer(GL_FRONT);
//glReadPixels(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
write_bmp(savename,grd_curscreen->sc_w,grd_curscreen->sc_h,buf);
free(buf);
key_flush();
start_time();
}
}

View file

@ -174,7 +174,7 @@ int ogl_texture_stats(void){
// grabbed++;
}
if (gr_renderstats){
gr_printf(5,GAME_FONT->ft_h*14+3*14,"%i(%i,%i) %iK(%iK wasted)",used,usedrgba,usedl4a4,truebytes/1024,(truebytes-databytes)/1024);
gr_printf(5,FONTSCALE_Y(GAME_FONT->ft_h*14+3*14),"%i(%i,%i) %iK(%iK wasted)",used,usedrgba,usedl4a4,truebytes/1024,(truebytes-databytes)/1024);
}
// glmprintf((0,"ogl tex stats: %i(%i,%i|%i,%i,%i,%i,%i) %i(%i)b (%i(%i)wasted)\n",used,usedrgba,usedl4a4,prio0,prio1,prio2,prio3,prioh,truebytes,truetexel,truebytes-databytes,truetexel-datatexel));
return truebytes;
@ -1179,7 +1179,7 @@ void ogl_end_frame(void){
void ogl_swap_buffers(void){
ogl_clean_texture_cache();
if (gr_renderstats){
gr_printf(5,GAME_FONT->ft_h*13+3*13,"%i flat %i tex %i sprites %i bitmaps",r_polyc,r_tpolyc,r_bitmapc,r_ubitmapc);
gr_printf(5,FONTSCALE_Y(GAME_FONT->ft_h*13+3*13),"%i flat %i tex %i sprites %i bitmaps",r_polyc,r_tpolyc,r_bitmapc,r_ubitmapc);
// glmprintf((0,"ogl_end_frame: %i polys, %i tmaps, %i sprites, %i bitmaps, %i bitblts, %i pixels\n",r_polyc,r_tpolyc,r_bitmapc,r_ubitmapc,r_ubitbltc,r_upixelc));//we need to do it here because some things get drawn after end_frame
}
ogl_do_palfx();

View file

@ -69,7 +69,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "network.h"
#include "newmenu.h"
#include "cntrlcen.h"
#include "d_delay.h"
#include "automap.h"
@ -130,7 +129,6 @@ void init_automap_colors(void)
Hostage_color = K_HOSTAGE_COLOR;
Font_color_20 = K_FONT_COLOR_20;
Green_31 = K_GREEN_31;
White_63 = gr_find_closest_color_current(63,63,63);
Blue_48 = gr_find_closest_color_current(0,0,48);
Red_48 = gr_find_closest_color_current(48,0,0);
@ -141,20 +139,20 @@ ubyte Automap_visited[MAX_SEGMENTS];
// Edge list variables
static int Num_edges=0;
static int Max_edges; //set each frame
static int Max_edges; //set each frame
static int Highest_edge_index = -1;
static Edge_info Edges[MAX_EDGES];
static short DrawingListBright[MAX_EDGES];
// Map movement defines
#define PITCH_DEFAULT 9000
#define ZOOM_DEFAULT i2f(20*10)
#define ZOOM_MIN_VALUE i2f(20*5)
#define ZOOM_MAX_VALUE i2f(20*100)
#define PITCH_DEFAULT 9000
#define ZOOM_DEFAULT i2f(20*10)
#define ZOOM_MIN_VALUE i2f(20*5)
#define ZOOM_MAX_VALUE i2f(20*100)
#define SLIDE_SPEED (350)
#define ZOOM_SPEED_FACTOR (500) //(1500)
#define ROT_SPEED_DIVISOR (115000)
#define SLIDE_SPEED (350)
#define ZOOM_SPEED_FACTOR (500)
#define ROT_SPEED_DIVISOR (115000)
// Screen anvas variables
#ifndef AUTOMAP_DIRECT_RENDER
@ -195,8 +193,8 @@ void automap_clear_visited()
Automap_visited[i] = 0;
}
grs_canvas *name_canv;
char name_level[128];
grs_canvas *name_canv;
char name_level[128];
//print to canvas & double height
grs_canvas *print_to_canvas(char *s,grs_font *font, int fc, int bc)
@ -266,7 +264,6 @@ void create_name_canv()
strcat(name_level, Current_level_name);
gr_set_fontcolor(BM_XRGB(0,31,0),-1);
// name_canv = print_to_canvas(name_level,Gamefonts[GFONT_SMALL], BM_XRGB(0,31,0), -1);
gr_set_curfont((Gamefonts[GFONT_SMALL]));
gr_printf(5,5,"%s", name_level);
}
@ -332,7 +329,7 @@ void draw_automap()
color = get_team(Player_num);
else
#endif
color = Player_num; // Note link to above if!
color = Player_num; // Note link to above if!
gr_setcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b));
draw_player(&Objects[Players[Player_num].objnum]);
@ -383,7 +380,6 @@ void draw_automap()
g3_end_frame();
// gr_bitmapm(5, 5, &name_canv->cv_bitmap);
create_name_canv();
#ifdef OGL
@ -401,12 +397,11 @@ void draw_automap()
extern void GameLoop(int, int );
extern int set_segment_depths(int start_seg, ubyte *segbuf);
extern int Current_display_mode;
u_int32_t automap_mode = SM(640,480);
int automap_width = 640;
int automap_height = 480;
int automap_use_game_res=1; // ZICO - should be better
int nice_automap = 1; // ZICO - should be better (command-line switches deactivated)
int automap_use_game_res=1;
int nice_automap = 1;
int Automap_active = 0;
#define MAP_BACKGROUND_FILENAME "MAP.PCX"
@ -463,8 +458,6 @@ void do_automap( int key_code ) {
automap_width=grd_curscreen->sc_canvas.cv_bitmap.bm_w;
automap_height=grd_curscreen->sc_canvas.cv_bitmap.bm_h;
// create_name_canv();
gr_palette_clear();
#ifndef AUTOMAP_DIRECT_RENDER
@ -613,8 +606,6 @@ void do_automap( int key_code ) {
case KEY_ALTED+KEY_PADENTER:
gr_toggle_fullscreen_game();
break;
//end addition -MM
}
}
@ -673,8 +664,6 @@ void do_automap( int key_code ) {
t1 = t2;
}
// gr_free_canvas(name_canv); name_canv=NULL;
#ifndef AUTOMAP_DIRECT_RENDER
if (must_free_canvas)
free(Page.cv_bitmap.bm_data);
@ -709,7 +698,6 @@ void adjust_segment_limit(int SegmentLimit)
}
}
}
}
void draw_all_edges()
@ -733,7 +721,7 @@ void draw_all_edges()
if ( e->flags & EF_TOO_FAR) continue;
if (e->flags&EF_FRONTIER) { // A line that is between what we have seen and what we haven't
if (e->flags&EF_FRONTIER) { // A line that is between what we have seen and what we haven't
if ( (!(e->flags&EF_SECRET))&&(e->color==Wall_normal_color))
continue; // If a line isn't secret and is normal color, then don't draw it
}
@ -1074,7 +1062,6 @@ void add_unknown_segment_edges(segment *seg)
// Only add edges that have no children
if (seg->children[sn] == -1) {
get_side_verts(vertex_list,segnum,sn);
add_one_unknown_edge( vertex_list[0], vertex_list[1] );
add_one_unknown_edge( vertex_list[1], vertex_list[2] );
add_one_unknown_edge( vertex_list[2], vertex_list[3] );
@ -1154,7 +1141,5 @@ void automap_build_edge_list()
break;
}
}
mprintf( (0, "Automap used %d / %d edges\n", Num_edges, Max_edges ));
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -142,21 +142,21 @@ void nm_draw_background(int x1, int y1, int x2, int y2 )
//scale the bevels to the res too. All the gwidth/height stuff is needed so that the corners have the correct angles at odd resolutions like 320x400 where the ratios are different for x and y
#ifdef OGL
gr_setcolor( BM_XRGB(1,1,1) );
for (w=5*(GWIDTH/320.0);w>=0;w--)
gr_urect( x2-w+1, y1+w*((GHEIGHT/200.0)/(GWIDTH/320.0)), x2+1, y2-(GHEIGHT/200.0) );//right edge
for (h=5*(GHEIGHT/200.0);h>=0;h--)
gr_urect( x1+h*((GWIDTH/320.0)/(GHEIGHT/200.0)), y2+1, x2+1, y2-h+1 );//bottom edge
#else
// #ifdef OGL
// gr_setcolor( BM_XRGB(1,1,1) );
//
// for (w=5*(GWIDTH/320.0);w>=0;w--)
// gr_urect( x2-w+1, y1+w*((GHEIGHT/200.0)/(GWIDTH/320.0)), x2+1, y2-(GHEIGHT/200.0) );//right edge
// for (h=5*(GHEIGHT/200.0);h>=0;h--)
// gr_urect( x1+h*((GWIDTH/320.0)/(GHEIGHT/200.0)), y2+1, x2+1, y2-h+1 );//bottom edge
// #else
gr_setcolor( BM_XRGB(0,0,0) );
for (w=5*(GWIDTH/320.0);w>=0;w--)
gr_urect( x2-w, y1+w*((GHEIGHT/200.0)/(GWIDTH/320.0)), x2-w, y2-(GHEIGHT/200.0) );//right edge
for (h=5*(GHEIGHT/200.0);h>=0;h--)
gr_urect( x1+h*((GWIDTH/320.0)/(GHEIGHT/200.0)), y2-h, x2, y2-h );//bottom edge
#endif
// #endif
Gr_scanline_darkening_level = GR_FADE_LEVELS;

View file

@ -11,67 +11,12 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
* $Source: /cvsroot/dxx-rebirth/d1x-rebirth/main/radar.c,v $
* $Revision: 1.1.1.1 $
* $Author: zicodxx $
* $Date: 2006/03/17 19:41:45 $
*
*
* Routines for drawing the radar.
* .
*
* $Log: radar.c,v $
* Revision 1.1.1.1 2006/03/17 19:41:45 zicodxx
* initial import
*
* Revision 1.2 1999/07/10 02:59:07 donut
* more from orulz
*
* Revision 1.1.1.1 1999/06/14 22:11:14 donut
* Import of d1x 1.37 source.
*
* Revision 1.10 1995/02/27 12:31:15 john
* Version 2.0.
*
* Revision 1.9 1995/02/01 21:03:36 john
* Lintified.
*
* Revision 1.8 1994/08/12 22:41:28 john
* Took away Player_stats; add Players array.
*
* Revision 1.7 1994/07/15 09:38:00 john
* Moved in radar_farthest_dist.
*
* Revision 1.6 1994/07/14 22:05:57 john
* Made radar display not conflict with hostage
* vclip talking.
*
* Revision 1.5 1994/07/12 18:41:51 yuan
* Tweaked location of radar and hostage screen...
* Still needs work.
*
*
* Revision 1.4 1994/07/07 14:59:00 john
* Made radar powerups.
*
*
* Revision 1.3 1994/07/07 10:05:36 john
* Pegged objects in radar to edges.
*
* Revision 1.2 1994/07/06 19:36:33 john
* Initial version of radar.
*
* Revision 1.1 1994/07/06 17:22:07 john
* Initial revision
*
*
*/
#ifdef RCS
static char rcsid[] = "$Id: radar.c,v 1.1.1.1 2006/03/17 19:41:45 zicodxx Exp $";
#endif
#include <stdlib.h>
#include "error.h"
@ -90,16 +35,9 @@ static char rcsid[] = "$Id: radar.c,v 1.1.1.1 2006/03/17 19:41:45 zicodxx Exp $"
#include "network.h"
#include "gauges.h"
//added/moved on 9/17/98 by Victor Rachels - radar toggle
int show_radar=0;
//end this section
//added on 11/12/98 by Victor Rachels for Network radar
int Network_allow_radar=0;
//end this section
//changed 7/5/99 - Owen Evans - radar resizes with screen size
short Hostage_monitor_size, Hostage_monitor_x, Hostage_monitor_y;
//end changed - OE
static fix radx, rady, rox, roy, cenx, ceny;
@ -112,10 +50,7 @@ typedef struct blip {
blip Blips[MAX_BLIPS];
int N_blips = 0;
fix Radar_farthest_dist = (F1_0 * 20 * 15); // 15 segments away
//fix Radar_farthest_dist = (F1_0 * 20 * 8); // 8 segments away
void radar_plot_object( object * objp, int hue )
{
@ -156,29 +91,27 @@ void radar_render_frame()
int i,color;
object * objp;
// added 7/5/99 - Owen Evans - radar resizes with screen size
switch (Cockpit_mode)
{
case CM_FULL_SCREEN:
Hostage_monitor_size = Game_window_w / 6;
Hostage_monitor_x = (grd_curscreen->sc_w - Game_window_w) / 2;
Hostage_monitor_y = (grd_curscreen->sc_h - Game_window_h) / 2;
break;
case CM_FULL_COCKPIT:
Hostage_monitor_size = 40;
Hostage_monitor_x = 0;
Hostage_monitor_y = 80;
break;
case CM_STATUS_BAR:
Hostage_monitor_size = Game_window_w / 6;
Hostage_monitor_x = (grd_curscreen->sc_w - Game_window_w) / 2;
Hostage_monitor_y = (max_window_h - Game_window_h) / 2;
break;
case CM_REAR_VIEW: //no radar in rear view or letterbox!
case CM_LETTERBOX:
return;
}
//end added - OE
switch (Cockpit_mode)
{
case CM_FULL_SCREEN:
Hostage_monitor_size = Game_window_w / 6;
Hostage_monitor_x = (grd_curscreen->sc_w - Game_window_w) / 2;
Hostage_monitor_y = (grd_curscreen->sc_h - Game_window_h) / 2;
break;
case CM_FULL_COCKPIT:
Hostage_monitor_size = 40*(SHEIGHT/200);
Hostage_monitor_x = 0;
Hostage_monitor_y = 80*(SHEIGHT/200);
break;
case CM_STATUS_BAR:
Hostage_monitor_size = Game_window_w / 6;
Hostage_monitor_x = (grd_curscreen->sc_w - Game_window_w) / 2;
Hostage_monitor_y = (max_window_h - Game_window_h) / 2;
break;
case CM_REAR_VIEW: //no radar in rear view or letterbox!
case CM_LETTERBOX:
return;
}
if (hostage_is_vclip_playing())
return;
@ -189,25 +122,15 @@ void radar_render_frame()
gr_ucircle( i2f(Hostage_monitor_x+Hostage_monitor_size/2), i2f(Hostage_monitor_y+Hostage_monitor_size/2), i2f(Hostage_monitor_size)/2);
//other stuff added 9/14/98 by Victor Rachels for fun.
gr_circle( i2f(Hostage_monitor_x+Hostage_monitor_size/2), i2f(Hostage_monitor_y+Hostage_monitor_size/2), i2f(Hostage_monitor_size) / 8 );
gr_upixel((Hostage_monitor_x+Hostage_monitor_size/2), (Hostage_monitor_y+Hostage_monitor_size/2) );
gr_uline(i2f(Hostage_monitor_x+Hostage_monitor_size/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2),i2f(Hostage_monitor_x+Hostage_monitor_size*2/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2));
gr_uline(i2f(Hostage_monitor_x+Hostage_monitor_size-Hostage_monitor_size/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2),i2f(Hostage_monitor_x+Hostage_monitor_size-Hostage_monitor_size*2/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2));
//other stuff added 9/14/98 by Victor Rachels for fun.
gr_circle( i2f(Hostage_monitor_x+Hostage_monitor_size/2), i2f(Hostage_monitor_y+Hostage_monitor_size/2), i2f(Hostage_monitor_size) / 8 );
gr_upixel((Hostage_monitor_x+Hostage_monitor_size/2), (Hostage_monitor_y+Hostage_monitor_size/2) );
gr_uline(i2f(Hostage_monitor_x+Hostage_monitor_size/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2),i2f(Hostage_monitor_x+Hostage_monitor_size*2/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2));
gr_uline(i2f(Hostage_monitor_x+Hostage_monitor_size-Hostage_monitor_size/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2),i2f(Hostage_monitor_x+Hostage_monitor_size-Hostage_monitor_size*2/10),i2f(Hostage_monitor_y+Hostage_monitor_size/2));
//killed 7/5/99 - Owen Evans - make radar much more useable
// // Erase old blips
// for (i=0; i<N_blips; i++ ) {
// gr_setcolor(gr_gpixel( &GameBitmaps[cockpit_bitmap[0].index], Blips[i].x, Blips[i].y ));
// gr_upixel( Blips[i].x, Blips[i].y );
// }
//end killed - OE
N_blips = 0;
// if ( !(Players[Player_num].flags & (PLAYER_FLAGS_RADAR_ENEMIES | PLAYER_FLAGS_RADAR_POWERUPS )) ) return;
radx = i2f(Hostage_monitor_size*4)/2;
rady = i2f(Hostage_monitor_size*4)/2;
cenx = i2f(Hostage_monitor_x)+i2f(Hostage_monitor_size)/2;
@ -230,23 +153,19 @@ void radar_render_frame()
radar_plot_object( objp, gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b) );
}
break;
case OBJ_HOSTAGE:
radar_plot_object( objp, BM_XRGB(0,31,0) );
break;
case OBJ_POWERUP:
//if ( Players[Player_num].flags & PLAYER_FLAGS_RADAR_POWERUPS )
if(!(Game_mode & GM_MULTI))
radar_plot_object( objp, BM_XRGB(0,0,31) );
break;
case OBJ_ROBOT:
// //if ( Players[Player_num].flags & PLAYER_FLAGS_RADAR_ENEMIES )
radar_plot_object( objp, BM_XRGB(31,0,0) );
break;
// added 7/5/99 - Owen Evans - reactor is now shown on radar
case OBJ_CNTRLCEN:
radar_plot_object( objp, BM_XRGB(31,31,31) );
break;
// end added - OE
case OBJ_HOSTAGE:
radar_plot_object( objp, BM_XRGB(0,31,0) );
break;
case OBJ_POWERUP:
if(!(Game_mode & GM_MULTI))
radar_plot_object( objp, BM_XRGB(0,0,31) );
break;
case OBJ_ROBOT:
radar_plot_object( objp, BM_XRGB(31,0,0) );
break;
case OBJ_CNTRLCEN:
radar_plot_object( objp, BM_XRGB(31,31,31) );
break;
default:
break;
}

View file

@ -11,199 +11,12 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
* $Source: /cvsroot/dxx-rebirth/d1x-rebirth/main/weapon.c,v $
* $Revision: 1.1.1.1 $
* $Author: zicodxx $
* $Date: 2006/03/17 19:44:46 $
*
*
* Functions for weapons...
*
* $Log: weapon.c,v $
* Revision 1.1.1.1 2006/03/17 19:44:46 zicodxx
* initial import
*
* Revision 1.1.1.1 1999/06/14 22:12:04 donut
* Import of d1x 1.37 source.
*
* Revision 2.1 1995/03/21 14:38:43 john
* Ifdef'd out the NETWORK code.
*
* Revision 2.0 1995/02/27 11:27:25 john
* New version 2.0, which has no anonymous unions, builds with
* Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
*
* Revision 1.54 1995/02/15 15:21:48 mike
* make smart missile select if mega missiles used up.
*
*
* Revision 1.53 1995/02/12 02:12:30 john
* Fixed bug with state restore making weapon beeps.
*
* Revision 1.52 1995/02/09 20:42:15 mike
* change weapon autoselect, always autoselect smart, mega.
*
* Revision 1.51 1995/02/07 20:44:26 mike
* autoselect mega, smart when you pick them up.
*
* Revision 1.50 1995/02/07 13:32:25 rob
* Added include of multi.h
*
* Revision 1.49 1995/02/07 13:21:33 yuan
* Fixed 2nd typo
*
* Revision 1.48 1995/02/07 13:16:39 yuan
* Fixed typo.
*
* Revision 1.47 1995/02/07 12:53:12 rob
* Added network sound prop. to weapon switch.
*
* Revision 1.46 1995/02/06 15:53:17 mike
* don't autoselect smart or mega missile when you pick it up.
*
* Revision 1.45 1995/02/02 21:43:34 mike
* make autoselection better.
*
* Revision 1.44 1995/02/02 16:27:21 mike
* make concussion missiles trade up.
*
* Revision 1.43 1995/02/01 23:34:57 adam
* messed with weapon change sounds
*
* Revision 1.42 1995/02/01 17:12:47 mike
* Make smart missile, mega missile not auto-select.
*
* Revision 1.41 1995/02/01 15:50:54 mike
* fix bogus weapon selection sound code.
*
* Revision 1.40 1995/01/31 16:16:31 mike
* Separate smart blobs for robot and player.
*
* Revision 1.39 1995/01/30 21:12:11 mike
* Use new weapon selection sounds, different for primary and secondary.
*
* Revision 1.38 1995/01/29 13:46:52 mike
* Don't auto-select fusion cannon when you run out of energy.
*
* Revision 1.37 1995/01/20 11:11:13 allender
* record weapon changes again. (John somehow lost my 1.35 changes).
*
* Revision 1.36 1995/01/19 17:00:46 john
* Made save game work between levels.
*
* Revision 1.34 1995/01/09 17:03:48 mike
* fix autoselection of weapons.
*
* Revision 1.33 1995/01/05 15:46:31 john
* Made weapons not rearm when starting a saved game.
*
* Revision 1.32 1995/01/03 12:34:23 mike
* autoselect next lower weapon if run out of smart or mega missile.
*
* Revision 1.31 1994/12/12 21:39:37 matt
* Changed vulcan ammo: 10K max, 5K w/weapon, 1250 per powerup
*
* Revision 1.30 1994/12/09 19:55:04 matt
* Added weapon name in "not available in shareware" message
*
* Revision 1.29 1994/12/06 13:50:24 adam
* added shareware msg. when choosing 4 top weapons
*
* Revision 1.28 1994/12/02 22:07:13 mike
* if you gots 19 concussion missiles and you runs over 4, say you picks up 1, not 4, we do the math, see?
*
* Revision 1.27 1994/12/02 20:06:24 matt
* Made vulcan ammo print at approx 25 times actual
*
* Revision 1.26 1994/12/02 15:05:03 matt
* Fixed bogus weapon constants and arrays
*
* Revision 1.25 1994/12/02 10:50:34 yuan
* Localization
*
* Revision 1.24 1994/11/29 15:48:28 matt
* selecting weapon now makes sound
*
* Revision 1.23 1994/11/28 11:26:58 matt
* Cleaned up hud message printing for picking up weapons
*
* Revision 1.22 1994/11/27 23:13:39 matt
* Made changes for new mprintf calling convention
*
* Revision 1.21 1994/11/12 16:38:34 mike
* clean up default ammo stuff.
*
* Revision 1.20 1994/11/07 17:41:18 mike
* messages for when you try to fire a weapon you don't have or don't have ammo for.
*
* Revision 1.19 1994/10/21 20:40:05 mike
* fix double vulcan ammo.
*
* Revision 1.18 1994/10/20 09:49:05 mike
* kill messages no one liked...*sniff* *sniff*
*
* Revision 1.17 1994/10/19 11:17:07 mike
* Limit amount of player ammo.
*
* Revision 1.16 1994/10/12 08:04:18 mike
* Fix proximity/homing confusion.
*
* Revision 1.15 1994/10/11 18:27:58 matt
* Changed auto selection of secondary weapons
*
* Revision 1.14 1994/10/08 23:37:54 matt
* Don't pick up weapons you already have; also fixed auto_select bug
* for seconary weapons
*
* Revision 1.13 1994/10/08 14:55:47 matt
* Fixed bug that selected vulcan cannon when picked up ammo, even though
* you didn't have the weapon.
*
* Revision 1.12 1994/10/08 12:50:32 matt
* Fixed bug that let you select weapons you don't have
*
* Revision 1.11 1994/10/07 23:37:56 matt
* Made weapons select when pick up better one
*
* Revision 1.10 1994/10/07 16:02:08 matt
* Fixed problem with weapon auto-select
*
* Revision 1.9 1994/10/05 17:00:20 matt
* Made player_has_weapon() public and moved constants to header file
*
* Revision 1.8 1994/09/26 11:27:13 mike
* Fix auto selection of weapon when you run out of ammo.
*
* Revision 1.7 1994/09/13 16:40:45 mike
* Add rearm delay and missile firing delay.
*
* Revision 1.6 1994/09/13 14:43:12 matt
* Added cockpit weapon displays
*
* Revision 1.5 1994/09/03 15:23:06 mike
* Auto select next weaker weapon when one runs out, clean up code.
*
* Revision 1.4 1994/09/02 16:38:19 mike
* Eliminate a pile of arrays, associate weapon data with Weapon_info.
*
* Revision 1.3 1994/09/02 11:57:10 mike
* Add a bunch of stuff, I forget what.
*
* Revision 1.2 1994/06/03 16:26:32 john
* Initial version.
*
* Revision 1.1 1994/06/03 14:40:43 john
* Initial revision
*
*
*/
#ifdef RCS
#pragma off (unreferenced)
static char rcsid[] = "$Id: weapon.c,v 1.1.1.1 2006/03/17 19:44:46 zicodxx Exp $";
#pragma on (unreferenced)
#endif
#include "game.h"
#include "weapon.h"
#include "mono.h"
@ -217,54 +30,22 @@ static char rcsid[] = "$Id: weapon.c,v 1.1.1.1 2006/03/17 19:44:46 zicodxx Exp $
#include "multi.h"
#include "reorder.h"
//#define FUSION_KEEPS_CHARGE
// Note, only Vulcan cannon requires ammo.
//ubyte Default_primary_ammo_level[MAX_PRIMARY_WEAPONS] = {255, 0, 255, 255, 255};
//ubyte Default_secondary_ammo_level[MAX_SECONDARY_WEAPONS] = {3, 0, 0, 0, 0};
// Convert primary weapons to indices in Weapon_info array.
// Convert primary weapons to indices in Weapon_info array.
ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS] = {0, 11, 12, 13, 14};
ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS] = {8, 15, 16, 17, 18};
int Primary_ammo_max[MAX_PRIMARY_WEAPONS] = {0, VULCAN_AMMO_MAX, 0, 0, 0};
ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS] = {20, 10, 10, 5, 5};
weapon_info Weapon_info[MAX_WEAPON_TYPES];
int N_weapon_types=0;
byte Primary_weapon, Secondary_weapon;
//char *Primary_weapon_names[MAX_PRIMARY_WEAPONS] = {
// "Laser Cannon",
// "Vulcan Cannon",
// "Spreadfire Cannon",
// "Plasma Cannon",
// "Fusion Cannon"
//};
//char *Secondary_weapon_names[MAX_SECONDARY_WEAPONS] = {
// "Concussion Missile",
// "Homing Missile",
// "Proximity Bomb",
// "Smart Missile",
// "Mega Missile"
//};
//char *Primary_weapon_names_short[MAX_PRIMARY_WEAPONS] = {
// "Laser",
// "Vulcan",
// "Spread",
// "Plasma",
// "Fusion"
//};
//char *Secondary_weapon_names_short[MAX_SECONDARY_WEAPONS] = {
// "Concsn\nMissile",
// "Homing\nMissile",
// "Proxim.\nBomb",
// "Smart\nMissile",
// "Mega\nMissile"
//};
char *Primary_weapon_names_short[MAX_PRIMARY_WEAPONS] = {
"Laser",
"Vulcan",
"Spread",
"Plasma",
"Fusion"
};
// ------------------------------------------------------------------------------------
// Return:
@ -284,37 +65,37 @@ int player_has_weapon(int weapon_num, int secondary_flag)
Players[Player_num].energy = 0;
if (!secondary_flag) {
if(weapon_num >= MAX_PRIMARY_WEAPONS)
{
switch(weapon_num-MAX_PRIMARY_WEAPONS)
{
case 0 : if((Players[Player_num].laser_level != 0)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 1 : if((Players[Player_num].laser_level != 1)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 2 : if((Players[Player_num].laser_level != 2)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 3 : if((Players[Player_num].laser_level != 3)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 4 : if((Players[Player_num].laser_level != 0)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 5 : if((Players[Player_num].laser_level != 1)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 6 : if((Players[Player_num].laser_level != 2)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 7 : if((Players[Player_num].laser_level != 3)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
}
weapon_num = 0;
}
if(weapon_num >= MAX_PRIMARY_WEAPONS)
{
switch(weapon_num-MAX_PRIMARY_WEAPONS)
{
case 0 : if((Players[Player_num].laser_level != 0)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 1 : if((Players[Player_num].laser_level != 1)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 2 : if((Players[Player_num].laser_level != 2)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 3 : if((Players[Player_num].laser_level != 3)||(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 4 : if((Players[Player_num].laser_level != 0)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 5 : if((Players[Player_num].laser_level != 1)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 6 : if((Players[Player_num].laser_level != 2)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
case 7 : if((Players[Player_num].laser_level != 3)||!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
return 0;
break;
}
weapon_num = 0;
}
weapon_index = Primary_weapon_to_weapon_info[weapon_num];
@ -324,18 +105,17 @@ int player_has_weapon(int weapon_num, int secondary_flag)
if (Weapon_info[weapon_index].ammo_usage <= Players[Player_num].primary_ammo[weapon_num])
return_value |= HAS_AMMO_FLAG;
//added on 1/21/99 by Victor Rachels... yet another hack
//fusion has 0 energy usage, HAS_ENERGY_FLAG was always true
if(weapon_num==FUSION_INDEX)
{
if(Players[Player_num].energy >= F1_0*2)
return_value |= HAS_ENERGY_FLAG;
}
else
//end this section addition - VR
if (Weapon_info[weapon_index].energy_usage <= Players[Player_num].energy)
return_value |= HAS_ENERGY_FLAG;
//added on 1/21/99 by Victor Rachels... yet another hack
//fusion has 0 energy usage, HAS_ENERGY_FLAG was always true
if(weapon_num==FUSION_INDEX)
{
if(Players[Player_num].energy >= F1_0*2)
return_value |= HAS_ENERGY_FLAG;
}
else
//end this section addition - VR
if (Weapon_info[weapon_index].energy_usage <= Players[Player_num].energy)
return_value |= HAS_ENERGY_FLAG;
} else {
weapon_index = Secondary_weapon_to_weapon_info[weapon_num];
@ -348,13 +128,11 @@ int player_has_weapon(int weapon_num, int secondary_flag)
if (Weapon_info[weapon_index].energy_usage <= Players[Player_num].energy)
return_value |= HAS_ENERGY_FLAG;
}
return return_value;
}
// ------------------------------------------------------------------------------------
//if message flag set, print message saying selected
// if message flag set, print message saying selected
void select_weapon(int weapon_num, int secondary_flag, int print_message, int wait_for_rearm)
{
char *weapon_name;
@ -365,31 +143,31 @@ void select_weapon(int weapon_num, int secondary_flag, int print_message, int wa
#endif
if (!secondary_flag) {
//added on 10/9/98 by Victor Rachels to add laser cycle
if (weapon_num >= MAX_PRIMARY_WEAPONS)
{
LaserPowSelected=weapon_num;
weapon_num = 0;
if(Primary_weapon==0)
return;
}
else if (weapon_num == 0)
LaserPowSelected=0;
//end this section addition
//added on 10/9/98 by Victor Rachels to add laser cycle
if (weapon_num >= MAX_PRIMARY_WEAPONS)
{
LaserPowSelected=weapon_num;
weapon_num = 0;
if(Primary_weapon==0)
return;
}
else if (weapon_num == 0)
LaserPowSelected=0;
//end this section addition
if (Primary_weapon != weapon_num) {
#ifndef FUSION_KEEPS_CHARGE
#ifndef FUSION_KEEPS_CHARGE
//added 8/6/98 by Victor Rachels to fix fusion charge bug
Fusion_charge=0;
//end edit - Victor Rachels
#endif
#endif
if (wait_for_rearm) digi_play_sample_once( SOUND_GOOD_SELECTION_PRIMARY, F1_0 );
#ifdef NETWORK
#ifdef NETWORK
if (Game_mode & GM_MULTI) {
if (wait_for_rearm) multi_send_play_sound(SOUND_GOOD_SELECTION_PRIMARY, F1_0);
}
#endif
#endif
if (wait_for_rearm)
Next_laser_fire_time = GameTime + REARM_TIME;
else
@ -404,11 +182,11 @@ void select_weapon(int weapon_num, int secondary_flag, int print_message, int wa
if (Secondary_weapon != weapon_num) {
if (wait_for_rearm) digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
#ifdef NETWORK
#ifdef NETWORK
if (Game_mode & GM_MULTI) {
if (wait_for_rearm) multi_send_play_sound(SOUND_GOOD_SELECTION_PRIMARY, F1_0);
}
#endif
#endif
if (wait_for_rearm)
Next_missile_fire_time = GameTime + REARM_TIME;
else
@ -424,9 +202,7 @@ void select_weapon(int weapon_num, int secondary_flag, int print_message, int wa
if (print_message)
hud_message(MSGC_WEAPON_SELECT, "%s %s", weapon_name, TXT_SELECTED);
//added on 2/8/99 by Victor Rachels to add allweapon hud info
gauge_update_hud_mode=1;
//end this section additon - VR
gauge_update_hud_mode=1;
}
// ------------------------------------------------------------------------------------
@ -434,32 +210,25 @@ void select_weapon(int weapon_num, int secondary_flag, int print_message, int wa
void do_weapon_select(int weapon_num, int secondary_flag)
{
//added on 10/9/98 by Victor Rachels to add laser cycle
int oweapon = weapon_num;
int oweapon = weapon_num;
//end this section addition - Victor Rachels
int weapon_status = player_has_weapon(weapon_num, secondary_flag);
char *weapon_name;
#ifdef SHAREWARE // do special hud msg. for picking registered weapon in shareware version.
#ifdef SHAREWARE // do special hud msg. for picking registered weapon in shareware version.
if (weapon_num >= NUM_SHAREWARE_WEAPONS) {
weapon_name = secondary_flag?SECONDARY_WEAPON_NAMES(weapon_num):PRIMARY_WEAPON_NAMES(weapon_num);
hud_message(MSGC_GAME_FEEDBACK, "%s %s!", weapon_name,TXT_NOT_IN_SHAREWARE);
digi_play_sample( SOUND_BAD_SELECTION, F1_0 );
return;
}
#endif
#endif
if (!secondary_flag) {
//added on 10/9/98 by Victor Rachels to add laser cycle
if (weapon_num >= MAX_PRIMARY_WEAPONS)
// switch(weapon_num-MAX_PRIMARY_WEAPONS)
// {
// case 0 :
weapon_num = 0;
// break;
// }
//end this section addition - Victor Rachels
if (weapon_num >= MAX_PRIMARY_WEAPONS)
weapon_num = 0;
weapon_name = PRIMARY_WEAPON_NAMES(weapon_num);
if ((weapon_status & HAS_WEAPON_FLAG) == 0) {
@ -482,76 +251,13 @@ void do_weapon_select(int weapon_num, int secondary_flag)
}
}
//added on 10/9/98 by Victor Rachels to add laser cycle
weapon_num=oweapon;
//end this section addition - Victor Rachels
weapon_num=oweapon;
select_weapon(weapon_num, secondary_flag, 1, 1);
}
//added/killed on 10/8/98 by Victor Rachels to remove #if 0
//-killed- // original non-customizable version
//-killed- // ----------------------------------------------------------------------------------------
//-killed- // Automatically select next best weapon if unable to fire current weapon.
//-killed- // Weapon type: 0==primary, 1==secondary
//-killed- void auto_select_weapon(int weapon_type)
//-killed- {
//-killed- int r;
//-killed-
//-killed- if (weapon_type==0) {
//-killed- r = player_has_weapon(Primary_weapon, 0);
//-killed- if (r != HAS_ALL) {
//-killed- int cur_weapon;
//-killed- int try_again = 1;
//-killed-
//-killed- cur_weapon = Primary_weapon;
//-killed-
//-killed- while (try_again) {
//-killed- cur_weapon--;
//-killed- if (cur_weapon < 0)
//-killed- cur_weapon = MAX_PRIMARY_WEAPONS-1;
//-killed-
//-killed- // Hack alert! Because the fusion uses 0 energy at the end (it's got the weird chargeup)
//-killed- // it looks like it takes 0 to fire, but it doesn't, so never auto-select.
//-killed- if (cur_weapon == FUSION_INDEX)
//-killed- continue;
//-killed-
//-killed- if (cur_weapon == Primary_weapon) {
//-killed- hud_message(MSGC_WEAPON_EMPTY, TXT_NO_PRIMARY);
//-killed- try_again = 0; // Tried all weapons!
//-killed- select_weapon(0, 0, 0, 1);
//-killed- } else if (player_has_weapon(cur_weapon, 0) == HAS_ALL) {
//-killed- select_weapon(cur_weapon, 0, 1, 1 );
//-killed- try_again = 0;
//-killed- }
//-killed- }
//-killed- }
//-killed-
//-killed- } else {
//-killed-
//-killed- Assert(weapon_type==1);
//-killed-
//-killed- if (Secondary_weapon != PROXIMITY_INDEX) {
//-killed- if (!(player_has_weapon(Secondary_weapon, 1) == HAS_ALL)) {
//-killed- if (Secondary_weapon > SMART_INDEX)
//-killed- if (player_has_weapon(SMART_INDEX, 1) == HAS_ALL) {
//-killed- select_weapon(SMART_INDEX, 1, 1, 1);
//-killed- goto weapon_selected;
//-killed- }
//-killed- if (player_has_weapon(HOMING_INDEX, 1) == HAS_ALL)
//-killed- select_weapon(HOMING_INDEX, 1, 1, 1);
//-killed- else if (player_has_weapon(CONCUSSION_INDEX, 1) == HAS_ALL)
//-killed- select_weapon(CONCUSSION_INDEX, 1, 1, 1);
//-killed- weapon_selected: ;
//-killed- }
//-killed- }
//-killed- }
//-killed-
//-killed- }
// ----------------------------------------------------------------------------------------
// Automatically select best available weapon if unable to fire current weapon.
// Weapon type: 0==primary, 1==secondary
// Weapon type: 0==primary, 1==secondary
void auto_select_weapon(int weapon_type) {
int i;
int *order = weapon_type ? secondary_order : primary_order;
@ -562,24 +268,22 @@ void auto_select_weapon(int weapon_type) {
if (player_has_weapon(
weapon_type ? Secondary_weapon : Primary_weapon,
weapon_type) != HAS_ALL)
{
//added on 1/21/99 by Victor Rachels for noenergy vulcan select
if ((weapon_type==0) &&
(order[VULCAN_INDEX] > 0) &&
(player_has_weapon(VULCAN_INDEX,0)==HAS_ALL))
{
select_weapon(VULCAN_INDEX,0,0,1);
return;
}
//end this section addition - VR
{
if ((weapon_type==0) &&
(order[VULCAN_INDEX] > 0) &&
(player_has_weapon(VULCAN_INDEX,0)==HAS_ALL))
{
select_weapon(VULCAN_INDEX,0,0,1);
return;
}
for (i = 0; i < weapon_count; i++)
if ((order[i] > best_order) &&
(player_has_weapon(i, weapon_type) == HAS_ALL))
{
{
best_weapon = i;
best_order = order[i];
}
}
if (best_weapon >= 0)
select_weapon(best_weapon, weapon_type, 1, 1);
else if (weapon_type == 0) {
@ -620,45 +324,43 @@ void show_weapon_status(void)
mprintf((0, "\n"));
mprintf((0, "\n"));
}
#endif
// select primary weapon if it has a higher order than the current weapon
// select primary weapon if it has a higher order than the current weapon
void maybe_select_primary(int weapon_index)
{
if (primary_order[weapon_index] > 0)
{
if(LaserPowSelected&&Primary_weapon==0)
{
if(primary_order[weapon_index] > primary_order[LaserPowSelected])
select_weapon(weapon_index, 0, 0, 1);
}
else if(primary_order[weapon_index] > primary_order[Primary_weapon])
select_weapon(weapon_index, 0, 0, 1);
else{
// nm_messagebox(NULL,1,TXT_OK,"murp %i==1,%i=prim,%i==7,%i!=7",weapon_index,Primary_weapon,player_has_weapon(weapon_index,0),player_has_weapon(Primary_weapon,0));
if((weapon_index==VULCAN_INDEX) &&
(player_has_weapon(weapon_index,0)==HAS_ALL) &&
(player_has_weapon(Primary_weapon,0)!=HAS_ALL))
select_weapon(weapon_index, 0, 0, 1);
}
}
if (primary_order[weapon_index] > 0)
{
if(LaserPowSelected&&Primary_weapon==0)
{
if(primary_order[weapon_index] > primary_order[LaserPowSelected])
select_weapon(weapon_index, 0, 0, 1);
}
else if(primary_order[weapon_index] > primary_order[Primary_weapon])
select_weapon(weapon_index, 0, 0, 1);
else{
if((weapon_index==VULCAN_INDEX) &&
(player_has_weapon(weapon_index,0)==HAS_ALL) &&
(player_has_weapon(Primary_weapon,0)!=HAS_ALL))
select_weapon(weapon_index, 0, 0, 1);
}
}
}
// select secondary weapon if it has a higher order than the current weapon
// select secondary weapon if it has a higher order than the current weapon
void maybe_select_secondary(int weapon_index)
{
if ((secondary_order[weapon_index] > 0) &&
(secondary_order[weapon_index] > secondary_order[Secondary_weapon]))
(secondary_order[weapon_index] > secondary_order[Secondary_weapon]))
select_weapon(weapon_index, 1, 0, 1);
}
// ---------------------------------------------------------------------
//called when one of these weapons is picked up
//when you pick up a secondary, you always get the weapon & ammo for it
// called when one of these weapons is picked up
// when you pick up a secondary, you always get the weapon & ammo for it
// Returns true if powerup picked up, else returns false.
int pick_up_secondary(int weapon_index,int count)
{
@ -678,22 +380,14 @@ int pick_up_secondary(int weapon_index,int count)
Players[Player_num].secondary_ammo[weapon_index] = Secondary_ammo_max[weapon_index];
}
//added on 9/14/98 by Victor Rachels to make weapon cycle toggle
if(Allow_secondary_cycle)
{
//end this section addition - Victor Rachels (with '}' at below)
if(Allow_secondary_cycle)
{
maybe_select_secondary(weapon_index);
if ((Players[Player_num].secondary_ammo[Secondary_weapon] == 0) &&
(secondary_order[weapon_index] > 0))
select_weapon(weapon_index,1, 0, 1);
}
//if you pick up a missile with a higher order than the current,
//then select it
maybe_select_secondary(weapon_index);
//if you pick up a missile and you're out of ammo, and it may be
//autoselected, then select it
if ((Players[Player_num].secondary_ammo[Secondary_weapon] == 0) &&
(secondary_order[weapon_index] > 0))
select_weapon(weapon_index,1, 0, 1);
}
//note: flash for all but concussion was 7,14,21
if (count>1) {
PALETTE_FLASH_ADD(15,15,15);
hud_message(MSGC_PICKUP_OK, "%d %s%s",num_picked_up,SECONDARY_WEAPON_NAMES(weapon_index), TXT_SX);
@ -703,9 +397,7 @@ int pick_up_secondary(int weapon_index,int count)
hud_message(MSGC_PICKUP_OK, "%s!",SECONDARY_WEAPON_NAMES(weapon_index));
}
//added on 2/8/99 by Victor Rachels to add allweapon hud info
gauge_update_hud_mode=1;
//end this section additon - VR
gauge_update_hud_mode=1;
return 1;
}
@ -723,27 +415,20 @@ int pick_up_primary(int weapon_index)
Players[Player_num].primary_weapon_flags |= flag;
//added on 9/14/98 by Victor Rachels for weapon cycle toggle
if (Allow_primary_cycle)
{
//end this section addition - Victor Rachels
if (!(old_flags & flag))
maybe_select_primary(weapon_index);
}
if (Allow_primary_cycle)
{
if (!(old_flags & flag))
maybe_select_primary(weapon_index);
}
PALETTE_FLASH_ADD(7,14,21);
hud_message(MSGC_PICKUP_OK, "%s!",PRIMARY_WEAPON_NAMES(weapon_index));
//added on 2/8/99 by Victor Rachels to add allweapon hud info
gauge_update_hud_mode=1;
//end this section additon - VR
gauge_update_hud_mode=1;
return 1;
}
//called when ammo (for the vulcan cannon) is picked up
// Return true if ammo picked up, else return false.
//Return true if ammo picked up, else return false.
int pick_up_ammo(int class_flag,int weapon_index,int ammo_count)
{
int old_ammo=class_flag; //kill warning
@ -755,19 +440,15 @@ int pick_up_ammo(int class_flag,int weapon_index,int ammo_count)
old_ammo = Players[Player_num].primary_ammo[weapon_index];
Players[Player_num].primary_ammo[weapon_index] += ammo_count;
Players[Player_num].primary_ammo[weapon_index] += ammo_count;
if (Players[Player_num].primary_ammo[weapon_index] > Primary_ammo_max[weapon_index])
Players[Player_num].primary_ammo[weapon_index] = Primary_ammo_max[weapon_index];
if (Players[Player_num].primary_weapon_flags&(1<<weapon_index) && old_ammo==0)
//added on 11/01/98 by Victor Rachels - fix primary autoselect
if(Allow_primary_cycle) //since this function is vulcan only anyway
//end this section addition
maybe_select_primary(weapon_index);
if (Players[Player_num].primary_weapon_flags&(1<<weapon_index) && old_ammo==0)
if(Allow_primary_cycle) //since this function is vulcan only anyway
maybe_select_primary(weapon_index);
//added on 2/8/99 by Victor Rachels to add allweapon hud info
gauge_update_hud_mode=1;
//end this section additon - VR
gauge_update_hud_mode=1;
return 1;
}