Skip to content

Commit

Permalink
Merge remote-tracking branch 'dda/pr/856' into dda-master
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade committed May 11, 2013
2 parents 1670222 + 042e838 commit 8f11e36
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 4 deletions.
52 changes: 52 additions & 0 deletions disease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ void dis_msg(game *g, dis_type type)
case DI_TEARGAS:
g->add_msg("You inhale a lungful of tear gas.");
break;
case DI_CRUSHED:
g->add_msg("The ceiling collapses on you!");
break;
case DI_BOULDERING:
g->add_msg("You are slowed by the rubble.");
case DI_BOOMERED:
g->add_msg("You're covered in bile!");
break;
Expand Down Expand Up @@ -382,6 +387,32 @@ void dis_effect(game *g, player &p, disease &dis)
}
break;

case DI_CRUSHED:
p.hurtall(10);
//This could be developed on later, for instance
//to deal different damage amounts to different body parts and
//to account for helmets and other armor
break;

case DI_BOULDERING:
switch(g->u.disease_intensity(DI_BOULDERING)){
case 1:
p.dex_cur -= 1;
break;
case 2:
p.dex_cur -= 3;
break;
case 3:
p.dex_cur -= 5;
break;
default:
debugmsg("Something went wrong with DI_BOULDERING.");
debugmsg("Check disease.cpp");
}
if (p.dex_cur < 1) {
p.dex_cur = 1;
}

case DI_BOOMERED:
p.per_cur -= 5;
break;
Expand Down Expand Up @@ -1171,6 +1202,7 @@ int disease_speed_boost(disease dis)
case DI_ASTHMA: return 0 - int(dis.duration / 5);
case DI_GRACK: return +20000;
case DI_METH: return (dis.duration > 600 ? 50 : -40);
case DI_BOULDERING: return ( 0 - (dis.intensity * 10));
default: return 0;
}
}
Expand Down Expand Up @@ -1314,6 +1346,7 @@ std::string dis_name(disease dis)
return "Meth Comedown";

case DI_IN_PIT: return "Stuck in Pit";
case DI_BOULDERING: return "Clambering Over Rubble";

case DI_STEMCELL_TREATMENT: return "Stem cell treatment";

Expand Down Expand Up @@ -1502,6 +1535,25 @@ Loss of health - Torso";
Loss of health - Entire Body\n\
Your clothing and other equipment may be consumed by the flames.";

case DI_CRUSHED: return "\
If you're seeing this, there is a bug in disease.cpp!";

case DI_BOULDERING:
switch (dis.intensity){
case 1:
return "\
Dexterity - 1; Speed -10%\
You are being slowed by climbing over a pile of rubble";
case 2:
return "\
Dexterity - 3; Speed -20%\
You are being slowed by climbing over a heap of rubble";
case 3:
return "\
Dexterity - 5; Speed -30%\
You are being slowed by climbing over a mountain of rubble";
}

case DI_BOOMERED: return "\
Perception - 5\n\
Range of Sight: 1; All sight is tinted magenta";
Expand Down
91 changes: 91 additions & 0 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ void map::step_in_field(int x, int y, game *g)
inside = (veh && veh->is_inside(veh_part));
}

if (cur->type != fd_rubble){
g->u.rem_disease(DI_BOULDERING);
}

switch (cur->type) {
case fd_null:
case fd_blood: // It doesn't actually do anything
Expand Down Expand Up @@ -762,6 +766,10 @@ void map::step_in_field(int x, int y, game *g)
}
break;

case fd_rubble:
g->u.add_disease(DI_BOULDERING, 0, g, cur->density, 3);
break;

case fd_smoke:
if (cur->density == 3 && !inside)
{
Expand Down Expand Up @@ -909,6 +917,11 @@ void map::mon_in_field(int x, int y, game *g, monster *z)
}
// Drop through to smoke

case fd_rubble:
if (!z->has_flag(MF_FLIES) && !z->has_flag(MF_AQUATIC))
z->add_effect(ME_BOULDERING, 1);
break;

case fd_smoke:
if (!z->has_flag(MF_NO_BREATHE)){
if (cur->density == 3)
Expand Down Expand Up @@ -1024,3 +1037,81 @@ bool vector_has(std::vector <item> vec, itype_id type)
}
return false;
}

