Skip to content

Commit

Permalink
Smile Thought nach gewonnenem Kampf und Spawnen
Browse files Browse the repository at this point in the history
git-svn-id: http://infon.googlecode.com/svn/trunk@53 8171fb75-e542-0410-96e4-03d5dd800671
  • Loading branch information
dividuum committed Aug 6, 2006
1 parent 90a3382 commit 6278250
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions client.c
Expand Up @@ -115,6 +115,9 @@ static void client_handle_packet(packet_t *packet) {
case PACKET_WORLD_INFO:
gui_world_info_from_network(packet);
break;
case PACKET_CREATURE_SMILE:
gui_creature_smile_from_network(packet);
break;
case PACKET_WELCOME_MSG:
client_writeto("guiclient\n", 10);
break;
Expand Down
2 changes: 2 additions & 0 deletions client.rb
Expand Up @@ -111,6 +111,8 @@ def readXX(len)
puts "king: %d " % socket.read8
when 6:
puts "world info %dx%d koth: %d,%d" % [socket.read8, socket.read8, socket.read8, socket.read8]
when 7:
puts "smile %d" % socket.read16
when 32:
socket.write("guiclient\n")
puts "welcome: %s" % socket.read(len).delete("\n").strip
Expand Down
9 changes: 9 additions & 0 deletions creature.c
Expand Up @@ -44,6 +44,13 @@ static creature_t *creature_find_unused() {
return NULL;
}

static void creature_make_smile(const creature_t *creature, client_t *client) {
packet_t packet;
packet_init(&packet, PACKET_CREATURE_SMILE);
packet_write16(&packet, creature_num(creature));
server_send_packet(&packet, client);
}

creature_t *creature_by_num(int creature_num) {
if (creature_num < 0 || creature_num >= MAXCREATURES)
return NULL;
Expand Down Expand Up @@ -334,6 +341,7 @@ void creature_do_attack(creature_t *creature, int delta) {
return;

creature_kill(target, creature);
creature_make_smile(creature, SEND_BROADCAST);
finished_attacking:
creature_set_state(creature, CREATURE_IDLE);
}
Expand Down Expand Up @@ -809,6 +817,7 @@ creature_t *creature_spawn(player_t *player, int x, int y, int type, int points)
creature_to_network(creature, CREATURE_DIRTY_ALL, SEND_BROADCAST);
creature->dirtymask = CREATURE_DIRTY_NONE;

creature_make_smile(creature, SEND_BROADCAST);
return creature;
}

Expand Down
13 changes: 13 additions & 0 deletions gui_creature.c
Expand Up @@ -71,7 +71,11 @@ void gui_creature_draw() {

//if (game_time > creature->last_state_change + 300 &&
// game_time < creature->last_state_change + 1000)
if (creature->smile_time + 1000 > game_time) {
video_draw(x + 15, y - 10, sprite_get(SPRITE_THOUGHT + 8));
} else {
video_draw(x + 15, y - 10, sprite_get(SPRITE_THOUGHT + creature->state));
}

//if (time < creature->last_msg_set + 2000)
video_tiny(x - strlen(creature->message) * 6 / 2 + 9, y + 14, creature->message);
Expand Down Expand Up @@ -204,6 +208,15 @@ void gui_creature_move(int delta) {
}
}

void gui_creature_smile_from_network(packet_t *packet) {
uint16_t creatureno;

if (!packet_read16(packet, &creatureno)) PROTOCOL_ERROR();
if (creatureno >= MAXCREATURES) PROTOCOL_ERROR();
gui_creature_t *creature = &creatures[creatureno];
creature->smile_time = game_time;
}

void gui_creature_from_network(packet_t *packet) {
uint16_t creatureno;

Expand Down
2 changes: 2 additions & 0 deletions gui_creature.h
Expand Up @@ -56,13 +56,15 @@ typedef struct gui_creature_s {
int last_y;

char message[9];
int smile_time;
} gui_creature_t;

void gui_creature_draw();
void gui_creature_move(int delta);

/* Network */
void gui_creature_from_network(packet_t *packet);
void gui_creature_smile_from_network(packet_t *packet);

void gui_creature_init();
void gui_creature_shutdown();
Expand Down
1 change: 1 addition & 0 deletions packet.h
Expand Up @@ -36,6 +36,7 @@ typedef struct {
#define PACKET_QUIT_MSG 4
#define PACKET_KOTH_UPDATE 5
#define PACKET_WORLD_INFO 6
#define PACKET_CREATURE_SMILE 7
#define PACKET_WELCOME_MSG 32
#define PACKET_START_COMPRESS 254
#define PACKET_HANDSHAKE 255
Expand Down
2 changes: 1 addition & 1 deletion sprite.h
Expand Up @@ -60,7 +60,7 @@

// Thought Konstanten
#define SPRITE_THOUGHT (SPRITE_FOOD + SPRITE_NUM_FOOD)
#define SPRITE_NUM_THOUGHT CREATURE_STATES
#define SPRITE_NUM_THOUGHT CREATURE_STATES + 1 /* + Smile */

// Koth Krone
#define SPRITE_CROWN (SPRITE_THOUGHT + SPRITE_NUM_THOUGHT)
Expand Down
2 changes: 1 addition & 1 deletion world.c
Expand Up @@ -75,7 +75,7 @@ int world_dig(int x, int y, maptype_e type) {
if (MAPTILE(x, y).type != SOLID)
return 0;

fprintf(stderr, "world_dig(%d, %d, %d)\n", x, y, type);
// fprintf(stderr, "world_dig(%d, %d, %d)\n", x, y, type);

// Pfadsuche fuer Bodenbasierte Viecher aktualisieren
if (type == PLAIN)
Expand Down

0 comments on commit 6278250

Please sign in to comment.