This commit is contained in:
Jakob Fries 2007-08-09 00:18:11 +00:00
parent 204a66b610
commit d5e3c556bf
5 changed files with 68 additions and 14 deletions

View file

@ -570,6 +570,10 @@ sprites {
tee_foot_outline 13 2 2 1
tee_eye_normal 10 2 1 1
tee_eye_pain 11 3 1 1
tee_eye_happy 11 2 1 1
tee_eye_surprise 12 0 1 1
tee_eye_angry 10 3 1 1
}
chatbubbles images.chat_bubbles 4 4 {

View file

@ -790,7 +790,7 @@ static void anim_eval_add(animstate *state, animation *anim, float time, float a
anim_add(state, &add, amount);
}
static void render_tee(animstate *anim, int skin, vec2 dir, vec2 pos)
static void render_tee(animstate *anim, int skin, int emote, vec2 dir, vec2 pos)
{
vec2 direction = dir;
vec2 position = pos;
@ -819,10 +819,26 @@ static void render_tee(animstate *anim, int skin, vec2 dir, vec2 pos)
// draw eyes
if(p == 1)
{
// normal
switch (emote)
{
case EMOTE_PAIN:
select_sprite(SPRITE_TEE_EYE_PAIN, 0, 0, shift*4);
break;
case EMOTE_HAPPY:
select_sprite(SPRITE_TEE_EYE_HAPPY, 0, 0, shift*4);
break;
case EMOTE_SURPRISE:
select_sprite(SPRITE_TEE_EYE_SURPRISE, 0, 0, shift*4);
break;
case EMOTE_ANGRY:
select_sprite(SPRITE_TEE_EYE_ANGRY, 0, 0, shift*4);
break;
default:
select_sprite(SPRITE_TEE_EYE_NORMAL, 0, 0, shift*4);
break;
}
gfx_quads_draw(position.x-4+direction.x*4, position.y-8+direction.y*3, basesize, basesize);
gfx_quads_draw(position.x+4+direction.x*4, position.y-8+direction.y*3, basesize, basesize);
gfx_quads_draw(position.x+4+direction.x*4, position.y-8+direction.y*3, -basesize, basesize);
}
}
@ -1078,7 +1094,7 @@ static void render_player(const obj_player *prev, const obj_player *player)
// render the tee
int skin = gametype == GAMETYPE_TDM ? skinseed + player->team : player->clientid;
render_tee(&state, skin, direction, position);
render_tee(&state, skin, player->emote, direction, position);
if(player->state == STATE_CHATTING)
{
@ -1552,7 +1568,7 @@ void render_game()
// render victim tee
x -= 24.0f;
int skin = gametype == GAMETYPE_TDM ? skinseed + client_datas[killmsgs[r].victim].team : killmsgs[r].victim;
render_tee(&idlestate, skin, vec2(1,0), vec2(x, y+28));
render_tee(&idlestate, skin, EMOTE_NORMAL, vec2(1,0), vec2(x, y+28));
x -= 32.0f;
// render weapon
@ -1570,7 +1586,7 @@ void render_game()
// render killer tee
x -= 24.0f;
skin = gametype == GAMETYPE_TDM ? skinseed + client_datas[killmsgs[r].killer].team : killmsgs[r].killer;
render_tee(&idlestate, skin, vec2(1,0), vec2(x, y+28));
render_tee(&idlestate, skin, EMOTE_NORMAL, vec2(1,0), vec2(x, y+28));
x -= 32.0f;
// render killer name
@ -1746,7 +1762,7 @@ void render_game()
gfx_pretty_text(x+w-tw-35, y, font_size, buf);
// render avatar
render_tee(&idlestate, player->clientid, vec2(1,0), vec2(x+90, y+28));
render_tee(&idlestate, player->clientid, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28));
y += 50.0f;
}

View file

@ -58,10 +58,11 @@ enum
enum
{
EMOTE_NORMAL=0,
EMOTE_BLINK,
EMOTE_WINK,
EMOTE_PAIN,
EMOTE_HAPPY,
EMOTE_SURPRISE,
EMOTE_ANGRY,
EMOTE_BLINK,
};
enum

View file

@ -807,6 +807,9 @@ void player::try_respawn()
active_weapon = WEAPON_GUN;
reload_timer = 0;
emote_type = EMOTE_HAPPY;
emote_stop = server_tick() + server_tickspeed();
// Create sound and spawn effects
create_sound(pos, SOUND_PLAYER_SPAWN);
create_spawn(pos);
@ -1407,7 +1410,7 @@ bool player::take_damage(vec2 force, int dmg, int from, int weapon)
// do damage hit sound
if(from >= 0)
create_targetted_sound(pos, SOUND_HIT, from);
create_targetted_sound(players[from].pos, SOUND_HIT, from);
// check for death
if(health <= 0)
@ -1433,6 +1436,8 @@ bool player::take_damage(vec2 force, int dmg, int from, int weapon)
else
create_sound(pos, SOUND_PLAYER_PAIN_SHORT);
emote_type = EMOTE_PAIN;
emote_stop = server_tick() + 500 * server_tickspeed() / 1000;
// spawn blood?
return true;
@ -1446,7 +1451,14 @@ void player::snap(int snaping_client)
player->y = (int)pos.y;
player->vx = (int)vel.x;
player->vy = (int)vel.y;
player->emote = EMOTE_NORMAL;
if (emote_stop < server_tick())
{
emote_type = EMOTE_NORMAL;
emote_stop = -1;
}
player->emote = emote_type;
player->latency = latency_avg;
player->latency_flux = latency_max-latency_min;
@ -1472,8 +1484,8 @@ void player::snap(int snaping_client)
if(length(vel) > 15.0f)
player->emote = EMOTE_HAPPY;
if(damage_taken_tick+50 > server_tick())
player->emote = EMOTE_PAIN;
//if(damage_taken_tick+50 > server_tick())
// player->emote = EMOTE_PAIN;
if(player->emote == EMOTE_NORMAL)
{
@ -1590,6 +1602,24 @@ void powerup::tick()
pplayer->active_weapon = WEAPON_NINJA;
respawntime = data->powerupinfo[type].respawntime;
create_sound(pos, SOUND_PICKUP_NINJA);
// loop through all players, setting their emotes
entity *ents[64];
const int types[] = {OBJTYPE_PLAYER};
int num = world.find_entities(vec2(0, 0), 1000000, ents, 64, types, 1);
for (int i = 0; i < num; i++)
{
player *p = (player *)ents[i];
if (p != pplayer)
{
p->emote_type = EMOTE_SURPRISE;
p->emote_stop = server_tick() + server_tickspeed();
}
}
pplayer->emote_type = EMOTE_ANGRY;
pplayer->emote_stop = server_tick() + 1200 * server_tickspeed() / 1000;
break;
}
default:

View file

@ -219,6 +219,9 @@ public:
int damage_taken;
int emote_type;
int emote_stop;
// we need a defered position so we can handle the physics correctly
baselib::vec2 defered_pos;
baselib::vec2 vel;