From: Christian Heller Date: Tue, 27 Aug 2013 02:37:23 +0000 (+0200) Subject: Killed monsters evolve into corpse items. X-Git-Tag: tce~1024 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/ledger?a=commitdiff_plain;h=e9282787cecf5439513dbfaedeac235cdc841e91;p=plomrogue Killed monsters evolve into corpse items. --- diff --git a/defs b/defs index efa67c2..5761952 100644 --- a/defs +++ b/defs @@ -1,5 +1,5 @@ -1 m a 1 ANT -2 m z 3 ZOMBIE -3 m S 9 SHOGGOTH -4 i # THING +1 m a 4 1 ANT +2 m z 5 3 ZOMBIE +3 m S 5 9 SHOGGOTH +4 i # DIRT 5 i % SKELETON diff --git a/src/map_object_actions.c b/src/map_object_actions.c index a4e186d..53253bc 100644 --- a/src/map_object_actions.c +++ b/src/map_object_actions.c @@ -74,7 +74,6 @@ static void player_hits_monster(struct World * world, struct Monster * monster) update_log(world, msg); free(msg); monster->hitpoints--; - if (0 == monster->hitpoints) { hit_dsc = "You kill the "; @@ -82,6 +81,12 @@ static void player_hits_monster(struct World * world, struct Monster * monster) sprintf(msg, "\n%s%s.", hit_dsc, monster_dsc); update_log(world, msg); free(msg); + struct MonsterDef * md = (struct MonsterDef * ) mod; + struct Item * corpse = malloc(sizeof(struct Item)); + corpse->map_obj.type = md->corpse_id; + corpse->map_obj.pos = monster->map_obj.pos; + corpse->map_obj.next = world->item; + world->item = corpse; if (world->monster == monster) { world->monster = world->monster->map_obj.next; @@ -211,4 +216,3 @@ extern char is_passable (struct Map * map, struct yx_uint16 pos) } return passable; } - diff --git a/src/map_objects.c b/src/map_objects.c index 4beb4fd..8cb1fca 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -112,8 +112,9 @@ extern void init_map_object_defs(struct World * world, char * filename) } else { - md.hitpoints_start = atoi (line_p + 4); - line_p = strchr (line_p + 4, ' ') + 1; + md.corpse_id = atoi (line_p + 4); + md.hitpoints_start = atoi (line_p + 6); + line_p = strchr (line_p + 6, ' ') + 1; } mod.desc = calloc (strlen (line_p), sizeof(char)); memcpy (mod.desc, line_p, strlen(line_p) - 1); diff --git a/src/map_objects.h b/src/map_objects.h index a905b7b..4804033 100644 --- a/src/map_objects.h +++ b/src/map_objects.h @@ -68,6 +68,7 @@ struct ItemDef struct MonsterDef { struct MapObjDef map_obj_def; + uint8_t corpse_id; /* ID of object type killed monster changes to. */ uint8_t hitpoints_start; /* Hitpoints each monster starts with. */ };