2007-08-22 07:52:33 +00:00
|
|
|
#include <game/math.h>
|
2007-05-22 15:03:32 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2007-07-14 13:09:42 +00:00
|
|
|
#include <string.h>
|
2007-08-22 07:52:33 +00:00
|
|
|
|
|
|
|
extern "C" {
|
2007-10-07 15:32:54 +00:00
|
|
|
#include <engine/external/glfw/include/GL/glfw.h> // DEBUG TESTING
|
2007-08-22 07:52:33 +00:00
|
|
|
#include <engine/client/ui.h>
|
|
|
|
#include <engine/config.h>
|
|
|
|
};
|
|
|
|
|
2007-05-24 20:54:08 +00:00
|
|
|
#include "../game.h"
|
2007-08-22 21:13:33 +00:00
|
|
|
#include "../version.h"
|
2007-05-22 15:03:32 +00:00
|
|
|
#include "mapres_image.h"
|
|
|
|
#include "mapres_tilemap.h"
|
2007-07-13 13:40:04 +00:00
|
|
|
#include "data.h"
|
2007-07-22 11:53:15 +00:00
|
|
|
#include "menu.h"
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-10-08 20:34:11 +00:00
|
|
|
// sound channels
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CHN_GUI=0,
|
|
|
|
CHN_MUSIC,
|
|
|
|
CHN_WORLD,
|
|
|
|
};
|
|
|
|
|
2007-07-16 18:40:14 +00:00
|
|
|
data_container *data = 0x0;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-08-10 12:43:27 +00:00
|
|
|
int gametype = GAMETYPE_DM;
|
2007-11-04 00:19:41 +00:00
|
|
|
//static int skinseed = 0;
|
2007-07-22 11:53:15 +00:00
|
|
|
|
2007-08-04 21:26:20 +00:00
|
|
|
static int music_menu = -1;
|
|
|
|
static int music_menu_id = -1;
|
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CHATMODE_NONE=0,
|
|
|
|
CHATMODE_ALL,
|
|
|
|
CHATMODE_TEAM,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int chat_mode = CHATMODE_NONE;
|
2007-07-22 11:53:15 +00:00
|
|
|
static bool menu_active = false;
|
2007-08-14 22:48:49 +00:00
|
|
|
static bool emoticon_selector_active = false;
|
2007-07-22 09:16:38 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
static vec2 mouse_pos;
|
2007-10-28 11:30:25 +00:00
|
|
|
static vec2 local_character_pos;
|
2007-10-28 19:28:09 +00:00
|
|
|
static vec2 local_target_pos;
|
2007-10-28 11:30:25 +00:00
|
|
|
static const obj_player_character *local_character = 0;
|
2007-10-28 16:48:52 +00:00
|
|
|
static const obj_player_character *local_prev_character = 0;
|
2007-10-28 11:30:25 +00:00
|
|
|
static const obj_player_info *local_info = 0;
|
|
|
|
static const obj_game *gameobj = 0;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
// do this better and nicer
|
|
|
|
struct skin
|
|
|
|
{
|
|
|
|
int org_texture;
|
|
|
|
int color_texture;
|
|
|
|
char name[31];
|
|
|
|
const char term[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_SKINS=256,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tee_render_info
|
|
|
|
{
|
|
|
|
int texture;
|
|
|
|
vec4 color;
|
|
|
|
};
|
|
|
|
|
|
|
|
static skin skins[MAX_SKINS] = {{-1, -1, {0}, {0}}};
|
|
|
|
static int num_skins = 0;
|
|
|
|
|
|
|
|
static struct client_data
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
|
|
|
char name[64];
|
2007-11-04 00:19:41 +00:00
|
|
|
char skin_name[64];
|
|
|
|
int skin_id;
|
|
|
|
int skin_color;
|
2007-07-22 11:53:15 +00:00
|
|
|
int team;
|
2007-08-14 22:48:49 +00:00
|
|
|
int emoticon;
|
|
|
|
int emoticon_start;
|
2007-09-09 18:21:14 +00:00
|
|
|
player_core predicted;
|
2007-11-04 00:19:41 +00:00
|
|
|
|
|
|
|
tee_render_info skin_info;
|
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
} client_datas[MAX_CLIENTS];
|
|
|
|
|
2007-10-14 13:54:02 +00:00
|
|
|
class client_effects
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
float zoom;
|
|
|
|
float currentzoom;
|
|
|
|
float stage;
|
|
|
|
int lastzoomin;
|
|
|
|
int lastincrease;
|
|
|
|
|
|
|
|
client_effects()
|
|
|
|
{
|
|
|
|
currentzoom = zoom = 3.0f;
|
|
|
|
stage = 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
float getorgzoom() { return zoom; }
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
float getzoom(int tick, float intratick, const obj_player_character *player)
|
2007-10-14 13:54:02 +00:00
|
|
|
{
|
|
|
|
float currentstage = ((float)player->weaponstage) * 0.1f;
|
|
|
|
if (currentstage < stage)
|
|
|
|
{
|
|
|
|
if ((tick - lastincrease) > (client_tickspeed() / 2))
|
|
|
|
stage = currentstage;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastincrease = tick;
|
|
|
|
stage = currentstage;
|
|
|
|
}
|
|
|
|
|
|
|
|
float targetzoom = 3.0f + stage;
|
|
|
|
currentzoom = LERP(currentzoom, targetzoom, 0.1);
|
|
|
|
return currentzoom;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
client_effects cl_effects;
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
inline float frandom() { return rand()/(float)(RAND_MAX); }
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-10-08 20:34:11 +00:00
|
|
|
void snd_play_random(int chn, int setid, float vol, vec2 pos)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
soundset *set = &data->sounds[setid];
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
if(!set->num_sounds)
|
|
|
|
return;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
if(set->num_sounds == 1)
|
|
|
|
{
|
2007-10-08 20:34:11 +00:00
|
|
|
snd_play_at(chn, set->sounds[0].id, 0, pos.x, pos.y);
|
2007-07-13 13:40:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// play a random one
|
2007-05-22 15:03:32 +00:00
|
|
|
int id;
|
|
|
|
do {
|
2007-07-13 13:40:04 +00:00
|
|
|
id = rand() % set->num_sounds;
|
|
|
|
} while(id == set->last);
|
2007-10-08 20:34:11 +00:00
|
|
|
snd_play_at(chn, set->sounds[id].id, 0, pos.x, pos.y);
|
2007-07-13 13:40:04 +00:00
|
|
|
set->last = id;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// sound volume tweak
|
2007-08-14 18:37:16 +00:00
|
|
|
static const float stereo_separation = 0.001f;
|
|
|
|
static const float stereo_separation_deadzone = 200.0f;
|
|
|
|
static const float volume_distance_falloff = 200.0f;
|
|
|
|
static const float volume_distance_deadzone = 320.0f;
|
2007-05-22 15:03:32 +00:00
|
|
|
static const float volume_gun = 0.5f;
|
|
|
|
static const float volume_tee = 0.5f;
|
|
|
|
static const float volume_hit = 0.5f;
|
|
|
|
static const float volume_music = 0.8f;
|
|
|
|
|
|
|
|
void sound_vol_pan(const vec2& p, float *vol, float *pan)
|
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
vec2 player_to_ev = p - local_character_pos;
|
2007-05-22 15:03:32 +00:00
|
|
|
*pan = 0.0f;
|
|
|
|
*vol = 1.0f;
|
|
|
|
|
2007-05-27 10:54:33 +00:00
|
|
|
if(fabs(player_to_ev.x) > stereo_separation_deadzone)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
*pan = stereo_separation * (player_to_ev.x - sign(player_to_ev.x)*stereo_separation_deadzone);
|
|
|
|
if(*pan < -1.0f) *pan = -1.0f;
|
|
|
|
if(*pan > 1.0f) *pan = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
float len = length(player_to_ev);
|
|
|
|
if(len > volume_distance_deadzone)
|
|
|
|
{
|
|
|
|
*vol = volume_distance_falloff / (len - volume_distance_deadzone);
|
|
|
|
|
|
|
|
if(*vol < 0.0f) *vol = 0.0f;
|
|
|
|
if(*vol > 1.0f) *vol = 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
enum
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
SPRITE_FLAG_FLIP_Y=1,
|
|
|
|
};
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static float sprite_w_scale;
|
|
|
|
static float sprite_h_scale;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static void select_sprite(sprite *spr, int flags=0, int sx=0, int sy=0)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
int x = spr->x+sx;
|
|
|
|
int y = spr->y+sy;
|
|
|
|
int w = spr->w;
|
|
|
|
int h = spr->h;
|
|
|
|
int cx = spr->set->gridx;
|
|
|
|
int cy = spr->set->gridy;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
float f = sqrtf(h*h + w*w);
|
|
|
|
sprite_w_scale = w/f;
|
|
|
|
sprite_h_scale = h/f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
if(flags&SPRITE_FLAG_FLIP_Y)
|
|
|
|
gfx_quads_setsubset(x/(float)cx,(y+h)/(float)cy,(x+w)/(float)cx,y/(float)cy);
|
|
|
|
else
|
|
|
|
gfx_quads_setsubset(x/(float)cx,y/(float)cy,(x+w)/(float)cx,(y+h)/(float)cy);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-30 19:46:31 +00:00
|
|
|
void select_sprite(int id, int flags=0, int sx=0, int sy=0)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
if(id < 0 || id > data->num_sprites)
|
|
|
|
return;
|
|
|
|
select_sprite(&data->sprites[id], flags, sx, sy);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 18:23:26 +00:00
|
|
|
void draw_sprite(float x, float y, float size)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
gfx_quads_draw(x, y, size*sprite_w_scale, size*sprite_h_scale);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
class damage_indicators
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int64 lastupdate;
|
|
|
|
struct item
|
|
|
|
{
|
|
|
|
vec2 pos;
|
2007-07-14 13:09:42 +00:00
|
|
|
vec2 dir;
|
2007-05-22 15:03:32 +00:00
|
|
|
float life;
|
|
|
|
float startangle;
|
|
|
|
};
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
enum
|
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
MAX_ITEMS=64,
|
2007-05-22 15:03:32 +00:00
|
|
|
};
|
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
damage_indicators()
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
lastupdate = 0;
|
2007-07-14 13:09:42 +00:00
|
|
|
num_items = 0;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
item items[MAX_ITEMS];
|
|
|
|
int num_items;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
item *create_i()
|
|
|
|
{
|
|
|
|
if (num_items < MAX_ITEMS)
|
|
|
|
{
|
|
|
|
item *p = &items[num_items];
|
|
|
|
num_items++;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
void destroy_i(item *i)
|
|
|
|
{
|
|
|
|
num_items--;
|
|
|
|
*i = items[num_items];
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
void create(vec2 pos, vec2 dir)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
item *i = create_i();
|
|
|
|
if (i)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
i->pos = pos;
|
|
|
|
i->life = 0.75f;
|
2007-07-21 18:07:27 +00:00
|
|
|
i->dir = dir*-1;
|
2007-07-14 13:09:42 +00:00
|
|
|
i->startangle = (( (float)rand()/(float)RAND_MAX) - 1.0f) * 2.0f * pi;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
void render()
|
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
|
|
|
for(int i = 0; i < num_items;)
|
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
vec2 pos = mix(items[i].pos+items[i].dir*75.0f, items[i].pos, clamp((items[i].life-0.60f)/0.15f, 0.0f, 1.0f));
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
items[i].life -= client_frametime();
|
2007-05-22 15:03:32 +00:00
|
|
|
if(items[i].life < 0.0f)
|
|
|
|
destroy_i(&items[i]);
|
|
|
|
else
|
|
|
|
{
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(1.0f,1.0f,1.0f, items[i].life/0.1f);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_setrotation(items[i].startangle + items[i].life * 2.0f);
|
2007-07-14 13:09:42 +00:00
|
|
|
select_sprite(SPRITE_STAR1);
|
|
|
|
draw_sprite(pos.x, pos.y, 48.0f);
|
2007-05-22 15:03:32 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
};
|
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
static damage_indicators damageind;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
class particle_system
|
|
|
|
{
|
|
|
|
public:
|
2007-07-13 13:40:04 +00:00
|
|
|
struct particle
|
|
|
|
{
|
|
|
|
vec2 pos;
|
|
|
|
vec2 vel;
|
|
|
|
float life;
|
|
|
|
float max_life;
|
|
|
|
float size;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
float rot;
|
|
|
|
float rotspeed;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
float gravity;
|
|
|
|
float friction;
|
|
|
|
int iparticle;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
vec4 color;
|
|
|
|
};
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_PARTICLES=1024,
|
|
|
|
};
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
particle particles[MAX_PARTICLES];
|
|
|
|
int num_particles;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
particle_system()
|
|
|
|
{
|
|
|
|
num_particles = 0;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
void new_particle(vec2 pos, vec2 vel, float life, float size, float gravity, float friction)
|
|
|
|
{
|
|
|
|
if (num_particles >= MAX_PARTICLES)
|
|
|
|
return;
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
particles[num_particles].iparticle = rand() % data->num_particles;
|
2007-05-22 15:03:32 +00:00
|
|
|
particles[num_particles].pos = pos;
|
|
|
|
particles[num_particles].vel = vel;
|
2007-07-13 13:40:04 +00:00
|
|
|
particles[num_particles].life = life - (data->particles[particles[num_particles].iparticle].lifemod/100.0f) * life;
|
2007-05-22 15:03:32 +00:00
|
|
|
particles[num_particles].size = size;
|
|
|
|
particles[num_particles].max_life = life;
|
|
|
|
particles[num_particles].gravity = gravity;
|
|
|
|
particles[num_particles].friction = friction;
|
|
|
|
particles[num_particles].rot = frandom()*pi*2;
|
|
|
|
particles[num_particles].rotspeed = frandom() * 10.0f;
|
|
|
|
num_particles++;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
void update(float time_passed)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < num_particles; i++)
|
|
|
|
{
|
|
|
|
particles[i].vel.y += particles[i].gravity*time_passed;
|
|
|
|
particles[i].vel *= particles[i].friction;
|
|
|
|
vec2 vel = particles[i].vel*time_passed;
|
2007-09-09 18:21:14 +00:00
|
|
|
move_point(&particles[i].pos, &vel, 0.1f+0.9f*frandom(), NULL);
|
2007-05-22 15:03:32 +00:00
|
|
|
particles[i].vel = vel* (1.0f/time_passed);
|
|
|
|
particles[i].life += time_passed;
|
|
|
|
particles[i].rot += time_passed * particles[i].rotspeed;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// check particle death
|
|
|
|
if(particles[i].life > particles[i].max_life)
|
|
|
|
{
|
|
|
|
num_particles--;
|
|
|
|
particles[i] = particles[num_particles];
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
void render()
|
|
|
|
{
|
|
|
|
gfx_blend_additive();
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
for(int i = 0; i < num_particles; i++)
|
|
|
|
{
|
|
|
|
int type = particles[i].iparticle;
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(data->particles[type].spr);
|
2007-05-22 15:03:32 +00:00
|
|
|
float a = 1 - particles[i].life / particles[i].max_life;
|
|
|
|
vec2 p = particles[i].pos;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_setrotation(particles[i].rot);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(
|
2007-07-13 13:40:04 +00:00
|
|
|
data->particles[type].color_r,
|
|
|
|
data->particles[type].color_g,
|
|
|
|
data->particles[type].color_b,
|
|
|
|
pow(a, 0.75f));
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_draw(p.x, p.y,particles[i].size,particles[i].size);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
gfx_quads_end();
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_blend_normal();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static particle_system temp_system;
|
2007-07-21 21:17:38 +00:00
|
|
|
|
|
|
|
class projectile_particles
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
LISTSIZE = 1000,
|
|
|
|
};
|
2007-10-28 11:30:25 +00:00
|
|
|
// meh, just use size %
|
2007-07-21 21:17:38 +00:00
|
|
|
int lastadd[LISTSIZE];
|
|
|
|
projectile_particles()
|
2007-08-04 21:54:24 +00:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-04 21:54:24 +00:00
|
|
|
void reset()
|
2007-07-21 21:17:38 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < LISTSIZE; i++)
|
|
|
|
lastadd[i] = -1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addparticle(int projectiletype, int projectileid, vec2 pos, vec2 vel)
|
|
|
|
{
|
2007-07-21 21:47:21 +00:00
|
|
|
int particlespersecond = data->projectileinfo[projectiletype].particlespersecond;
|
2007-07-21 21:17:38 +00:00
|
|
|
int lastaddtick = lastadd[projectileid % LISTSIZE];
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-06 17:01:06 +00:00
|
|
|
if(!particlespersecond)
|
|
|
|
return;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 21:17:38 +00:00
|
|
|
if ((client_tick() - lastaddtick) > (client_tickspeed() / particlespersecond))
|
|
|
|
{
|
|
|
|
lastadd[projectileid % LISTSIZE] = client_tick();
|
2007-07-21 21:47:21 +00:00
|
|
|
float life = data->projectileinfo[projectiletype].particlelife;
|
|
|
|
float size = data->projectileinfo[projectiletype].particlesize;
|
2007-07-21 21:17:38 +00:00
|
|
|
vec2 v = vel * 0.2f + normalize(vec2(frandom()-0.5f, -frandom()))*(32.0f+frandom()*32.0f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 21:17:38 +00:00
|
|
|
// add the particle (from projectiletype later on, but meh...)
|
|
|
|
temp_system.new_particle(pos, v, life, size, 0, 0.95f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static projectile_particles proj_particles;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
static char chat_input[512];
|
|
|
|
static unsigned chat_input_len;
|
|
|
|
static const int chat_max_lines = 10;
|
|
|
|
|
|
|
|
struct chatline
|
|
|
|
{
|
|
|
|
int tick;
|
2007-07-30 07:05:34 +00:00
|
|
|
int client_id;
|
2007-10-04 22:00:10 +00:00
|
|
|
int team;
|
2007-07-14 13:09:42 +00:00
|
|
|
char text[512+64];
|
|
|
|
};
|
|
|
|
|
|
|
|
chatline chat_lines[chat_max_lines];
|
|
|
|
static int chat_current_line = 0;
|
|
|
|
|
|
|
|
void chat_reset()
|
|
|
|
{
|
|
|
|
for(int i = 0; i < chat_max_lines; i++)
|
|
|
|
chat_lines[i].tick = -1000000;
|
|
|
|
chat_current_line = 0;
|
|
|
|
}
|
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
void chat_add_line(int client_id, int team, const char *line)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-08-10 11:03:16 +00:00
|
|
|
chat_current_line = (chat_current_line+1)%chat_max_lines;
|
|
|
|
chat_lines[chat_current_line].tick = client_tick();
|
|
|
|
chat_lines[chat_current_line].client_id = client_id;
|
2007-10-04 22:00:10 +00:00
|
|
|
chat_lines[chat_current_line].team = team;
|
2007-08-10 11:03:16 +00:00
|
|
|
|
2007-07-30 07:05:34 +00:00
|
|
|
if(client_id == -1) // server message
|
|
|
|
sprintf(chat_lines[chat_current_line].text, "*** %s", line);
|
|
|
|
else
|
2007-10-04 22:00:10 +00:00
|
|
|
{
|
|
|
|
sprintf(chat_lines[chat_current_line].text, "%s: %s", client_datas[client_id].name, line);
|
|
|
|
}
|
2007-07-29 22:56:25 +00:00
|
|
|
}
|
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
struct killmsg
|
|
|
|
{
|
|
|
|
int weapon;
|
|
|
|
int victim;
|
|
|
|
int killer;
|
|
|
|
int tick;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int killmsg_max = 5;
|
|
|
|
killmsg killmsgs[killmsg_max];
|
|
|
|
static int killmsg_current = 0;
|
|
|
|
|
2007-07-24 23:46:29 +00:00
|
|
|
extern unsigned char internal_data[];
|
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
|
|
|
|
extern void draw_round_rect(float x, float y, float w, float h, float r);
|
|
|
|
extern int render_popup(const char *caption, const char *text, const char *button_text);
|
|
|
|
|
|
|
|
static void render_loading(float percent)
|
|
|
|
{
|
|
|
|
gfx_clear(0.65f,0.78f,0.9f);
|
|
|
|
gfx_mapscreen(0,0,800.0f,600.0f);
|
|
|
|
|
|
|
|
float tw;
|
|
|
|
|
|
|
|
float w = 700;
|
|
|
|
float h = 200;
|
|
|
|
float x = 800/2-w/2;
|
|
|
|
float y = 600/2-h/2;
|
|
|
|
|
|
|
|
gfx_blend_normal();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(0,0,0,0.50f);
|
2007-08-14 18:37:16 +00:00
|
|
|
draw_round_rect(x, y, w, h, 40.0f);
|
|
|
|
gfx_quads_end();
|
|
|
|
|
|
|
|
const char *caption = "Loading";
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
tw = gfx_pretty_text_width(48.0f, caption, -1);
|
2007-08-14 18:37:16 +00:00
|
|
|
ui_do_label(x+w/2-tw/2, y+20, caption, 48.0f);
|
|
|
|
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(1,1,1,1.0f);
|
2007-08-14 18:37:16 +00:00
|
|
|
draw_round_rect(x+40, y+h-75, (w-80)*percent, 25, 5.0f);
|
|
|
|
gfx_quads_end();
|
|
|
|
|
|
|
|
gfx_swap();
|
|
|
|
}
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
static void skinscan(const char *name, int is_dir, void *user)
|
|
|
|
{
|
|
|
|
int l = strlen(name);
|
|
|
|
if(l < 4 || is_dir || num_skins == MAX_SKINS)
|
|
|
|
return;
|
|
|
|
if(strcmp(name+l-4, ".png") != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char buf[512];
|
|
|
|
sprintf(buf, "data/skins/%s", name);
|
|
|
|
IMAGE_INFO info;
|
|
|
|
if(!gfx_load_png(&info, buf))
|
|
|
|
{
|
|
|
|
dbg_msg("game", "failed to load skin from %s", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
skins[num_skins].org_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data);
|
|
|
|
|
|
|
|
// create colorless version
|
|
|
|
unsigned char *d = (unsigned char *)info.data;
|
|
|
|
int step = info.format == IMG_RGBA ? 4 : 3;
|
|
|
|
|
|
|
|
for(int i = 0; i < info.width*info.height; i++)
|
|
|
|
{
|
|
|
|
int v = (d[i*step]+d[i*step+1]+d[i*step+2])/3;
|
|
|
|
d[i*step] = v;
|
|
|
|
d[i*step+1] = v;
|
|
|
|
d[i*step+2] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
skins[num_skins].color_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data);
|
|
|
|
mem_free(info.data);
|
|
|
|
|
|
|
|
// set skin data
|
|
|
|
strncpy(skins[num_skins].name, name, min((int)sizeof(skins[num_skins].name),l-4));
|
|
|
|
dbg_msg("game", "load skin %s", skins[num_skins].name);
|
|
|
|
num_skins++;
|
|
|
|
}
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_init()
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-11-08 09:11:32 +00:00
|
|
|
// init menu
|
|
|
|
modmenu_init();
|
|
|
|
|
2007-10-08 20:34:11 +00:00
|
|
|
// setup sound channels
|
|
|
|
snd_set_channel(CHN_GUI, 1.0f, 0.0f);
|
|
|
|
snd_set_channel(CHN_MUSIC, 1.0f, 0.0f);
|
|
|
|
snd_set_channel(CHN_WORLD, 1.0f, 1.0f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// load the data container
|
2007-07-24 23:46:29 +00:00
|
|
|
data = load_data_from_memory(internal_data);
|
2007-07-21 18:07:27 +00:00
|
|
|
|
2007-08-04 21:26:20 +00:00
|
|
|
// TODO: should be removed
|
2007-10-04 22:00:10 +00:00
|
|
|
music_menu = snd_load_wv("data/audio/music_menu.wv");
|
2007-10-02 16:19:25 +00:00
|
|
|
snd_set_listener_pos(0.0f, 0.0f);
|
2007-08-14 18:37:16 +00:00
|
|
|
|
|
|
|
float total = data->num_sounds+data->num_images;
|
|
|
|
float current = 0;
|
2007-08-04 21:26:20 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// load sounds
|
2007-07-13 13:40:04 +00:00
|
|
|
for(int s = 0; s < data->num_sounds; s++)
|
2007-08-14 18:37:16 +00:00
|
|
|
{
|
|
|
|
render_loading(current/total);
|
2007-07-13 13:40:04 +00:00
|
|
|
for(int i = 0; i < data->sounds[s].num_sounds; i++)
|
2007-08-09 14:55:11 +00:00
|
|
|
{
|
|
|
|
int id;
|
2007-10-06 17:01:06 +00:00
|
|
|
//if (strcmp(data->sounds[s].sounds[i].filename + strlen(data->sounds[s].sounds[i].filename) - 3, ".wv") == 0)
|
|
|
|
id = snd_load_wv(data->sounds[s].sounds[i].filename);
|
|
|
|
//else
|
|
|
|
// id = snd_load_wav(data->sounds[s].sounds[i].filename);
|
2007-08-09 14:55:11 +00:00
|
|
|
|
|
|
|
data->sounds[s].sounds[i].id = id;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
current++;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// load textures
|
|
|
|
for(int i = 0; i < data->num_images; i++)
|
2007-08-14 18:37:16 +00:00
|
|
|
{
|
|
|
|
render_loading(current/total);
|
2007-07-13 13:40:04 +00:00
|
|
|
data->images[i].id = gfx_load_texture(data->images[i].filename);
|
2007-08-14 18:37:16 +00:00
|
|
|
current++;
|
|
|
|
}
|
2007-11-04 00:19:41 +00:00
|
|
|
|
|
|
|
// load skins
|
|
|
|
fs_listdir("data/skins", skinscan, 0);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_entergame()
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_shutdown()
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-11-08 09:11:32 +00:00
|
|
|
// shutdown the menu
|
|
|
|
modmenu_shutdown();
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
static void process_events(int s)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-08-14 18:37:16 +00:00
|
|
|
int num = snap_num_items(s);
|
2007-10-03 21:02:59 +00:00
|
|
|
for(int index = 0; index < num; index++)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-08-22 07:52:33 +00:00
|
|
|
SNAP_ITEM item;
|
2007-10-03 21:02:59 +00:00
|
|
|
const void *data = snap_get_item(s, index, &item);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
if(item.type == EVENT_DAMAGEINDICATION)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
ev_damageind *ev = (ev_damageind *)data;
|
|
|
|
damageind.create(vec2(ev->x, ev->y), get_direction(ev->angle));
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
else if(item.type == EVENT_EXPLOSION)
|
|
|
|
{
|
|
|
|
ev_explosion *ev = (ev_explosion *)data;
|
|
|
|
vec2 p(ev->x, ev->y);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// center explosion
|
|
|
|
temp_system.new_particle(p, vec2(0,0), 0.3f, 96.0f, 0, 0.95f);
|
|
|
|
temp_system.new_particle(p, vec2(0,0), 0.3f, 64.0f, 0, 0.95f);
|
|
|
|
temp_system.new_particle(p, vec2(0,0), 0.3f, 32.0f, 0, 0.95f);
|
|
|
|
temp_system.new_particle(p, vec2(0,0), 0.3f, 16.0f, 0, 0.95f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
for(int i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.2f+0.25f*frandom(), 16.0f, 0, 0.985f);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
for(int i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(256.0f+frandom()*512.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.2f+0.25f*frandom(), 16.0f, 128.0f, 0.985f);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < 64; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(frandom()*256.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.2f+0.25f*frandom(), 24.0f, 128.0f, 0.985f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(item.type == EVENT_SMOKE)
|
|
|
|
{
|
|
|
|
ev_explosion *ev = (ev_explosion *)data;
|
|
|
|
vec2 p(ev->x, ev->y);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// center explosion
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, -frandom()))*(32.0f+frandom()*32.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 64.0f, 0, 0.95f);
|
|
|
|
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 32.0f, 0, 0.95f);
|
|
|
|
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 16.0f, 0, 0.95f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(64.0f+frandom()*64.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 0, 0.985f);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(128.0f+frandom()*256.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
|
|
|
}
|
|
|
|
}
|
2007-07-21 19:03:50 +00:00
|
|
|
else if(item.type == EVENT_SPAWN)
|
|
|
|
{
|
|
|
|
ev_explosion *ev = (ev_explosion *)data;
|
|
|
|
vec2 p(ev->x, ev->y);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 19:03:50 +00:00
|
|
|
// center explosion
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, -frandom()))*(32.0f+frandom()*32.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 64.0f, 0, 0.95f);
|
|
|
|
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 32.0f, 0, 0.95f);
|
|
|
|
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 16.0f, 0, 0.95f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 19:03:50 +00:00
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(64.0f+frandom()*64.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 0, 0.985f);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 19:03:50 +00:00
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(128.0f+frandom()*256.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
|
|
|
}
|
|
|
|
}
|
2007-07-21 21:17:38 +00:00
|
|
|
else if(item.type == EVENT_DEATH)
|
|
|
|
{
|
|
|
|
ev_explosion *ev = (ev_explosion *)data;
|
|
|
|
vec2 p(ev->x, ev->y);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 21:17:38 +00:00
|
|
|
// center explosion
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, -frandom()))*(32.0f+frandom()*32.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 64.0f, 0, 0.95f);
|
|
|
|
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 32.0f, 0, 0.95f);
|
|
|
|
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
|
|
|
temp_system.new_particle(p, v, 1.2f, 16.0f, 0, 0.95f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 21:17:38 +00:00
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(64.0f+frandom()*64.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 0, 0.985f);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 21:17:38 +00:00
|
|
|
for(int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(128.0f+frandom()*256.0f);
|
|
|
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
|
|
|
}
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
else if(item.type == EVENT_SOUND)
|
|
|
|
{
|
|
|
|
ev_sound *ev = (ev_sound *)data;
|
|
|
|
vec2 p(ev->x, ev->y);
|
2007-07-13 13:40:04 +00:00
|
|
|
int soundid = ev->sound; //(ev->sound & SOUND_MASK);
|
2007-05-27 10:54:33 +00:00
|
|
|
//bool bstartloop = (ev->sound & SOUND_LOOPFLAG_STARTLOOP) != 0;
|
|
|
|
//bool bstoploop = (ev->sound & SOUND_LOOPFLAG_STOPLOOP) != 0;
|
2007-10-08 20:34:11 +00:00
|
|
|
//float vol, pan;
|
|
|
|
//sound_vol_pan(p, &vol, &pan);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
if(soundid >= 0 && soundid < NUM_SOUNDS)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
// TODO: we need to control the volume of the diffrent sounds
|
|
|
|
// depening on the category
|
2007-10-08 20:34:11 +00:00
|
|
|
snd_play_random(CHN_WORLD, soundid, 1.0f, p);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-14 18:37:16 +00:00
|
|
|
}
|
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
static player_core predicted_prev_player;
|
|
|
|
static player_core predicted_player;
|
|
|
|
|
|
|
|
extern "C" void modc_predict()
|
|
|
|
{
|
|
|
|
// repredict player
|
2007-10-28 16:48:52 +00:00
|
|
|
world_core world;
|
|
|
|
int local_cid = -1;
|
|
|
|
|
|
|
|
// search for players
|
|
|
|
for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
2007-10-28 16:48:52 +00:00
|
|
|
SNAP_ITEM item;
|
|
|
|
const void *data = snap_get_item(SNAP_CURRENT, i, &item);
|
|
|
|
int client_id = item.id;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
if(item.type == OBJTYPE_PLAYER_CHARACTER)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
2007-10-28 16:48:52 +00:00
|
|
|
const obj_player_character *character = (const obj_player_character *)data;
|
|
|
|
client_datas[client_id].predicted.world = &world;
|
|
|
|
world.players[client_id] = &client_datas[client_id].predicted;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
client_datas[client_id].predicted.read(character);
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
2007-10-28 16:48:52 +00:00
|
|
|
else if(item.type == OBJTYPE_PLAYER_INFO)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
2007-10-28 16:48:52 +00:00
|
|
|
const obj_player_info *info = (const obj_player_info *)data;
|
|
|
|
if(info->local)
|
|
|
|
local_cid = client_id;
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
// predict
|
|
|
|
for(int tick = client_tick()+1; tick <= client_predtick(); tick++)
|
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
// fetch the local
|
|
|
|
if(tick == client_predtick() && world.players[local_cid])
|
|
|
|
predicted_prev_player = *world.players[local_cid];
|
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
// first calculate where everyone should move
|
|
|
|
for(int c = 0; c < MAX_CLIENTS; c++)
|
|
|
|
{
|
|
|
|
if(!world.players[c])
|
|
|
|
continue;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
mem_zero(&world.players[c]->input, sizeof(world.players[c]->input));
|
|
|
|
if(local_cid == c)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
2007-10-28 16:48:52 +00:00
|
|
|
// apply player input
|
|
|
|
int *input = client_get_input(tick);
|
|
|
|
if(input)
|
|
|
|
world.players[c]->input = *((player_input*)input);
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
2007-10-28 16:48:52 +00:00
|
|
|
|
|
|
|
world.players[c]->tick();
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
// move all players and quantize their data
|
|
|
|
for(int c = 0; c < MAX_CLIENTS; c++)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
2007-10-28 16:48:52 +00:00
|
|
|
if(!world.players[c])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
world.players[c]->move();
|
|
|
|
world.players[c]->quantize();
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
2007-11-04 00:19:41 +00:00
|
|
|
|
|
|
|
if(tick == client_predtick() && world.players[local_cid])
|
|
|
|
predicted_player = *world.players[local_cid];
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_newsnapshot()
|
2007-08-14 18:37:16 +00:00
|
|
|
{
|
2007-10-28 16:48:52 +00:00
|
|
|
process_events(SNAP_CURRENT);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
if(config.stress)
|
|
|
|
{
|
|
|
|
if((client_tick()%250) == 0)
|
|
|
|
{
|
|
|
|
msg_pack_start(MSG_SAY, MSGFLAG_VITAL);
|
2007-09-25 21:53:14 +00:00
|
|
|
msg_pack_int(-1);
|
2007-08-14 18:37:16 +00:00
|
|
|
msg_pack_string("galenskap!!!!", 512);
|
|
|
|
msg_pack_end();
|
|
|
|
client_send_msg();
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
// clear out the invalid pointers
|
|
|
|
local_character = 0;
|
2007-10-28 16:48:52 +00:00
|
|
|
local_prev_character = 0;
|
2007-10-28 11:30:25 +00:00
|
|
|
local_info = 0;
|
|
|
|
gameobj = 0;
|
|
|
|
|
|
|
|
// setup world view
|
|
|
|
{
|
|
|
|
// 1. fetch local player
|
|
|
|
// 2. set him to the center
|
|
|
|
int num = snap_num_items(SNAP_CURRENT);
|
|
|
|
for(int i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
SNAP_ITEM item;
|
|
|
|
const void *data = snap_get_item(SNAP_CURRENT, i, &item);
|
|
|
|
|
|
|
|
if(item.type == OBJTYPE_PLAYER_INFO)
|
|
|
|
{
|
|
|
|
const obj_player_info *info = (const obj_player_info *)data;
|
|
|
|
if(info->local)
|
|
|
|
{
|
|
|
|
local_info = info;
|
|
|
|
const void *data = snap_find_item(SNAP_CURRENT, OBJTYPE_PLAYER_CHARACTER, item.id);
|
|
|
|
if(data)
|
|
|
|
{
|
|
|
|
local_character = (const obj_player_character *)data;
|
|
|
|
local_character_pos = vec2(local_character->x, local_character->y);
|
|
|
|
|
|
|
|
const void *p = snap_find_item(SNAP_PREV, OBJTYPE_PLAYER_CHARACTER, item.id);
|
|
|
|
if(p)
|
2007-10-28 16:48:52 +00:00
|
|
|
local_prev_character = (obj_player_character *)p;
|
2007-10-28 11:30:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(item.type == OBJTYPE_GAME)
|
|
|
|
gameobj = (obj_game *)data;
|
|
|
|
}
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
void send_info(bool start)
|
2007-08-14 22:48:49 +00:00
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
if(start)
|
|
|
|
msg_pack_start(MSG_STARTINFO, MSGFLAG_VITAL);
|
|
|
|
else
|
|
|
|
msg_pack_start(MSG_CHANGEINFO, MSGFLAG_VITAL);
|
|
|
|
msg_pack_string(config.player_name, 64);
|
|
|
|
msg_pack_string(config.player_skin, 64);
|
|
|
|
msg_pack_int(config.player_color);
|
2007-08-14 22:48:49 +00:00
|
|
|
msg_pack_end();
|
|
|
|
client_send_msg();
|
|
|
|
}
|
|
|
|
|
|
|
|
void send_emoticon(int emoticon)
|
|
|
|
{
|
|
|
|
msg_pack_start(MSG_EMOTICON, MSGFLAG_VITAL);
|
|
|
|
msg_pack_int(emoticon);
|
|
|
|
msg_pack_end();
|
|
|
|
client_send_msg();
|
|
|
|
}
|
|
|
|
|
2007-07-31 06:23:24 +00:00
|
|
|
static void render_projectile(const obj_projectile *prev, const obj_projectile *current, int itemid)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(data->weapons[current->type%data->num_weapons].sprite_proj);
|
2007-07-21 18:07:27 +00:00
|
|
|
vec2 vel = mix(vec2(prev->vx, prev->vy), vec2(current->vx, current->vy), client_intratick());
|
|
|
|
vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 21:17:38 +00:00
|
|
|
// add particle for this projectile
|
|
|
|
proj_particles.addparticle(current->type, itemid, pos, vel);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
if(length(vel) > 0.00001f)
|
|
|
|
gfx_quads_setrotation(get_angle(vel));
|
|
|
|
else
|
|
|
|
gfx_quads_setrotation(0);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
// TODO: do this, but nice
|
|
|
|
//temp_system.new_particle(pos, vec2(0,0), 0.3f, 14.0f, 0, 0.95f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-14 13:54:02 +00:00
|
|
|
gfx_quads_draw(pos.x, pos.y, 32, 32);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_setrotation(0);
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
|
|
|
|
2007-07-31 06:23:24 +00:00
|
|
|
static void render_powerup(const obj_powerup *prev, const obj_powerup *current)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-07-26 19:54:31 +00:00
|
|
|
vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
|
2007-05-22 15:03:32 +00:00
|
|
|
float angle = 0.0f;
|
2007-07-13 13:40:04 +00:00
|
|
|
float size = 64.0f;
|
2007-07-23 17:51:52 +00:00
|
|
|
if (current->type == POWERUP_WEAPON)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-22 12:01:20 +00:00
|
|
|
angle = 0; //-pi/6;//-0.25f * pi * 2.0f;
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(data->weapons[current->subtype%data->num_weapons].sprite_body);
|
|
|
|
size = data->weapons[current->subtype%data->num_weapons].visual_size;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
else
|
2007-07-13 13:40:04 +00:00
|
|
|
{
|
|
|
|
const int c[] = {
|
|
|
|
SPRITE_POWERUP_HEALTH,
|
|
|
|
SPRITE_POWERUP_ARMOR,
|
|
|
|
SPRITE_POWERUP_WEAPON,
|
|
|
|
SPRITE_POWERUP_NINJA,
|
|
|
|
SPRITE_POWERUP_TIMEFIELD
|
|
|
|
};
|
|
|
|
select_sprite(c[current->type]);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-26 19:54:31 +00:00
|
|
|
if(c[current->type] == SPRITE_POWERUP_NINJA)
|
|
|
|
{
|
|
|
|
proj_particles.addparticle(0, 0,
|
|
|
|
pos+vec2((frandom()-0.5f)*80.0f, (frandom()-0.5f)*20.0f),
|
|
|
|
vec2((frandom()-0.5f)*10.0f, (frandom()-0.5f)*10.0f));
|
|
|
|
size *= 2.0f;
|
|
|
|
pos.x += 10.0f;
|
|
|
|
}
|
2007-07-13 13:40:04 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_setrotation(angle);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
float offset = pos.y/32.0f + pos.x/32.0f;
|
2007-07-13 13:40:04 +00:00
|
|
|
pos.x += cosf(client_localtime()*2.0f+offset)*2.5f;
|
|
|
|
pos.y += sinf(client_localtime()*2.0f+offset)*2.5f;
|
|
|
|
draw_sprite(pos.x, pos.y, size);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
}
|
|
|
|
|
2007-07-31 06:23:24 +00:00
|
|
|
static void render_flag(const obj_flag *prev, const obj_flag *current)
|
2007-07-26 09:21:47 +00:00
|
|
|
{
|
|
|
|
float angle = 0.0f;
|
2007-10-03 21:02:59 +00:00
|
|
|
float size = 36.0f;
|
2007-07-26 09:21:47 +00:00
|
|
|
|
|
|
|
gfx_blend_normal();
|
2007-10-03 21:02:59 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-07-26 09:21:47 +00:00
|
|
|
gfx_quads_begin();
|
2007-10-03 21:02:59 +00:00
|
|
|
|
|
|
|
if(current->team == 0) // red team
|
|
|
|
select_sprite(SPRITE_FLAG_RED);
|
|
|
|
else
|
|
|
|
select_sprite(SPRITE_FLAG_BLUE);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-26 09:21:47 +00:00
|
|
|
gfx_quads_setrotation(angle);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-26 09:21:47 +00:00
|
|
|
vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-25 23:03:15 +00:00
|
|
|
if(current->local_carry)
|
2007-10-28 11:30:25 +00:00
|
|
|
pos = local_character_pos;
|
|
|
|
|
2007-09-25 23:03:15 +00:00
|
|
|
gfx_setcolor(current->team ? 0 : 1,0,current->team ? 1 : 0,1);
|
2007-10-03 21:02:59 +00:00
|
|
|
//draw_sprite(pos.x, pos.y, size);
|
|
|
|
gfx_quads_draw(pos.x, pos.y-size*0.75f, size, size*2);
|
2007-07-26 09:21:47 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
}
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static void anim_seq_eval(sequence *seq, float time, keyframe *frame)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
if(seq->num_frames == 0)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
frame->time = 0;
|
|
|
|
frame->x = 0;
|
|
|
|
frame->y = 0;
|
|
|
|
frame->angle = 0;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-07-13 13:40:04 +00:00
|
|
|
else if(seq->num_frames == 1)
|
|
|
|
{
|
|
|
|
*frame = seq->frames[0];
|
|
|
|
}
|
|
|
|
else
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
//time = max(0.0f, min(1.0f, time / duration)); // TODO: use clamp
|
|
|
|
keyframe *frame1 = 0;
|
|
|
|
keyframe *frame2 = 0;
|
|
|
|
float blend = 0.0f;
|
|
|
|
|
|
|
|
// TODO: make this smarter.. binary search
|
|
|
|
for (int i = 1; i < seq->num_frames; i++)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
if (seq->frames[i-1].time <= time && seq->frames[i].time >= time)
|
|
|
|
{
|
|
|
|
frame1 = &seq->frames[i-1];
|
|
|
|
frame2 = &seq->frames[i];
|
|
|
|
blend = (time - frame1->time) / (frame2->time - frame1->time);
|
|
|
|
break;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
}
|
2007-07-13 13:40:04 +00:00
|
|
|
|
|
|
|
if (frame1 && frame2)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
frame->time = time;
|
|
|
|
frame->x = mix(frame1->x, frame2->x, blend);
|
|
|
|
frame->y = mix(frame1->y, frame2->y, blend);
|
|
|
|
frame->angle = mix(frame1->angle, frame2->angle, blend);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
struct animstate
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
keyframe body;
|
|
|
|
keyframe back_foot;
|
|
|
|
keyframe front_foot;
|
|
|
|
keyframe attach;
|
|
|
|
};
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static void anim_eval(animation *anim, float time, animstate *state)
|
|
|
|
{
|
|
|
|
anim_seq_eval(&anim->body, time, &state->body);
|
|
|
|
anim_seq_eval(&anim->back_foot, time, &state->back_foot);
|
|
|
|
anim_seq_eval(&anim->front_foot, time, &state->front_foot);
|
|
|
|
anim_seq_eval(&anim->attach, time, &state->attach);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static void anim_add_keyframe(keyframe *seq, keyframe *added, float amount)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
seq->x += added->x*amount;
|
|
|
|
seq->y += added->y*amount;
|
|
|
|
seq->angle += added->angle*amount;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static void anim_add(animstate *state, animstate *added, float amount)
|
|
|
|
{
|
|
|
|
anim_add_keyframe(&state->body, &added->body, amount);
|
|
|
|
anim_add_keyframe(&state->back_foot, &added->back_foot, amount);
|
|
|
|
anim_add_keyframe(&state->front_foot, &added->front_foot, amount);
|
|
|
|
anim_add_keyframe(&state->attach, &added->attach, amount);
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
static void anim_eval_add(animstate *state, animation *anim, float time, float amount)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
animstate add;
|
|
|
|
anim_eval(anim, time, &add);
|
|
|
|
anim_add(state, &add, amount);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
static void render_hand(int skin_id, vec2 center_pos, vec2 dir, float angle_offset, vec2 post_rot_offset)
|
2007-08-14 15:03:59 +00:00
|
|
|
{
|
|
|
|
// for drawing hand
|
2007-11-04 00:19:41 +00:00
|
|
|
skin_id = skin_id%num_skins;
|
|
|
|
|
2007-08-14 15:03:59 +00:00
|
|
|
float basesize = 10.0f;
|
|
|
|
//dir = normalize(hook_pos-pos);
|
|
|
|
|
|
|
|
vec2 hand_pos = center_pos + dir;
|
|
|
|
float angle = get_angle(dir);
|
|
|
|
if (dir.x < 0)
|
|
|
|
angle -= angle_offset;
|
|
|
|
else
|
|
|
|
angle += angle_offset;
|
|
|
|
|
|
|
|
vec2 dirx = dir;
|
|
|
|
vec2 diry(-dir.y,dir.x);
|
|
|
|
|
|
|
|
if (dir.x < 0)
|
|
|
|
diry = -diry;
|
|
|
|
|
|
|
|
hand_pos += dirx * post_rot_offset.x;
|
|
|
|
hand_pos += diry * post_rot_offset.y;
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
//gfx_texture_set(data->images[IMAGE_CHAR_DEFAULT].id);
|
|
|
|
gfx_texture_set(skins[skin_id].color_texture);
|
2007-08-14 18:34:02 +00:00
|
|
|
gfx_quads_begin();
|
2007-08-14 15:03:59 +00:00
|
|
|
|
2007-08-14 18:34:02 +00:00
|
|
|
// two passes
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
bool outline = i == 0;
|
2007-08-14 15:03:59 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(outline?SPRITE_TEE_HAND_OUTLINE:SPRITE_TEE_HAND, 0, 0, 0);
|
2007-08-14 18:34:02 +00:00
|
|
|
gfx_quads_setrotation(angle);
|
|
|
|
gfx_quads_draw(hand_pos.x, hand_pos.y, 2*basesize, 2*basesize);
|
2007-08-14 15:03:59 +00:00
|
|
|
}
|
2007-08-14 18:34:02 +00:00
|
|
|
|
|
|
|
gfx_quads_setrotation(0);
|
|
|
|
gfx_quads_end();
|
2007-08-14 15:03:59 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
static void render_tee(animstate *anim, tee_render_info *info, int emote, vec2 dir, vec2 pos)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
vec2 direction = dir;
|
2007-07-14 13:09:42 +00:00
|
|
|
vec2 position = pos;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
//gfx_texture_set(data->images[IMAGE_CHAR_DEFAULT].id);
|
|
|
|
gfx_texture_set(info->texture);
|
2007-07-14 13:09:42 +00:00
|
|
|
gfx_quads_begin();
|
2007-11-04 00:19:41 +00:00
|
|
|
gfx_setcolor(info->color.r, info->color.g, info->color.b, info->color.a);
|
|
|
|
//gfx_quads_draw(pos.x, pos.y-128, 128, 128);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
// first pass we draw the outline
|
|
|
|
// second pass we draw the filling
|
2007-07-14 13:09:42 +00:00
|
|
|
for(int p = 0; p < 2; p++)
|
|
|
|
{
|
|
|
|
int outline = p==0 ? 1 : 0;
|
2007-11-04 00:19:41 +00:00
|
|
|
//int shift = skin;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
for(int f = 0; f < 2; f++)
|
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
float basesize = 16.0f;
|
2007-07-14 13:09:42 +00:00
|
|
|
if(f == 1)
|
|
|
|
{
|
2007-07-14 22:35:00 +00:00
|
|
|
gfx_quads_setrotation(anim->body.angle*pi*2);
|
2007-11-04 00:19:41 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
// draw body
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(outline?SPRITE_TEE_BODY_OUTLINE:SPRITE_TEE_BODY, 0, 0, 0);
|
2007-07-14 13:09:42 +00:00
|
|
|
gfx_quads_draw(position.x+anim->body.x, position.y+anim->body.y, 4*basesize, 4*basesize);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
// draw eyes
|
|
|
|
if(p == 1)
|
|
|
|
{
|
2007-08-09 00:18:11 +00:00
|
|
|
switch (emote)
|
|
|
|
{
|
|
|
|
case EMOTE_PAIN:
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(SPRITE_TEE_EYE_PAIN, 0, 0, 0);
|
2007-08-09 00:18:11 +00:00
|
|
|
break;
|
|
|
|
case EMOTE_HAPPY:
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(SPRITE_TEE_EYE_HAPPY, 0, 0, 0);
|
2007-08-09 00:18:11 +00:00
|
|
|
break;
|
|
|
|
case EMOTE_SURPRISE:
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(SPRITE_TEE_EYE_SURPRISE, 0, 0, 0);
|
2007-08-09 00:18:11 +00:00
|
|
|
break;
|
|
|
|
case EMOTE_ANGRY:
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(SPRITE_TEE_EYE_ANGRY, 0, 0, 0);
|
2007-08-09 00:18:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(SPRITE_TEE_EYE_NORMAL, 0, 0, 0);
|
2007-08-09 00:18:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-08-14 18:37:16 +00:00
|
|
|
int h = emote == EMOTE_BLINK ? (int)(basesize/3) : (int)(basesize);
|
2007-11-04 00:19:41 +00:00
|
|
|
gfx_quads_draw(position.x-4+direction.x*4, position.y-8+direction.y*3, basesize*1.5f, h*1.5f);
|
|
|
|
gfx_quads_draw(position.x+4+direction.x*4, position.y-8+direction.y*3, -basesize*1.5f, h*1.5f);
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw feet
|
2007-11-04 00:19:41 +00:00
|
|
|
select_sprite(outline?SPRITE_TEE_FOOT_OUTLINE:SPRITE_TEE_FOOT, 0, 0, 0);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
keyframe *foot = f ? &anim->front_foot : &anim->back_foot;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
float w = basesize*2.5f*1.5f;
|
|
|
|
float h = basesize*1.425f*1.5f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
gfx_quads_setrotation(foot->angle*pi*2);
|
2007-07-14 13:09:42 +00:00
|
|
|
gfx_quads_draw(position.x+foot->x, position.y+foot->y, w, h);
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
gfx_quads_end();
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 15:29:28 +00:00
|
|
|
void draw_circle(float x, float y, float r, int segments)
|
|
|
|
{
|
|
|
|
float f_segments = (float)segments;
|
|
|
|
for(int i = 0; i < segments; i+=2)
|
|
|
|
{
|
|
|
|
float a1 = i/f_segments * 2*pi;
|
|
|
|
float a2 = (i+1)/f_segments * 2*pi;
|
|
|
|
float a3 = (i+2)/f_segments * 2*pi;
|
|
|
|
float ca1 = cosf(a1);
|
|
|
|
float ca2 = cosf(a2);
|
|
|
|
float ca3 = cosf(a3);
|
|
|
|
float sa1 = sinf(a1);
|
|
|
|
float sa2 = sinf(a2);
|
|
|
|
float sa3 = sinf(a3);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-15 15:29:28 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
x, y,
|
|
|
|
x+ca1*r, y+sa1*r,
|
|
|
|
x+ca3*r, y+sa3*r,
|
|
|
|
x+ca2*r, y+sa2*r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-04 21:36:03 +00:00
|
|
|
void draw_round_rect_ext(float x, float y, float w, float h, float r, int corners)
|
2007-07-26 20:42:57 +00:00
|
|
|
{
|
|
|
|
int num = 8;
|
|
|
|
for(int i = 0; i < num; i+=2)
|
|
|
|
{
|
|
|
|
float a1 = i/(float)num * pi/2;
|
|
|
|
float a2 = (i+1)/(float)num * pi/2;
|
|
|
|
float a3 = (i+2)/(float)num * pi/2;
|
|
|
|
float ca1 = cosf(a1);
|
|
|
|
float ca2 = cosf(a2);
|
|
|
|
float ca3 = cosf(a3);
|
|
|
|
float sa1 = sinf(a1);
|
|
|
|
float sa2 = sinf(a2);
|
|
|
|
float sa3 = sinf(a3);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-11-04 21:36:03 +00:00
|
|
|
if(corners&1) // TL
|
2007-07-26 20:42:57 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
x+r, y+r,
|
|
|
|
x+(1-ca1)*r, y+(1-sa1)*r,
|
|
|
|
x+(1-ca3)*r, y+(1-sa3)*r,
|
|
|
|
x+(1-ca2)*r, y+(1-sa2)*r);
|
|
|
|
|
2007-11-04 21:36:03 +00:00
|
|
|
if(corners&2) // TR
|
2007-07-26 20:42:57 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
x+w-r, y+r,
|
|
|
|
x+w-r+ca1*r, y+(1-sa1)*r,
|
|
|
|
x+w-r+ca3*r, y+(1-sa3)*r,
|
|
|
|
x+w-r+ca2*r, y+(1-sa2)*r);
|
|
|
|
|
2007-11-04 21:36:03 +00:00
|
|
|
if(corners&4) // BL
|
2007-07-26 20:42:57 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
x+r, y+h-r,
|
|
|
|
x+(1-ca1)*r, y+h-r+sa1*r,
|
|
|
|
x+(1-ca3)*r, y+h-r+sa3*r,
|
|
|
|
x+(1-ca2)*r, y+h-r+sa2*r);
|
|
|
|
|
2007-11-04 21:36:03 +00:00
|
|
|
if(corners&8) // BR
|
2007-07-26 20:42:57 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
x+w-r, y+h-r,
|
|
|
|
x+w-r+ca1*r, y+h-r+sa1*r,
|
|
|
|
x+w-r+ca3*r, y+h-r+sa3*r,
|
|
|
|
x+w-r+ca2*r, y+h-r+sa2*r);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-26 20:42:57 +00:00
|
|
|
gfx_quads_drawTL(x+r, y+r, w-r*2, h-r*2); // center
|
|
|
|
gfx_quads_drawTL(x+r, y, w-r*2, r); // top
|
|
|
|
gfx_quads_drawTL(x+r, y+h-r, w-r*2, r); // bottom
|
|
|
|
gfx_quads_drawTL(x, y+r, r, h-r*2); // left
|
|
|
|
gfx_quads_drawTL(x+w-r, y+r, r, h-r*2); // right
|
2007-11-04 21:36:03 +00:00
|
|
|
|
|
|
|
if(!(corners&1)) gfx_quads_drawTL(x, y, r, r); // TL
|
|
|
|
if(!(corners&2)) gfx_quads_drawTL(x+w, y, -r, r); // TR
|
|
|
|
if(!(corners&4)) gfx_quads_drawTL(x, y+h, r, -r); // BL
|
|
|
|
if(!(corners&8)) gfx_quads_drawTL(x+w, y+h, -r, -r); // BR
|
2007-07-26 20:42:57 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 21:36:03 +00:00
|
|
|
void draw_round_rect(float x, float y, float w, float h, float r)
|
|
|
|
{
|
|
|
|
draw_round_rect_ext(x,y,w,h,r,0xf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
static void render_player(
|
|
|
|
const obj_player_character *prev_char,
|
|
|
|
const obj_player_character *player_char,
|
|
|
|
const obj_player_info *prev_info,
|
|
|
|
const obj_player_info *player_info
|
|
|
|
)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
obj_player_character prev;
|
|
|
|
obj_player_character player;
|
|
|
|
prev = *prev_char;
|
|
|
|
player = *player_char;
|
|
|
|
|
|
|
|
obj_player_info info = *player_info;
|
|
|
|
|
2007-09-09 21:47:25 +00:00
|
|
|
float intratick = client_intratick();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
if(player.health < 0) // dont render dead players
|
2007-07-14 13:09:42 +00:00
|
|
|
return;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
if(info.local && config.cl_predict)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
|
|
|
// apply predicted results
|
|
|
|
predicted_player.write(&player);
|
|
|
|
predicted_prev_player.write(&prev);
|
2007-09-09 21:47:25 +00:00
|
|
|
intratick = client_intrapredtick();
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
// TODO: proper skin selection
|
|
|
|
int skin_id = client_datas[info.clientid].skin_id; //charids[info.clientid];
|
|
|
|
//if(gametype != GAMETYPE_DM)
|
|
|
|
//skin_id = info.team*9; // 0 or 9
|
2007-08-14 15:03:59 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
vec2 direction = get_direction(player.angle);
|
|
|
|
float angle = player.angle/256.0f;
|
2007-09-09 21:47:25 +00:00
|
|
|
vec2 position = mix(vec2(prev.x, prev.y), vec2(player.x, player.y), intratick);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
if(prev.health < 0) // Don't flicker from previous position
|
|
|
|
position = vec2(player.x, player.y);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
bool stationary = player.vx < 1 && player.vx > -1;
|
|
|
|
bool inair = col_check_point(player.x, player.y+16) == 0;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// evaluate animation
|
|
|
|
float walk_time = fmod(position.x, 100.0f)/100.0f;
|
|
|
|
animstate state;
|
|
|
|
anim_eval(&data->animations[ANIM_BASE], 0, &state);
|
|
|
|
|
|
|
|
if(inair)
|
|
|
|
anim_eval_add(&state, &data->animations[ANIM_INAIR], 0, 1.0f); // TODO: some sort of time here
|
|
|
|
else if(stationary)
|
|
|
|
anim_eval_add(&state, &data->animations[ANIM_IDLE], 0, 1.0f); // TODO: some sort of time here
|
|
|
|
else
|
|
|
|
anim_eval_add(&state, &data->animations[ANIM_WALK], walk_time, 1.0f);
|
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
if (player.weapon == WEAPON_HAMMER)
|
2007-07-13 13:40:04 +00:00
|
|
|
{
|
2007-09-09 21:47:25 +00:00
|
|
|
float a = clamp((client_tick()-player.attacktick+intratick)/10.0f, 0.0f, 1.0f);
|
2007-07-13 13:40:04 +00:00
|
|
|
anim_eval_add(&state, &data->animations[ANIM_HAMMER_SWING], a, 1.0f);
|
|
|
|
}
|
2007-09-09 18:21:14 +00:00
|
|
|
if (player.weapon == WEAPON_NINJA)
|
2007-07-21 19:03:50 +00:00
|
|
|
{
|
2007-09-09 21:47:25 +00:00
|
|
|
float a = clamp((client_tick()-player.attacktick+intratick)/40.0f, 0.0f, 1.0f);
|
2007-07-21 19:03:50 +00:00
|
|
|
anim_eval_add(&state, &data->animations[ANIM_NINJA_SWING], a, 1.0f);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// draw hook
|
2007-09-09 18:21:14 +00:00
|
|
|
if (prev.hook_state>0 && player.hook_state>0)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
|
|
|
//gfx_quads_begin();
|
|
|
|
|
|
|
|
vec2 pos = position;
|
2007-09-09 21:47:25 +00:00
|
|
|
vec2 hook_pos = mix(vec2(prev.hook_x, prev.hook_y), vec2(player.hook_x, player.hook_y), intratick);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
float d = distance(pos, hook_pos);
|
|
|
|
vec2 dir = normalize(pos-hook_pos);
|
|
|
|
|
|
|
|
gfx_quads_setrotation(get_angle(dir)+pi);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// render head
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(SPRITE_HOOK_HEAD);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_draw(hook_pos.x, hook_pos.y, 24,16);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// render chain
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(SPRITE_HOOK_CHAIN);
|
2007-05-22 15:03:32 +00:00
|
|
|
for(float f = 24; f < d; f += 24)
|
|
|
|
{
|
|
|
|
vec2 p = hook_pos + dir*f;
|
|
|
|
gfx_quads_draw(p.x, p.y,24,16);
|
|
|
|
}
|
2007-08-14 15:03:59 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_setrotation(0);
|
|
|
|
gfx_quads_end();
|
2007-08-14 15:03:59 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
render_hand(skin_id, position, normalize(hook_pos-pos), -pi/2, vec2(20, 0));
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// draw gun
|
|
|
|
{
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-07-13 13:40:04 +00:00
|
|
|
gfx_quads_setrotation(state.attach.angle*pi*2+angle);
|
|
|
|
|
|
|
|
// normal weapons
|
2007-09-09 18:21:14 +00:00
|
|
|
int iw = clamp(player.weapon, 0, NUM_WEAPONS-1);
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(data->weapons[iw].sprite_body, direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
vec2 dir = direction;
|
|
|
|
float recoil = 0.0f;
|
2007-07-21 19:03:50 +00:00
|
|
|
vec2 p;
|
2007-09-09 18:21:14 +00:00
|
|
|
if (player.weapon == WEAPON_HAMMER)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-21 19:03:50 +00:00
|
|
|
// Static position for hammer
|
|
|
|
p = position;
|
|
|
|
p.y += data->weapons[iw].offsety;
|
2007-07-13 13:40:04 +00:00
|
|
|
// if attack is under way, bash stuffs
|
2007-05-22 15:03:32 +00:00
|
|
|
if(direction.x < 0)
|
2007-07-21 19:03:50 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2);
|
2007-07-21 19:03:50 +00:00
|
|
|
p.x -= data->weapons[iw].offsetx;
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
else
|
2007-07-21 19:03:50 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2);
|
2007-07-21 19:03:50 +00:00
|
|
|
}
|
|
|
|
draw_sprite(p.x, p.y, data->weapons[iw].visual_size);
|
|
|
|
}
|
2007-09-09 18:21:14 +00:00
|
|
|
else if (player.weapon == WEAPON_NINJA)
|
2007-07-21 19:03:50 +00:00
|
|
|
{
|
|
|
|
p = position;
|
|
|
|
p.y += data->weapons[iw].offsety;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-21 19:03:50 +00:00
|
|
|
if(direction.x < 0)
|
|
|
|
{
|
|
|
|
gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2);
|
|
|
|
p.x -= data->weapons[iw].offsetx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2);
|
|
|
|
}
|
|
|
|
draw_sprite(p.x, p.y, data->weapons[iw].visual_size);
|
2007-07-22 13:46:40 +00:00
|
|
|
|
|
|
|
// HADOKEN
|
2007-09-09 18:21:14 +00:00
|
|
|
if ((client_tick()-player.attacktick) <= (SERVER_TICK_SPEED / 6) && data->weapons[iw].nummuzzlesprites)
|
2007-07-22 13:46:40 +00:00
|
|
|
{
|
|
|
|
int itex = rand() % data->weapons[iw].nummuzzlesprites;
|
|
|
|
float alpha = 1.0f;
|
|
|
|
if (alpha > 0.0f && data->weapons[iw].sprite_muzzle[itex].psprite)
|
|
|
|
{
|
2007-09-09 18:21:14 +00:00
|
|
|
vec2 dir = vec2(player.x,player.y) - vec2(prev.x, prev.y);
|
2007-07-22 13:46:40 +00:00
|
|
|
dir = normalize(dir);
|
|
|
|
float hadokenangle = atan(dir.y/dir.x);
|
|
|
|
if (dir.x < 0.0f)
|
|
|
|
hadokenangle += pi;
|
|
|
|
gfx_quads_setrotation(hadokenangle);
|
2007-07-26 19:09:31 +00:00
|
|
|
//float offsety = -data->weapons[iw].muzzleoffsety;
|
2007-07-22 13:46:40 +00:00
|
|
|
select_sprite(data->weapons[iw].sprite_muzzle[itex].psprite, 0);
|
|
|
|
vec2 diry(-dir.y,dir.x);
|
|
|
|
p = position;
|
|
|
|
float offsetx = data->weapons[iw].muzzleoffsetx;
|
|
|
|
p -= dir * offsetx;
|
|
|
|
draw_sprite(p.x, p.y, 160.0f);
|
|
|
|
}
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
// TODO: should be an animation
|
|
|
|
recoil = 0;
|
2007-09-09 21:47:25 +00:00
|
|
|
float a = (client_tick()-player.attacktick+intratick)/5.0f;
|
2007-07-13 13:40:04 +00:00
|
|
|
if(a < 1)
|
|
|
|
recoil = sinf(a*pi);
|
2007-07-21 19:03:50 +00:00
|
|
|
p = position + dir * data->weapons[iw].offsetx - dir*recoil*10.0f;
|
|
|
|
p.y += data->weapons[iw].offsety;
|
|
|
|
draw_sprite(p.x, p.y, data->weapons[iw].visual_size);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
if (player.weapon == WEAPON_GUN || player.weapon == WEAPON_SHOTGUN)
|
2007-07-21 19:03:50 +00:00
|
|
|
{
|
|
|
|
// check if we're firing stuff
|
2007-09-09 18:21:14 +00:00
|
|
|
if (true)///prev.attackticks)
|
2007-07-21 19:03:50 +00:00
|
|
|
{
|
|
|
|
float alpha = 0.0f;
|
2007-09-09 18:21:14 +00:00
|
|
|
int phase1tick = (client_tick() - player.attacktick);
|
2007-07-21 19:03:50 +00:00
|
|
|
if (phase1tick < (data->weapons[iw].muzzleduration + 3))
|
|
|
|
{
|
|
|
|
float t = ((((float)phase1tick) + intratick)/(float)data->weapons[iw].muzzleduration);
|
|
|
|
alpha = LERP(2.0, 0.0f, min(1.0f,max(0.0f,t)));
|
|
|
|
}
|
|
|
|
|
|
|
|
int itex = rand() % data->weapons[iw].nummuzzlesprites;
|
|
|
|
if (alpha > 0.0f && data->weapons[iw].sprite_muzzle[itex].psprite)
|
|
|
|
{
|
|
|
|
float offsety = -data->weapons[iw].muzzleoffsety;
|
|
|
|
select_sprite(data->weapons[iw].sprite_muzzle[itex].psprite, direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0);
|
|
|
|
if(direction.x < 0)
|
|
|
|
offsety = -offsety;
|
|
|
|
|
|
|
|
vec2 diry(-dir.y,dir.x);
|
|
|
|
p += dir * data->weapons[iw].muzzleoffsetx + diry * offsety;
|
|
|
|
|
|
|
|
draw_sprite(p.x, p.y, data->weapons[iw].visual_size);
|
2007-09-23 18:27:04 +00:00
|
|
|
/*gfx_setcolor(1.0f,1.0f,1.0f,alpha);
|
2007-07-21 19:03:50 +00:00
|
|
|
vec2 diry(-dir.y,dir.x);
|
2007-09-09 18:21:14 +00:00
|
|
|
p += dir * muzzleparams[player.weapon].offsetx + diry * offsety;
|
|
|
|
gfx_quads_draw(p.x,p.y,muzzleparams[player.weapon].sizex, muzzleparams[player.weapon].sizey);*/
|
2007-07-21 19:03:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_end();
|
2007-08-14 15:03:59 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
switch (player.weapon)
|
2007-08-14 15:03:59 +00:00
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
case WEAPON_GUN: render_hand(skin_id, p, direction, -3*pi/4, vec2(-15, 4)); break;
|
|
|
|
case WEAPON_SHOTGUN: render_hand(skin_id, p, direction, -pi/2, vec2(-5, 4)); break;
|
|
|
|
case WEAPON_ROCKET: render_hand(skin_id, p, direction, -pi/2, vec2(-4, 7)); break;
|
2007-08-14 15:03:59 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-07-14 22:35:00 +00:00
|
|
|
|
2007-10-28 19:28:09 +00:00
|
|
|
// render the "shadow" tee
|
2007-10-28 11:30:25 +00:00
|
|
|
if(info.local && config.debug)
|
2007-09-09 18:21:14 +00:00
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
vec2 ghost_position = mix(vec2(prev_char->x, prev_char->y), vec2(player_char->x, player_char->y), client_intratick());
|
2007-11-04 00:19:41 +00:00
|
|
|
tee_render_info ghost = client_datas[info.clientid].skin_info;
|
|
|
|
ghost.color.a = 0.5f;
|
|
|
|
render_tee(&state, &ghost, player.emote, direction, ghost_position); // render ghost
|
2007-09-09 18:21:14 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 19:28:09 +00:00
|
|
|
// render the tee
|
2007-11-04 00:19:41 +00:00
|
|
|
render_tee(&state, &client_datas[info.clientid].skin_info, player.emote, direction, position);
|
2007-07-26 11:33:49 +00:00
|
|
|
|
2007-09-09 18:21:14 +00:00
|
|
|
if(player.state == STATE_CHATTING)
|
2007-07-26 11:33:49 +00:00
|
|
|
{
|
2007-11-08 20:07:24 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_EMOTICONS].id);
|
2007-07-26 11:33:49 +00:00
|
|
|
gfx_quads_begin();
|
2007-11-08 20:07:24 +00:00
|
|
|
select_sprite(SPRITE_DOTDOT);
|
2007-07-26 11:33:49 +00:00
|
|
|
gfx_quads_draw(position.x + 24, position.y - 40, 64,64);
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-07-14 22:35:00 +00:00
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
if (client_datas[info.clientid].emoticon_start != -1 && client_datas[info.clientid].emoticon_start + 2 * client_tickspeed() > client_tick())
|
2007-08-14 22:48:49 +00:00
|
|
|
{
|
|
|
|
gfx_texture_set(data->images[IMAGE_EMOTICONS].id);
|
|
|
|
gfx_quads_begin();
|
2007-08-15 00:09:24 +00:00
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
int since_start = client_tick() - client_datas[info.clientid].emoticon_start;
|
|
|
|
int from_end = client_datas[info.clientid].emoticon_start + 2 * client_tickspeed() - client_tick();
|
2007-08-15 00:09:24 +00:00
|
|
|
|
2007-08-15 00:20:04 +00:00
|
|
|
float a = 1;
|
|
|
|
|
|
|
|
if (from_end < client_tickspeed() / 5)
|
2007-08-15 00:09:24 +00:00
|
|
|
a = from_end / (client_tickspeed() / 5.0);
|
2007-08-15 00:20:04 +00:00
|
|
|
|
|
|
|
float h = 1;
|
|
|
|
if (since_start < client_tickspeed() / 10)
|
|
|
|
h = since_start / (client_tickspeed() / 10.0);
|
|
|
|
|
|
|
|
float wiggle = 0;
|
|
|
|
if (since_start < client_tickspeed() / 5)
|
|
|
|
wiggle = since_start / (client_tickspeed() / 5.0);
|
|
|
|
|
|
|
|
float wiggle_angle = sin(5*wiggle);
|
|
|
|
|
|
|
|
gfx_quads_setrotation(pi/6*wiggle_angle);
|
2007-08-15 00:09:24 +00:00
|
|
|
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(1.0f,1.0f,1.0f,a);
|
2007-08-14 22:48:49 +00:00
|
|
|
// client_datas::emoticon is an offset from the first emoticon
|
2007-10-28 11:30:25 +00:00
|
|
|
select_sprite(SPRITE_OOP + client_datas[info.clientid].emoticon);
|
2007-08-15 00:20:04 +00:00
|
|
|
gfx_quads_draw(position.x, position.y - 23 - 32*h, 64, 64*h);
|
2007-08-14 22:48:49 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-10-28 19:28:09 +00:00
|
|
|
|
|
|
|
// render name plate
|
|
|
|
if(!info.local && config.cl_nameplates)
|
|
|
|
{
|
|
|
|
//gfx_pretty_text_color
|
|
|
|
float a = 1;
|
|
|
|
if(config.cl_nameplates == 1)
|
|
|
|
a = clamp(1-powf(distance(local_target_pos, position)/200.0f,16.0f), 0.0f, 1.0f);
|
|
|
|
|
|
|
|
const char *name = client_datas[info.clientid].name;
|
|
|
|
float tw = gfx_pretty_text_width(28.0f, name, -1);
|
|
|
|
gfx_pretty_text_color(1,1,1,a);
|
|
|
|
gfx_pretty_text(position.x-tw/2.0f, position.y-60, 28.0f, name, -1);
|
|
|
|
}
|
2007-08-14 22:48:49 +00:00
|
|
|
}
|
2007-07-14 22:35:00 +00:00
|
|
|
|
|
|
|
void render_sun(float x, float y)
|
|
|
|
{
|
|
|
|
vec2 pos(x, y);
|
|
|
|
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_blend_additive();
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-07-14 22:35:00 +00:00
|
|
|
const int rays = 10;
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(1.0f,1.0f,1.0f,0.025f);
|
2007-07-14 22:35:00 +00:00
|
|
|
for(int r = 0; r < rays; r++)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-14 22:35:00 +00:00
|
|
|
float a = r/(float)rays + client_localtime()*0.025f;
|
|
|
|
float size = (1.0f/(float)rays)*0.25f;
|
|
|
|
vec2 dir0(sinf((a-size)*pi*2.0f), cosf((a-size)*pi*2.0f));
|
|
|
|
vec2 dir1(sinf((a+size)*pi*2.0f), cosf((a+size)*pi*2.0f));
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolorvertex(0, 1.0f,1.0f,1.0f,0.025f);
|
|
|
|
gfx_setcolorvertex(1, 1.0f,1.0f,1.0f,0.025f);
|
|
|
|
gfx_setcolorvertex(2, 1.0f,1.0f,1.0f,0.0f);
|
|
|
|
gfx_setcolorvertex(3, 1.0f,1.0f,1.0f,0.0f);
|
2007-07-14 22:35:00 +00:00
|
|
|
const float range = 1000.0f;
|
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
pos.x+dir0.x, pos.y+dir0.y,
|
|
|
|
pos.x+dir1.x, pos.y+dir1.y,
|
|
|
|
pos.x+dir0.x*range, pos.y+dir0.y*range,
|
|
|
|
pos.x+dir1.x*range, pos.y+dir1.y*range);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
gfx_quads_end();
|
2007-07-14 22:35:00 +00:00
|
|
|
gfx_blend_normal();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_SUN].id);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_draw(pos.x, pos.y, 256, 256);
|
2007-10-28 11:30:25 +00:00
|
|
|
gfx_quads_end();
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-14 22:48:49 +00:00
|
|
|
static bool emoticon_selector_inactive_override = false;
|
2007-08-15 10:07:44 +00:00
|
|
|
static vec2 emoticon_selector_mouse;
|
2007-08-14 22:48:49 +00:00
|
|
|
|
|
|
|
void emoticon_selector_reset()
|
|
|
|
{
|
2007-08-15 10:07:44 +00:00
|
|
|
emoticon_selector_mouse = vec2(0, 0);
|
2007-08-14 22:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int emoticon_selector_render()
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
inp_mouse_relative(&x, &y);
|
|
|
|
|
2007-08-15 10:07:44 +00:00
|
|
|
emoticon_selector_mouse.x += x;
|
|
|
|
emoticon_selector_mouse.y += y;
|
2007-08-14 22:48:49 +00:00
|
|
|
|
2007-08-15 15:29:28 +00:00
|
|
|
if (length(emoticon_selector_mouse) > 70)
|
|
|
|
emoticon_selector_mouse = normalize(emoticon_selector_mouse) * 70;
|
2007-08-14 22:48:49 +00:00
|
|
|
|
2007-08-15 17:57:21 +00:00
|
|
|
float selected_angle = get_angle(emoticon_selector_mouse) + 2*pi/24;
|
|
|
|
if (selected_angle < 0)
|
|
|
|
selected_angle += 2*pi;
|
2007-08-14 22:48:49 +00:00
|
|
|
|
|
|
|
static bool mouse_down = false;
|
|
|
|
bool return_now = false;
|
2007-10-28 11:30:25 +00:00
|
|
|
int selected_emoticon;
|
2007-08-15 17:57:21 +00:00
|
|
|
|
|
|
|
if (length(emoticon_selector_mouse) < 50)
|
|
|
|
selected_emoticon = -1;
|
|
|
|
else
|
2007-08-22 07:52:33 +00:00
|
|
|
selected_emoticon = (int)(selected_angle / (2*pi) * 12.0f);
|
2007-08-14 22:48:49 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
if (inp_key_pressed(KEY_MOUSE_1))
|
2007-08-14 22:48:49 +00:00
|
|
|
{
|
|
|
|
mouse_down = true;
|
|
|
|
}
|
|
|
|
else if (mouse_down)
|
|
|
|
{
|
|
|
|
mouse_down = false;
|
2007-08-15 17:57:21 +00:00
|
|
|
|
|
|
|
if (selected_emoticon != -1)
|
|
|
|
{
|
|
|
|
return_now = true;
|
|
|
|
emoticon_selector_active = false;
|
|
|
|
emoticon_selector_inactive_override = true;
|
|
|
|
}
|
2007-08-14 22:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx_mapscreen(0,0,400,300);
|
|
|
|
|
2007-08-15 15:29:28 +00:00
|
|
|
gfx_blend_normal();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-15 15:29:28 +00:00
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(0,0,0,0.3f);
|
2007-08-15 15:29:28 +00:00
|
|
|
draw_circle(200, 150, 80, 64);
|
|
|
|
gfx_quads_end();
|
|
|
|
|
2007-08-14 22:48:49 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_EMOTICONS].id);
|
|
|
|
gfx_quads_begin();
|
|
|
|
|
2007-08-14 23:28:33 +00:00
|
|
|
for (int i = 0; i < 12; i++)
|
2007-08-14 22:48:49 +00:00
|
|
|
{
|
2007-08-14 23:28:33 +00:00
|
|
|
float angle = 2*pi*i/12.0;
|
2007-08-15 10:07:44 +00:00
|
|
|
if (angle > pi)
|
|
|
|
angle -= 2*pi;
|
2007-08-14 22:48:49 +00:00
|
|
|
|
2007-08-15 17:57:21 +00:00
|
|
|
bool selected = selected_emoticon == i;
|
2007-08-14 22:48:49 +00:00
|
|
|
|
|
|
|
float size = selected ? 48 : 32;
|
|
|
|
|
|
|
|
float nudge_x = 60 * cos(angle);
|
|
|
|
float nudge_y = 60 * sin(angle);
|
|
|
|
select_sprite(SPRITE_OOP + i);
|
|
|
|
gfx_quads_draw(200 + nudge_x, 150 + nudge_y, size, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_quads_end();
|
|
|
|
|
2007-08-15 10:07:44 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_CURSOR].id);
|
|
|
|
gfx_quads_begin();
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(1,1,1,1);
|
2007-08-15 10:07:44 +00:00
|
|
|
gfx_quads_drawTL(emoticon_selector_mouse.x+200,emoticon_selector_mouse.y+150,12,12);
|
|
|
|
gfx_quads_end();
|
|
|
|
|
2007-08-15 17:57:21 +00:00
|
|
|
return return_now ? selected_emoticon : -1;
|
2007-08-14 22:48:49 +00:00
|
|
|
}
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
void render_goals(float x, float y, float w)
|
2007-10-03 21:02:59 +00:00
|
|
|
{
|
|
|
|
float h = 50.0f;
|
|
|
|
|
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_setcolor(0,0,0,0.5f);
|
|
|
|
draw_round_rect(x-10.f, y-10.f, w, h, 10.0f);
|
|
|
|
gfx_quads_end();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-03 21:02:59 +00:00
|
|
|
// render goals
|
|
|
|
//y = ystart+h-54;
|
|
|
|
if(gameobj && gameobj->time_limit)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
sprintf(buf, "Time Limit: %d min", gameobj->time_limit);
|
|
|
|
gfx_pretty_text(x+w/2, y, 32, buf, -1);
|
|
|
|
}
|
|
|
|
if(gameobj && gameobj->score_limit)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
sprintf(buf, "Score Limit: %d", gameobj->score_limit);
|
|
|
|
gfx_pretty_text(x+40, y, 32, buf, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
void render_scoreboard(float x, float y, float w, int team, const char *title)
|
2007-08-25 08:48:24 +00:00
|
|
|
{
|
|
|
|
//float w = 550.0f;
|
|
|
|
//float x = width/2-w/2;
|
|
|
|
//;
|
|
|
|
//float y = ystart;
|
|
|
|
//float w = 550.0f;
|
|
|
|
|
|
|
|
animstate idlestate;
|
|
|
|
anim_eval(&data->animations[ANIM_BASE], 0, &idlestate);
|
2007-10-28 11:30:25 +00:00
|
|
|
anim_eval_add(&idlestate, &data->animations[ANIM_IDLE], 0, 1.0f);
|
|
|
|
|
2007-10-03 21:02:59 +00:00
|
|
|
//float ystart = y;
|
2007-08-25 08:48:24 +00:00
|
|
|
float h = 600.0f;
|
|
|
|
|
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(0,0,0,0.5f);
|
2007-08-25 08:48:24 +00:00
|
|
|
draw_round_rect(x-10.f, y-10.f, w, h, 40.0f);
|
|
|
|
gfx_quads_end();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
// render title
|
|
|
|
if(!title)
|
|
|
|
{
|
|
|
|
if(gameobj->game_over)
|
|
|
|
title = "Game Over";
|
|
|
|
else
|
|
|
|
title = "Score Board";
|
|
|
|
}
|
|
|
|
|
2007-09-25 23:03:15 +00:00
|
|
|
float tw = gfx_pretty_text_width( 64, title, -1);
|
2007-08-25 08:48:24 +00:00
|
|
|
|
2007-10-03 21:32:02 +00:00
|
|
|
if(team == -1)
|
|
|
|
{
|
|
|
|
gfx_pretty_text(x+w/2-tw/2, y, 64, title, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gfx_pretty_text(x+10, y, 64, title, -1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-03 21:32:02 +00:00
|
|
|
char buf[128];
|
|
|
|
sprintf(buf, "%d", gameobj->teamscore[team&1]);
|
|
|
|
tw = gfx_pretty_text_width(64, buf, -1);
|
|
|
|
gfx_pretty_text(x+w-tw-40, y, 64, buf, -1);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
y += 64.0f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-03 21:32:02 +00:00
|
|
|
/*
|
|
|
|
if(team)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
sprintf(buf, "%4d", gameobj->teamscore[team&1]);
|
|
|
|
gfx_pretty_text(x+w/2-tw/2, y, 32, buf, -1);
|
|
|
|
}*/
|
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
|
|
|
|
// find players
|
2007-10-28 11:30:25 +00:00
|
|
|
const obj_player_info *players[MAX_CLIENTS] = {0};
|
2007-08-25 08:48:24 +00:00
|
|
|
int num_players = 0;
|
|
|
|
for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++)
|
|
|
|
{
|
|
|
|
SNAP_ITEM item;
|
|
|
|
const void *data = snap_get_item(SNAP_CURRENT, i, &item);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
if(item.type == OBJTYPE_PLAYER_INFO)
|
2007-08-25 08:48:24 +00:00
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
players[num_players] = (const obj_player_info *)data;
|
2007-08-25 08:48:24 +00:00
|
|
|
num_players++;
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
// sort players
|
|
|
|
for(int k = 0; k < num_players; k++) // ffs, bubblesort
|
|
|
|
{
|
|
|
|
for(int i = 0; i < num_players-k-1; i++)
|
|
|
|
{
|
|
|
|
if(players[i]->score < players[i+1]->score)
|
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
const obj_player_info *tmp = players[i];
|
2007-08-25 08:48:24 +00:00
|
|
|
players[i] = players[i+1];
|
|
|
|
players[i+1] = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// render headlines
|
|
|
|
gfx_pretty_text(x+10, y, 32, "Score", -1);
|
|
|
|
gfx_pretty_text(x+125, y, 32, "Name", -1);
|
|
|
|
gfx_pretty_text(x+w-70, y, 32, "Ping", -1);
|
|
|
|
y += 38.0f;
|
|
|
|
|
|
|
|
// render player scores
|
|
|
|
for(int i = 0; i < num_players; i++)
|
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
const obj_player_info *info = players[i];
|
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
// make sure that we render the correct team
|
2007-10-28 11:30:25 +00:00
|
|
|
if(team != -1 && info->team != team)
|
2007-08-25 08:48:24 +00:00
|
|
|
continue;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
char buf[128];
|
|
|
|
float font_size = 46.0f;
|
2007-10-28 11:30:25 +00:00
|
|
|
if(info->local)
|
2007-08-25 08:48:24 +00:00
|
|
|
{
|
|
|
|
// background so it's easy to find the local player
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
2007-09-23 18:27:04 +00:00
|
|
|
gfx_setcolor(1,1,1,0.25f);
|
2007-08-25 08:48:24 +00:00
|
|
|
draw_round_rect(x, y, w-20, 48, 20.0f);
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
sprintf(buf, "%4d", info->score);
|
2007-08-25 08:48:24 +00:00
|
|
|
gfx_pretty_text(x+60-gfx_pretty_text_width(font_size,buf,-1), y, font_size, buf, -1);
|
2007-10-28 11:30:25 +00:00
|
|
|
gfx_pretty_text(x+128, y, font_size, client_datas[info->clientid].name, -1);
|
|
|
|
|
|
|
|
sprintf(buf, "%4d", info->latency);
|
2007-08-25 08:48:24 +00:00
|
|
|
float tw = gfx_pretty_text_width(font_size, buf, -1);
|
|
|
|
gfx_pretty_text(x+w-tw-35, y, font_size, buf, -1);
|
|
|
|
|
|
|
|
// render avatar
|
2007-11-04 00:19:41 +00:00
|
|
|
render_tee(&idlestate, &client_datas[info->clientid].skin_info, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28));
|
2007-08-25 08:48:24 +00:00
|
|
|
y += 50.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
void mapscreen_to_world(float center_x, float center_y, float zoom)
|
|
|
|
{
|
|
|
|
const float default_zoom = 3.0f;
|
|
|
|
float width = 400*default_zoom*zoom;
|
|
|
|
float height = 300*default_zoom*zoom;
|
|
|
|
gfx_mapscreen(center_x-width/2, center_y-height/2, center_x+width/2, center_y+height/2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// renders the complete game world
|
|
|
|
void render_world(float center_x, float center_y, float zoom)
|
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
mapscreen_to_world(center_x, center_y, zoom);
|
|
|
|
//gfx_mapscreen(center_x-width/2, center_y-height/2, center_x+width/2, center_y+height/2);
|
2007-10-07 15:32:54 +00:00
|
|
|
|
|
|
|
// draw the sun
|
|
|
|
if(config.gfx_high_detail)
|
|
|
|
{
|
|
|
|
render_sun(20+center_x*0.6f, 20+center_y*0.6f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
// draw clouds
|
2007-10-07 15:32:54 +00:00
|
|
|
static vec2 cloud_pos[6] = {vec2(-500,0),vec2(-500,200),vec2(-500,400)};
|
|
|
|
static float cloud_speed[6] = {30, 20, 10};
|
|
|
|
static int cloud_sprites[6] = {SPRITE_CLOUD1, SPRITE_CLOUD2, SPRITE_CLOUD3};
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_CLOUDS].id);
|
|
|
|
gfx_quads_begin();
|
|
|
|
for(int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
float parallax_amount = 0.55f;
|
|
|
|
select_sprite(cloud_sprites[i]);
|
|
|
|
draw_sprite((cloud_pos[i].x+fmod(client_localtime()*cloud_speed[i]+i*100.0f, 3000.0f))+center_x*parallax_amount,
|
|
|
|
cloud_pos[i].y+center_y*parallax_amount, 300);
|
|
|
|
}
|
|
|
|
gfx_quads_end();
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// draw backdrop
|
|
|
|
gfx_texture_set(data->images[IMAGE_BACKDROP].id);
|
|
|
|
gfx_quads_begin();
|
|
|
|
float parallax_amount = 0.25f;
|
|
|
|
for(int x = -1; x < 3; x++)
|
|
|
|
gfx_quads_drawTL(1024*x+center_x*parallax_amount, (center_y)*parallax_amount+150+512, 1024, 512);
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// render background tilemaps
|
|
|
|
tilemap_render(32.0f, 0);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// render items
|
|
|
|
{
|
|
|
|
int num = snap_num_items(SNAP_CURRENT);
|
|
|
|
for(int i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
SNAP_ITEM item;
|
|
|
|
const void *data = snap_get_item(SNAP_CURRENT, i, &item);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
if(item.type == OBJTYPE_PROJECTILE)
|
|
|
|
{
|
|
|
|
const void *prev = snap_find_item(SNAP_PREV, item.type, item.id);
|
|
|
|
if(prev)
|
|
|
|
render_projectile((const obj_projectile *)prev, (const obj_projectile *)data, item.id);
|
|
|
|
}
|
|
|
|
else if(item.type == OBJTYPE_POWERUP)
|
|
|
|
{
|
|
|
|
const void *prev = snap_find_item(SNAP_PREV, item.type, item.id);
|
|
|
|
if(prev)
|
|
|
|
render_powerup((const obj_powerup *)prev, (const obj_powerup *)data);
|
|
|
|
}
|
|
|
|
else if(item.type == OBJTYPE_FLAG)
|
|
|
|
{
|
|
|
|
const void *prev = snap_find_item(SNAP_PREV, item.type, item.id);
|
|
|
|
if (prev)
|
|
|
|
render_flag((const obj_flag *)prev, (const obj_flag *)data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
// render players above all
|
2007-10-07 15:32:54 +00:00
|
|
|
{
|
|
|
|
int num = snap_num_items(SNAP_CURRENT);
|
|
|
|
for(int i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
SNAP_ITEM item;
|
|
|
|
const void *data = snap_get_item(SNAP_CURRENT, i, &item);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
if(item.type == OBJTYPE_PLAYER_CHARACTER)
|
2007-10-07 15:32:54 +00:00
|
|
|
{
|
|
|
|
const void *prev = snap_find_item(SNAP_PREV, item.type, item.id);
|
2007-10-28 11:30:25 +00:00
|
|
|
const void *prev_info = snap_find_item(SNAP_PREV, OBJTYPE_PLAYER_INFO, item.id);
|
|
|
|
const void *info = snap_find_item(SNAP_CURRENT, OBJTYPE_PLAYER_INFO, item.id);
|
|
|
|
if(prev && prev_info && info)
|
2007-10-07 15:32:54 +00:00
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
client_datas[((const obj_player_info *)info)->clientid].team = ((const obj_player_info *)info)->team;
|
2007-10-28 11:30:25 +00:00
|
|
|
render_player(
|
|
|
|
(const obj_player_character *)prev,
|
|
|
|
(const obj_player_character *)data,
|
|
|
|
(const obj_player_info *)prev_info,
|
|
|
|
(const obj_player_info *)info
|
|
|
|
);
|
2007-10-07 15:32:54 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
}
|
2007-10-07 15:32:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// render particles
|
|
|
|
temp_system.update(client_frametime());
|
|
|
|
temp_system.render();
|
|
|
|
|
|
|
|
// render foreground tilemaps
|
|
|
|
tilemap_render(32.0f, 1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// render damage indications
|
2007-10-28 11:30:25 +00:00
|
|
|
damageind.render();
|
2007-10-07 15:32:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
static void next_skin()
|
|
|
|
{
|
|
|
|
int skin_id = 0;
|
|
|
|
for(int i = 0; i < num_skins; i++)
|
|
|
|
{
|
|
|
|
if(strcmp(config.player_skin, skins[i].name) == 0)
|
|
|
|
{
|
|
|
|
skin_id = (i+1)%num_skins;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
config_set_player_skin(&config, skins[skin_id].name);
|
|
|
|
send_info(false);
|
|
|
|
}
|
|
|
|
|
2007-10-07 23:43:14 +00:00
|
|
|
static void do_input(int *v, int key)
|
|
|
|
{
|
|
|
|
*v += inp_key_presses(key) + inp_key_releases(key);
|
|
|
|
if((*v&1) != inp_key_state(key))
|
|
|
|
(*v)++;
|
|
|
|
*v &= INPUT_STATE_MASK;
|
|
|
|
}
|
|
|
|
|
2007-08-04 18:23:26 +00:00
|
|
|
void render_game()
|
2007-10-28 11:30:25 +00:00
|
|
|
{
|
2007-11-04 00:19:41 +00:00
|
|
|
if(inp_key_down('L'))
|
|
|
|
next_skin();
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
float width = 400*3.0f;
|
|
|
|
float height = 300*3.0f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 20:23:33 +00:00
|
|
|
bool spectate = false;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 16:48:52 +00:00
|
|
|
if(config.cl_predict)
|
|
|
|
local_character_pos = mix(predicted_prev_player.pos, predicted_player.pos, client_intrapredtick());
|
|
|
|
else if(local_character && local_prev_character)
|
|
|
|
{
|
|
|
|
local_character_pos = mix(
|
|
|
|
vec2(local_prev_character->x, local_prev_character->y),
|
|
|
|
vec2(local_character->x, local_character->y), client_intratick());
|
|
|
|
}
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
if(local_info && local_info->team == -1)
|
2007-10-07 20:23:33 +00:00
|
|
|
spectate = true;
|
2007-10-08 20:34:11 +00:00
|
|
|
|
|
|
|
// set listner pos
|
2007-10-28 11:30:25 +00:00
|
|
|
snd_set_listener_pos(local_character_pos.x, local_character_pos.y);
|
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
animstate idlestate;
|
|
|
|
anim_eval(&data->animations[ANIM_BASE], 0, &idlestate);
|
2007-10-28 11:30:25 +00:00
|
|
|
anim_eval_add(&idlestate, &data->animations[ANIM_IDLE], 0, 1.0f);
|
2007-07-22 11:53:15 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
if (inp_key_down(KEY_ESC))
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-10-04 22:00:10 +00:00
|
|
|
if (chat_mode)
|
|
|
|
chat_mode = CHATMODE_NONE;
|
2007-08-04 16:49:57 +00:00
|
|
|
else
|
|
|
|
menu_active = !menu_active;
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// handle chat input
|
2007-07-22 11:53:15 +00:00
|
|
|
if (!menu_active)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-10-04 22:00:10 +00:00
|
|
|
if(chat_mode != CHATMODE_NONE)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-10-04 22:00:10 +00:00
|
|
|
if(inp_key_down(KEY_ENTER))
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-07-22 11:53:15 +00:00
|
|
|
// send message
|
2007-07-26 19:58:48 +00:00
|
|
|
if(chat_input_len)
|
|
|
|
{
|
2007-10-07 15:32:54 +00:00
|
|
|
if(chat_input[0] == '/') // check for local command
|
2007-07-27 00:03:28 +00:00
|
|
|
config_set(&chat_input[1]);
|
|
|
|
else
|
|
|
|
{
|
2007-10-07 15:32:54 +00:00
|
|
|
// check for remote command
|
2007-09-23 21:00:57 +00:00
|
|
|
if(inp_key_pressed(KEY_RSHIFT) || inp_key_pressed(KEY_LSHIFT))
|
|
|
|
client_rcon(chat_input);
|
|
|
|
else
|
|
|
|
{
|
2007-10-07 15:32:54 +00:00
|
|
|
// send chat message
|
2007-09-23 21:00:57 +00:00
|
|
|
msg_pack_start(MSG_SAY, MSGFLAG_VITAL);
|
2007-10-04 22:00:10 +00:00
|
|
|
if(chat_mode == CHATMODE_ALL)
|
|
|
|
msg_pack_int(0);
|
|
|
|
else
|
|
|
|
msg_pack_int(1);
|
2007-09-23 21:00:57 +00:00
|
|
|
msg_pack_string(chat_input, 512);
|
|
|
|
msg_pack_end();
|
|
|
|
client_send_msg();
|
|
|
|
}
|
2007-07-27 00:03:28 +00:00
|
|
|
}
|
2007-07-26 19:58:48 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
chat_mode = CHATMODE_NONE;
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
int c = inp_last_char();
|
|
|
|
int k = inp_last_key();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
if (!(c >= 0 && c < 32))
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-07-22 11:53:15 +00:00
|
|
|
if (chat_input_len < sizeof(chat_input) - 1)
|
|
|
|
{
|
|
|
|
chat_input[chat_input_len] = c;
|
|
|
|
chat_input[chat_input_len+1] = 0;
|
|
|
|
chat_input_len++;
|
|
|
|
}
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-07-22 11:53:15 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
if(k == KEY_BACKSPACE)
|
2007-07-22 11:53:15 +00:00
|
|
|
{
|
|
|
|
if(chat_input_len > 0)
|
|
|
|
{
|
|
|
|
chat_input[chat_input_len-1] = 0;
|
|
|
|
chat_input_len--;
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-10-04 22:00:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if(chat_mode == CHATMODE_NONE)
|
|
|
|
{
|
|
|
|
if(inp_key_down(config.key_chat))
|
|
|
|
chat_mode = CHATMODE_ALL;
|
|
|
|
|
|
|
|
if(inp_key_down(config.key_teamchat))
|
|
|
|
chat_mode = CHATMODE_TEAM;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
if(chat_mode != CHATMODE_NONE)
|
|
|
|
{
|
|
|
|
mem_zero(chat_input, sizeof(chat_input));
|
|
|
|
chat_input_len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-10 12:43:27 +00:00
|
|
|
if (!menu_active)
|
2007-08-22 07:52:33 +00:00
|
|
|
inp_clear();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// fetch new input
|
2007-08-14 22:48:49 +00:00
|
|
|
if(!menu_active && (!emoticon_selector_active || emoticon_selector_inactive_override))
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
inp_mouse_relative(&x, &y);
|
|
|
|
mouse_pos += vec2(x, y);
|
2007-10-07 20:23:33 +00:00
|
|
|
if(!spectate)
|
|
|
|
{
|
|
|
|
float l = length(mouse_pos);
|
|
|
|
if(l > 600.0f)
|
|
|
|
mouse_pos = normalize(mouse_pos)*600.0f;
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-28 19:28:09 +00:00
|
|
|
local_target_pos = local_character_pos + mouse_pos;
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// snap input
|
|
|
|
{
|
2007-10-07 23:43:14 +00:00
|
|
|
static player_input input = {0};
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
input.target_x = (int)mouse_pos.x;
|
|
|
|
input.target_y = (int)mouse_pos.y;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
if(chat_mode != CHATMODE_NONE)
|
2007-07-26 11:33:49 +00:00
|
|
|
input.state = STATE_CHATTING;
|
|
|
|
else if(menu_active)
|
|
|
|
input.state = STATE_IN_MENU;
|
|
|
|
else
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-07-26 11:33:49 +00:00
|
|
|
input.state = STATE_PLAYING;
|
2007-10-07 23:43:14 +00:00
|
|
|
input.left = inp_key_state(config.key_move_left);
|
|
|
|
input.right = inp_key_state(config.key_move_right);
|
|
|
|
input.hook = inp_key_state(config.key_hook);
|
|
|
|
input.jump = inp_key_state(config.key_jump);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 23:43:14 +00:00
|
|
|
if(!emoticon_selector_active)
|
|
|
|
do_input(&input.fire, config.key_fire);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 23:43:14 +00:00
|
|
|
// weapon selection
|
|
|
|
do_input(&input.next_weapon, config.key_next_weapon);
|
|
|
|
do_input(&input.prev_weapon, config.key_prev_weapon);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 23:43:14 +00:00
|
|
|
if(inp_key_presses(config.key_next_weapon) || inp_key_presses(config.key_prev_weapon))
|
|
|
|
input.wanted_weapon = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(inp_key_presses(config.key_weapon1)) input.wanted_weapon = 1;
|
|
|
|
if(inp_key_presses(config.key_weapon2)) input.wanted_weapon = 2;
|
|
|
|
if(inp_key_presses(config.key_weapon3)) input.wanted_weapon = 3;
|
|
|
|
if(inp_key_presses(config.key_weapon4)) input.wanted_weapon = 4;
|
2007-10-14 13:54:02 +00:00
|
|
|
if(inp_key_presses(config.key_weapon5)) input.wanted_weapon = 5;
|
|
|
|
if(inp_key_presses(config.key_weapon6)) input.wanted_weapon = 6;
|
2007-10-07 23:43:14 +00:00
|
|
|
}
|
2007-08-14 18:37:16 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-14 18:37:16 +00:00
|
|
|
// stress testing
|
|
|
|
if(config.stress)
|
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
float t = client_localtime();
|
2007-08-14 18:37:16 +00:00
|
|
|
mem_zero(&input, sizeof(input));
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
input.left = ((int)t/2)&1;
|
|
|
|
input.right = ((int)t/2+1)&1;
|
|
|
|
input.jump = ((int)t);
|
|
|
|
input.fire = ((int)(t*10));
|
|
|
|
input.hook = ((int)(t*2))&1;
|
|
|
|
input.wanted_weapon = ((int)t)%NUM_WEAPONS;
|
2007-08-14 18:37:16 +00:00
|
|
|
input.target_x = (int)(sinf(t*3)*100.0f);
|
|
|
|
input.target_y = (int)(cosf(t*3)*100.0f);
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
snap_input(&input, sizeof(input));
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// center at char but can be moved when mouse is far away
|
|
|
|
float offx = 0, offy = 0;
|
2007-08-15 10:18:01 +00:00
|
|
|
if (config.dynamic_camera)
|
|
|
|
{
|
|
|
|
int deadzone = 300;
|
|
|
|
if(mouse_pos.x > deadzone) offx = mouse_pos.x-deadzone;
|
|
|
|
if(mouse_pos.x <-deadzone) offx = mouse_pos.x+deadzone;
|
|
|
|
if(mouse_pos.y > deadzone) offy = mouse_pos.y-deadzone;
|
|
|
|
if(mouse_pos.y <-deadzone) offy = mouse_pos.y+deadzone;
|
|
|
|
offx = offx*2/3;
|
|
|
|
offy = offy*2/3;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// render the world
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_clear(0.65f,0.78f,0.9f);
|
2007-10-07 20:23:33 +00:00
|
|
|
if(spectate)
|
|
|
|
render_world(mouse_pos.x, mouse_pos.y, 1.0f);
|
|
|
|
else
|
2007-10-28 11:30:25 +00:00
|
|
|
{
|
|
|
|
render_world(local_character_pos.x+offx, local_character_pos.y+offy, 1.0f);
|
|
|
|
|
|
|
|
// draw screen box
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_lines_begin();
|
|
|
|
float cx = local_character_pos.x+offx;
|
|
|
|
float cy = local_character_pos.y+offy;
|
|
|
|
float w = 400*3/2;
|
|
|
|
float h = 300*3/2;
|
|
|
|
gfx_lines_draw(cx-w,cy-h,cx+w,cy-h);
|
|
|
|
gfx_lines_draw(cx+w,cy-h,cx+w,cy+h);
|
|
|
|
gfx_lines_draw(cx+w,cy+h,cx-w,cy+h);
|
|
|
|
gfx_lines_draw(cx-w,cy+h,cx-w,cy-h);
|
|
|
|
gfx_lines_end();
|
|
|
|
}
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-10-14 13:54:02 +00:00
|
|
|
|
|
|
|
// pseudo format
|
|
|
|
// ZOOM ZOOM
|
2007-10-28 11:30:25 +00:00
|
|
|
float zoom = 3.0;
|
|
|
|
if(local_character)
|
|
|
|
cl_effects.getzoom(client_tick(), client_intratick(), local_character);
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
// DEBUG TESTING
|
2007-10-14 13:54:02 +00:00
|
|
|
if(inp_key_pressed('M') || zoom > 3.01f)
|
2007-07-24 22:53:43 +00:00
|
|
|
{
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_clear_mask(0);
|
|
|
|
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_blend_normal();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_mask_op(MASK_NONE, 1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_quads_begin();
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_setcolor(0.65f,0.78f,0.9f,1.0f);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-14 13:54:02 +00:00
|
|
|
float fov;
|
|
|
|
if (zoom > 3.01f)
|
|
|
|
fov = pi * (zoom - 3.0f) / 6.0f;
|
|
|
|
else
|
|
|
|
fov = pi / 6.0f;
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
float fade = 0.7f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
float a = get_angle(normalize(vec2(mouse_pos.x, mouse_pos.y)));
|
|
|
|
vec2 d = get_dir(a);
|
|
|
|
vec2 d0 = get_dir(a-fov/2.0f);
|
|
|
|
vec2 d1 = get_dir(a+fov/2.0f);
|
2007-07-29 15:21:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
vec2 cd0 = get_dir(a-(fov*fade)/2.0f); // center direction
|
|
|
|
vec2 cd1 = get_dir(a+(fov*fade)/2.0f);
|
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
vec2 p0n = local_character_pos + d0*32.0f;
|
|
|
|
vec2 p1n = local_character_pos + d1*32.0f;
|
|
|
|
vec2 p0f = local_character_pos + d0*1000.0f;
|
|
|
|
vec2 p1f = local_character_pos + d1*1000.0f;
|
2007-10-07 15:32:54 +00:00
|
|
|
|
2007-10-28 11:30:25 +00:00
|
|
|
vec2 cn = local_character_pos + d*32.0f;
|
|
|
|
vec2 cf = local_character_pos + d*1000.0f;
|
|
|
|
|
|
|
|
vec2 cp0n = local_character_pos + cd0*32.0f;
|
|
|
|
vec2 cp0f = local_character_pos + cd0*1000.0f;
|
|
|
|
vec2 cp1n = local_character_pos + cd1*32.0f;
|
|
|
|
vec2 cp1f = local_character_pos + cd1*1000.0f;
|
2007-10-07 15:32:54 +00:00
|
|
|
|
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
p0n.x,p0n.y,
|
|
|
|
p1n.x,p1n.y,
|
|
|
|
p0f.x,p0f.y,
|
|
|
|
p1f.x,p1f.y);
|
2007-07-24 22:53:43 +00:00
|
|
|
gfx_quads_end();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_mask_op(MASK_SET, 0);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
render_world(local_character_pos.x+offx, local_character_pos.y+offy, 2.0f);
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_mask_op(MASK_NONE, 0);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
mapscreen_to_world(local_character_pos.x+offx, local_character_pos.y+offy, 1.0f);
|
2007-09-25 23:03:15 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_setcolor(0.5f,0.9f,0.5f,0.25f);
|
|
|
|
float r=0.5f, g=1.0f, b=0.5f;
|
2007-10-07 19:37:51 +00:00
|
|
|
float r2=r*0.25f, g2=g*0.25f, b2=b*0.25f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 19:37:51 +00:00
|
|
|
gfx_setcolor(r,g,b,0.2f);
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
cn.x,cn.y,
|
|
|
|
cn.x,cn.y,
|
|
|
|
cp0f.x,cp0f.y,
|
|
|
|
cp1f.x,cp1f.y);
|
|
|
|
|
2007-10-07 19:37:51 +00:00
|
|
|
gfx_setcolorvertex(0, r, g, b, 0.2f);
|
|
|
|
gfx_setcolorvertex(1, r2, g2, b2, 0.9f);
|
|
|
|
gfx_setcolorvertex(2, r, g, b, 0.2f);
|
|
|
|
gfx_setcolorvertex(3, r2, g2, b2, 0.9f);
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
cn.x,cn.y,
|
|
|
|
p0n.x,p0n.y,
|
|
|
|
cp0f.x,cp0f.y,
|
|
|
|
p0f.x,p0f.y);
|
|
|
|
|
|
|
|
gfx_quads_draw_freeform(
|
|
|
|
cn.x,cn.y,
|
|
|
|
p1n.x,p1n.y,
|
|
|
|
cp1f.x,cp1f.y,
|
|
|
|
p1f.x,p1f.y);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
gfx_quads_end();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
|
2007-10-07 15:32:54 +00:00
|
|
|
//gfx_mapscreen(0,0,400*3,300*3);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
if(local_character && !spectate)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// render cursor
|
2007-08-15 15:31:22 +00:00
|
|
|
if (!menu_active && (!emoticon_selector_active || emoticon_selector_inactive_override))
|
2007-07-22 11:53:15 +00:00
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
select_sprite(data->weapons[local_character->weapon%data->num_weapons].sprite_cursor);
|
2007-07-22 11:53:15 +00:00
|
|
|
float cursorsize = 64;
|
2007-10-28 19:28:09 +00:00
|
|
|
draw_sprite(local_target_pos.x, local_target_pos.y, cursorsize);
|
2007-07-22 11:53:15 +00:00
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
// render ammo count
|
|
|
|
// render gui stuff
|
|
|
|
gfx_quads_end();
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_mapscreen(0,0,400,300);
|
2007-10-14 13:54:02 +00:00
|
|
|
// if weaponstage is active, put a "glow" around the stage ammo
|
|
|
|
select_sprite(SPRITE_TEE_BODY);
|
2007-10-28 11:30:25 +00:00
|
|
|
for (int i = 0; i < local_character->weaponstage; i++)
|
|
|
|
gfx_quads_drawTL(local_character->ammocount * 12 -i*12, 32, 11, 11);
|
|
|
|
select_sprite(data->weapons[local_character->weapon%data->num_weapons].sprite_proj);
|
|
|
|
for (int i = 0; i < local_character->ammocount; i++)
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_drawTL(10+i*12,34,10,10);
|
2007-10-14 13:54:02 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
|
|
|
int h = 0;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// render health
|
|
|
|
select_sprite(SPRITE_HEALTH_FULL);
|
2007-10-28 11:30:25 +00:00
|
|
|
for(; h < local_character->health; h++)
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_drawTL(10+h*12,10,10,10);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(SPRITE_HEALTH_EMPTY);
|
2007-05-22 15:03:32 +00:00
|
|
|
for(; h < 10; h++)
|
|
|
|
gfx_quads_drawTL(10+h*12,10,10,10);
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
// render armor meter
|
2007-05-22 15:03:32 +00:00
|
|
|
h = 0;
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(SPRITE_ARMOR_FULL);
|
2007-10-28 11:30:25 +00:00
|
|
|
for(; h < local_character->armor; h++)
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_drawTL(10+h*12,22,10,10);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
select_sprite(SPRITE_ARMOR_EMPTY);
|
2007-05-22 15:03:32 +00:00
|
|
|
for(; h < 10; h++)
|
|
|
|
gfx_quads_drawTL(10+h*12,22,10,10);
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
// render kill messages
|
|
|
|
{
|
|
|
|
gfx_mapscreen(0, 0, width*1.5f, height*1.5f);
|
|
|
|
float startx = width*1.5f-10.0f;
|
|
|
|
float y = 10.0f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
for(int i = 0; i < killmsg_max; i++)
|
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
int r = (killmsg_current+i+1)%killmsg_max;
|
|
|
|
if(client_tick() > killmsgs[r].tick+50*10)
|
|
|
|
continue;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
float font_size = 48.0f;
|
2007-08-22 07:52:33 +00:00
|
|
|
float killername_w = gfx_pretty_text_width(font_size, client_datas[killmsgs[r].killer].name, -1);
|
|
|
|
float victimname_w = gfx_pretty_text_width(font_size, client_datas[killmsgs[r].victim].name, -1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
float x = startx;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
// render victim name
|
|
|
|
x -= victimname_w;
|
2007-08-22 07:52:33 +00:00
|
|
|
gfx_pretty_text(x, y, font_size, client_datas[killmsgs[r].victim].name, -1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
// render victim tee
|
|
|
|
x -= 24.0f;
|
2007-11-04 00:19:41 +00:00
|
|
|
//int skin = gametype == GAMETYPE_TDM ? skinseed + client_datas[killmsgs[r].victim].team : killmsgs[r].victim;
|
|
|
|
render_tee(&idlestate, &client_datas[killmsgs[r].victim].skin_info, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28));
|
2007-07-14 22:35:00 +00:00
|
|
|
x -= 32.0f;
|
|
|
|
|
|
|
|
// render weapon
|
|
|
|
x -= 44.0f;
|
2007-07-22 11:53:15 +00:00
|
|
|
if (killmsgs[r].weapon >= 0)
|
|
|
|
{
|
2007-07-30 19:46:31 +00:00
|
|
|
gfx_texture_set(data->images[IMAGE_GAME].id);
|
2007-07-22 11:53:15 +00:00
|
|
|
gfx_quads_begin();
|
|
|
|
select_sprite(data->weapons[killmsgs[r].weapon].sprite_body);
|
|
|
|
draw_sprite(x, y+28, 96);
|
|
|
|
gfx_quads_end();
|
|
|
|
}
|
2007-07-14 22:35:00 +00:00
|
|
|
x -= 52.0f;
|
|
|
|
|
|
|
|
// render killer tee
|
|
|
|
x -= 24.0f;
|
2007-11-04 00:19:41 +00:00
|
|
|
//skin = gametype == GAMETYPE_TDM ? skinseed + client_datas[killmsgs[r].killer].team : killmsgs[r].killer;
|
|
|
|
render_tee(&idlestate, &client_datas[killmsgs[r].killer].skin_info, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28));
|
2007-07-14 22:35:00 +00:00
|
|
|
x -= 32.0f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
// render killer name
|
|
|
|
x -= killername_w;
|
2007-08-22 07:52:33 +00:00
|
|
|
gfx_pretty_text(x, y, font_size, client_datas[killmsgs[r].killer].name, -1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
y += 44;
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 22:35:00 +00:00
|
|
|
// render chat
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
2007-07-14 22:35:00 +00:00
|
|
|
gfx_mapscreen(0,0,400,300);
|
2007-07-14 13:09:42 +00:00
|
|
|
float x = 10.0f;
|
|
|
|
float y = 300.0f-50.0f;
|
|
|
|
float starty = -1;
|
2007-10-04 22:00:10 +00:00
|
|
|
if(chat_mode != CHATMODE_NONE)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
|
|
|
// render chat input
|
|
|
|
char buf[sizeof(chat_input)+16];
|
2007-10-04 22:00:10 +00:00
|
|
|
if(chat_mode == CHATMODE_ALL)
|
|
|
|
sprintf(buf, "All: %s_", chat_input);
|
|
|
|
else if(chat_mode == CHATMODE_TEAM)
|
|
|
|
sprintf(buf, "Team: %s_", chat_input);
|
|
|
|
else
|
|
|
|
sprintf(buf, "Chat: %s_", chat_input);
|
2007-08-22 07:52:33 +00:00
|
|
|
gfx_pretty_text(x, y, 10.0f, buf, 380);
|
2007-07-14 13:09:42 +00:00
|
|
|
starty = y;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
y -= 10;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-14 13:09:42 +00:00
|
|
|
int i;
|
|
|
|
for(i = 0; i < chat_max_lines; i++)
|
|
|
|
{
|
|
|
|
int r = ((chat_current_line-i)+chat_max_lines)%chat_max_lines;
|
|
|
|
if(client_tick() > chat_lines[r].tick+50*15)
|
|
|
|
break;
|
2007-08-10 11:03:16 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
int lines = int(gfx_pretty_text_width(10, chat_lines[r].text, -1)) / 380 + 1;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
gfx_pretty_text_color(1,1,1,1);
|
|
|
|
if(chat_lines[r].client_id == -1)
|
|
|
|
gfx_pretty_text_color(1,1,0.5f,1); // system
|
|
|
|
else if(chat_lines[r].team)
|
|
|
|
gfx_pretty_text_color(0.5f,1,0.5f,1); // team message
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-10 11:03:16 +00:00
|
|
|
gfx_pretty_text(x, y - 8 * (lines - 1), 10, chat_lines[r].text, 380);
|
|
|
|
y -= 8 * lines;
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-04 22:00:10 +00:00
|
|
|
gfx_pretty_text_color(1,1,1,1);
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-15 10:47:50 +00:00
|
|
|
// render goals
|
|
|
|
if(gameobj)
|
|
|
|
{
|
2007-07-22 09:16:38 +00:00
|
|
|
gametype = gameobj->gametype;
|
2007-07-15 10:47:50 +00:00
|
|
|
gfx_mapscreen(0,0,400,300);
|
|
|
|
if(!gameobj->sudden_death)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
int time = 0;
|
|
|
|
if(gameobj->time_limit)
|
|
|
|
{
|
|
|
|
time = gameobj->time_limit*60 - ((client_tick()-gameobj->round_start_tick)/client_tickspeed());
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-15 10:47:50 +00:00
|
|
|
if(gameobj->game_over)
|
|
|
|
time = 0;
|
2007-10-28 11:30:25 +00:00
|
|
|
}
|
2007-07-15 10:47:50 +00:00
|
|
|
else
|
|
|
|
time = (client_tick()-gameobj->round_start_tick)/client_tickspeed();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-07-15 10:47:50 +00:00
|
|
|
sprintf(buf, "%d:%02d", time /60, time %60);
|
2007-08-22 07:52:33 +00:00
|
|
|
float w = gfx_pretty_text_width(16, buf, -1);
|
|
|
|
gfx_pretty_text(200-w/2, 2, 16, buf, -1);
|
2007-07-15 10:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(gameobj->sudden_death)
|
|
|
|
{
|
|
|
|
const char *text = "Sudden Death";
|
2007-08-22 07:52:33 +00:00
|
|
|
float w = gfx_pretty_text_width(16, text, -1);
|
|
|
|
gfx_pretty_text(200-w/2, 2, 16, text, -1);
|
2007-07-15 10:47:50 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-03 22:09:48 +00:00
|
|
|
if(gametype == GAMETYPE_TDM || gametype == GAMETYPE_CTF)
|
|
|
|
{
|
|
|
|
for(int t = 0; t < 2; t++)
|
|
|
|
{
|
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
|
|
|
if(t == 0)
|
|
|
|
gfx_setcolor(1,0,0,0.5f);
|
|
|
|
else
|
|
|
|
gfx_setcolor(0,0,1,0.5f);
|
|
|
|
draw_round_rect(320+t*35, 300-15, 30, 50, 5.0f);
|
|
|
|
gfx_quads_end();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-03 22:09:48 +00:00
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "%d", gameobj->teamscore[t]);
|
|
|
|
float w = gfx_pretty_text_width(14, buf, -1);
|
|
|
|
gfx_pretty_text(320+t*35+30/2-w/2, 300-15, 14, buf, -1);
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-06 17:36:24 +00:00
|
|
|
// render warmup timer
|
|
|
|
if(gameobj->warmup)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
float w = gfx_pretty_text_width(24, "Warmup", -1);
|
|
|
|
gfx_pretty_text(200+-w/2, 50, 24, "Warmup", -1);
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-06 17:36:24 +00:00
|
|
|
int seconds = gameobj->warmup/SERVER_TICK_SPEED;
|
|
|
|
if(seconds < 5)
|
|
|
|
sprintf(buf, "%d.%d", seconds, (gameobj->warmup*10/SERVER_TICK_SPEED)%10);
|
|
|
|
else
|
|
|
|
sprintf(buf, "%d", seconds);
|
|
|
|
w = gfx_pretty_text_width(24, buf, -1);
|
|
|
|
gfx_pretty_text(200+-w/2, 75, 24, buf, -1);
|
|
|
|
}
|
2007-07-15 10:47:50 +00:00
|
|
|
}
|
2007-08-10 12:43:27 +00:00
|
|
|
|
|
|
|
if (menu_active)
|
|
|
|
{
|
|
|
|
if (modmenu_render(true))
|
|
|
|
menu_active = false;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-10 12:43:27 +00:00
|
|
|
//ingamemenu_render();
|
|
|
|
return;
|
|
|
|
}
|
2007-08-14 22:48:49 +00:00
|
|
|
|
2007-10-09 20:55:37 +00:00
|
|
|
if(chat_mode == CHATMODE_NONE && !menu_active && inp_key_pressed(config.key_emoticon))
|
2007-08-14 22:48:49 +00:00
|
|
|
{
|
|
|
|
if (!emoticon_selector_active)
|
|
|
|
{
|
|
|
|
emoticon_selector_active = true;
|
|
|
|
emoticon_selector_reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
emoticon_selector_active = false;
|
|
|
|
emoticon_selector_inactive_override = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (emoticon_selector_active && !emoticon_selector_inactive_override)
|
|
|
|
{
|
|
|
|
int emoticon = emoticon_selector_render();
|
|
|
|
if (emoticon != -1)
|
|
|
|
send_emoticon(emoticon);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
// render score board
|
2007-08-22 07:52:33 +00:00
|
|
|
if(inp_key_pressed(KEY_TAB) || // user requested
|
2007-10-28 11:30:25 +00:00
|
|
|
(!spectate && (local_character && local_character->health == -1)) || // not spectating and is dead
|
2007-07-15 10:47:50 +00:00
|
|
|
(gameobj && gameobj->game_over) // game over
|
|
|
|
)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-14 13:09:42 +00:00
|
|
|
gfx_mapscreen(0, 0, width, height);
|
|
|
|
|
2007-08-25 08:48:24 +00:00
|
|
|
float w = 550.0f;
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-04 19:04:31 +00:00
|
|
|
if (gameobj && gameobj->gametype == GAMETYPE_DM)
|
2007-07-15 10:47:50 +00:00
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
render_scoreboard(width/2-w/2, 150.0f, w, -1, 0);
|
2007-08-25 08:48:24 +00:00
|
|
|
//render_scoreboard(gameobj, 0, 0, -1, 0);
|
2007-07-15 10:47:50 +00:00
|
|
|
}
|
2007-08-25 08:48:24 +00:00
|
|
|
else
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-10-28 11:30:25 +00:00
|
|
|
render_scoreboard(width/2-w-20, 150.0f, w, 0, "Red Team");
|
|
|
|
render_scoreboard(width/2 + 20, 150.0f, w, 1, "Blue Team");
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
|
|
|
render_goals(width/2-w/2, 150+600+25, w);
|
2007-08-25 08:48:24 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-14 13:09:42 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_render()
|
2007-08-04 18:23:26 +00:00
|
|
|
{
|
|
|
|
// this should be moved around abit
|
|
|
|
if(client_state() == CLIENTSTATE_ONLINE)
|
|
|
|
{
|
2007-08-04 21:26:20 +00:00
|
|
|
if (music_menu_id != -1)
|
|
|
|
{
|
|
|
|
snd_stop(music_menu_id);
|
|
|
|
music_menu_id = -1;
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-04 18:23:26 +00:00
|
|
|
render_game();
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-07 20:23:33 +00:00
|
|
|
// handle team switching
|
2007-11-04 00:19:41 +00:00
|
|
|
// TODO: FUGLY!!!
|
2007-10-07 20:23:33 +00:00
|
|
|
if(config.team != -10)
|
|
|
|
{
|
|
|
|
msg_pack_start(MSG_SETTEAM, MSGFLAG_VITAL);
|
|
|
|
msg_pack_int(config.team);
|
|
|
|
msg_pack_end();
|
|
|
|
client_send_msg();
|
|
|
|
}
|
2007-08-04 18:23:26 +00:00
|
|
|
}
|
|
|
|
else // if (client_state() != CLIENTSTATE_CONNECTING && client_state() != CLIENTSTATE_LOADING)
|
|
|
|
{
|
2007-08-04 21:26:20 +00:00
|
|
|
if (music_menu_id == -1)
|
2007-10-08 20:34:11 +00:00
|
|
|
{
|
|
|
|
music_menu_id = snd_play(CHN_MUSIC, music_menu, SNDFLAG_LOOP);
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-08-04 18:23:26 +00:00
|
|
|
//netaddr4 server_address;
|
2007-08-10 12:43:27 +00:00
|
|
|
if(modmenu_render(false) == -1)
|
2007-08-04 18:23:26 +00:00
|
|
|
client_quit();
|
|
|
|
}
|
2007-10-28 11:30:25 +00:00
|
|
|
|
2007-10-09 20:52:54 +00:00
|
|
|
//
|
|
|
|
config.team = -10;
|
2007-08-04 18:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void menu_do_disconnected();
|
|
|
|
void menu_do_connecting();
|
2007-08-10 12:43:27 +00:00
|
|
|
void menu_do_connected();
|
2007-08-04 18:23:26 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_statechange(int state, int old)
|
2007-08-04 18:23:26 +00:00
|
|
|
{
|
|
|
|
if(state == CLIENTSTATE_OFFLINE)
|
|
|
|
menu_do_disconnected();
|
|
|
|
if(state == CLIENTSTATE_CONNECTING)
|
|
|
|
menu_do_connecting();
|
2007-08-10 12:43:27 +00:00
|
|
|
if (state == CLIENTSTATE_ONLINE)
|
|
|
|
menu_do_connected();
|
2007-08-04 18:23:26 +00:00
|
|
|
}
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
extern "C" void modc_message(int msg)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
|
|
|
if(msg == MSG_CHAT)
|
|
|
|
{
|
|
|
|
int cid = msg_unpack_int();
|
2007-09-25 23:03:15 +00:00
|
|
|
int team = msg_unpack_int();
|
2007-07-14 13:09:42 +00:00
|
|
|
const char *message = msg_unpack_string();
|
2007-10-04 22:00:10 +00:00
|
|
|
dbg_msg("message", "chat cid=%d team=%d msg='%s'", cid, team, message);
|
|
|
|
chat_add_line(cid, team, message);
|
2007-08-14 22:48:49 +00:00
|
|
|
|
2007-08-05 08:59:38 +00:00
|
|
|
if(cid >= 0)
|
2007-10-08 20:34:11 +00:00
|
|
|
snd_play(CHN_GUI, data->sounds[SOUND_CHAT_CLIENT].sounds[0].id, 0);
|
2007-08-05 08:59:38 +00:00
|
|
|
else
|
2007-10-08 20:34:11 +00:00
|
|
|
snd_play(CHN_GUI, data->sounds[SOUND_CHAT_SERVER].sounds[0].id, 0);
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-11-04 00:19:41 +00:00
|
|
|
else if(msg == MSG_SETINFO)
|
2007-07-14 13:09:42 +00:00
|
|
|
{
|
|
|
|
int cid = msg_unpack_int();
|
|
|
|
const char *name = msg_unpack_string();
|
2007-11-04 00:19:41 +00:00
|
|
|
const char *skinname = msg_unpack_string();
|
|
|
|
int color = msg_unpack_int();
|
|
|
|
(void)color;
|
2007-07-14 13:09:42 +00:00
|
|
|
strncpy(client_datas[cid].name, name, 64);
|
2007-11-04 00:19:41 +00:00
|
|
|
strncpy(client_datas[cid].skin_name, skinname, 64);
|
|
|
|
client_datas[cid].skin_info.color = vec4(1,1,1,1); //color;
|
|
|
|
|
|
|
|
// find new skin
|
|
|
|
client_datas[cid].skin_id = 0;
|
|
|
|
for(int i = 0; i < num_skins; i++)
|
|
|
|
{
|
|
|
|
if(strcmp(skins[i].name, client_datas[cid].skin_name) == 0)
|
|
|
|
{
|
|
|
|
client_datas[cid].skin_id = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
client_datas[cid].skin_info.texture = skins[client_datas[cid].skin_id].org_texture;
|
|
|
|
}
|
|
|
|
else if(msg == MSG_READY_TO_ENTER)
|
|
|
|
{
|
|
|
|
client_entergame();
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-07-14 22:35:00 +00:00
|
|
|
else if(msg == MSG_KILLMSG)
|
|
|
|
{
|
|
|
|
killmsg_current = (killmsg_current+1)%killmsg_max;
|
|
|
|
killmsgs[killmsg_current].killer = msg_unpack_int();
|
|
|
|
killmsgs[killmsg_current].victim = msg_unpack_int();
|
|
|
|
killmsgs[killmsg_current].weapon = msg_unpack_int();
|
|
|
|
killmsgs[killmsg_current].tick = client_tick();
|
|
|
|
}
|
2007-08-14 22:48:49 +00:00
|
|
|
else if (msg == MSG_EMOTICON)
|
|
|
|
{
|
|
|
|
int cid = msg_unpack_int();
|
|
|
|
int emoticon = msg_unpack_int();
|
|
|
|
client_datas[cid].emoticon = emoticon;
|
|
|
|
client_datas[cid].emoticon_start = client_tick();
|
|
|
|
}
|
2007-07-14 13:09:42 +00:00
|
|
|
}
|
2007-08-22 21:13:33 +00:00
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
extern "C" void modc_connected()
|
|
|
|
{
|
|
|
|
// init some stuff
|
|
|
|
col_init(32);
|
|
|
|
img_init();
|
|
|
|
tilemap_init();
|
|
|
|
chat_reset();
|
|
|
|
|
|
|
|
proj_particles.reset();
|
|
|
|
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
{
|
|
|
|
client_datas[i].name[0] = 0;
|
|
|
|
client_datas[i].team = 0;
|
|
|
|
client_datas[i].emoticon = 0;
|
|
|
|
client_datas[i].emoticon_start = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < killmsg_max; i++)
|
|
|
|
killmsgs[i].tick = -100000;
|
|
|
|
|
|
|
|
send_info(true);
|
2007-11-04 22:30:08 +00:00
|
|
|
|
|
|
|
config.ui_page = 5;
|
2007-11-04 00:19:41 +00:00
|
|
|
}
|
2007-08-22 21:13:33 +00:00
|
|
|
|
|
|
|
extern "C" const char *modc_net_version() { return TEEWARS_NETVERSION; }
|