Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
KA101 committed Nov 4, 2014
2 parents 6626212 + 53ff7ec commit 86b0547
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 39 deletions.
26 changes: 13 additions & 13 deletions data/json/items/ranged.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
"burst": 0,
"clip_size": 7,
"reload": 75,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "sw_619",
Expand Down Expand Up @@ -647,7 +647,7 @@
"burst": 0,
"clip_size": 7,
"reload": 75,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "taurus_38",
Expand Down Expand Up @@ -729,7 +729,7 @@
"burst": 0,
"clip_size": 6,
"reload": 60,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "sw_500",
Expand Down Expand Up @@ -757,7 +757,7 @@
"burst": 0,
"clip_size": 5,
"reload": 80,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "raging_bull",
Expand Down Expand Up @@ -785,7 +785,7 @@
"burst": 0,
"clip_size": 5,
"reload": 80,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "ruger_redhawk",
Expand Down Expand Up @@ -813,7 +813,7 @@
"burst": 0,
"clip_size": 6,
"reload": 80,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "deagle_44",
Expand Down Expand Up @@ -978,7 +978,7 @@
"burst": 0,
"clip_size": 6,
"reload": 75,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "l_bak_223",
Expand Down Expand Up @@ -1006,7 +1006,7 @@
"burst": 0,
"clip_size": 5,
"reload": 75,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "muzzle", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "fn57",
Expand Down Expand Up @@ -3192,7 +3192,7 @@
"burst": 0,
"clip_size": 5,
"reload": 90,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "rm103a_pistol",
Expand Down Expand Up @@ -3825,7 +3825,7 @@
"burst": 0,
"clip_size": 4,
"reload": 100,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "cop_38",
Expand Down Expand Up @@ -3853,7 +3853,7 @@
"burst": 0,
"clip_size": 4,
"reload": 100,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "arx160",
Expand Down Expand Up @@ -4209,7 +4209,7 @@
"burst" : 0,
"clip_size": 6,
"reload" : 130,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "colt_army",
Expand Down Expand Up @@ -4237,7 +4237,7 @@
"burst" : 0,
"clip_size": 5,
"reload" : 150,
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
"valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]]
},
{
"id": "rifle_flintlock",
Expand Down
12 changes: 8 additions & 4 deletions src/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,21 +1439,25 @@ void map::step_in_field(int x, int y)
} break;

case fd_acid:
//Acid deals damage at all levels now; the inside refers to inside a vehicle.
//TODO: Add resistance to this with rubber shoes or something?
if (cur->getFieldDensity() == 3 && !inside) {
// Assume vehicles block acid damage entirely,
// you're certainly not standing in it.
if (veh) {
break;
}
if (cur->getFieldDensity() == 3) {
add_msg(m_bad, _("The acid burns your legs and feet!"));
g->u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_ACID, rng( 4, 10 ) ) );
g->u.deal_damage( nullptr, bp_foot_r, damage_instance( DT_ACID, rng( 4, 10 ) ) );
g->u.deal_damage( nullptr, bp_leg_l, damage_instance( DT_ACID, rng( 2, 8 ) ) );
g->u.deal_damage( nullptr, bp_leg_r, damage_instance( DT_ACID, rng( 2, 8 ) ) );
} else if (cur->getFieldDensity() == 2 && !inside) {
} else if (cur->getFieldDensity() == 2) {
add_msg(m_bad, _("The acid burns your legs and feet!"));
g->u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_ACID, rng( 2, 5 ) ) );
g->u.deal_damage( nullptr, bp_foot_r, damage_instance( DT_ACID, rng( 2, 5 ) ) );
g->u.deal_damage( nullptr, bp_leg_l, damage_instance( DT_ACID, rng( 1, 4 ) ) );
g->u.deal_damage( nullptr, bp_leg_r, damage_instance( DT_ACID, rng( 1, 4 ) ) );
} else if (!inside) {
} else {
add_msg(m_bad, _("The acid burns your legs and feet!"));
g->u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_ACID, rng( 1, 3 ) ) );
g->u.deal_damage( nullptr, bp_foot_r, damage_instance( DT_ACID, rng( 1, 3 ) ) );
Expand Down
57 changes: 35 additions & 22 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3975,14 +3975,24 @@ void game::update_scent()
player_last_moved = calendar::turn;
}

// note: the next two intermediate variables need to be at least
// note: the next four intermediate matrices need to be at least
// [2*SCENT_RADIUS+3][2*SCENT_RADIUS+1] in size to hold enough data
// The code I'm modifying used [SEEX * MAPSIZE]. I'm staying with that to avoid new bugs.
int sum_3_scent_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable

// These two matrices are transposed so that x addresses are contiguous in memory
int sum_3_scent_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable
int squares_used_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable

bool has_wall_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // stash instead of
bool reduce_scent_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // checking 14884 * (3 redundant)
// these are for caching flag lookups
bool blocks_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // currently only TFLAG_WALL blocks scent
bool reduces_scent[SEEX * MAPSIZE][SEEY * MAPSIZE];


