uint32_t io_teleport_pc(dungeon_t *d) { /* Just for fun. */ pair_t dest; do { dest[dim_x] = rand_range(1, DUNGEON_X - 2); dest[dim_y] = rand_range(1, DUNGEON_Y - 2); } while (charpair(dest)); d->charmap[character_get_y(d->pc)][character_get_x(d->pc)] = NULL; d->charmap[dest[dim_y]][dest[dim_x]] = d->pc; character_set_y(d->pc, dest[dim_y]); character_set_x(d->pc, dest[dim_x]); if (mappair(dest) < ter_floor) { mappair(dest) = ter_floor; } pc_observe_terrain(d->pc, d); dijkstra(d); dijkstra_tunnel(d); return 0; }
void move_character(dungeon_t *d, character *c, pair_t next) { int rs; pair_t p; if (charpair(next) && ((next[dim_y] != character_get_y(c)) || (next[dim_x] != character_get_x(c)))) { d->combat_message = ""; rs = do_combat(d, c, charpair(next)); } /* No character in new position. */ if(rs == 0 || !charpair(next)){ d->charmap[character_get_y(c)][character_get_x(c)] = NULL; character_set_y(c, next[dim_y]); character_set_x(c, next[dim_x]); d->charmap[character_get_y(c)][character_get_x(c)] = c; } if (c == d->pc) { pc_set_speed(d, c); } }
void pc::DoBombCombat(dungeon_t *d, character* c) { int i, j; int damage = 100; int damageSplash = (damage / 2); int dmgUsed = 0; for(i = (character_get_y(c) - 1); i <= (character_get_y(c) + 1); i++) { for(j = (character_get_x(c) - 1); j <= (character_get_x(c) + 1); j++) { if(d->charmap[i][j] && d->charmap[i][j] != d->the_pc) { if(i == character_get_y(c) && j == character_get_x(c)) { dmgUsed = damage; } else { dmgUsed = damageSplash; } io_queue_message("You hit the %s for %d.", d->charmap[i][j]->name, dmgUsed); if (dmgUsed >= d->charmap[i][j]->hp) { io_queue_message("The %s dies.", d->charmap[i][j]->name); d->charmap[i][j]->hp = 0; d->charmap[i][j]->alive = 0; d->num_monsters--; charpair(d->charmap[i][j]->position) = NULL; } else { d->charmap[i][j]->hp -= dmgUsed; } } } } }
void pc::DoRangedCombat(dungeon_t *d, character* c) { int i; int damage = 0; int defenderDodge = c->dodge; int defenderDef = c->defence; int blocked = 0; float defMultipler; if(rand()%100 + 1 > defenderDodge) { for (i = 2; i < num_eq_slots; i++) { if (d->the_pc->eq[i]) { damage += d->the_pc->eq[i]->roll_dice(); } } blocked = damage; defMultipler = ((float)100 / (float)(100 + defenderDef)); damage = (damage * defMultipler); blocked = blocked - damage; io_queue_message("you hit the %s for %d. It blocked %d damage.", c->name, damage, blocked); if (damage >= c->hp) { c->hp = 0; c->alive = 0; d->num_monsters--; charpair(c->position) = NULL; io_queue_message("The %s dies.", c->name); } else { c->hp -= damage; } } else { io_queue_message("The %s dodged your ranged attack", c->name); } }