void map::field_effect(int x, int y, game *g) //Applies effect of field immediately
{
field *cur = &field_at(x, y);
switch (cur->type) { //Can add independent code for different types of fields to apply different effects
case fd_rubble:
int hit_chance = 10;
int fdmon = g->mon_at(x, y); //The index of the monster at (x,y), or -1 if there isn't one
int fdnpc = g->npc_at(x, y); //The index of the NPC at (x,y), or -1 if there isn't one
npc *me;
if (fdnpc != -1)
me = g->active_npc[fdnpc];
int veh_part;
bool pc_inside;
bool npc_inside;
if (g->u.in_vehicle) {
vehicle *veh = g->m.veh_at(x, y, veh_part);
pc_inside = (veh && veh->is_inside(veh_part));
}
if (me->in_vehicle) {
vehicle *veh = g->m.veh_at(x, y, veh_part);
npc_inside = (veh && veh->is_inside(veh_part));
}
if (g->u.posx == x && g->u.posy == y && !pc_inside) { //If there's a PC at (x,y) and he's not in a covered vehicle...
if (g->u.dodge(g) < rng(1, hit_chance) || one_in(g->u.dodge(g))) {
int how_many_limbs_hit = rng(0, num_hp_parts);
for ( int i = 0 ; i < how_many_limbs_hit ; i++ ) {
g->u.hp_cur[rng(0, num_hp_parts)] -= rng(0, 10);
}
if (one_in(g->u.dex_cur)) {
g->u.add_disease(DI_DOWNED, 2, g);
}
if (one_in(g->u.str_cur)) {
g->u.add_disease(DI_STUNNED, 2, g);
}
}
else if (one_in(g->u.str_cur)) {
g->u.add_disease(DI_DOWNED, 1, g);
}
//Avoiding disease system for the moment, since I was having trouble with it.
// g->u.add_disease(DI_CRUSHED, 42, g); //Using a disease allows for easy modification without messing with field code
// g->u.rem_disease(DI_CRUSHED); //For instance, if we wanted to easily add a chance of limb mangling or a stun effect later
}
if (fdmon != -1 && fdmon < g->z.size()) { //If there's a monster at (x,y)...
monster* monhit = &(g->z[fdmon]);
int dam = 10; //This is a simplistic damage implementation. It can be improved, for instance to account for armor
if (monhit->hurt(dam)) //Ideally an external disease-like system would handle this to make it easier to modify later
g->kill_mon(fdmon, false);
}
if (fdnpc != -1) {
if (fdnpc < g->active_npc.size() && !npc_inside) { //If there's an NPC at (x,y) and he's not in a covered vehicle...
if (me->dodge(g) < rng(1, hit_chance) || one_in(me->dodge(g))) {
int how_many_limbs_hit = rng(0, num_hp_parts);
for ( int i = 0 ; i < how_many_limbs_hit ; i++ ) {
me->hp_cur[rng(0, num_hp_parts)] -= rng(0, 10);
}
if (one_in(me->dex_cur)) {
me->add_disease(DI_DOWNED, 2, g);
}
if (one_in(me->str_cur)) {
me->add_disease(DI_STUNNED, 2, g);
}
}
else if (one_in(me->str_cur)) {
me->add_disease(DI_DOWNED, 1, g);
}
}
if (me->hp_cur[hp_head] <= 0 || me->hp_cur[hp_torso] <= 0) {
me->die(g, false); //Right now cave-ins are treated as not the player's fault. This should be iterated on.
g->active_npc.erase(g->active_npc.begin() + fdnpc);
} //Still need to add vehicle damage, but I'm ignoring that for now.
}
vehicle *veh = veh_at(x, y, veh_part);
if (veh) {
veh->damage(veh_part, (veh->parts[veh_part].hp/3 * cur->density), 1, false);
}
}
}
34 changes: 33 additions & 1 deletion map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ vehicle* map::veh_at(const int x, const int y, int &part_num)
part_num = it->second.second;
return it->second.first;
}
debugmsg ("vehicle part cache cache indacated vehicle not found :/");
debugmsg ("vehicle part cache cache indicated vehicle not found :/");
return NULL;
}

