From e7241d743cbd73b2950ce73daba35491a47735ea Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Mon, 10 Mar 2008 19:36:05 +0000 Subject: [PATCH] fixed the ninja rendering --- data/skins/{ninja.png => x_ninja.png} | Bin datasrc/teewars.ds | 4 ++-- src/game/client/gc_client.h | 1 + src/game/client/gc_effects.cpp | 21 +++++++++++++++++++++ src/game/client/gc_hooks.cpp | 8 ++++++-- src/game/client/gc_menu.cpp | 5 +++++ src/game/client/gc_render_obj.cpp | 26 ++++++++++++++++++++++---- 7 files changed, 57 insertions(+), 8 deletions(-) rename data/skins/{ninja.png => x_ninja.png} (100%) diff --git a/data/skins/ninja.png b/data/skins/x_ninja.png similarity index 100% rename from data/skins/ninja.png rename to data/skins/x_ninja.png diff --git a/datasrc/teewars.ds b/datasrc/teewars.ds index ac3d37483..bcc21edf7 100644 --- a/datasrc/teewars.ds +++ b/datasrc/teewars.ds @@ -269,8 +269,8 @@ powerups { } ninja { amount 1 - respawntime 90 - startspawntime 90 + respawntime 5 + startspawntime 0 } } diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h index 483137653..5c89dc61f 100644 --- a/src/game/client/gc_client.h +++ b/src/game/client/gc_client.h @@ -146,6 +146,7 @@ void effect_air_jump(vec2 pos); void effect_damage_indicator(vec2 pos, vec2 dir); void effect_playerspawn(vec2 pos); void effect_playerdeath(vec2 pos); +void effect_powerupshine(vec2 pos, vec2 size); // particles struct particle diff --git a/src/game/client/gc_effects.cpp b/src/game/client/gc_effects.cpp index 6394075ee..fcf7ac931 100644 --- a/src/game/client/gc_effects.cpp +++ b/src/game/client/gc_effects.cpp @@ -25,6 +25,27 @@ void effect_air_jump(vec2 pos) particle_add(PARTGROUP_GENERAL, &p); } +void effect_powerupshine(vec2 pos, vec2 size) +{ + if(!add_trail) + return; + + particle p; + p.set_default(); + p.spr = SPRITE_PART_SLICE; + p.pos = pos + vec2((frandom()-0.5f)*size.x, (frandom()-0.5f)*size.y); + p.vel = vec2(0, 0); + p.life_span = 0.5f; + p.start_size = 16.0f; + p.end_size = 0; + p.rot = frandom()*pi*2; + p.rotspeed = pi*2; + p.gravity = 500; + p.friction = 0.9f; + p.flow_affected = 0.0f; + particle_add(PARTGROUP_GENERAL, &p); +} + void effect_smoketrail(vec2 pos, vec2 vel) { if(!add_trail) diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp index e1644f366..7d2e15462 100644 --- a/src/game/client/gc_hooks.cpp +++ b/src/game/client/gc_hooks.cpp @@ -506,8 +506,12 @@ extern "C" void modc_message(int msg) if(msg_unpack_error() || cid < 0 || cid >= MAX_CLIENTS) return; - strncpy(client_datas[cid].name, name, 64); - strncpy(client_datas[cid].skin_name, skinname, 64); + str_copy(client_datas[cid].name, name, 64); + str_copy(client_datas[cid].skin_name, skinname, 64); + + // make sure that we don't set a special skin on the client + if(client_datas[cid].skin_name[0] == 'x' || client_datas[cid].skin_name[1] == '_') + str_copy(client_datas[cid].skin_name, "default", 64); int use_custom_color = msg_unpack_int(); client_datas[cid].skin_info.color_body = skin_get_color(msg_unpack_int()); diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp index d4b45effb..cc6363f76 100644 --- a/src/game/client/gc_menu.cpp +++ b/src/game/client/gc_menu.cpp @@ -1258,6 +1258,11 @@ static void menu2_render_settings_player(RECT main_view) for(int i = start; i < start+num && i < skin_num(); i++) { const skin *s = skin_get(i); + + // no special skins + if(s->name[0] == 'x' && s->name[1] == '_') + continue; + char buf[128]; str_format(buf, sizeof(buf), "%s", s->name); int selected = 0; diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp index 995994ed0..73f58a859 100644 --- a/src/game/client/gc_render_obj.cpp +++ b/src/game/client/gc_render_obj.cpp @@ -9,6 +9,7 @@ #include "gc_render.h" #include "gc_anim.h" #include "gc_client.h" +#include "gc_skin.h" void render_projectile(const NETOBJ_PROJECTILE *current, int itemid) @@ -89,10 +90,7 @@ void render_powerup(const NETOBJ_POWERUP *prev, const NETOBJ_POWERUP *current) 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));*/ + effect_powerupshine(pos, vec2(96,18)); size *= 2.0f; pos.x += 10.0f; } @@ -261,6 +259,10 @@ void render_player( float intratick = client_intratick(); float ticktime = client_ticktime(); + + bool is_teamplay = false; + if(netobjects.gameobj && netobjects.gameobj->gametype != GAMETYPE_DM) + is_teamplay = true; if(player.health < 0) // dont render dead players return; @@ -396,6 +398,20 @@ void render_player( } else if (player.weapon == WEAPON_NINJA) { + // change the skin for the player to the ninja + int skin = skin_find("x_ninja"); + if(skin != -1) + { + if(is_teamplay) + render_info.texture = skin_get(skin)->color_texture; + else + { + render_info.texture = skin_get(skin)->org_texture; + render_info.color_body = vec4(1,1,1,1); + render_info.color_feet = vec4(1,1,1,1); + } + } + p = position; p.y += data->weapons[iw].offsety; @@ -403,10 +419,12 @@ void render_player( { gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2); p.x -= data->weapons[iw].offsetx; + effect_powerupshine(p+vec2(32,0), vec2(32,12)); } else { gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2); + effect_powerupshine(p-vec2(32,0), vec2(32,12)); } draw_sprite(p.x, p.y, data->weapons[iw].visual_size);