// for loop constants
const int scentmap_minx = u.posx - SCENT_RADIUS;
const int scentmap_maxx = u.posx + SCENT_RADIUS;
const int scentmap_miny = u.posy - SCENT_RADIUS;
const int scentmap_maxy = u.posy + SCENT_RADIUS;

const int diffusivity = 100; // decrease this to reduce gas spread. Keep it under 125 for
// stability. This is essentially a decimal number * 1000.
Expand All @@ -3997,27 +4007,27 @@ void game::update_scent()
// note: this method needs an array that is one square larger on each side in the x direction
// than the final scent matrix. I think this is fine since SCENT_RADIUS is less than
// SEEX*MAPSIZE, but if that changes, this may need tweaking.
for (int x = u.posx - SCENT_RADIUS - 1; x <= u.posx + SCENT_RADIUS + 1; x++) {
for (int y = u.posy - SCENT_RADIUS; y <= u.posy + SCENT_RADIUS; y++) {
for (int x = scentmap_minx - 1; x <= scentmap_maxx + 1; ++x) {
for (int y = scentmap_miny; y <= scentmap_maxy; ++y) {
// cache expensive flag checks, once per tile.
if (y == u.posy - SCENT_RADIUS) { // Setting y-1 y-0, when we are at the top row...
if (y == scentmap_miny) { // Setting y-1 y-0, when we are at the top row...
for (int i = y - 1; i <= y; ++i) {
has_wall_here[x][i] = m.has_flag(TFLAG_WALL, x, i);
reduce_scent_here[x][i] = m.has_flag(TFLAG_REDUCE_SCENT, x, i);
blocks_scent[x][i] = m.has_flag(TFLAG_WALL, x, i);
reduces_scent[x][i] = m.has_flag(TFLAG_REDUCE_SCENT, x, i);
}
}
has_wall_here[x][y + 1] = m.has_flag(TFLAG_WALL, x, y + 1); // ...so only y+1 here.
reduce_scent_here[x][y + 1] = m.has_flag(TFLAG_REDUCE_SCENT, x, y + 1);
blocks_scent[x][y + 1] = m.has_flag(TFLAG_WALL, x, y + 1); // ...so only y+1 here.
reduces_scent[x][y + 1] = m.has_flag(TFLAG_REDUCE_SCENT, x, y + 1);

// remember the sum of the scent val for the 3 neighboring squares that can defuse into
sum_3_scent_y[y][x] = 0;
squares_used_y[y][x] = 0;
for (int i = y - 1; i <= y + 1; ++i) {
if (has_wall_here[x][i] == false) {
if (reduce_scent_here[x][i] == true) {
if (not blocks_scent[x][i]) {
if (reduces_scent[x][i]) {
// only 20% of scent can diffuse on REDUCE_SCENT squares
sum_3_scent_y[y][x] += 2 * grscent[x][i];
squares_used_y[y][x] += 2; // only 20% diffuses into REDUCE_SCENT squares
squares_used_y[y][x] += 2;
} else {
sum_3_scent_y[y][x] += 10 * grscent[x][i];
squares_used_y[y][x] += 10;
Expand All @@ -4026,17 +4036,17 @@ void game::update_scent()
}
}
}
for (int x = u.posx - SCENT_RADIUS; x <= u.posx + SCENT_RADIUS; x++) {
for (int y = u.posy - SCENT_RADIUS; y <= u.posy + SCENT_RADIUS; y++) {
if (has_wall_here[x][y] == false) {
for (int x = scentmap_minx; x <= scentmap_maxx; ++x) {
for (int y = scentmap_miny; y <= scentmap_maxy; ++y) {
if (not blocks_scent[x][y]) {
// to how many neighboring squares do we diffuse out? (include our own square
// since we also include our own square when diffusing in)
int squares_used = squares_used_y[y][x - 1]
+ squares_used_y[y][x]
+ squares_used_y[y][x + 1];

int this_diffusivity;
if (reduce_scent_here[x][y] == false) {
if (not reduces_scent[x][y]) {
this_diffusivity = diffusivity;
} else {
this_diffusivity = diffusivity / 5; //less air movement for REDUCE_SCENT square
Expand All @@ -4049,9 +4059,12 @@ void game::update_scent()
// we've already summed neighboring scent values in the y direction in the previous
// loop. Now we do it for the x direction, multiply by diffusion, and this is what
// diffuses into our current square.
grscent[x][y] = (temp_scent + this_diffusivity *
(sum_3_scent_y[y][x - 1] + sum_3_scent_y[y][x] +
sum_3_scent_y[y][x + 1])) / (1000 * 10);
grscent[x][y] =
(temp_scent
+ this_diffusivity * (sum_3_scent_y[y][x - 1]
+ sum_3_scent_y[y][x]
+ sum_3_scent_y[y][x + 1])
) / (1000 * 10);


const int fslime = m.get_field_strength(point(x, y), fd_slime) * 10;
Expand All @@ -4064,7 +4077,7 @@ void game::update_scent()
debugmsg("Wacky scent at %d, %d (%d)", x, y, grscent[x][y]);
grscent[x][y] = 0; // Scent should never be higher
}
} else { // there is a wall here
} else { // this cell blocks scent
grscent[x][y] = 0;
}
}
Expand Down

0 comments on commit 86b0547

Please sign in to comment.