Expand Down Expand Up @@ -1651,6 +1651,22 @@ void map::destroy(game *g, const int x, const int y, const bool makesound)
}
}
ter_set(x, y, t_rubble);
for (int i = x - 1; i <= x + 1; i++) {
for (int j = y - 1; j <= y + 1; j++) {
if (one_in(2)) {
//debugmsg("1");
if (!g->m.has_flag(noitem, x, y)) {
//debugmsg("2");
if (g->m.field_at(i, j).type != fd_rubble) {
//debugmsg("Rubble spawned!");
g->m.add_field(g, i, j, fd_rubble, rng(1,3));
g->m.field_effect(i, j, g);
}
}
}
}
}
//TODO: Make rubble decay into smoke
for (int i = x - 1; i <= x + 1; i++)
for (int j = y - 1; j <= y + 1; j++) {
if ((i == x && j == y) || !has_flag(collapses, i, j))
Expand Down Expand Up @@ -1685,6 +1701,22 @@ void map::destroy(game *g, const int x, const int y, const bool makesound)
}
}
ter_set(x, y, t_rubble);
for (int i = x - 1; i <= x + 1; i++) {
for (int j = y - 1; j <= y + 1; j++) {
if (one_in(2)) {
//debugmsg("1");
if (!g->m.has_flag(noitem, x, y)) {
//debugmsg("2");
if (g->m.field_at(i, j).type != fd_rubble) {
//debugmsg("Rubble spawned!");
g->m.add_field(g, i, j, fd_rubble, rng(1,3));
g->m.field_effect(i, j, g);
}
}
}
}
}
//TODO: Make rubble decay into smoke
for (int i = x - 1; i <= x + 1; i++)
for (int j = y - 1; j <= y + 1; j++) {
if ((i == x && j == y) || !has_flag(supports_roof, i, j))
Expand Down
5 changes: 3 additions & 2 deletions map.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ class map
point random_outdoor_tile();

void translate(const ter_id from, const ter_id to); // Change all instances of $from->$to
void translate_radius(const ter_id from, const ter_id to, const float radi, const int uX, const int uY);
void translate_radius(const ter_id from, const ter_id to, const float radi, const int uX, const int uY);
bool close_door(const int x, const int y, const bool inside);
bool open_door(const int x, const int y, const bool inside);
// bash: if res pointer is supplied, res will contain absorbed impact or -1
bool bash(const int x, const int y, const int str, std::string &sound, int *res = 0);
void destroy(game *g, const int x, const int y, const bool makesound);
void shoot(game *g, const int x, const int y, int &dam, const bool hit_items, const unsigned flags);
bool hit_with_acid(game *g, const int x, const int y);
bool hit_with_fire(game *g, const int x, const int y);
bool hit_with_fire(game *g, const int x, const int y);
void marlossify(const int x, const int y);
bool has_adjacent_furniture(const int x, const int y);
void mop_spills(const int x, const int y);
Expand Down Expand Up @@ -167,6 +167,7 @@ class map
bool process_fields_in_submap(game *g, const int gridn); // See fields.cpp
void step_in_field(const int x, const int y, game *g); // See fields.cpp
void mon_in_field(const int x, const int y, game *g, monster *z); // See fields.cpp
void field_effect(int x, int y, game *g); //See fields.cpp

// Computers
computer* computer_at(const int x, const int y);
Expand Down
4 changes: 4 additions & 0 deletions mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ enum field_id {
fd_acid,
fd_sap,
fd_fire,
fd_rubble,
fd_smoke,
fd_toxic_gas,
fd_tear_gas,
Expand Down Expand Up @@ -756,6 +757,9 @@ const field_t fieldlist[] = {
{{"small fire", "fire", "raging fire"}, '4',
{c_yellow, c_ltred, c_red}, {true, true, true}, {true, true, true}, 800},

{{"rubble heap", "rubble pile", "mountain of rubble"}, '#',
{c_dkgray, c_dkgray, c_dkgray}, {true, true, false},{false, false, false}, 0},

{{"thin smoke", "smoke", "thick smoke"}, '8',
{c_white, c_ltgray, c_dkgray}, {true, false, false},{false, true, true}, 300},

Expand Down
6 changes: 6 additions & 0 deletions monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ void monster::move(game *g)
moves = 0;
return;
}
if (has_effect(ME_BOULDERING)){
moves -= 20;
if (moves < 0)
moves = 0;
return;
}
if (friendly != 0) {
if (friendly > 0)
friendly--;
Expand Down
1 change: 1 addition & 0 deletions monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ME_TARGETED, // Targeting locked on--for robots that shoot guns
ME_DOCILE, // Don't attack other monsters--for tame monster
ME_HIT_BY_PLAYER, // We shot or hit them
ME_RUN, // For hit-and-run monsters; we're running for a bit;
ME_BOULDERING, // Monster is moving over rubble
NUM_MONSTER_EFFECTS
};

Expand Down
9 changes: 9 additions & 0 deletions npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,11 @@ void npc::move_to(game *g, int x, int y)
moves -= 100;
return;
}
if (has_disease(DI_BOULDERING)) {
moves -= 20;
if (moves < 0)
moves = 0;
}
if (recoil > 0) { // Start by dropping recoil a little
if (int(str_cur / 2) + sklevel[sk_gun] >= recoil)
recoil = 0;
Expand Down Expand Up @@ -996,6 +1001,10 @@ void npc::move_to(game *g, int x, int y)
g->m.bash(x, y, smashskill, bashsound);
g->sound(x, y, 18, bashsound);
} else
if (g->m.field_at(x, y).type == fd_rubble)
g->u.add_disease(DI_BOULDERING, 100, g, g->m.field_at(x,y).density, 3);
else
g->u.rem_disease(DI_BOULDERING);
moves -= 100;
}

Expand Down
2 changes: 1 addition & 1 deletion pldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum dis_type {
DI_INFECTION,
DI_COMMON_COLD, DI_FLU, DI_RECOVER,
// Fields
DI_SMOKE, DI_ONFIRE, DI_TEARGAS,
DI_SMOKE, DI_ONFIRE, DI_TEARGAS, DI_CRUSHED, DI_BOULDERING,
// Monsters
DI_BOOMERED, DI_SAP, DI_SPORES, DI_FUNGUS, DI_SLIMED,
DI_DEAF, DI_BLIND,
Expand Down

0 comments on commit 8f11e36

Please sign in to comment.