From c6c08cbcc41da83535dfc0899a986f93ce369404 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 01:58:45 -0700 Subject: [PATCH 01/42] Add intelligent danger avoidance --- src/field.cpp | 1 + src/monmove.cpp | 109 ++++++++++++++++++++++++++++++++++++--- src/monster.h | 4 ++ src/monstergenerator.cpp | 1 + src/mtype.h | 1 + 5 files changed, 109 insertions(+), 7 deletions(-) diff --git a/src/field.cpp b/src/field.cpp index c0ae7dd393a1..8061ad0ac6f6 100644 --- a/src/field.cpp +++ b/src/field.cpp @@ -38,6 +38,7 @@ field_t fieldlist[num_fields]; void game::init_fields() { + // ID, {name}, symbol, priority, {color}, {transparency}, {dangerous}, half-life, {move_cost} field_t tmp_fields[num_fields] = { { diff --git a/src/monmove.cpp b/src/monmove.cpp index 806f8c635e4c..12feda6bd506 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -26,6 +26,8 @@ #define MONSTER_FOLLOW_DIST 8 +const species_id FUNGUS( "FUNGUS" ); + const efftype_id effect_bouldering( "bouldering" ); const efftype_id effect_docile( "docile" ); const efftype_id effect_downed( "downed" ); @@ -38,6 +40,64 @@ bool monster::wander() return ( goal == pos() ); } +bool monster::is_dangerous_field( const field &fd ) const +{ + if( fd.fieldCount() == 0 ) { + return false; + } + + for( auto &fld : fd ) { + if( is_dangerous_field( fld.second ) ) { + return true; + } + } + + return false; +} + +bool monster::is_dangerous_field( const field_entry &entry ) const +{ + const field_id fid = entry.getFieldType(); + switch( fid ) { + case fd_smoke: + case fd_tear_gas: + case fd_toxic_gas: + case fd_relax_gas: + case fd_nuke_gas: + if (has_flag( MF_NO_BREATHE )) { + return false; + } + break; + case fd_acid: + if (has_flag( MF_ACIDPROOF) || has_flag( MF_FLIES)) { + return false; + } + break; + case fd_fire: + if (has_flag( MF_FIREPROOF )) { + return false; + } + break; + case fd_electricity: + if (has_flag( MF_ELECTRIC)) { + return false; + } + break; + case fd_fungal_haze: + if (has_flag( MF_NO_BREATHE ) || type->in_species(FUNGUS)) { + return false; + } + break; + case fd_fungicidal_gas: + if (!type->in_species(FUNGUS)) { + return false; + } + default: + return entry.is_dangerous(); + } + return entry.is_dangerous(); +} + bool monster::can_move_to( const tripoint &p ) const { const bool can_climb = has_flag( MF_CLIMBS ) || has_flag( MF_FLIES ); @@ -89,6 +149,41 @@ bool monster::can_move_to( const tripoint &p ) const } } + if (has_flag( MF_INTELLIGENT_PATHS)) { + // Don't enter sharp terrain unless tiny, or attacking + if( g->m.has_flag( "SHARP", p ) && !( attitude( &( g->u ) ) == MATT_ATTACK || + type->size == MS_TINY || has_flag( MF_FLIES ) ) ) { + return false; + } + + // Don't enter open pits ever unless tiny, can fly or climb well + if( !( type->size == MS_TINY || can_climb ) && + ( g->m.ter( p ) == t_pit || g->m.ter( p ) == t_pit_spiked || g->m.ter( p ) == t_pit_glass ) ) { + return false; + } + + // Don't enter lava ever + if( g->m.ter( p ) == t_lava ) { + return false; + } + + // Don't enter any dangerous fields + const field &local_field = g->m.field_at( p ); + if (is_dangerous_field( local_field )) { + return false; + } + + // And don't step on any traps (if we can see) + const trap &tr = g->m.tr_at( p ); + if (has_flag( MF_SEES ) && !tr.is_benign() && g->m.has_floor( p )) { + return false; + } + + if( g->m.has_flag( TFLAG_NO_FLOOR, p ) && !has_flag( MF_FLIES ) ) { + return false; + } + } + return true; } @@ -147,10 +242,10 @@ float monster::rate_target( Creature &c, float best, bool smart ) const void monster::plan( const mfactions &factions ) { // Bots are more intelligent than most living stuff - bool electronic = has_flag( MF_ELECTRONIC ); + bool smart_planning = has_flag( MF_ELECTRONIC ) || has_flag( MF_INTELLIGENT_PATHS ); Creature *target = nullptr; // 8.6f is rating for tank drone 60 tiles away, moose 16 or boomer 33 - float dist = !electronic ? 1000 : 8.6f; + float dist = !smart_planning ? 1000 : 8.6f; bool fleeing = false; bool docile = friendly != 0 && has_effect( effect_docile ); bool angers_hostile_weak = type->anger.find( MTRIG_HOSTILE_WEAK ) != type->anger.end(); @@ -162,7 +257,7 @@ void monster::plan( const mfactions &factions ) // If we can see the player, move toward them or flee. if( friendly == 0 && sees( g->u ) ) { - dist = rate_target( g->u, dist, electronic ); + dist = rate_target( g->u, dist, smart_planning ); fleeing = fleeing || is_fleeing( g->u ); target = &g->u; if( dist <= 5 ) { @@ -174,7 +269,7 @@ void monster::plan( const mfactions &factions ) for( int i = 0, numz = g->num_zombies(); i < numz; i++ ) { monster &tmp = g->zombie( i ); if( tmp.friendly == 0 ) { - float rating = rate_target( tmp, dist, electronic ); + float rating = rate_target( tmp, dist, smart_planning ); if( rating < dist ) { target = &tmp; dist = rating; @@ -193,7 +288,7 @@ void monster::plan( const mfactions &factions ) for( size_t i = 0; i < g->active_npc.size(); i++ ) { npc *me = g->active_npc[i]; - float rating = rate_target( *me, dist, electronic ); + float rating = rate_target( *me, dist, smart_planning ); bool fleeing_from = is_fleeing( *me ); // Switch targets if closer and hostile or scarier than current target if( ( rating < dist && fleeing ) || @@ -219,7 +314,7 @@ void monster::plan( const mfactions &factions ) for( int i : fac.second ) { // mon indices monster &mon = g->zombie( i ); - float rating = rate_target( mon, dist, electronic ); + float rating = rate_target( mon, dist, smart_planning ); if( rating < dist ) { target = &mon; dist = rating; @@ -246,7 +341,7 @@ void monster::plan( const mfactions &factions ) if( group_morale || swarms ) { for( const int i : myfaction_iter->second ) { monster &mon = g->zombie( i ); - float rating = rate_target( mon, dist, electronic ); + float rating = rate_target( mon, dist, smart_planning ); if( group_morale && rating <= 10 ) { morale += 10 - rating; } diff --git a/src/monster.h b/src/monster.h index 64f66ef08231..fd86636540ec 100644 --- a/src/monster.h +++ b/src/monster.h @@ -4,6 +4,7 @@ #include "creature.h" #include "enums.h" #include "int_id.h" +#include "field.h" #include class map; @@ -164,6 +165,9 @@ class monster : public Creature, public JsonSerializer, public JsonDeserializer int calc_movecost( const tripoint &f, const tripoint &t ) const; int calc_climb_cost( const tripoint &f, const tripoint &t ) const; + bool is_dangerous_field( const field &fld ) const; + bool is_dangerous_field( const field_entry &entry ) const; + /** * Attempt to move to p. * diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 6da152080b8c..71043daaab96 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -399,6 +399,7 @@ void MonsterGenerator::init_flags() flag_map["REVIVES_HEALTHY"] = MF_REVIVES_HEALTHY; flag_map["NO_NECRO"] = MF_NO_NECRO; flag_map["PUSH_MON"] = MF_PUSH_MON; + flag_map["INTELLIGENT_PATHS"] = MF_INTELLIGENT_PATHS; } void MonsterGenerator::set_species_ids( mtype &mon ) diff --git a/src/mtype.h b/src/mtype.h index 47373aab517c..ed88bd6573f2 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -148,6 +148,7 @@ enum m_flag : int { MF_NIGHT_INVISIBILITY, // Monsters that are invisible in poor light conditions MF_REVIVES_HEALTHY, // When revived, this monster has full hitpoints and speed MF_NO_NECRO, // This monster can't be revived by necros. It will still rise on its own. + MF_INTELLIGENT_PATHS, // This monster will path around dangers instead of through them. MF_MAX // Sets the length of the flags - obviously must be LAST }; From 1a4cb900c38fdaedc2e24a6064016acf830a9722 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 01:59:18 -0700 Subject: [PATCH 02/42] Clean up some unreachable code --- src/character.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index d07a90c6a782..1015cf4d0bb4 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1861,8 +1861,6 @@ bool Character::is_dangerous_field( const field_entry &entry ) const default: return !has_trait( debug_nodmg ) && entry.is_dangerous(); } - - return false; } bool Character::is_dangerous_field( const field_id fid ) const @@ -1899,8 +1897,6 @@ bool Character::is_dangerous_field( const field_id fid ) const default: return field_type_dangerous( fid ); } - - return false; } int Character::throw_range( const item &it ) const From 6e32081558a738a5398bd34a41a075fb43b7a193 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 01:59:30 -0700 Subject: [PATCH 03/42] Add Intelligent pathing to monsters --- data/json/monsters.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/data/json/monsters.json b/data/json/monsters.json index 47897c6cd36c..972f1aefa42c 100755 --- a/data/json/monsters.json +++ b/data/json/monsters.json @@ -2681,7 +2681,7 @@ "death_function":["NORMAL"], "special_attacks":[["RESURRECT", 0]], "description":"A twisted mockery of the human form, emaciated, with jet black skin and glowing red eyes. It is somehow painful to look at, awakening fears deep within your psyche, and even the air around it seems more sinister, somehow darker and more dangerous.", - "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES"], + "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "INTELLIGENT_PATHS"], "anger_triggers":["HURT", "PLAYER_CLOSE", "PLAYER_WEAK"] },{ "type" : "MONSTER", @@ -2713,7 +2713,7 @@ "special_attacks":[["SCIENCE", 20]], "starting_ammo" : { "bot_manhack": 3 }, "description":"Apart from the jet black eyes it would be easy to believe this scientist was still alive. Clad in a tattered lab coat, it looks to have some measure of situational awareness and resourcefulness.", - "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "BLEED", "CBM_SCI", "ACIDPROOF", "NO_BREATHE", "REVIVES", "BONES", "PUSH_MON"] + "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "BLEED", "CBM_SCI", "ACIDPROOF", "NO_BREATHE", "REVIVES", "BONES", "PUSH_MON", "INTELLIGENT_PATHS"] },{ "type" : "MONSTER", "id" : "mon_zombie_soldier", @@ -2971,7 +2971,7 @@ "death_function":["NORMAL"], "special_attacks":[["UPGRADE", 10]], "description":"Once human, its features have tightened, its lips pulled back into an unnatural grin, revealing rows of blackened teeth beneath its large, piercing eyes. It stands tall and its movements are fluid and tightly controlled. A feeling of danger permeates the air around it, and the light that falls on it seems somehow harsher and more glaring.", - "flags":["SEES", "HEARS", "SMELLS", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES"], + "flags":["SEES", "HEARS", "SMELLS", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "INTELLIGENT_PATHS"], "anger_triggers":["HURT", "PLAYER_CLOSE", "PLAYER_WEAK"] },{ "type" : "MONSTER", @@ -4940,7 +4940,7 @@ "death_function":"NORMAL", "special_attacks":[["PARROT", 0]], "description":"A flexuous monstrosity seeming as a giant crab covered in writhing antennae, clawed tentacles, and star-shaped growths, with a head like the insides of a fish but for its dire utterance.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "POISON", "NO_BREATHE", "ARTHROPOD_BLOOD", "FAT"] + "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "POISON", "NO_BREATHE", "ARTHROPOD_BLOOD", "FAT", "INTELLIGENT_PATHS"] },{ "type" : "MONSTER", "id" : "mon_yugg", @@ -5073,7 +5073,7 @@ "hp":100, "death_function":"NORMAL", "description":"A bizarre humanoid creature with a calculating stare. Its twitching hands move so fast they appear to be nothing but blurs.", - "flags":["SMELLS", "HEARS", "WARM", "NO_BREATHE", "GRABS", "BONES"] + "flags":["SMELLS", "HEARS", "WARM", "NO_BREATHE", "GRABS", "BONES", "INTELLIGENT_PATHS"] },{ "type" : "MONSTER", "id" : "mon_blank", @@ -5127,7 +5127,7 @@ "death_function":"NORMAL", "special_attacks":[["FEAR_PARALYZE", 20]], "description":"A monster with an obese human body and the head of a cow. It treads slowly, and milky white drool drips from its mouth.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "GROUP_BASH", "ANIMAL", "FUR", "NO_BREATHE", "BONES", "FAT"] + "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "GROUP_BASH", "ANIMAL", "FUR", "NO_BREATHE", "BONES", "FAT", "INTELLIGENT_PATHS"] },{ "type" : "MONSTER", "id" : "mon_shadow", @@ -6308,7 +6308,7 @@ "death_function":"NORMAL", "special_attacks":[["BRANDISH", 10]], "description":"Living in the woods, \nkilling for sport, \neating all the bodies, \nactual cannibal Shia LaBeouf.", - "flags":["SEES", "HEARS", "WARM", "BASHES", "POISON", "BONES", "BLEED", "NO_BREATHE"], + "flags":["SEES", "HEARS", "WARM", "BASHES", "POISON", "BONES", "BLEED", "NO_BREATHE", "INTELLIGENT_PATHS"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT", "PLAYER_CLOSE"], "fear_triggers":["FIRE"] },{ From 69d615b81281a650597a5a3cdeed16dc7101186d Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 02:08:28 -0700 Subject: [PATCH 04/42] Small logic cleanup. --- src/monmove.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index 12feda6bd506..7e47d7695123 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -42,10 +42,12 @@ bool monster::wander() bool monster::is_dangerous_field( const field &fd ) const { + // No fields = not dangerous (obviously) if( fd.fieldCount() == 0 ) { return false; } + // Else check each field to see if it's dangerous to us for( auto &fld : fd ) { if( is_dangerous_field( fld.second ) ) { return true; @@ -58,6 +60,7 @@ bool monster::is_dangerous_field( const field &fd ) const bool monster::is_dangerous_field( const field_entry &entry ) const { const field_id fid = entry.getFieldType(); + // Check immunity towards fields switch( fid ) { case fd_smoke: case fd_tear_gas: @@ -93,8 +96,10 @@ bool monster::is_dangerous_field( const field_entry &entry ) const return false; } default: - return entry.is_dangerous(); + // Suppress warning + break; } + // If we weren't immune to anything return the field's danger level. return entry.is_dangerous(); } From baf9dd5cb802ee80fd0cd609a441738e8a4f755d Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 03:02:47 -0700 Subject: [PATCH 05/42] Cache g->m.ter(p) --- src/monmove.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index 7e47d7695123..efc095e58e41 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -124,6 +124,7 @@ bool monster::can_move_to( const tripoint &p ) const return false; } + ter_id target = g->m.ter(p); // various animal behaviours if( has_flag( MF_ANIMAL ) ) { // don't enter sharp terrain unless tiny, or attacking @@ -134,12 +135,12 @@ bool monster::can_move_to( const tripoint &p ) const // Don't enter open pits ever unless tiny, can fly or climb well if( !( type->size == MS_TINY || can_climb ) && - ( g->m.ter( p ) == t_pit || g->m.ter( p ) == t_pit_spiked || g->m.ter( p ) == t_pit_glass ) ) { + ( target == t_pit || target == t_pit_spiked || target == t_pit_glass ) ) { return false; } // don't enter lava ever - if( g->m.ter( p ) == t_lava ) { + if( target == t_lava ) { return false; } @@ -163,12 +164,12 @@ bool monster::can_move_to( const tripoint &p ) const // Don't enter open pits ever unless tiny, can fly or climb well if( !( type->size == MS_TINY || can_climb ) && - ( g->m.ter( p ) == t_pit || g->m.ter( p ) == t_pit_spiked || g->m.ter( p ) == t_pit_glass ) ) { + ( target == t_pit || target == t_pit_spiked || target == t_pit_glass ) ) { return false; } // Don't enter lava ever - if( g->m.ter( p ) == t_lava ) { + if( target == t_lava ) { return false; } From 74b4ff495a2550a16ca84fc26373a16ef6dc04cb Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 03:03:30 -0700 Subject: [PATCH 06/42] Inline variables --- src/monmove.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index efc095e58e41..9cbda788a379 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -174,14 +174,12 @@ bool monster::can_move_to( const tripoint &p ) const } // Don't enter any dangerous fields - const field &local_field = g->m.field_at( p ); - if (is_dangerous_field( local_field )) { + if (is_dangerous_field( g->m.field_at( p ) )) { return false; } // And don't step on any traps (if we can see) - const trap &tr = g->m.tr_at( p ); - if (has_flag( MF_SEES ) && !tr.is_benign() && g->m.has_floor( p )) { + if (has_flag( MF_SEES ) && !g->m.tr_at( p ).is_benign() && g->m.has_floor( p )) { return false; } From 44ea4d495b09ca75d9766d9b4fd017b88f1a16d7 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 18:44:05 -0700 Subject: [PATCH 07/42] Field logic cleanup and generalization --- src/character.cpp | 75 ++++++++++++++--------------------------------- src/character.h | 4 +-- src/creature.cpp | 24 +++++++++++++++ src/creature.h | 13 ++++++++ src/game.cpp | 2 +- src/monmove.cpp | 58 +++++++----------------------------- src/monster.h | 3 +- src/npcmove.cpp | 7 +++-- 8 files changed, 77 insertions(+), 109 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 1015cf4d0bb4..9530903b4812 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1829,74 +1829,43 @@ nc_color Character::symbol_color() const return basic; } -bool Character::is_dangerous_field( const field &fd ) const -{ - if( fd.fieldCount() == 0 || has_trait( debug_nodmg ) ) { - return false; - } - - for( auto &fld : fd ) { - if( is_dangerous_field( fld.second ) ) { - return true; - } - } - - return false; -} - -bool Character::is_dangerous_field( const field_entry &entry ) const -{ - const field_id fid = entry.getFieldType(); - switch( fid ) { - // @todo Lower density fields are less dangerous - case fd_smoke: - case fd_tear_gas: - case fd_toxic_gas: - case fd_gas_vent: - case fd_relax_gas: - case fd_fungal_haze: - case fd_electricity: - case fd_acid: - return is_dangerous_field( fid ); - default: - return !has_trait( debug_nodmg ) && entry.is_dangerous(); - } -} - -bool Character::is_dangerous_field( const field_id fid ) const +bool Character::is_immune_field( const field_id fid ) const { + // Obviously this makes us invincible if( has_trait( debug_nodmg ) ) { - return false; + return true; } + // Check to see if we are immune switch( fid ) { case fd_smoke: - return get_env_resist( bp_mouth ) < 12; + return get_env_resist( bp_mouth ) >= 12; case fd_tear_gas: case fd_toxic_gas: case fd_gas_vent: case fd_relax_gas: - return get_env_resist( bp_mouth ) < 15; + return get_env_resist( bp_mouth ) >= 15; case fd_fungal_haze: - return get_env_resist( bp_mouth ) < 15 || - get_env_resist( bp_eyes ) < 15 || - has_trait("M_IMMUNE"); + return has_trait("M_IMMUNE") || (get_env_resist( bp_mouth ) >= 15 && + get_env_resist( bp_eyes ) >= 15); case fd_electricity: - return !is_elec_immune(); + return is_elec_immune(); case fd_acid: - return !has_trait("ACIDPROOF") && - (is_on_ground() || - get_env_resist( bp_foot_l ) < 15 || - get_env_resist( bp_foot_r ) < 15 || - get_env_resist( bp_leg_l ) < 15 || - get_env_resist( bp_leg_r ) < 15 || - get_armor_type( DT_ACID, bp_foot_l ) < 5 || - get_armor_type( DT_ACID, bp_foot_r ) < 5 || - get_armor_type( DT_ACID, bp_leg_l ) < 5 || - get_armor_type( DT_ACID, bp_leg_r ) < 5); + return has_trait("ACIDPROOF") || + (!is_on_ground() && get_env_resist( bp_foot_l ) >= 15 && + get_env_resist( bp_foot_r ) >= 15 && + get_env_resist( bp_leg_l ) >= 15 && + get_env_resist( bp_leg_r ) >= 15 && + get_armor_type( DT_ACID, bp_foot_l ) >= 5 && + get_armor_type( DT_ACID, bp_foot_r ) >= 5 && + get_armor_type( DT_ACID, bp_leg_l ) >= 5 && + get_armor_type( DT_ACID, bp_leg_r ) >= 5); default: - return field_type_dangerous( fid ); + // Suppress warning + break; } + // If we haven't found immunity yet fall up to the next level + return Creature::is_immune_field(fid); } int Character::throw_range( const item &it ) const diff --git a/src/character.h b/src/character.h index 71b32fbea630..1828c64e5c43 100644 --- a/src/character.h +++ b/src/character.h @@ -459,9 +459,7 @@ class Character : public Creature, public visitable */ virtual bool query_yn( const char *mes, ... ) const = 0; - bool is_dangerous_field( const field &fld ) const; - bool is_dangerous_field( const field_entry &entry ) const; - bool is_dangerous_field( const field_id fid ) const; + virtual bool is_immune_field( const field_id fid ) const; /** Returns true if the player has some form of night vision */ bool has_nv(); diff --git a/src/creature.cpp b/src/creature.cpp index 1edbbfc10d6f..350bed4c7b0b 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -156,6 +156,30 @@ bool Creature::digging() const return false; } + +bool Creature::is_dangerous_fields( const field &fld ) const +{ + // Can't be dangerous if there are no fields there + if( fld.fieldCount() == 0 ) { + return false; + } + + // Else check each field to see if it's dangerous to us + for( auto &dfield : fld ) { + if( is_dangerous_field( dfield.second ) ) { + return true; + } + } + // No fields were found to be dangerous, so the field set isn't dangerous + return false; +} + +bool Creature::is_dangerous_field( const field_entry &entry ) const +{ + // If it's dangerous and we're not immune return true, else return false + return entry.is_dangerous() && !is_immune_field(entry.getFieldType()); +} + bool Creature::sees( const Creature &critter ) const { if( critter.is_hallucination() ) { diff --git a/src/creature.h b/src/creature.h index 9eb51591e831..efe9857ab7b0 100644 --- a/src/creature.h +++ b/src/creature.h @@ -8,6 +8,7 @@ #include "output.h" #include "string_id.h" #include "cursesdef.h" // WINDOW +#include "field.h" #include #include @@ -242,6 +243,18 @@ class Creature virtual bool is_immune_effect( const efftype_id &type ) const = 0; virtual bool is_immune_damage( const damage_type type ) const = 0; + // Field dangers + /** Returns true if there is a field in the field set that is dangerous to us. */ + bool is_dangerous_fields( const field &fld ) const; + /** Returns true if the given field entry is dangerous to us. */ + bool is_dangerous_field( const field_entry &entry ) const; + /** Returns true if we are immune to the field type with the given fid. Does not + * handle density, so this function should only be called through is_dangerous_field(). + */ + virtual bool is_immune_field( const field_id ) const { + return false; + }; + /** Returns multiplier on fall damage at low velocity (knockback/pit/1 z-level, not 5 z-levels) */ virtual float fall_damage_mod() const = 0; /** Deals falling/collision damage with terrain/creature at pos */ diff --git a/src/game.cpp b/src/game.cpp index 3e16a26b3f4c..3caee17c4c25 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -13430,7 +13430,7 @@ void game::vertical_move(int movez, bool force) for( npc *np : npcs_to_bring ) { const auto found = std::find_if( candidates.begin(), candidates.end(), [this, np]( const tripoint &c ) { - return !np->is_dangerous_field( m.field_at( c ) ) && m.tr_at( c ).is_benign(); + return !np->is_dangerous_fields( m.field_at( c ) ) && m.tr_at( c ).is_benign(); } ); if( found != candidates.end() ) { diff --git a/src/monmove.cpp b/src/monmove.cpp index 9cbda788a379..2c186b7b4feb 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -40,67 +40,31 @@ bool monster::wander() return ( goal == pos() ); } -bool monster::is_dangerous_field( const field &fd ) const +bool monster::is_immune_field( const field_id fid ) const { - // No fields = not dangerous (obviously) - if( fd.fieldCount() == 0 ) { - return false; - } - - // Else check each field to see if it's dangerous to us - for( auto &fld : fd ) { - if( is_dangerous_field( fld.second ) ) { - return true; - } - } - - return false; -} - -bool monster::is_dangerous_field( const field_entry &entry ) const -{ - const field_id fid = entry.getFieldType(); - // Check immunity towards fields - switch( fid ) { + switch (fid) { case fd_smoke: case fd_tear_gas: case fd_toxic_gas: case fd_relax_gas: case fd_nuke_gas: - if (has_flag( MF_NO_BREATHE )) { - return false; - } - break; + return has_flag(MF_NO_BREATHE); case fd_acid: - if (has_flag( MF_ACIDPROOF) || has_flag( MF_FLIES)) { - return false; - } - break; + return has_flag(MF_ACIDPROOF) || has_flag(MF_FLIES); case fd_fire: - if (has_flag( MF_FIREPROOF )) { - return false; - } - break; + return has_flag(MF_FIREPROOF); case fd_electricity: - if (has_flag( MF_ELECTRIC)) { - return false; - } - break; + return has_flag(MF_ELECTRIC); case fd_fungal_haze: - if (has_flag( MF_NO_BREATHE ) || type->in_species(FUNGUS)) { - return false; - } - break; + return has_flag(MF_NO_BREATHE) || type->in_species(FUNGUS); case fd_fungicidal_gas: - if (!type->in_species(FUNGUS)) { - return false; - } + return !type->in_species(FUNGUS); default: // Suppress warning break; } - // If we weren't immune to anything return the field's danger level. - return entry.is_dangerous(); + // No specific immunity was found, so fall upwards + return Creature::is_immune_field(fid); } bool monster::can_move_to( const tripoint &p ) const @@ -174,7 +138,7 @@ bool monster::can_move_to( const tripoint &p ) const } // Don't enter any dangerous fields - if (is_dangerous_field( g->m.field_at( p ) )) { + if (is_dangerous_fields( g->m.field_at( p ) )) { return false; } diff --git a/src/monster.h b/src/monster.h index fd86636540ec..955df39773c0 100644 --- a/src/monster.h +++ b/src/monster.h @@ -165,8 +165,7 @@ class monster : public Creature, public JsonSerializer, public JsonDeserializer int calc_movecost( const tripoint &f, const tripoint &t ) const; int calc_climb_cost( const tripoint &f, const tripoint &t ) const; - bool is_dangerous_field( const field &fld ) const; - bool is_dangerous_field( const field_entry &entry ) const; + virtual bool is_immune_field( const field_id fid ) const; /** * Attempt to move to p. diff --git a/src/npcmove.cpp b/src/npcmove.cpp index d9aca5e8b7b1..e8c1501443e4 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -107,7 +107,7 @@ bool clear_shot_reach( const tripoint &from, const tripoint &to ) bool npc::sees_dangerous_field( const tripoint &p ) const { - return is_dangerous_field( g->m.field_at( p ) ); + return is_dangerous_fields( g->m.field_at( p ) ); } bool npc::could_move_onto( const tripoint &p ) const @@ -2012,8 +2012,9 @@ bool npc::find_corpse_to_pulp() // Pulp only stuff that revives, but don't pulp acid stuff // That is, if you aren't protected from this stuff! if( it.can_revive() ) { - // If the first encountered corpse is acidic, it is not safe to bash - if( is_dangerous_field( it.get_mtype()->bloodType() ) ) { + // If the first encountered corpse bleeds something dangerous then + // it is not safe to bash. + if( is_dangerous_field( field_entry(it.get_mtype()->bloodType(), 1, 0) ) ) { return nullptr; } From b5e8a02e8a7ceca26879cc1d5bd822dfca42a112 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Fri, 20 May 2016 19:03:41 -0700 Subject: [PATCH 08/42] Split out path and prioritization functions --- data/json/monsters.json | 30 +++++++++++++++--------------- src/monmove.cpp | 4 ++-- src/monstergenerator.cpp | 3 ++- src/mtype.h | 3 ++- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/data/json/monsters.json b/data/json/monsters.json index 972f1aefa42c..efd01a76de73 100755 --- a/data/json/monsters.json +++ b/data/json/monsters.json @@ -2681,7 +2681,7 @@ "death_function":["NORMAL"], "special_attacks":[["RESURRECT", 0]], "description":"A twisted mockery of the human form, emaciated, with jet black skin and glowing red eyes. It is somehow painful to look at, awakening fears deep within your psyche, and even the air around it seems more sinister, somehow darker and more dangerous.", - "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "INTELLIGENT_PATHS"], + "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"], "anger_triggers":["HURT", "PLAYER_CLOSE", "PLAYER_WEAK"] },{ "type" : "MONSTER", @@ -2713,7 +2713,7 @@ "special_attacks":[["SCIENCE", 20]], "starting_ammo" : { "bot_manhack": 3 }, "description":"Apart from the jet black eyes it would be easy to believe this scientist was still alive. Clad in a tattered lab coat, it looks to have some measure of situational awareness and resourcefulness.", - "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "BLEED", "CBM_SCI", "ACIDPROOF", "NO_BREATHE", "REVIVES", "BONES", "PUSH_MON", "INTELLIGENT_PATHS"] + "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "BLEED", "CBM_SCI", "ACIDPROOF", "NO_BREATHE", "REVIVES", "BONES", "PUSH_MON", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_zombie_soldier", @@ -2971,7 +2971,7 @@ "death_function":["NORMAL"], "special_attacks":[["UPGRADE", 10]], "description":"Once human, its features have tightened, its lips pulled back into an unnatural grin, revealing rows of blackened teeth beneath its large, piercing eyes. It stands tall and its movements are fluid and tightly controlled. A feeling of danger permeates the air around it, and the light that falls on it seems somehow harsher and more glaring.", - "flags":["SEES", "HEARS", "SMELLS", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "INTELLIGENT_PATHS"], + "flags":["SEES", "HEARS", "SMELLS", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"], "anger_triggers":["HURT", "PLAYER_CLOSE", "PLAYER_WEAK"] },{ "type" : "MONSTER", @@ -4940,7 +4940,7 @@ "death_function":"NORMAL", "special_attacks":[["PARROT", 0]], "description":"A flexuous monstrosity seeming as a giant crab covered in writhing antennae, clawed tentacles, and star-shaped growths, with a head like the insides of a fish but for its dire utterance.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "POISON", "NO_BREATHE", "ARTHROPOD_BLOOD", "FAT", "INTELLIGENT_PATHS"] + "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "POISON", "NO_BREATHE", "ARTHROPOD_BLOOD", "FAT", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_yugg", @@ -5073,7 +5073,7 @@ "hp":100, "death_function":"NORMAL", "description":"A bizarre humanoid creature with a calculating stare. Its twitching hands move so fast they appear to be nothing but blurs.", - "flags":["SMELLS", "HEARS", "WARM", "NO_BREATHE", "GRABS", "BONES", "INTELLIGENT_PATHS"] + "flags":["SMELLS", "HEARS", "WARM", "NO_BREATHE", "GRABS", "BONES", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_blank", @@ -5127,7 +5127,7 @@ "death_function":"NORMAL", "special_attacks":[["FEAR_PARALYZE", 20]], "description":"A monster with an obese human body and the head of a cow. It treads slowly, and milky white drool drips from its mouth.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "GROUP_BASH", "ANIMAL", "FUR", "NO_BREATHE", "BONES", "FAT", "INTELLIGENT_PATHS"] + "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "GROUP_BASH", "ANIMAL", "FUR", "NO_BREATHE", "BONES", "FAT", "PATH_AVOID_DANGER"] },{ "type" : "MONSTER", "id" : "mon_shadow", @@ -5471,7 +5471,7 @@ "death_function":"BROKEN", "special_attacks":[["PHOTOGRAPH", 30]], "description":"A fusion-driven UAV largely comprised of a high-resolution camera lens, this spheroid robot hovers above the ground, silent witness to the carnage and mayhem around it.", - "flags":["SEES", "FLIES", "ELECTRONIC", "NO_BREATHE", "NOHEAD"] + "flags":["SEES", "FLIES", "ELECTRONIC", "NO_BREATHE", "NOHEAD", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_manhack", @@ -5786,7 +5786,7 @@ "hp":120, "death_function":"EXPLODE", "description":"The Ford Sanitron, a utility robot designed for cleaning up waste material in hazardous conditions.", - "flags":["SEES", "HEARS", "BASHES", "ELECTRONIC", "NO_BREATHE"] + "flags":["SEES", "HEARS", "BASHES", "ELECTRONIC", "NO_BREATHE", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_copbot", @@ -5819,7 +5819,7 @@ "death_function":"BROKEN", "special_attacks":[["COPBOT", 3]], "description":"One of the many models of armored law enforcement robots employed shortly before the collapse of civilization. Solar powered like many other robots, it maintains its programmed pursuit of law and order, propelled on a trio of omni wheels.", - "flags":["SEES", "HEARS", "BASHES", "ELECTRONIC", "NO_BREATHE"] + "flags":["SEES", "HEARS", "BASHES", "ELECTRONIC", "NO_BREATHE", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_molebot", @@ -5882,7 +5882,7 @@ "death_function":"BROKEN", "special_attacks":[["FLAMETHROWER", 10]], "description":"The Honda Regnal, a tall robot walking on three spidery legs. For weapons, it has a trio of spiked retractable cables and a flamethrower mounted on its head.", - "flags":["SEES", "HEARS", "GOODHEARING", "BASHES", "NO_BREATHE", "ELECTRONIC", "CLIMBS"] + "flags":["SEES", "HEARS", "GOODHEARING", "BASHES", "NO_BREATHE", "ELECTRONIC", "CLIMBS", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_chickenbot", @@ -5916,7 +5916,7 @@ "special_attacks":[["CHICKENBOT", 4]], "starting_ammo" : {"556":1000, "40mm_frag":100}, "description":"The Northrup ATSV, a massive, heavily-armed and armored robot walking on a pair of reverse-jointed legs. Armed with a 40mm anti-vehicle grenade launcher, 5.56 anti-personnel gun, and the ability to electrify itself against attackers, it is an effective automated sentry, though production was limited due to a legal dispute.", - "flags":["SEES", "HEARS", "BASHES", "NO_BREATHE", "ELECTRONIC"] + "flags":["SEES", "HEARS", "BASHES", "NO_BREATHE", "ELECTRONIC", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_tankbot", @@ -5950,7 +5950,7 @@ "special_attacks":[["MULTI_ROBOT", 3]], "starting_ammo" : {"556":1000, "40mm_frag":100, "120mm_HEAT":40}, "description":"The Northrup Emancipator is the first and only automated tank ever produced, made shortly after the split-up of Northrup Grumman. Clad in depleted uranium plating, and armed with advanced munitions and a 120-mm gun, it is capable of delivering extraordinary firepower.", - "flags":["SEES", "HEARS", "GOODHEARING", "NOHEAD", "BASHES", "DESTROYS", "NO_BREATHE", "ELECTRONIC"] + "flags":["SEES", "HEARS", "GOODHEARING", "NOHEAD", "BASHES", "DESTROYS", "NO_BREATHE", "ELECTRONIC", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_turret_searchlight", @@ -5983,7 +5983,7 @@ "death_function":"FOCUSEDBEAM", "special_attacks":[["SEARCHLIGHT", 1]], "description":"Three high-powered searchlights with automated search AI and mounting, continually seeking targets.", - "flags":["SEES", "NOHEAD", "ELECTRONIC", "IMMOBILE", "NO_BREATHE"] + "flags":["SEES", "NOHEAD", "ELECTRONIC", "IMMOBILE", "NO_BREATHE", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_exploder", @@ -6308,7 +6308,7 @@ "death_function":"NORMAL", "special_attacks":[["BRANDISH", 10]], "description":"Living in the woods, \nkilling for sport, \neating all the bodies, \nactual cannibal Shia LaBeouf.", - "flags":["SEES", "HEARS", "WARM", "BASHES", "POISON", "BONES", "BLEED", "NO_BREATHE", "INTELLIGENT_PATHS"], + "flags":["SEES", "HEARS", "WARM", "BASHES", "POISON", "BONES", "BLEED", "NO_BREATHE", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT", "PLAYER_CLOSE"], "fear_triggers":["FIRE"] },{ @@ -6649,7 +6649,7 @@ "death_function":"BROKEN", "special_attacks":[["RIOTBOT", 1]], "description":"Nonviolent riot-control bot. Designed to suppress riots and make mass arrests of those participating. Though its relaxation gas is by far its best-known weapon, it carries a blinding flash and a low-powered stungun for self-defense--in addition to its supply of electronic handcuffs.", - "flags":["SEES", "HEARS", "GOODHEARING", "ELECTRONIC", "NO_BREATHE"] + "flags":["SEES", "HEARS", "GOODHEARING", "ELECTRONIC", "NO_BREATHE", "PRIORITIZE_TARGETS"] }, { "type" : "MONSTER", "id" : "mon_zombie_technician", diff --git a/src/monmove.cpp b/src/monmove.cpp index 2c186b7b4feb..699e704efd46 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -119,7 +119,7 @@ bool monster::can_move_to( const tripoint &p ) const } } - if (has_flag( MF_INTELLIGENT_PATHS)) { + if (has_flag( MF_PATH_AVOID_DANGER)) { // Don't enter sharp terrain unless tiny, or attacking if( g->m.has_flag( "SHARP", p ) && !( attitude( &( g->u ) ) == MATT_ATTACK || type->size == MS_TINY || has_flag( MF_FLIES ) ) ) { @@ -210,7 +210,7 @@ float monster::rate_target( Creature &c, float best, bool smart ) const void monster::plan( const mfactions &factions ) { // Bots are more intelligent than most living stuff - bool smart_planning = has_flag( MF_ELECTRONIC ) || has_flag( MF_INTELLIGENT_PATHS ); + bool smart_planning = has_flag( MF_PRIORITIZE_TARGETS ); Creature *target = nullptr; // 8.6f is rating for tank drone 60 tiles away, moose 16 or boomer 33 float dist = !smart_planning ? 1000 : 8.6f; diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 71043daaab96..a75ae6c01143 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -399,7 +399,8 @@ void MonsterGenerator::init_flags() flag_map["REVIVES_HEALTHY"] = MF_REVIVES_HEALTHY; flag_map["NO_NECRO"] = MF_NO_NECRO; flag_map["PUSH_MON"] = MF_PUSH_MON; - flag_map["INTELLIGENT_PATHS"] = MF_INTELLIGENT_PATHS; + flag_map["PATH_AVOID_DANGER"] = MF_PATH_AVOID_DANGER; + flag_map["PRIORITIZE_TARGETS"] = MF_PRIORITIZE_TARGETS; } void MonsterGenerator::set_species_ids( mtype &mon ) diff --git a/src/mtype.h b/src/mtype.h index ed88bd6573f2..d785d8d09350 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -148,7 +148,8 @@ enum m_flag : int { MF_NIGHT_INVISIBILITY, // Monsters that are invisible in poor light conditions MF_REVIVES_HEALTHY, // When revived, this monster has full hitpoints and speed MF_NO_NECRO, // This monster can't be revived by necros. It will still rise on its own. - MF_INTELLIGENT_PATHS, // This monster will path around dangers instead of through them. + MF_PATH_AVOID_DANGER, // This monster will path around dangers instead of through them. + MF_PRIORITIZE_TARGETS, // This monster will prioritize targets depending on their danger levels MF_MAX // Sets the length of the flags - obviously must be LAST }; From b12a33ff26e8611691fc5c40b0629a7785d8e68c Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Sat, 21 May 2016 14:42:35 -0700 Subject: [PATCH 09/42] Astyle --- src/monmove.cpp | 60 +++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index 699e704efd46..e29a1774da2c 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -35,36 +35,36 @@ const efftype_id effect_pacified( "pacified" ); const efftype_id effect_pushed( "pushed" ); const efftype_id effect_stunned( "stunned" ); -bool monster::wander() +bool monster::wander( ) { return ( goal == pos() ); } bool monster::is_immune_field( const field_id fid ) const { - switch (fid) { + switch( fid ) { case fd_smoke: case fd_tear_gas: case fd_toxic_gas: case fd_relax_gas: case fd_nuke_gas: - return has_flag(MF_NO_BREATHE); + return has_flag( MF_NO_BREATHE ); case fd_acid: - return has_flag(MF_ACIDPROOF) || has_flag(MF_FLIES); + return has_flag( MF_ACIDPROOF ) || has_flag( MF_FLIES ); case fd_fire: - return has_flag(MF_FIREPROOF); + return has_flag( MF_FIREPROOF ); case fd_electricity: - return has_flag(MF_ELECTRIC); + return has_flag( MF_ELECTRIC ); case fd_fungal_haze: - return has_flag(MF_NO_BREATHE) || type->in_species(FUNGUS); + return has_flag( MF_NO_BREATHE ) || type->in_species( FUNGUS ); case fd_fungicidal_gas: - return !type->in_species(FUNGUS); + return !type->in_species( FUNGUS ); default: // Suppress warning break; } // No specific immunity was found, so fall upwards - return Creature::is_immune_field(fid); + return Creature::is_immune_field( fid ); } bool monster::can_move_to( const tripoint &p ) const @@ -88,7 +88,7 @@ bool monster::can_move_to( const tripoint &p ) const return false; } - ter_id target = g->m.ter(p); + ter_id target = g->m.ter( p ); // various animal behaviours if( has_flag( MF_ANIMAL ) ) { // don't enter sharp terrain unless tiny, or attacking @@ -119,7 +119,7 @@ bool monster::can_move_to( const tripoint &p ) const } } - if (has_flag( MF_PATH_AVOID_DANGER)) { + if( has_flag( MF_PATH_AVOID_DANGER ) ) { // Don't enter sharp terrain unless tiny, or attacking if( g->m.has_flag( "SHARP", p ) && !( attitude( &( g->u ) ) == MATT_ATTACK || type->size == MS_TINY || has_flag( MF_FLIES ) ) ) { @@ -138,12 +138,12 @@ bool monster::can_move_to( const tripoint &p ) const } // Don't enter any dangerous fields - if (is_dangerous_fields( g->m.field_at( p ) )) { + if( is_dangerous_fields( g->m.field_at( p ) ) ) { return false; } // And don't step on any traps (if we can see) - if (has_flag( MF_SEES ) && !g->m.tr_at( p ).is_benign() && g->m.has_floor( p )) { + if( has_flag( MF_SEES ) && !g->m.tr_at( p ).is_benign() && g->m.has_floor( p ) ) { return false; } @@ -217,7 +217,8 @@ void monster::plan( const mfactions &factions ) bool fleeing = false; bool docile = friendly != 0 && has_effect( effect_docile ); bool angers_hostile_weak = type->anger.find( MTRIG_HOSTILE_WEAK ) != type->anger.end(); - int angers_hostile_near = ( type->anger.find( MTRIG_HOSTILE_CLOSE ) != type->anger.end() ) ? 5 : 0; + int angers_hostile_near = + ( type->anger.find( MTRIG_HOSTILE_CLOSE ) != type->anger.end() ) ? 5 : 0; int fears_hostile_near = ( type->fear.find( MTRIG_HOSTILE_CLOSE ) != type->fear.end() ) ? 5 : 0; bool group_morale = has_flag( MF_GROUP_MORALE ) && morale < type->morale; bool swarms = has_flag( MF_SWARMS ); @@ -301,7 +302,7 @@ void monster::plan( const mfactions &factions ) auto const &myfaction_iter = factions.find( actual_faction ); if( myfaction_iter == factions.end() ) { DebugLog( D_ERROR, D_GAME ) << disp_name() << " tried to find faction " - << actual_faction.id().str() << " which wasn't loaded in game::monmove"; + << actual_faction.id().str() << " which wasn't loaded in game::monmove"; swarms = false; group_morale = false; } @@ -518,9 +519,9 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina { const float angle = atan2( source.x - destination.x, source.y - destination.y ); if( trigdist ) { - return 100.0 / trig_adjustment_values[ 314 + ( int )( angle * 100 ) ]; + return 100.0 / trig_adjustment_values[314 + ( int )( angle * 100 )]; } - return 100.0 / square_adjustment_values[( int )( 314 + ( angle * 100 ) ) ]; + return 100.0 / square_adjustment_values[( int )( 314 + ( angle * 100 ) )]; } // General movement. @@ -529,7 +530,7 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina // 2) Sight-based tracking // 3) Scent-based tracking // 4) Sound-based tracking -void monster::move() +void monster::move( ) { // We decrement wandf no matter what. We'll save our wander_to plans until // after we finish out set_dest plans, UNLESS they time out first. @@ -548,8 +549,9 @@ void monster::move() if( !is_hallucination() && has_flag( MF_ABSORBS ) && !g->m.has_flag( TFLAG_SEALED, pos() ) ) { if( !g->m.i_at( pos() ).empty() ) { if( g->u.sees( *this ) ) { - add_msg( _( "The %s flows around the objects on the floor and they are quickly dissolved!" ), - name().c_str() ); + add_msg( + _( "The %s flows around the objects on the floor and they are quickly dissolved!" ), + name().c_str() ); } for( auto &elem : g->m.i_at( pos() ) ) { hp += elem.volume(); // Yeah this means it can get more HP than normal. @@ -755,7 +757,8 @@ void monster::move() ( !pacified && attack_at( next_step ) ) || ( !pacified && bash_at( next_step ) ) || ( !pacified && push_to( next_step, 0, 0 ) ) || - move_to( next_step, false, ( staggers ? get_stagger_adjust( pos(), destination ) : 1.0 ) ); + move_to( next_step, false, + ( staggers ? get_stagger_adjust( pos(), destination ) : 1.0 ) ); if( !did_something ) { moves -= 100; // If we don't do this, we'll get infinite loops. } @@ -802,7 +805,7 @@ void monster::footsteps( const tripoint &p ) return; } -tripoint monster::scent_move() +tripoint monster::scent_move( ) { std::vector smoves; @@ -963,7 +966,7 @@ bool monster::bash_at( const tripoint &p ) return false; } -int monster::bash_estimate() +int monster::bash_estimate( ) { int estimate = bash_skill(); if( has_flag( MF_GROUP_BASH ) ) { @@ -974,7 +977,7 @@ int monster::bash_estimate() return estimate; } -int monster::bash_skill() +int monster::bash_skill( ) { int ret = type->melee_dice * type->melee_sides; // IOW, the critter's max bashing damage if( has_flag( MF_BORES ) ) { @@ -1091,14 +1094,16 @@ bool monster::move_to( const tripoint &p, bool force, const float stagger_adjust force = true; if( g->u.sees( *this ) ) { add_msg( _( "The %1$s flies over the %2$s." ), name().c_str(), - g->m.has_flag_furn( "CLIMBABLE", p ) ? g->m.furnname( p ).c_str() : g->m.tername( p ).c_str() ); + g->m.has_flag_furn( "CLIMBABLE", p ) ? g->m.furnname( p ).c_str() : + g->m.tername( p ).c_str() ); } } else if( has_flag( MF_CLIMBS ) ) { moves -= 150; force = true; if( g->u.sees( *this ) ) { add_msg( _( "The %1$s climbs over the %2$s." ), name().c_str(), - g->m.has_flag_furn( "CLIMBABLE", p ) ? g->m.furnname( p ).c_str() : g->m.tername( p ).c_str() ); + g->m.has_flag_furn( "CLIMBABLE", p ) ? g->m.furnname( p ).c_str() : + g->m.tername( p ).c_str() ); } } } @@ -1118,7 +1123,8 @@ bool monster::move_to( const tripoint &p, bool force, const float stagger_adjust // is consistent even if the monster stumbles, // and the same regardless of the distance measurement mode. const int cost = stagger_adjustment * - ( float )( climbs ? calc_climb_cost( pos(), p ) : calc_movecost( pos(), p ) ); + ( float )( climbs ? calc_climb_cost( pos(), p ) : + calc_movecost( pos(), p ) ); if( cost > 0 ) { moves -= cost; From fffc8cd5e86fca8423a6637abd26612d4569e380 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Sat, 21 May 2016 14:50:13 -0700 Subject: [PATCH 10/42] Small astyle fix --- src/monmove.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index e29a1774da2c..f818d6586aef 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -35,7 +35,7 @@ const efftype_id effect_pacified( "pacified" ); const efftype_id effect_pushed( "pushed" ); const efftype_id effect_stunned( "stunned" ); -bool monster::wander( ) +bool monster::wander() { return ( goal == pos() ); } @@ -160,7 +160,7 @@ void monster::set_dest( const tripoint &p ) goal = p; } -void monster::unset_dest( ) +void monster::unset_dest() { goal = pos(); } @@ -530,7 +530,7 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina // 2) Sight-based tracking // 3) Scent-based tracking // 4) Sound-based tracking -void monster::move( ) +void monster::move() { // We decrement wandf no matter what. We'll save our wander_to plans until // after we finish out set_dest plans, UNLESS they time out first. @@ -805,7 +805,7 @@ void monster::footsteps( const tripoint &p ) return; } -tripoint monster::scent_move( ) +tripoint monster::scent_move() { std::vector smoves; @@ -966,7 +966,7 @@ bool monster::bash_at( const tripoint &p ) return false; } -int monster::bash_estimate( ) +int monster::bash_estimate() { int estimate = bash_skill(); if( has_flag( MF_GROUP_BASH ) ) { @@ -977,7 +977,7 @@ int monster::bash_estimate( ) return estimate; } -int monster::bash_skill( ) +int monster::bash_skill() { int ret = type->melee_dice * type->melee_sides; // IOW, the critter's max bashing damage if( has_flag( MF_BORES ) ) { @@ -1371,7 +1371,7 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) /** * Stumble in a random direction, but with some caveats. */ -void monster::stumble( ) +void monster::stumble() { // Only move every 3rd turn. if( !one_in( 3 ) ) { From a6c2666f7971ec39bd0942a04413b66c7f1ca1e0 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Sat, 21 May 2016 17:38:50 -0700 Subject: [PATCH 11/42] Another astyle attempt --- src/monmove.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index f818d6586aef..881b49869aa8 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -302,7 +302,8 @@ void monster::plan( const mfactions &factions ) auto const &myfaction_iter = factions.find( actual_faction ); if( myfaction_iter == factions.end() ) { DebugLog( D_ERROR, D_GAME ) << disp_name() << " tried to find faction " - << actual_faction.id().str() << " which wasn't loaded in game::monmove"; + << actual_faction.id().str() + << " which wasn't loaded in game::monmove"; swarms = false; group_morale = false; } From 1442a4d11b9f57ddb12fcdcbb54321e497d90a3d Mon Sep 17 00:00:00 2001 From: DLaboratory Date: Tue, 31 May 2016 23:12:24 +0800 Subject: [PATCH 12/42] fix std::min float/double type issue --- src/mondeath.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 3586370f2594..5c7d9308a8e7 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -79,7 +79,7 @@ void mdeath::normal(monster *z) z->made_of( material_id( "iflesh" ) )); if (leaveGibs) { const auto area = g->m.points_in_radius( z->pos(), 1 ); - const int number_of_gibs = std::min( floor( corpseDamage ) - 1, 1 + max_hp / 5.0 ) + ( is_big_beast ? rng( 1, 6 ) : 0 ); + const int number_of_gibs = std::min( floor( corpseDamage ) - 1, 1 + max_hp / 5.0f ) + ( is_big_beast ? rng( 1, 6 ) : 0 ); for( int i = 0; i < number_of_gibs; ++i ) { g->m.add_splatter( z->gibType(), random_entry( area ), rng( 1, i + 1 ) ); g->m.add_splatter( z->bloodType(), random_entry( area ) ); From 3c8e8a48fa0ad11b7faaf3cddf8998b6229b45a9 Mon Sep 17 00:00:00 2001 From: Jak Wings Date: Wed, 1 Jun 2016 11:01:21 +0800 Subject: [PATCH 13/42] Fix OS X launcher script * PWD is a special vairable of the shell, do not modify it directly. * In case the users installed thirdparty utilities, which may cause the failure of scripts like /etc/bashrc_Apple_Terminal loaded by the Apple terminal, we reset the PATH with a sane value. * Reformat the code with a better style. --- data/osx/Cataclysm.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/data/osx/Cataclysm.sh b/data/osx/Cataclysm.sh index f9447d53d563..910c411d83a8 100755 --- a/data/osx/Cataclysm.sh +++ b/data/osx/Cataclysm.sh @@ -1,20 +1,22 @@ #!/bin/sh -PWD=`dirname "${0}"` -cd "${PWD}/../Resources/" +export PATH=/usr/bin:/bin:/usr/sbin:/sbin -COMMAND=' -OSREV=`uname -r | cut -d. -f1`; -if [ $OSREV -ge 11 ] ; then - export DYLD_LIBRARY_PATH=./; - export DYLD_FRAMEWORK_PATH=./; +V_SCRIPT_PATH=$(dirname "${0}") +cd "${V_SCRIPT_PATH}/../Resources/" + +V_KERNEL_RELEASE=$(uname -r | cut -d. -f1) +if [[ "${V_KERNEL_RELEASE}" -ge 11 ]]; then + K_LIBRARY_PATH=DYLD_LIBRARY_PATH + K_FRAMEWORK_PATH=DYLD_FRAMEWORK_PATH else - export DYLD_FALLBACK_LIBRARY_PATH=./; - export DYLD_FALLBACK_FRAMEWORK_PATH=./; -fi;' + K_LIBRARY_PATH=DYLD_FALLBACK_LIBRARY_PATH + K_FRAMEWORK_PATH=DYLD_FALLBACK_FRAMEWORK_PATH +fi -if [ -f "cataclysm" ] ; then - osascript -e 'tell application "Terminal" to activate do script "cd '`pwd`';'"${COMMAND}"'./cataclysm;exit;"' +if [[ -f cataclysm ]]; then + V_SHELL_SCRIPT="export PATH=${PATH} ${K_LIBRARY_PATH}=. ${K_FRAMEWORK_PATH}=.; cd '${PWD}' && ./cataclysm; exit" + osascript -e "tell application \"Terminal\" to activate do script \"${V_SHELL_SCRIPT}\"" else - eval "${COMMAND}" + export ${K_LIBRARY_PATH}=. ${K_FRAMEWORK_PATH}=. ./cataclysm-tiles -fi \ No newline at end of file +fi From 4a041e6f4549ac71f72e1f9a9dc71cc66816d66b Mon Sep 17 00:00:00 2001 From: DLaboratory Date: Wed, 1 Jun 2016 21:22:46 +0800 Subject: [PATCH 14/42] disable multi processor compilation with msvc With multi processor compilation enabled, it is even slower than when disabled. And it produces extreme heat. Not good. --- msvc140/Cataclysm.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msvc140/Cataclysm.vcxproj b/msvc140/Cataclysm.vcxproj index 8cd0ba17818e..18232cba9595 100644 --- a/msvc140/Cataclysm.vcxproj +++ b/msvc140/Cataclysm.vcxproj @@ -161,8 +161,8 @@ Generate version.h - true - false + false + true \ No newline at end of file From af1d5641411921172b8aa8b6fa9143ffd7f0de3b Mon Sep 17 00:00:00 2001 From: DLaboratory Date: Wed, 1 Jun 2016 22:37:52 +0800 Subject: [PATCH 15/42] fix std::min float/double type issue (reverted from commit 1442a4d11b9f57ddb12fcdcbb54321e497d90a3d) --- src/mondeath.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 5c7d9308a8e7..3586370f2594 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -79,7 +79,7 @@ void mdeath::normal(monster *z) z->made_of( material_id( "iflesh" ) )); if (leaveGibs) { const auto area = g->m.points_in_radius( z->pos(), 1 ); - const int number_of_gibs = std::min( floor( corpseDamage ) - 1, 1 + max_hp / 5.0f ) + ( is_big_beast ? rng( 1, 6 ) : 0 ); + const int number_of_gibs = std::min( floor( corpseDamage ) - 1, 1 + max_hp / 5.0 ) + ( is_big_beast ? rng( 1, 6 ) : 0 ); for( int i = 0; i < number_of_gibs; ++i ) { g->m.add_splatter( z->gibType(), random_entry( area ), rng( 1, i + 1 ) ); g->m.add_splatter( z->bloodType(), random_entry( area ) ); From 114f6beb82a0e0a56c7a3d42eb1ebfd230173363 Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Wed, 1 Jun 2016 21:25:12 +0200 Subject: [PATCH 16/42] Make longcraft use craft_command --- src/craft_command.cpp | 6 ++++++ src/crafting.cpp | 27 +++++++++------------------ src/player_activity.cpp | 2 +- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/craft_command.cpp b/src/craft_command.cpp index 8ddf2498f6ce..9d015318eefc 100644 --- a/src/craft_command.cpp +++ b/src/craft_command.cpp @@ -132,6 +132,12 @@ std::list craft_command::consume_components() return used; } + if( !check_item_components_missing( crafter->crafting_inventory() ).empty() && + !crafter->has_trait( "DEBUG_HS" ) ) { + debugmsg( "Aborting crafting: couldn't find necessary components" ); + return used; + } + for( const auto &it : item_selections ) { std::list tmp = crafter->consume_items( it, batch_size ); used.splice( used.end(), tmp ); diff --git a/src/crafting.cpp b/src/crafting.cpp index 1a241ba9da43..b64845a178b9 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -781,13 +781,7 @@ void player::complete_craft() if( last_craft.has_cached_selections() ) { last_craft.consume_components(); } else { - for( const auto &it : making->requirements.get_components() ) { - consume_items( it, batch_size ); - } - - for( const auto &it : making->requirements.get_tools() ) { - consume_tools( it, batch_size ); - } + debugmsg( "No components selected" ); } activity.type = ACT_NULL; return; @@ -801,19 +795,16 @@ void player::complete_craft() return; } + if( !last_craft.has_cached_selections() ) { + debugmsg( "No components selected" ); + return; + } + // If we're here, the craft was a success! // Use up the components and tools - std::list used; - if( last_craft.has_cached_selections() ) { - used = last_craft.consume_components(); - } else { - for( const auto &it : making->requirements.get_components() ) { - std::list tmp = consume_items( it, batch_size ); - used.splice( used.end(), tmp ); - } - for( const auto &it : making->requirements.get_tools() ) { - consume_tools( it, batch_size ); - } + const std::list &used = last_craft.consume_components(); + if( used.empty() && !has_trait( "DEBUG_HS" ) ) { + return; } // Set up the new item, and assign an inventory letter if available diff --git a/src/player_activity.cpp b/src/player_activity.cpp index b46ec6184b8d..edc4c204a612 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -366,7 +366,7 @@ void player_activity::finish( player *p ) type = ACT_NULL; // Workaround for a bug where longcraft can be unset in complete_craft(). if( p->making_would_work( p->lastrecipe, batch_size ) ) { - p->make_all_craft( p->lastrecipe, batch_size ); + p->last_craft.execute(); } } break; From 32fe940d8e1399444d78126f81dd400a0cb80687 Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Wed, 1 Jun 2016 21:59:18 +0200 Subject: [PATCH 17/42] Fix bug/exploit with missing components for crafting --- src/craft_command.cpp | 11 ++++++++--- src/crafting.cpp | 35 ++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/craft_command.cpp b/src/craft_command.cpp index 9d015318eefc..e66d3b499c91 100644 --- a/src/craft_command.cpp +++ b/src/craft_command.cpp @@ -126,15 +126,20 @@ bool craft_command::query_continue( const std::vector> std::list craft_command::consume_components() { std::list used; + if( crafter->has_trait( "DEBUG_HS" ) ) { + return used; + } if( empty() ) { debugmsg( "Warning: attempted to consume items from an empty craft_command" ); return used; } - if( !check_item_components_missing( crafter->crafting_inventory() ).empty() && - !crafter->has_trait( "DEBUG_HS" ) ) { - debugmsg( "Aborting crafting: couldn't find necessary components" ); + inventory map_inv; + map_inv.form_from_map( crafter->pos(), PICKUP_RANGE ); + + if( !check_item_components_missing( map_inv ).empty() ) { + debugmsg( "Aborting crafting: couldn't find cached components" ); return used; } diff --git a/src/crafting.cpp b/src/crafting.cpp index b64845a178b9..f633aa1d59ea 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -781,7 +781,13 @@ void player::complete_craft() if( last_craft.has_cached_selections() ) { last_craft.consume_components(); } else { - debugmsg( "No components selected" ); + // @todo Guarantee that selections are cached + for( const auto &it : making->requirements.get_components() ) { + consume_items( it, batch_size ); + } + for( const auto &it : making->requirements.get_tools() ) { + consume_tools( it, batch_size ); + } } activity.type = ACT_NULL; return; @@ -795,16 +801,27 @@ void player::complete_craft() return; } - if( !last_craft.has_cached_selections() ) { - debugmsg( "No components selected" ); - return; - } - // If we're here, the craft was a success! // Use up the components and tools - const std::list &used = last_craft.consume_components(); - if( used.empty() && !has_trait( "DEBUG_HS" ) ) { - return; + std::list used; + if( !last_craft.has_cached_selections() ) { + // This should fail and return, but currently crafting_command isn't saved + // Meaning there are still cases where has_cached_selections will be false + // @todo Allow saving last_craft and debugmsg+fail craft if selection isn't cached + if( !has_trait( "DEBUG_HS" ) ) { + for( const auto &it : making->requirements.get_components() ) { + std::list tmp = consume_items( it, batch_size ); + used.splice( used.end(), tmp ); + } + for( const auto &it : making->requirements.get_tools() ) { + consume_tools( it, batch_size ); + } + } + } else if( !has_trait( "DEBUG_HS" ) ) { + used = last_craft.consume_components(); + if( used.empty() ) { + return; + } } // Set up the new item, and assign an inventory letter if available From e7b5c370973bcac64a8ea878ec46517488666b66 Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Wed, 1 Jun 2016 23:42:59 +0200 Subject: [PATCH 18/42] Fix crafting and liquids, allow buckets --- src/crafting.cpp | 24 ++++++++++++------------ src/game.h | 2 +- src/inventory_ui.cpp | 10 ++++++++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/crafting.cpp b/src/crafting.cpp index f633aa1d59ea..9a55e0e40bee 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -357,10 +357,10 @@ bool recipe::check_eligible_containers_for_crafting( int batch ) const if( !cont.is_container_empty() ) { if( cont.contents.front().typeId() == prod.typeId() ) { - charges_to_store -= cont.get_remaining_capacity_for_liquid( cont.contents.front() ); + charges_to_store -= cont.get_remaining_capacity_for_liquid( cont.contents.front(), true ); } } else { - charges_to_store -= cont.get_remaining_capacity_for_liquid( prod ); + charges_to_store -= cont.get_remaining_capacity_for_liquid( prod, true ); } } @@ -388,10 +388,10 @@ bool recipe::check_eligible_containers_for_crafting( int batch ) const return true; } -bool is_container_eligible_for_crafting( const item &cont ) +bool is_container_eligible_for_crafting( const item &cont, bool allow_bucket ) { - if( cont.is_watertight_container() ) { - return !cont.is_container_full(); + if( cont.is_watertight_container() || ( allow_bucket && cont.is_bucket() ) ) { + return !cont.is_container_full( allow_bucket ); } return false; @@ -401,17 +401,17 @@ std::vector player::get_eligible_containers_for_crafting() { std::vector conts; - if( is_container_eligible_for_crafting( weapon ) ) { + if( is_container_eligible_for_crafting( weapon, true ) ) { conts.push_back( weapon ); } for( item &i : worn ) { - if( is_container_eligible_for_crafting( i ) ) { + if( is_container_eligible_for_crafting( i, false ) ) { conts.push_back( i ); } } for( size_t i = 0; i < inv.size(); i++ ) { for( item it : inv.const_stack( i ) ) { - if( is_container_eligible_for_crafting( it ) ) { + if( is_container_eligible_for_crafting( it, false ) ) { conts.push_back( it ); } } @@ -421,7 +421,7 @@ std::vector player::get_eligible_containers_for_crafting() for( const auto &loc : closest_tripoints_first( PICKUP_RANGE, pos() ) ) { if( g->m.accessible_items( pos(), loc, PICKUP_RANGE ) ) { for( item &it : g->m.i_at( loc ) ) { - if( is_container_eligible_for_crafting( it ) ) { + if( is_container_eligible_for_crafting( it, true ) ) { conts.emplace_back( it ); } } @@ -433,7 +433,7 @@ std::vector player::get_eligible_containers_for_crafting() part = veh->part_with_feature( part, "CARGO" ); if( part != -1 ) { for( item &it : veh->get_items( part ) ) { - if( is_container_eligible_for_crafting( it ) ) { + if( is_container_eligible_for_crafting( it, false ) ) { conts.emplace_back( it ); } } @@ -1694,7 +1694,7 @@ void player::complete_disassemble( int item_pos, const tripoint &loc, } } if( act_item.made_of( LIQUID ) ) { - g->handle_all_liquid( act_item ); + g->handle_all_liquid( act_item, PICKUP_RANGE ); } else if( veh != NULL && veh->add_item( veh_part, act_item ) ) { // add_item did put the items in the vehicle, nothing further to be done } else { @@ -1754,7 +1754,7 @@ void remove_ammo( std::list &dis_items, player &p ) void drop_or_handle( const item &newit, player &p ) { if( newit.made_of( LIQUID ) && &p == &g->u ) { // TODO: what about NPCs? - g->handle_all_liquid( newit ); + g->handle_all_liquid( newit, PICKUP_RANGE ); } else { item tmp( newit ); p.i_add_or_drop( tmp ); diff --git a/src/game.h b/src/game.h index 1d78f4cb64d6..aa57f94a9d72 100644 --- a/src/game.h +++ b/src/game.h @@ -559,7 +559,7 @@ class game * charges of the liquid have been transferred. * `true` indicates some charges have been transferred (but not necessarily all of them). */ - void handle_all_liquid( item liquid, int radius = 0 ); + void handle_all_liquid( item liquid, int radius ); /** * Consume / handle as much of the liquid as possible in varying ways. This function can diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index f97e64d75bae..a3cd092f5360 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -1128,16 +1128,22 @@ item_location game::inv_map_splice( item *game::inv_map_for_liquid(const item &liquid, const std::string &title, int radius) { + // Vehicle filter shouldn't allow buckets auto sealable_filter = [&]( const item &candidate ) { return candidate.get_remaining_capacity_for_liquid( liquid, false ) > 0; }; + // Map filter should allow buckets auto bucket_filter = [&]( const item &candidate ) { return candidate.get_remaining_capacity_for_liquid( liquid, true ) > 0; }; - // Buckets can only be filled when on the ground - return inv_map_splice( sealable_filter, bucket_filter, sealable_filter, title, radius, + // Inventory filter should allow only held buckets + auto inv_filter = [&]( const item &candidate ) { + return candidate.get_remaining_capacity_for_liquid( liquid, &candidate == &g->u.weapon ) > 0; + }; + + return inv_map_splice( inv_filter, bucket_filter, sealable_filter, title, radius, string_format( _( "You don't have a suitable container for carrying %s." ), liquid.type_name( 1 ).c_str() ) ).get_item(); } From 3e237671f74a211c1fc7f830a4adf0eeab19ed99 Mon Sep 17 00:00:00 2001 From: Chezzo Date: Wed, 1 Jun 2016 18:33:53 -0400 Subject: [PATCH 19/42] fixed broken apcs, added mod content --- gfx/ChestHole32Tileset/tile_config.json | 150 +++++++++++++++++++----- 1 file changed, 123 insertions(+), 27 deletions(-) diff --git a/gfx/ChestHole32Tileset/tile_config.json b/gfx/ChestHole32Tileset/tile_config.json index 448b20f22c19..157f1d25eaca 100644 --- a/gfx/ChestHole32Tileset/tile_config.json +++ b/gfx/ChestHole32Tileset/tile_config.json @@ -10466,7 +10466,7 @@ }, { "id": "overlay_wielded_primitive_shovel", - "fg": 2499, + "fg": 2480, "bg": 632, "rotates": false }, @@ -13167,13 +13167,13 @@ }, { "id": "overlay_wielded_teleporter", - "fg": 3445, + "fg": 3930, "bg": 632, "rotates": false }, { "id": "overlay_wielded_portal", - "fg": 3445, + "fg": 3931, "bg": 632, "rotates": false }, @@ -22227,7 +22227,7 @@ "rotates": true }, { - "id": "vp_mounted_tank_105", + "id": ["vp_mounted_tank_105", "atiharturret"], "fg": 3899, "rotates": true }, @@ -23608,47 +23608,47 @@ }, { "id": "overlay_wielded_wrench", - "fg": 3886, + "fg": 3887, "rotates": false }, { "id": ["overlay_female_worn_armor_cuirass", "armor_cuirass"], - "fg": 3887, + "fg": 3888, "rotates": false }, { "id": "overlay_male_worn_armor_cuirass", - "fg": 3888, + "fg": 3889, "rotates": false }, { "id": ["overlay_female_worn_armor_wyrm", "armor_wyrm"], - "fg": 3889, + "fg": 3890, "rotates": false }, { "id": "overlay_male_worn_armor_wyrm", - "fg": 3890, + "fg": 3891, "rotates": false }, { "id": "blob_dormant", - "fg": 3891, + "fg": 3892, "rotates": false }, { "id": ["blood_athame", "blood_athame_active"], - "fg": 3892, + "fg": 3893, "rotates": false }, { "id": ["bloodaxe", "bloodaxe_act"], - "fg": 3893, + "fg": 3894, "rotates": false }, { "id": "bloodscourge", - "fg": 3894, + "fg": 3895, "rotates": false }, { @@ -24422,12 +24422,12 @@ }, { "id": "overlay_worn_mask_bunker_on", - "fg": 475, + "fg": 3688, "rotates": false }, { "id": "overlay_worn_mask_bunker", - "fg": 475, + "fg": 3688, "rotates": false }, { @@ -30089,7 +30089,7 @@ "rotates": false }, { - "id": "vp_funnel", + "id": ["vp_funnel", "leather_funnel", "makeshift_funnel"], "fg": 2377, "bg": 632, "rotates": false @@ -31058,7 +31058,7 @@ }, { "id": "knuckle_nail", - "fg": 1272, + "fg": 3807, "bg": 632, "rotates": false }, @@ -33968,19 +33968,19 @@ }, { "id": "tr_portal", - "fg": 2600, + "fg": 3931, "bg": 632, "rotates": false }, { "id": "tr_telepad", - "fg": 2604, + "fg": 3931, "bg": 632, "rotates": false }, { "id": "telepad", - "fg": 2604, + "fg": 3931, "bg": 632, "rotates": false }, @@ -35792,13 +35792,109 @@ }, { "id": "teleporter", - "fg": 3445, + "fg": 3930, "bg": 632, "rotates": false }, { "id": "portal", - "fg": 3445, + "fg": 3931, + "bg": 632, + "rotates": false + }, + { + "id": "mon_compsognathus", + "fg": 3932, + "bg": 632, + "rotates": false + }, + { + "id": "mon_eoraptor", + "fg": 3932, + "bg": 632, + "rotates": false + }, + { + "id": "mon_gallimimus", + "fg": 3933, + "bg": 632, + "rotates": false + }, + { + "id": "mon_titanis", + "fg": 3934, + "bg": 632, + "rotates": false + }, + { + "id": "mon_spinosaurus", + "fg": 3935, + "bg": 632, + "rotates": false + }, + { + "id": "mon_tyrannosaurus", + "fg": 3936, + "bg": 632, + "rotates": false + }, + { + "id": "mon_triceratops", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_stegosaurus", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_ankylosaurus", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_allosaurus", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_velociraptor", + "fg": 3941, + "bg": 632, + "rotates": false + }, + { + "id": "mon_deinonychus", + "fg": 3942, + "bg": 632, + "rotates": false + }, + { + "id": "mon_utahraptor", + "fg": 3943, + "bg": 632, + "rotates": false + }, + { + "id": "mon_dilophosaurus", + "fg": 3944, + "bg": 632, + "rotates": false + }, + { + "id": "mon_parasaurolophus", + "fg": 3945, + "bg": 632, + "rotates": false + }, + { + "id": "mon_dimorphodon", + "fg": 3946, "bg": 632, "rotates": false }, @@ -41776,7 +41872,7 @@ "rotates": false }, { - "id": ["vp_reaper", "v_reaper_item", "v_plow_item", "vp_plow"], + "id": ["vp_reaper", "reaper_advanced", "v_reaper_item", "v_plow_item", "vp_plow"], "fg": 3610, "bg": 632, "rotates": false @@ -48634,7 +48730,7 @@ }, { "id": "overlay_wielded_bagh_nakha", - "fg": 1822, + "fg": 3807, "rotates": false }, { @@ -51084,7 +51180,7 @@ }, { "id": "vp_board_ne", - "fg": 2649, + "fg": 2648, "rotates": true, "multitile": true, "additional_tiles": [ @@ -51096,7 +51192,7 @@ }, { "id": "vp_hdboard_ne", - "fg": 2649, + "fg": 2648, "rotates": true, "multitile": true, "additional_tiles": [ @@ -52658,7 +52754,7 @@ ] }, { - "id": "vp_mounted_m240", + "id": ["vp_mounted_m240", "rifleturret", "50turret", "ascorpion"], "fg": 2733, "rotates": true, "multitile": true, From 695eab3e774b4f39c5fdebb63328d0ed99b416e7 Mon Sep 17 00:00:00 2001 From: Chezzo Date: Wed, 1 Jun 2016 18:42:07 -0400 Subject: [PATCH 20/42] adds same for ChestHoleTileset --- gfx/ChestHoleTileset/tile_config.json | 100 +++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/gfx/ChestHoleTileset/tile_config.json b/gfx/ChestHoleTileset/tile_config.json index 92c7f2d6526b..cfb95f5dea4b 100755 --- a/gfx/ChestHoleTileset/tile_config.json +++ b/gfx/ChestHoleTileset/tile_config.json @@ -35745,13 +35745,109 @@ }, { "id": "teleporter", - "fg": 3445, + "fg": 3930, "bg": 632, "rotates": false }, { "id": "portal", - "fg": 3445, + "fg": 3931, + "bg": 632, + "rotates": false + }, + { + "id": "mon_compsognathus", + "fg": 3932, + "bg": 632, + "rotates": false + }, + { + "id": "mon_eoraptor", + "fg": 3932, + "bg": 632, + "rotates": false + }, + { + "id": "mon_gallimimus", + "fg": 3933, + "bg": 632, + "rotates": false + }, + { + "id": "mon_titanis", + "fg": 3934, + "bg": 632, + "rotates": false + }, + { + "id": "mon_spinosaurus", + "fg": 3935, + "bg": 632, + "rotates": false + }, + { + "id": "mon_tyrannosaurus", + "fg": 3936, + "bg": 632, + "rotates": false + }, + { + "id": "mon_triceratops", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_stegosaurus", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_ankylosaurus", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_allosaurus", + "fg": 3937, + "bg": 632, + "rotates": false + }, + { + "id": "mon_velociraptor", + "fg": 3941, + "bg": 632, + "rotates": false + }, + { + "id": "mon_deinonychus", + "fg": 3942, + "bg": 632, + "rotates": false + }, + { + "id": "mon_utahraptor", + "fg": 3943, + "bg": 632, + "rotates": false + }, + { + "id": "mon_dilophosaurus", + "fg": 3944, + "bg": 632, + "rotates": false + }, + { + "id": "mon_parasaurolophus", + "fg": 3945, + "bg": 632, + "rotates": false + }, + { + "id": "mon_dimorphodon", + "fg": 3946, "bg": 632, "rotates": false }, From 9948f7a2253cfd4fe0d56a0b652f9616e3d856e8 Mon Sep 17 00:00:00 2001 From: Chezzo Date: Wed, 1 Jun 2016 18:46:40 -0400 Subject: [PATCH 21/42] adds all the changes to ChestHole, not just dinos --- gfx/ChestHoleTileset/tile_config.json | 194 +++++++++++++++++--------- 1 file changed, 128 insertions(+), 66 deletions(-) diff --git a/gfx/ChestHoleTileset/tile_config.json b/gfx/ChestHoleTileset/tile_config.json index cfb95f5dea4b..dc9bfd97d9df 100755 --- a/gfx/ChestHoleTileset/tile_config.json +++ b/gfx/ChestHoleTileset/tile_config.json @@ -9,6 +9,7 @@ { "file": "tiles.png", "tiles": [ + { "id": "overlay_wielded_10mm", "fg": 1, @@ -2605,7 +2606,7 @@ "rotates": false }, { - "id": "overlay_wielded_overlay_worn_fireman_belt", + "id": ["overlay_wielded_overlay_worn_fireman_belt", "overlay_worn_baldric", "baldric"], "fg": 3172, "bg": 632, "rotates": false @@ -3070,6 +3071,21 @@ "id": "overlay_wielded_helmet_hsurvivor", "fg": 3687 }, + { + "id": "overlay_wielded_overlay_worn_helmet_hsurvivor", + "fg": 3681, + "rotates": false + }, + { + "id": "overlay_wielded_overlay_worn_mask_hsurvivor", + "fg": 3682, + "rotates": false + }, + { + "id": "overlay_wielded_overlay_worn_helmet_xlsurvivor", + "fg": 372, + "rotates": false + }, { "id": "overlay_wielded_helmet_xlsurvivor", "fg": 372 @@ -9102,6 +9118,12 @@ "bg": 632, "rotates": false }, + { + "id": "overlay_wielded_ltcarb", + "fg": 3643, + "bg": 632, + "rotates": false + }, { "id": "overlay_wielded_laser_rifle", "fg": 1472, @@ -10445,7 +10467,7 @@ }, { "id": "overlay_wielded_primitive_shovel", - "fg": 2499, + "fg": 2480, "bg": 632, "rotates": false }, @@ -11784,6 +11806,12 @@ "bg": 632, "rotates": false }, + { + "id": "overlay_wielded_tec9", + "fg": 1578, + "bg": 632, + "rotates": false + }, { "id": "overlay_wielded_teleumbrella", "fg": 1406, @@ -13140,13 +13168,13 @@ }, { "id": "overlay_wielded_teleporter", - "fg": 3445, + "fg": 3930, "bg": 632, "rotates": false }, { "id": "overlay_wielded_portal", - "fg": 3445, + "fg": 3931, "bg": 632, "rotates": false }, @@ -17101,11 +17129,26 @@ "fg": 1479, "rotates": false }, + { + "id": "overlay_wielded_garand", + "fg": 3662, + "rotates": false + }, { "id": "overlay_wielded_m1911", "fg": 1480, "rotates": false }, + { + "id": "overlay_wielded_m1903", + "fg": 1480, + "rotates": false + }, + { + "id": "overlay_wielded_m1918", + "fg": 1480, + "rotates": false + }, { "id": "overlay_wielded_m2010", "fg": 1481, @@ -17131,6 +17174,11 @@ "fg": 1490, "rotates": false }, + { + "id": "overlay_wielded_marlin_9a", + "fg": 3645, + "rotates": false + }, { "id": "overlay_wielded_mosin91_30", "fg": 1494, @@ -18013,12 +18061,12 @@ "rotates": false }, { - "id": "overlay_female_worn_armor_blarmor", + "id": ["overlay_female_worn_armor_blarmor", "overlay_female_worn_armor_lamellar"], "fg": 3697, "rotates": false }, { - "id": "overlay_male_worn_armor_blarmor", + "id": ["overlay_male_worn_armor_blarmor", "overlay_male_worn_armor_lamellar"], "fg": 3700, "rotates": false }, @@ -18083,12 +18131,12 @@ "rotates": false }, { - "id": "overlay_male_worn_armor_scrapsuit", + "id": ["overlay_male_worn_armor_scrapsuit", "overlay_male_worn_armor_lorica"], "fg": 3728, "rotates": false }, { - "id": "overlay_female_worn_armor_scrapsuit", + "id": ["overlay_female_worn_armor_scrapsuit", "overlay_female_worn_armor_lorica"], "fg": 3729, "rotates": false }, @@ -20192,7 +20240,7 @@ "rotates": false }, { - "id": "armor_blarmor", + "id": ["armor_blarmor", "armor_lamellar"], "fg": 3702, "bg": 632, "rotates": false @@ -22180,7 +22228,7 @@ "rotates": true }, { - "id": "vp_mounted_tank_105", + "id": ["vp_mounted_tank_105", "atiharturret"], "fg": 3899, "rotates": true }, @@ -22871,7 +22919,7 @@ "rotates": false }, { - "id": ["lw12mag", "lw21mag", "lw223bigmag", "lw223mag"], + "id": ["lw12mag", "lw21mag", "lw223bigmag", "lw223mag", "ruger1022bigmag"], "fg": 3755, "rotates": false }, @@ -23561,52 +23609,52 @@ }, { "id": "overlay_wielded_wrench", - "fg": 3886, + "fg": 3887, "rotates": false }, { "id": ["overlay_female_worn_armor_cuirass", "armor_cuirass"], - "fg": 3887, + "fg": 3888, "rotates": false }, { "id": "overlay_male_worn_armor_cuirass", - "fg": 3888, + "fg": 3889, "rotates": false }, { "id": ["overlay_female_worn_armor_wyrm", "armor_wyrm"], - "fg": 3889, + "fg": 3890, "rotates": false }, { "id": "overlay_male_worn_armor_wyrm", - "fg": 3890, + "fg": 3891, "rotates": false }, { "id": "blob_dormant", - "fg": 3891, + "fg": 3892, "rotates": false }, { "id": ["blood_athame", "blood_athame_active"], - "fg": 3892, + "fg": 3893, "rotates": false }, { "id": ["bloodaxe", "bloodaxe_act"], - "fg": 3893, + "fg": 3894, "rotates": false }, { "id": "bloodscourge", - "fg": 3894, + "fg": 3895, "rotates": false }, { - "id": ["overlay_worn_belt223", "overlay_worn_belt308", "overlay_worn_belt308_reusable", "overlay_worn_8x40_100_mag", "overlay_worn_20x66_40_mag", "overlay_worn_360_400_mag", "overlay_worn_8x40_250_mag", "overlay_worn_8x40_500_mag", "overlay_worn_beltshot"], - "fg": 3885, + "id": "overlay_female_worn_armor_chitin", + "fg": 3665, "rotates": false }, { @@ -24133,7 +24181,7 @@ "rotates": false }, { - "id": "overlay_worn_chainmail_suit", + "id": ["overlay_worn_chainmail_suit", "overlay_worn_chainmail_hauberk"], "fg": 460, "rotates": false }, @@ -24375,12 +24423,12 @@ }, { "id": "overlay_worn_mask_bunker_on", - "fg": 475, + "fg": 3688, "rotates": false }, { "id": "overlay_worn_mask_bunker", - "fg": 475, + "fg": 3688, "rotates": false }, { @@ -29450,7 +29498,7 @@ }, { "id": "cx4", - "fg": 3643, + "fg": 1448, "bg": 632, "rotates": false }, @@ -30042,7 +30090,7 @@ "rotates": false }, { - "id": "vp_funnel", + "id": ["vp_funnel", "leather_funnel", "makeshift_funnel"], "fg": 2377, "bg": 632, "rotates": false @@ -31011,7 +31059,7 @@ }, { "id": "knuckle_nail", - "fg": 1272, + "fg": 3807, "bg": 632, "rotates": false }, @@ -31082,8 +31130,8 @@ "rotates": false }, { - "id": ["ltcarb", "m1918", "m1903", "garand"], - "fg": 3645, + "id": "ltcarb", + "fg": 3643, "bg": 632, "rotates": false }, @@ -31315,7 +31363,7 @@ "rotates": false }, { - "id": ["makeshift_halberd", "halberd", "halberd_inferior", "halberd_fake", "glaive"], + "id": ["makeshift_halberd", "halberd", "halberd_inferior", "halberd_fake", "glaive", "naginata"], "fg": 2435, "bg": 632, "rotates": false @@ -33771,7 +33819,7 @@ }, { "id": "tec9", - "fg": 3646, + "fg": 1578, "bg": 632, "rotates": false }, @@ -33806,7 +33854,7 @@ "rotates": false }, { - "id": "textbook_computers", + "id": ["textbook_computers", "abdul_necro"], "fg": 2614, "bg": 632, "rotates": false @@ -33921,19 +33969,19 @@ }, { "id": "tr_portal", - "fg": 2600, + "fg": 3931, "bg": 632, "rotates": false }, { "id": "tr_telepad", - "fg": 2604, + "fg": 3931, "bg": 632, "rotates": false }, { "id": "telepad", - "fg": 2604, + "fg": 3931, "bg": 632, "rotates": false }, @@ -35234,7 +35282,7 @@ "rotates": false }, { - "id": ["overlay_wielded_katana", "overlay_wielded_katana_inferior", "overlay_wielded_katana_fake", "jian_inferior"], + "id": ["overlay_wielded_katana", "overlay_wielded_katana_inferior", "overlay_wielded_katana_fake", "overlay_wielded_jian_inferior", "jian_inferior"], "fg": 3387, "bg": 632, "rotates": false @@ -36141,7 +36189,7 @@ "rotates": false }, { - "id": "armor_scrapsuit", + "id": ["armor_scrapsuit", "armor_lorica"], "fg": 3730, "bg": 632, "rotates": false @@ -36885,7 +36933,7 @@ "rotates": false }, { - "id": "weed", + "id": ["weed", "cannibis"], "fg": 994, "bg": 632 }, @@ -38281,7 +38329,7 @@ "rotates": false }, { - "id": "book_archery", + "id": ["book_archery", "book_archery", "book_asgard", "book_bloodmagic", "book_hexenhammer", "book_magicfordummies", "book_potioncraft", "book_sacrifice", "book_scrollcraft", "book_summoning"], "fg": 686, "bg": 634, "rotates": false @@ -40264,7 +40312,7 @@ "id": "t_wall", "fg": [ { "weight":1, "sprite":[2918, 2913, 2918, 2919]}, - { "weight":1, "sprite":[2918, 3627, 2918, 2919]}, + { "weight":1, "sprite":[2918, 3627, 2918, 3627]}, { "weight":9999, "sprite":[2918, 2919, 2918, 2919]} ], "bg": 633, @@ -40448,7 +40496,7 @@ "rotates": false }, { - "id": "t_tree_deadpine", + "id": ["t_tree_deadpine", "t_tree_dead"], "fg": 2183, "bg": 640, "rotates": false @@ -41825,7 +41873,7 @@ "rotates": false }, { - "id": ["vp_reaper", "v_reaper_item", "v_plow_item", "vp_plow"], + "id": ["vp_reaper", "reaper_advanced", "v_reaper_item", "v_plow_item", "vp_plow"], "fg": 3610, "bg": 632, "rotates": false @@ -42280,13 +42328,7 @@ }, { "id": "player_male", - "fg": [ - { "weight":15, "sprite": 1706}, - { "weight":15, "sprite": 3597}, - { "weight":15, "sprite": 3598}, - { "weight":15, "sprite": 3599}, - { "weight":15, "sprite": 3600} - ], + "fg": 1706, "bg": 642, "rotates": false }, @@ -46345,7 +46387,7 @@ "rotates": false }, { - "id": "overlay_wielded_battleaxe_fake", + "id": ["overlay_wielded_battleaxe_fake","overlay_wielded_battleaxe_inferior"], "fg": 1310, "rotates": false }, @@ -46355,7 +46397,7 @@ "rotates": false }, { - "id": ["overlay_wielded_battleaxe", "overlay_wielded_battleaxe_inferior"], + "id": "overlay_wielded_battleaxe", "fg": 1310, "rotates": false }, @@ -47340,11 +47382,26 @@ "fg": 1479, "rotates": false }, + { + "id": "garand", + "fg": 3663, + "rotates": false + }, { "id": "m1911", "fg": 1480, "rotates": false }, + { + "id": "m1903", + "fg": 1480, + "rotates": false + }, + { + "id": "m1918", + "fg": 1480, + "rotates": false + }, { "id": "m2010", "fg": 1481, @@ -47566,7 +47623,7 @@ "rotates": false }, { - "id": "overlay_wielded_rm99_pistol", + "id": ["overlay_wielded_rm99_pistol", "overlay_wielded_makarov", "overlay_wielded_walther_ppk", "overlay_wielded_glock"], "fg": 1504, "rotates": false }, @@ -47741,8 +47798,8 @@ "rotates": false }, { - "id": ["overlay_wielded_ltcarb", "overlay_wielded_m1918", "overlay_wielded_m1903", "overlay_wielded_garand"], - "fg": 3644, + "id": "overlay_wielded_ltcarb", + "fg": 3642, "rotates": false }, { @@ -48026,7 +48083,7 @@ "rotates": false }, { - "id": "overlay_wielded_glock_19", + "id": ["overlay_wielded_glock_19", "overlay_wielded_glock_22"], "fg": 1515, "rotates": false }, @@ -48067,12 +48124,12 @@ }, { "id": "overlay_wielded_mac_10", - "fg": 3647, + "fg": 1516, "rotates": false }, { "id": "overlay_wielded_rm2000_smg", - "fg": 3647, + "fg": 1516, "rotates": false }, { @@ -48081,7 +48138,7 @@ "rotates": false }, { - "id": "overlay_wielded_tec9", + "id": ["overlay_wielded_tec9", "overlay_wielded_sten"], "fg": 3647, "rotates": false }, @@ -48323,6 +48380,11 @@ "fg": 1525, "rotates": false }, + { + "id": "overlay_wielded_cx4", + "fg": 3646, + "rotates": false + }, { "id": "overlay_wielded_needlegun", "fg": 1525, @@ -48669,7 +48731,7 @@ }, { "id": "overlay_wielded_bagh_nakha", - "fg": 1822, + "fg": 3807, "rotates": false }, { @@ -50094,7 +50156,7 @@ "rotates": false }, { - "id": ["overlay_wielded_makeshift_halberd", "overlay_wielded_halberd", "overlay_wielded_halberd_inferior", "overlay_wielded_halberd_fake", "overlay_wielded_glaive"], + "id": ["overlay_wielded_makeshift_halberd", "overlay_wielded_halberd", "overlay_wielded_halberd_inferior", "overlay_wielded_halberd_fake", "overlay_wielded_glaive", "overlay_wielded_naginata"], "fg": 2477, "rotates": false }, @@ -50653,7 +50715,7 @@ }, { "id": "vp_engine_1cyl", - "fg": 2629, + "fg": 2630, "rotates": false, "multitile": true, "additional_tiles": [ @@ -50665,7 +50727,7 @@ }, { "id": "vp_engine_1cyl_small", - "fg": 2629, + "fg": 2630, "rotates": false, "multitile": true, "additional_tiles": [ @@ -51119,7 +51181,7 @@ }, { "id": "vp_board_ne", - "fg": 2649, + "fg": 2648, "rotates": true, "multitile": true, "additional_tiles": [ @@ -51131,7 +51193,7 @@ }, { "id": "vp_hdboard_ne", - "fg": 2649, + "fg": 2648, "rotates": true, "multitile": true, "additional_tiles": [ @@ -52693,7 +52755,7 @@ ] }, { - "id": "vp_mounted_m240", + "id": ["vp_mounted_m240", "rifleturret", "50turret", "ascorpion"], "fg": 2733, "rotates": true, "multitile": true, From e04ba172fe1b23fb50a8809e4074e541a6184dad Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Thu, 2 Jun 2016 16:14:02 +0200 Subject: [PATCH 22/42] Fix mapgen failing to place the stairs --- src/mapgen_functions.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 8c208c084293..98eb1dcfec0d 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -2563,13 +2563,20 @@ void mapgen_generic_house(map *m, oter_id terrain_type, mapgendata dat, int turn if ("house_base" == terrain_type.t().id_base ) { int attempts = 100; + int stairs_height = actual_house_height - 1; do { - rn = rng(lw + 1, rw - 1); + rn = rng( lw + 1, rw - 1 ); + // After 50 failed attempts, relax the placement limitations a bit + // Otherwise it will most likely fail the next 50 too + if( attempts < 50 ) { + stairs_height = rng( 1, SEEY ); + } attempts--; - } while (m->ter(rn, actual_house_height - 1) != t_floor && attempts); - if( m->ter(rn, actual_house_height - 1) == t_floor && attempts && !m->has_furn( rn, actual_house_height - 1 ) ) { - m->ter_set(rn, actual_house_height - 1, t_stairs_down); - } + if( m->ter( rn, stairs_height ) == t_floor && !m->has_furn( rn, stairs_height ) ) { + m->ter_set( rn, stairs_height, t_stairs_down ); + break; + } + } while( attempts > 0 ); } if (one_in(100)) { // todo: region data // Houses have a 1 in 100 chance of wasps! for (int i = 0; i < SEEX * 2; i++) { From 704a89522ed950bd07a95c0581f621ff49f11f01 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Thu, 2 Jun 2016 13:40:20 -0700 Subject: [PATCH 23/42] Switch to forward includes --- src/creature.cpp | 1 + src/creature.h | 5 +++-- src/monster.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/creature.cpp b/src/creature.cpp index 350bed4c7b0b..3e37d0fc33cd 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -12,6 +12,7 @@ #include "itype.h" #include "vehicle.h" #include "debug.h" +#include "field.h" #include #include diff --git a/src/creature.h b/src/creature.h index efe9857ab7b0..33109a93018d 100644 --- a/src/creature.h +++ b/src/creature.h @@ -8,12 +8,10 @@ #include "output.h" #include "string_id.h" #include "cursesdef.h" // WINDOW -#include "field.h" #include #include #include - class game; class JsonObject; class JsonOut; @@ -28,6 +26,9 @@ enum field_id : int; enum damage_type : int; class material_type; using material_id = string_id; +class field; +class field_entry; +enum field_id : int; enum m_size : int { MS_TINY = 0, // Squirrel diff --git a/src/monster.h b/src/monster.h index 955df39773c0..326562c0483b 100644 --- a/src/monster.h +++ b/src/monster.h @@ -4,7 +4,6 @@ #include "creature.h" #include "enums.h" #include "int_id.h" -#include "field.h" #include class map; @@ -14,6 +13,7 @@ class monfaction; class player; struct mtype; enum monster_trigger : int; +enum field_id : int; using mfaction_id = int_id; using mtype_id = string_id; From ae7206cbfd0934f5abd224de137bc4861acdae5f Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Thu, 2 Jun 2016 13:40:50 -0700 Subject: [PATCH 24/42] Remove redundant check --- src/creature.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/creature.cpp b/src/creature.cpp index 3e37d0fc33cd..328c58314515 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -160,11 +160,6 @@ bool Creature::digging() const bool Creature::is_dangerous_fields( const field &fld ) const { - // Can't be dangerous if there are no fields there - if( fld.fieldCount() == 0 ) { - return false; - } - // Else check each field to see if it's dangerous to us for( auto &dfield : fld ) { if( is_dangerous_field( dfield.second ) ) { From 6614e9481b93f48f5333f08069309208e7592319 Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Thu, 2 Jun 2016 14:50:16 -0700 Subject: [PATCH 25/42] Split out PATH_AVOID_DANGER --- data/json/monsters.json | 94 +++++++++---------- data/json/monsters/obsolete.json | 4 +- data/mods/DinoMod/dinosaur.json | 32 +++---- data/mods/PKs_Rebalance/pk_critter_misc.json | 6 +- .../PKs_Rebalance/pk_critter_triffid.json | 4 +- .../mods/PKs_Rebalance/pk_critter_zombie.json | 2 +- src/monmove.cpp | 76 ++++++--------- src/monstergenerator.cpp | 3 +- src/mtype.h | 3 +- 9 files changed, 104 insertions(+), 120 deletions(-) diff --git a/data/json/monsters.json b/data/json/monsters.json index efd01a76de73..cf30518d6a8e 100755 --- a/data/json/monsters.json +++ b/data/json/monsters.json @@ -58,7 +58,7 @@ } ], "description":"One of the vesper bats, a family of winged insect-eating mammals. It roosts in caves and other hollows, and uses a form of echolocation to aerially navigate through tricky terrain at rapid speeds.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "WARM", "FLIES", "ANIMAL", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "WARM", "FLIES", "ANIMAL", "PATH_AVOID_DANGER_1", "BONES", "LEATHER"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -85,7 +85,7 @@ "hp":16, "death_function":"NORMAL", "description":"The North American beaver, the continent's largest rodent. Its paddle-shaped tail helps ferry it through the water, and its prominent teeth can chew through wood, which it uses to build dam-like nests in lakes and streams.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "SWIMS", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "SWIMS", "WARM", "FUR", "BONES", "FAT"], "anger_triggers":["PLAYER_CLOSE", "HURT"], "fear_triggers":["SOUND"], "categories":["WILDLIFE"] @@ -114,7 +114,7 @@ "hp":4, "death_function":"NORMAL", "description":"A mallard duck, often seen around rivers and other bodies of water. It feeds primarily on insects, seeds, roots, and, pre-cataclysm, bread scraps.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FLIES", "BONES", "FEATHER", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FLIES", "BONES", "FEATHER", "FAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -143,7 +143,7 @@ "hp":100, "death_function":"NORMAL", "description":"The American black bear. A large omnivorous scavenger, it has powerful claws and jaws, and is an effective ambush hunter. It can pose a considerable threat, although most individuals are shy around humans.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BLEED", "BASHES", "ATTACKMON", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BLEED", "BASHES", "ATTACKMON", "BONES", "FAT"], "anger_triggers":["HURT", "PLAYER_CLOSE"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND"], @@ -174,7 +174,7 @@ "hp":100, "death_function":"SMOKEBURST", "description":"A smoking husk is all that remains of this once proud bear. Its black eyes gaze at you with malice... and hunger.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BLEED", "BASHES", "ATTACKMON", "BONES", "FAT", "FIREPROOF", "NO_BREATHE", "POISON"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BLEED", "BASHES", "ATTACKMON", "BONES", "FAT", "FIREPROOF", "NO_BREATHE", "POISON"], "special_attacks":[ ["SMOKECLOUD", 1], { @@ -211,7 +211,7 @@ "hp":16, "death_function":"NORMAL", "description":"A spotted wild cat living across much of North America. It is not a serious threat to humans, but it can be aggressive if not left alone.", - "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "BONES", "FAT"], + "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "BONES", "FAT"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] @@ -241,7 +241,7 @@ "hp":12, "death_function":"NORMAL", "description":"A small domesticated predator gone feral in the absence of human stewardship. Harried by the elements and the rigors of survival, it is scruffy and skittish.", - "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "BONES", "FAT"], + "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "BONES", "FAT"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FRIEND_ATTACKED"], "categories":["WILDLIFE"] @@ -269,7 +269,7 @@ "hp":8, "death_function":"NORMAL", "description":"A domesticated descendant of junglefowl, it may still be the most numerous bird in the world. Before the Cataclysm, it was raised by humans as a source of meat, eggs, and early morning wakeup calls.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FLIES", "BONES", "FEATHER", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FLIES", "BONES", "FEATHER", "FAT"], "categories":["WILDLIFE"] },{ "type" : "MONSTER", @@ -296,7 +296,7 @@ "hp":4, "death_function":"NORMAL", "description":"The eastern chipmunk, a tiny omnivorous rodent with a characteristic striped coat. It spends much of the day patrolling its elaborate burrow and the precious stores of foraged food within.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "ANIMAL", "BONES"], + "flags":["SEES", "SMELLS", "HEARS", "WARM", "ANIMAL", "PATH_AVOID_DANGER_1", "BONES"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -332,7 +332,7 @@ } ], "description":"The Eastern cougar, a large feline predator. Once thought extinct in this region, conservation efforts were successful in restoring a thriving population.", - "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT", "PLAYER_CLOSE", "FRIEND_ATTACKED"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND"], @@ -369,7 +369,7 @@ "hp":100, "death_function":"NORMAL", "description":"The domestic cow, a baleful, ruminating farm animal. It is quite muscular, and the males can have a violent streak to accompany their nasty-looking horns.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES", "FAT"], "anger_triggers":["HURT"], "placate_triggers":["PLAYER_WEAK"], "fear_triggers":["PLAYER_CLOSE"], @@ -400,7 +400,7 @@ "hp":22, "death_function":"NORMAL", "description":"The Eastern coyote, also called the tweed wolf, is a territorial canine descended from the offspring of gray wolves and true coyotes. It is intimidated by humans and other predators, but will fight if threatened.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES"], "anger_triggers":["STALK", "FRIEND_ATTACKED", "PLAYER_WEAK", "HURT", "PLAYER_CLOSE"], "placate_triggers":["MEAT"], "categories":["WILDLIFE"] @@ -430,7 +430,7 @@ "hp":20, "death_function":"NORMAL", "description":"The Northeastern coyote, a widespread canine pack hunter. More timid than a wolf, it is an opportunistic feeder and prefers to hunt smaller and weaker prey.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["FRIEND_ATTACKED", "PLAYER_WEAK", "PLAYER_CLOSE"], "placate_triggers":["MEAT"], "categories":["WILDLIFE"] @@ -459,7 +459,7 @@ "hp":4, "death_function":"NORMAL", "description":"A small, elegant black bird, famous for its distinctive call. An intelligent bird, there is a glitter of mischief behind its eyes.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FLIES", "BONES", "FEATHER"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FLIES", "BONES", "FEATHER"], "fear_triggers":["PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -488,7 +488,7 @@ "hp":60, "death_function":"NORMAL", "description":"The northern woodland white-tailed deer, a quick and strong grazing animal. Favored prey of coyotes, wolves, and giant spider mutants.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES", "FAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -517,7 +517,7 @@ "hp":30, "death_function":"NORMAL", "description": "With mangy fur and hungry eyes, it's clear that this once domesticated dog has gone feral.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["HURT", "FRIEND_ATTACKED", "FRIEND_DIED"], "placate_triggers":["MEAT"], "categories":["WILDLIFE"] @@ -548,7 +548,7 @@ "hp":20, "death_function":"NORMAL", "description":"A small omnivorous canine with an almost cat-like manner. It is a solitary hunter, and one of the only canids able to climb trees.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES"], "anger_triggers":["FRIEND_ATTACKED", "FRIEND_DIED"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], @@ -580,7 +580,7 @@ "hp":30, "death_function":"NORMAL", "description":"The red fox, an omnivorous canine and largest of the true foxes, it is a wily hunter with a combative, suspicious temperament.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["FRIEND_ATTACKED", "FRIEND_DIED"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], @@ -610,7 +610,7 @@ "hp":12, "death_function":"NORMAL", "description":"Also known as the woodchuck, this ground squirrel has no actual talent for chucking wood.", - "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES", "FAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -637,7 +637,7 @@ "hp":10, "death_function":"NORMAL", "description":"The snowshoe hare, a small grass-eater with a brown fur coat that changes to white in the wintertime.", - "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES"], + "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -665,7 +665,7 @@ "hp":90, "death_function":"NORMAL", "description":"A hooved grazing mammal with a mane of hair, a sweeping tail, and powerful-looking muscles.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES", "FAT"], "anger_triggers":["FRIEND_ATTACKED"], "placate_triggers":["PLAYER_WEAK"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], @@ -695,7 +695,7 @@ "hp":4, "death_function":"NORMAL", "description":"The Northern bog lemming, a small, predominantly vegetarian rodent that spends its life in the murk of swamps and other wetlands. Contrary to popular belief, these creatures are not particularly hapless or suicidal, but they can eat themselves into scarcity within a few generations.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL"], + "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "PATH_AVOID_DANGER_1"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -723,7 +723,7 @@ "hp":30, "death_function":"NORMAL", "description":"The American mink, a partially-aquatic weasel, once factory-farmed for its fur. It is a capable fisher, but the presence of otters in these parts makes it rely more on food from the land.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "HIT_AND_RUN", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["FRIEND_ATTACKED", "FRIEND_DIED"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], @@ -754,7 +754,7 @@ "hp":120, "death_function":"NORMAL", "description":"The Eastern moose, the largest living species of deer. The bulls are quite ill-tempered, especially in the rutting season.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BLEED", "ATTACKMON", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BLEED", "ATTACKMON", "BONES", "FAT"], "anger_triggers":["HURT", "PLAYER_CLOSE"], "placate_triggers":["PLAYER_WEAK"], "fear_triggers":["SOUND"], @@ -784,7 +784,7 @@ "hp":10, "death_function":"NORMAL", "description":"A large omnivorous rodent with a thick furry pelt, found in wetlands across the northern hemisphere. It marks its territory with a musky odor for which it is named.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "FUR", "BONES", "FAT"], + "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "PATH_AVOID_DANGER_1", "FUR", "BONES", "FAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -812,7 +812,7 @@ "hp":12, "death_function":"NORMAL", "description":"The North American river otter is a shy water dwelling relative of the weasel living in large families along the banks of streams. It is an excellent fisher and a resourceful survivor, using the abandoned dens of beavers and other animals to raise its own young.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "SWIMS", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "SWIMS", "WARM", "FUR", "BONES", "FAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -839,7 +839,7 @@ "hp":50, "death_function":"NORMAL", "description":"A domesticated omnivore descended from the wild boar, intelligent and inquisitive. Left to its own devices, it has gone feral.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["PLAYER_WEAK", "FRIEND_ATTACKED"], "placate_triggers":["MEAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], @@ -868,7 +868,7 @@ "hp":8, "death_function":"NORMAL", "description":"A small mammal with a cute wiggling nose, cotton tail, and made of delicious flesh.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -897,7 +897,7 @@ "hp":6, "death_function":"NORMAL", "description":"The black rat, an omnivorous rodent with sheer black fur and a long, rough tail. Harbinger of pestilence, famine, and mange, it will sometimes swarm over the dead or dying.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "FUR", "BONES"], + "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "PATH_AVOID_DANGER_1", "FUR", "BONES"], "anger_triggers":["PLAYER_WEAK"], "fear_triggers":["PLAYER_CLOSE"], "categories":["WILDLIFE"] @@ -927,7 +927,7 @@ "hp":10, "death_function":"NORMAL", "description":"A worm-tailed rodent with long whiskers and beady eyes. The way it squeaks makes it sound... hungry.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "FUR", "BONES"], + "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "PATH_AVOID_DANGER_1", "FUR", "BONES"], "anger_triggers":["PLAYER_WEAK", "FRIEND_ATTACKED", "FRIEND_DIED"], "categories":["WILDLIFE"] },{ @@ -955,7 +955,7 @@ "hp":90, "death_function":"NORMAL", "description":"A timid, hooved grazing mammal, and one of the first animals ever domesticated, its body is covered in a thick layer of wool, and the males have long, spiralling horns.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "WOOL", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "WOOL", "BONES", "FAT"], "anger_triggers":[], "placate_triggers":["PLAYER_WEAK"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FRIEND_ATTACKED"], @@ -1013,7 +1013,7 @@ "hp":6, "death_function":"NORMAL", "description":"A small granivorous rodent with a long bushy tail, often seen darting amid the branches of trees. A skittish varmint with an expression of unwavering austerity, it is the mortal enemy of cat and dog alike.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "BONES"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "BONES"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -1068,7 +1068,7 @@ "hp":20, "death_function":"NORMAL", "description":"The long-tailed weasel, a small but ubiquitous predator whose range extends across the continent. It forms its den in small burrows, preferring to occupy the nesting holes of its prey.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "SWIMS", "WARM", "FUR", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "SWIMS", "WARM", "FUR", "BONES", "FAT"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -1098,7 +1098,7 @@ "hp":40, "death_function":"NORMAL", "description":"A cunning pack predator, once extinct in the New England area, the wolf was successfully reintroduced and their numbers reached record highs in the decade before the cataclysm. Lucky you.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["STALK", "FRIEND_ATTACKED", "FRIEND_DIED", "PLAYER_WEAK", "PLAYER_CLOSE"], "placate_triggers":["MEAT"], "categories":["WILDLIFE"] @@ -2681,7 +2681,7 @@ "death_function":["NORMAL"], "special_attacks":[["RESURRECT", 0]], "description":"A twisted mockery of the human form, emaciated, with jet black skin and glowing red eyes. It is somehow painful to look at, awakening fears deep within your psyche, and even the air around it seems more sinister, somehow darker and more dangerous.", - "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"], + "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "PATH_AVOID_DANGER_1", "PRIORITIZE_TARGETS"], "anger_triggers":["HURT", "PLAYER_CLOSE", "PLAYER_WEAK"] },{ "type" : "MONSTER", @@ -2713,7 +2713,7 @@ "special_attacks":[["SCIENCE", 20]], "starting_ammo" : { "bot_manhack": 3 }, "description":"Apart from the jet black eyes it would be easy to believe this scientist was still alive. Clad in a tattered lab coat, it looks to have some measure of situational awareness and resourcefulness.", - "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "BLEED", "CBM_SCI", "ACIDPROOF", "NO_BREATHE", "REVIVES", "BONES", "PUSH_MON", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"] + "flags":["SEES", "HEARS", "SMELLS", "STUMBLES", "WARM", "BASHES", "POISON", "BLEED", "CBM_SCI", "ACIDPROOF", "NO_BREATHE", "REVIVES", "BONES", "PUSH_MON", "PATH_AVOID_DANGER_2", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_zombie_soldier", @@ -2971,7 +2971,7 @@ "death_function":["NORMAL"], "special_attacks":[["UPGRADE", 10]], "description":"Once human, its features have tightened, its lips pulled back into an unnatural grin, revealing rows of blackened teeth beneath its large, piercing eyes. It stands tall and its movements are fluid and tightly controlled. A feeling of danger permeates the air around it, and the light that falls on it seems somehow harsher and more glaring.", - "flags":["SEES", "HEARS", "SMELLS", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"], + "flags":["SEES", "HEARS", "SMELLS", "WARM", "BASHES", "POISON", "NO_BREATHE", "REVIVES", "BONES", "PATH_AVOID_DANGER_2", "PRIORITIZE_TARGETS"], "anger_triggers":["HURT", "PLAYER_CLOSE", "PLAYER_WEAK"] },{ "type" : "MONSTER", @@ -4731,7 +4731,7 @@ "death_function":"THING", "special_attacks":[["DOGTHING", 40]], "description":"A domesticated mongrel of the canine persuasion. In the absence of human society, it has turned feral. You feel a sudden urge to destroy it.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "WARM", "FUR"] + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR"] },{ "type" : "MONSTER", "id" : "mon_headless_dog_thing", @@ -4940,7 +4940,7 @@ "death_function":"NORMAL", "special_attacks":[["PARROT", 0]], "description":"A flexuous monstrosity seeming as a giant crab covered in writhing antennae, clawed tentacles, and star-shaped growths, with a head like the insides of a fish but for its dire utterance.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "POISON", "NO_BREATHE", "ARTHROPOD_BLOOD", "FAT", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"] + "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "POISON", "NO_BREATHE", "ARTHROPOD_BLOOD", "FAT", "PATH_AVOID_DANGER_2", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_yugg", @@ -5073,7 +5073,7 @@ "hp":100, "death_function":"NORMAL", "description":"A bizarre humanoid creature with a calculating stare. Its twitching hands move so fast they appear to be nothing but blurs.", - "flags":["SMELLS", "HEARS", "WARM", "NO_BREATHE", "GRABS", "BONES", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"] + "flags":["SMELLS", "HEARS", "WARM", "NO_BREATHE", "GRABS", "BONES", "PATH_AVOID_DANGER_2", "PRIORITIZE_TARGETS"] },{ "type" : "MONSTER", "id" : "mon_blank", @@ -5100,7 +5100,7 @@ "death_function":"NORMAL", "special_attacks":[["SHRIEK", 10]], "description":"This looks like a human body, but its flesh is snow-white, and its face is featureless save for a perfectly round mouth.", - "flags":["SMELLS", "HEARS", "WARM", "ANIMAL", "SUNDEATH", "NO_BREATHE", "HUMAN", "BONES"] + "flags":["SMELLS", "HEARS", "WARM", "ANIMAL", "PATH_AVOID_DANGER_1", "SUNDEATH", "NO_BREATHE", "HUMAN", "BONES"] },{ "type" : "MONSTER", "id" : "mon_gozu", @@ -5127,7 +5127,7 @@ "death_function":"NORMAL", "special_attacks":[["FEAR_PARALYZE", 20]], "description":"A monster with an obese human body and the head of a cow. It treads slowly, and milky white drool drips from its mouth.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "GROUP_BASH", "ANIMAL", "FUR", "NO_BREATHE", "BONES", "FAT", "PATH_AVOID_DANGER"] + "flags":["SEES", "SMELLS", "HEARS", "WARM", "BASHES", "GROUP_BASH", "ANIMAL", "PATH_AVOID_DANGER_1", "FUR", "NO_BREATHE", "BONES", "FAT", "PATH_AVOID_DANGER_1"] },{ "type" : "MONSTER", "id" : "mon_shadow", @@ -5319,7 +5319,7 @@ ["IMPALE",20] ], "description":"Eight-feet-tall ghastly white penguins. Placid unless otherwise provoked.", - "flags":["HEARS", "KEENNOSE", "GOODHEARING", "SMELLS", "ANIMAL", "WARM", "BONES", "FEATHER", "FAT", "SWIMS", "SUNDEATH"], + "flags":["HEARS", "KEENNOSE", "GOODHEARING", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "BONES", "FEATHER", "FAT", "SWIMS", "SUNDEATH"], "anger_triggers":["HURT", "FRIEND_DIED", "FRIEND_ATTACKED"], "categories":["WILDLIFE"] },{ @@ -6114,7 +6114,7 @@ "hp":15, "death_function":"NORMAL", "description":"A large and colorful game bird native to the forests of North America. Its head and beak are covered in fleshy protuberances.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FLIES", "BONES", "FEATHER", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FLIES", "BONES", "FEATHER", "FAT"], "fear_triggers":["PLAYER_CLOSE", "FRIEND_DIED"], "categories":["WILDLIFE"] },{ @@ -6143,7 +6143,7 @@ "hp":14, "death_function":"NORMAL", "description":"A small mammal native to North America, distinctive for its dexterous paws and facial markings. It is resourceful and agile enough to open sealed containers with its paws.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["FRIEND_ATTACKED", "HURT"], "categories":["WILDLIFE"] },{ @@ -6172,7 +6172,7 @@ "hp":12, "death_function":"NORMAL", "description":"The Virginia opossum, a small omnivorous marsupial native to North America. About the size of a cat, it is hardy and adaptive, and a fairly common sight in urban areas.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "FUR", "KEENNOSE", "BLEED", "BONES", "FAT"], "anger_triggers":["FRIEND_ATTACKED", "HURT"], "fear_triggers":["PLAYER_CLOSE"], "categories":["WILDLIFE"] @@ -6308,7 +6308,7 @@ "death_function":"NORMAL", "special_attacks":[["BRANDISH", 10]], "description":"Living in the woods, \nkilling for sport, \neating all the bodies, \nactual cannibal Shia LaBeouf.", - "flags":["SEES", "HEARS", "WARM", "BASHES", "POISON", "BONES", "BLEED", "NO_BREATHE", "PATH_AVOID_DANGER", "PRIORITIZE_TARGETS"], + "flags":["SEES", "HEARS", "WARM", "BASHES", "POISON", "BONES", "BLEED", "NO_BREATHE", "PATH_AVOID_DANGER_2", "PRIORITIZE_TARGETS"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT", "PLAYER_CLOSE"], "fear_triggers":["FIRE"] },{ diff --git a/data/json/monsters/obsolete.json b/data/json/monsters/obsolete.json index d3cf0d8ad2fe..cbd20bbe8a3c 100644 --- a/data/json/monsters/obsolete.json +++ b/data/json/monsters/obsolete.json @@ -24,7 +24,7 @@ "hp":4, "death_function":"NORMAL", "description":"The white-footed mouse, a prolific rodent with a white underbelly and a long fuzzy tail. A common sight in fields, forests, and research centers.", - "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "VERMIN"], + "flags":["SEES", "SMELLS", "HEARS", "WARM", "SWIMS", "ANIMAL", "PATH_AVOID_DANGER_1", "VERMIN"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ @@ -51,7 +51,7 @@ "hp":4, "death_function":"NORMAL", "description":"The masked shrew, a mouse-like creature with a pointed, whiskery snout. It digs tunnels into the ground in search of bugs to eat.", - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "WARM", "VERMIN"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "VERMIN"], "fear_triggers":["SOUND", "PLAYER_CLOSE"], "categories":["WILDLIFE"] },{ diff --git a/data/mods/DinoMod/dinosaur.json b/data/mods/DinoMod/dinosaur.json index 47c95abc66d1..b5b32338bde7 100644 --- a/data/mods/DinoMod/dinosaur.json +++ b/data/mods/DinoMod/dinosaur.json @@ -32,7 +32,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A bipedal dinosaur about the size of a small cat. Its teeth and claws look quite sharp.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "HIT_AND_RUN", "ANIMAL", "VIS50", "BLEED", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "HIT_AND_RUN", "ANIMAL", "PATH_AVOID_DANGER_1", "VIS50", "BLEED", "BONES", "LEATHER"], "anger_triggers":["PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "placate_triggers":["MEAT"], @@ -65,7 +65,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A feathered bipedal dinosaur, standing as tall as a human. It looks somewhat like a reptilian ostrich.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "VIS40", "BONES", "FEATHER", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "PATH_AVOID_DANGER_1", "VIS40", "BONES", "FEATHER", "LEATHER"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "categories":["DINOSAUR"] },{ @@ -96,7 +96,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"It looks like a dodo, only much bigger, with longer, muscular legs and a predatory gleam in its eyes.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "GRABS", "KEENNOSE", "VIS50", "BLEED", "BONES", "FEATHER", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "GRABS", "KEENNOSE", "VIS50", "BLEED", "BONES", "FEATHER", "LEATHER"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -129,7 +129,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A huge dinosaur about the size of a small house, with a ferocious crocodile-like head and a sail on its back.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "BASHES", "DESTROYS", "VIS50", "BLEED", "ATTACKMON", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "DESTROYS", "VIS50", "BLEED", "ATTACKMON", "BONES", "LEATHER"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -162,7 +162,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"Look at those TEETH!", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "BASHES", "DESTROYS", "VIS50", "BLEED", "ATTACKMON", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "DESTROYS", "VIS50", "BLEED", "ATTACKMON", "BONES", "LEATHER"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -195,7 +195,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A massive rhino-like dinosaur with a bony crest from which three large horns emerge.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "BASHES", "VIS30", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "VIS30", "BONES", "LEATHER"], "anger_triggers":["HURT"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "categories":["DINOSAUR"] @@ -227,7 +227,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A large quadruped dinosaur with plates on its back, and a spiked tail.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "BASHES", "VIS30", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "VIS30", "BONES", "LEATHER"], "anger_triggers":["HURT"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "categories":["DINOSAUR"] @@ -259,7 +259,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"This dinosaur looks like a giant prehistoric armadillo. Its tail ends in a massive spiked club of bone.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "BASHES", "VIS30", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "VIS30", "BONES", "LEATHER"], "anger_triggers":["HURT"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "categories":["DINOSAUR"] @@ -291,7 +291,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A large predatory bipedal dinosaur, with tiger-like stripes on its broad back.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "BASHES", "VIS50", "BLEED", "ATTACKMON", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "VIS50", "BLEED", "ATTACKMON", "BONES", "LEATHER"], "anger_triggers":["STALK", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -324,7 +324,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A bipedal dinosaur about the size of a chicken. It roots around the undergrowth, scavenging on small animals and plants.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "HIT_AND_RUN", "ANIMAL", "VIS50", "BONES"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "HIT_AND_RUN", "ANIMAL", "PATH_AVOID_DANGER_1", "VIS50", "BONES"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "categories":["DINOSAUR"] },{ @@ -355,7 +355,7 @@ "death_function":"NORMAL", "special_attack":["LEAP"], "description":"A small bipedal dinosaur covered with feathers. Small, hooked claws emerge from its feet and hands.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "KEENNOSE", "VIS50", "BLEED", "BONES", "FEATHER", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "KEENNOSE", "VIS50", "BLEED", "BONES", "FEATHER", "LEATHER"], "anger_triggers":["STALK", "FRIEND_ATTACKED", "FRIEND_DIED", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -388,7 +388,7 @@ "death_function":"NORMAL", "special_attack":["LEAP"], "description":"A medium-sized bipedal dinosaur covered with feathers. At the end of each foot is a large sickle-like claw.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "KEENNOSE", "VIS50", "BLEED", "ATTACKMON", "BONES", "FEATHER", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "KEENNOSE", "VIS50", "BLEED", "ATTACKMON", "BONES", "FEATHER", "LEATHER"], "anger_triggers":["STALK", "FRIEND_ATTACKED", "FRIEND_DIED", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -421,7 +421,7 @@ "death_function":"NORMAL", "special_attack":["LEAP"], "description":"A large bipedal dinosaur with feathered arms, a long tail, and scythe-like claws.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "KEENNOSE", "VIS50", "BLEED", "ATTACKMON", "BONES", "FEATHER", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "KEENNOSE", "VIS50", "BLEED", "ATTACKMON", "BONES", "FEATHER", "LEATHER"], "anger_triggers":["STALK", "FRIEND_ATTACKED", "FRIEND_DIED", "PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], @@ -454,7 +454,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A huge mottled dinosaur with a blunt head crest. It contentedly strips leaves from a nearby shrub.", - "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "BASHES", "VIS30", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "GOODHEARING", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "VIS30", "BONES", "LEATHER"], "anger_triggers":["HURT"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "categories":["DINOSAUR"] @@ -486,7 +486,7 @@ "death_function":"NORMAL", "special_attack":["NONE"], "description":"A small flying reptile, circling overhead looking for prey.", - "flags":["SEES", "SMELLS", "HEARS", "FLIES", "HIT_AND_RUN", "ANIMAL", "VIS50", "BLEED", "BONES"], + "flags":["SEES", "SMELLS", "HEARS", "FLIES", "HIT_AND_RUN", "ANIMAL", "PATH_AVOID_DANGER_1", "VIS50", "BLEED", "BONES"], "fear_triggers":["SOUND", "PLAYER_CLOSE", "FIRE"], "placate_triggers":["MEAT"], "categories":["DINOSAUR"] @@ -518,7 +518,7 @@ "death_function":"NORMAL", "special_attack":["BOOMER"], "description":"A medium dinosaur with a sticky green bile dripping from its teeth.", - "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "KEENNOSE", "VIS50", "BLEED", "BONES", "LEATHER"], + "flags":["SEES", "SMELLS", "HEARS", "ANIMAL", "PATH_AVOID_DANGER_1", "KEENNOSE", "VIS50", "BLEED", "BONES", "LEATHER"], "anger_triggers":["PLAYER_WEAK", "HURT"], "fear_triggers":["SOUND", "FIRE"], "placate_triggers":["MEAT"], diff --git a/data/mods/PKs_Rebalance/pk_critter_misc.json b/data/mods/PKs_Rebalance/pk_critter_misc.json index 2af91736337f..21efe03cee92 100644 --- a/data/mods/PKs_Rebalance/pk_critter_misc.json +++ b/data/mods/PKs_Rebalance/pk_critter_misc.json @@ -75,7 +75,7 @@ "armor_cut":1, "hp":170, "special_attacks":[["SMASH", 50]], - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "BASHES", "WARM", "FUR", "BLEED", "ATTACKMON", "BONES", "FAT"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "WARM", "FUR", "BLEED", "ATTACKMON", "BONES", "FAT"], "anger_triggers":["HURT", "PLAYER_CLOSE", "FIRE", "FRIEND_ATTACKED"], "placate_triggers":["PLAYER_WEAK"] },{ @@ -135,7 +135,7 @@ "death_function":"NORMAL", "special_attacks":[["GRAB", 30], ["VINE", 15]], "description":"One of the most durable creatures in the world, the tardigrade has outlived the dinosaurs and humanity both. This is a plump and now moose-sized eight-legged critter with a creviced shell with in-laid segments. Along the length of the shell pairs of sensory tentacles can be seen waving around. Although its clawed digits seem to be for grasping the tentacles, due to their sheer size, lend themselves to flailing in defense.", - "flags":["SEES", "SMELLS", "STUMBLES", "BASHES", "ARTHROPOD_BLOOD", "NO_BREATHE", "SWIMS", "ANIMAL", "FAT","CHITIN"], + "flags":["SEES", "SMELLS", "STUMBLES", "BASHES", "ARTHROPOD_BLOOD", "NO_BREATHE", "SWIMS", "ANIMAL", "PATH_AVOID_DANGER_1", "FAT","CHITIN"], "anger_triggers":["HURT", "STALK", "FRIEND_DIED"], "placate_triggers":["PLAYER_WEAK"], "//" : "Due to the way he was designed, one concern was him getting slaughtered for the oodles of meat. The solution is to make him candig and uncommon." @@ -175,7 +175,7 @@ ] }, ["GRAB", 30], ["GRAB_DRAG", 10]], "description":"In the late 20th century there was an urban legend about pet alligators getting flushed down the toilet and growing to adulthood in sewers. This large specimen doesn't look like its used to humans as anything other than a meal.", - "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "KEENNOSE", "ANIMAL", "BLEED", "ATTACKMON", "BONES", "LEATHER", "SWIMS"], + "flags":["SEES", "HEARS", "GOODHEARING", "SMELLS", "KEENNOSE", "ANIMAL", "PATH_AVOID_DANGER_1", "BLEED", "ATTACKMON", "BONES", "LEATHER", "SWIMS"], "anger_triggers":["PLAYER_CLOSE", "PLAYER_WEAK"], "placate_triggers":["MEAT"], "fear_triggers": ["FIRE", "HURT"], diff --git a/data/mods/PKs_Rebalance/pk_critter_triffid.json b/data/mods/PKs_Rebalance/pk_critter_triffid.json index c38b8951bd76..107e7ed8fa23 100644 --- a/data/mods/PKs_Rebalance/pk_critter_triffid.json +++ b/data/mods/PKs_Rebalance/pk_critter_triffid.json @@ -523,7 +523,7 @@ "starting_ammo": { "grenade": 1, "flashbang": 1}, "death_function":["EXPLODE", "ACID", "SMOKEBURST"], "description":"a dried up shrub with rustling brown leaves adept at ambushes. Highly volatile and easily excited.", - "flags":["SEES", "HEARS", "GOODHEARING", "CAN_DIG", "ANIMAL", "SWIMS", "NOHEAD", "BASHES"], + "flags":["SEES", "HEARS", "GOODHEARING", "CAN_DIG", "ANIMAL", "PATH_AVOID_DANGER_1", "SWIMS", "NOHEAD", "BASHES"], "anger_triggers":["SOUND", "PLAYER_WEAK"], "//": "I dont know if they fit in well, but they add a means for the tiffids to troll." },{ @@ -554,7 +554,7 @@ "starting_ammo": { "c4": 1, "EMPbomb": 3}, "death_function":["EXPLODE", "ACID", "SMOKEBURST"], "description":"Somehow this dessicated plant has become charged up with some lightning? Probably not good for nearby elctronic devices. . .", - "flags":["SEES", "SMELLS","KEENNOSE", "HEARS", "GOODHEARING", "CAN_DIG", "ANIMAL", "SWIMS", "NOHEAD", "BASHES"], + "flags":["SEES", "SMELLS","KEENNOSE", "HEARS", "GOODHEARING", "CAN_DIG", "ANIMAL", "PATH_AVOID_DANGER_1", "SWIMS", "NOHEAD", "BASHES"], "anger_triggers":["SOUND", "PLAYER_WEAK"], "//": "And these guys give them some means of taking down elctronics." } diff --git a/data/mods/PKs_Rebalance/pk_critter_zombie.json b/data/mods/PKs_Rebalance/pk_critter_zombie.json index 92ab4fa48054..e209c1ca1d16 100644 --- a/data/mods/PKs_Rebalance/pk_critter_zombie.json +++ b/data/mods/PKs_Rebalance/pk_critter_zombie.json @@ -10,7 +10,7 @@ "melee_cut":4, "hp":230, "special_attacks":[["SMASH", 50]], - "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "BASHES", "WARM", "FUR", "BLEED", "ATTACKMON", "BONES", "FAT", "POISON"], + "flags":["SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "BASHES", "WARM", "FUR", "BLEED", "ATTACKMON", "BONES", "FAT", "POISON"], "anger_triggers":["HURT", "PLAYER_CLOSE", "FIRE", "FRIEND_ATTACKED"] },{ "type" : "MONSTER", diff --git a/src/monmove.cpp b/src/monmove.cpp index 881b49869aa8..1fab29dfaeb7 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -88,41 +88,17 @@ bool monster::can_move_to( const tripoint &p ) const return false; } - ter_id target = g->m.ter( p ); - // various animal behaviours - if( has_flag( MF_ANIMAL ) ) { - // don't enter sharp terrain unless tiny, or attacking - if( g->m.has_flag( "SHARP", p ) && !( attitude( &( g->u ) ) == MATT_ATTACK || - type->size == MS_TINY || has_flag( MF_FLIES ) ) ) { - return false; - } - - // Don't enter open pits ever unless tiny, can fly or climb well - if( !( type->size == MS_TINY || can_climb ) && - ( target == t_pit || target == t_pit_spiked || target == t_pit_glass ) ) { - return false; - } - - // don't enter lava ever + const ter_id target = g->m.ter( p ); + const field &target_field = g->m.field_at( p ); + const trap &target_trap = g->m.tr_at(p); + // Various avoiding behaviors + if( has_flag( MF_AVOID_DANGER_1 ) || has_flag( MF_AVOID_DANGER_2 ) ) { + // Don't enter lava ever if( target == t_lava ) { return false; } - - // don't enter fire or electricity ever - const field &local_field = g->m.field_at( p ); - if( local_field.findField( fd_fire ) || local_field.findField( fd_electricity ) ) { - return false; - } - - if( g->m.has_flag( TFLAG_NO_FLOOR, p ) && !has_flag( MF_FLIES ) ) { - return false; - } - } - - if( has_flag( MF_PATH_AVOID_DANGER ) ) { - // Don't enter sharp terrain unless tiny, or attacking - if( g->m.has_flag( "SHARP", p ) && !( attitude( &( g->u ) ) == MATT_ATTACK || - type->size == MS_TINY || has_flag( MF_FLIES ) ) ) { + // Don't ever throw ourselves off cliffs + if( !g->m.has_floor( p ) && !has_flag( MF_FLIES ) ) { return false; } @@ -132,23 +108,29 @@ bool monster::can_move_to( const tripoint &p ) const return false; } - // Don't enter lava ever - if( target == t_lava ) { - return false; - } - - // Don't enter any dangerous fields - if( is_dangerous_fields( g->m.field_at( p ) ) ) { - return false; - } - - // And don't step on any traps (if we can see) - if( has_flag( MF_SEES ) && !g->m.tr_at( p ).is_benign() && g->m.has_floor( p ) ) { - return false; + // The following behaviors are overridden when attacking + if( attitude( &( g->u ) ) != MATT_ATTACK ) { + if( g->m.has_flag( "SHARP", p ) && + !( type->size == MS_TINY || has_flag( MF_FLIES ) ) ) { + return false; + } } - if( g->m.has_flag( TFLAG_NO_FLOOR, p ) && !has_flag( MF_FLIES ) ) { - return false; + // Differently handled behaviors + if( has_flag( MF_AVOID_DANGER_2 ) ) { + // Don't enter any dangerous fields + if( is_dangerous_fields( target_field ) ) { + return false; + } + // Don't step on any traps (if we can see) + if( has_flag( MF_SEES ) && !target_trap.is_benign() && g->m.has_floor( p ) ) { + return false; + } + } else if( has_flag( MF_AVOID_DANGER_1 ) ) { + // Don't enter fire or electricity ever (other dangerous fields are fine though) + if( target_field.findField( fd_fire ) || target_field.findField( fd_electricity ) ) { + return false; + } } } diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index a75ae6c01143..327143291dde 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -399,7 +399,8 @@ void MonsterGenerator::init_flags() flag_map["REVIVES_HEALTHY"] = MF_REVIVES_HEALTHY; flag_map["NO_NECRO"] = MF_NO_NECRO; flag_map["PUSH_MON"] = MF_PUSH_MON; - flag_map["PATH_AVOID_DANGER"] = MF_PATH_AVOID_DANGER; + flag_map["PATH_AVOID_DANGER_1"] = MF_AVOID_DANGER_1; + flag_map["PATH_AVOID_DANGER_2"] = MF_AVOID_DANGER_2; flag_map["PRIORITIZE_TARGETS"] = MF_PRIORITIZE_TARGETS; } diff --git a/src/mtype.h b/src/mtype.h index d785d8d09350..ce6ca4ecf14e 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -148,7 +148,8 @@ enum m_flag : int { MF_NIGHT_INVISIBILITY, // Monsters that are invisible in poor light conditions MF_REVIVES_HEALTHY, // When revived, this monster has full hitpoints and speed MF_NO_NECRO, // This monster can't be revived by necros. It will still rise on its own. - MF_PATH_AVOID_DANGER, // This monster will path around dangers instead of through them. + MF_AVOID_DANGER_1, // This monster will path around some dangers instead of through them. + MF_AVOID_DANGER_2, // This monster will path around most dangers instead of through them. MF_PRIORITIZE_TARGETS, // This monster will prioritize targets depending on their danger levels MF_MAX // Sets the length of the flags - obviously must be LAST }; From ebcbbf21df62002b3dd7d216038af93495fbda8d Mon Sep 17 00:00:00 2001 From: Christian Buskirk Date: Thu, 2 Jun 2016 15:12:10 -0700 Subject: [PATCH 26/42] Add override declarations for the clang compiler --- src/character.h | 2 +- src/monster.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/character.h b/src/character.h index cf93845af7e5..9d67731696c3 100644 --- a/src/character.h +++ b/src/character.h @@ -459,7 +459,7 @@ class Character : public Creature, public visitable */ virtual bool query_yn( const char *mes, ... ) const = 0; - virtual bool is_immune_field( const field_id fid ) const; + virtual bool is_immune_field( const field_id fid ) const override; /** Returns true if the player has some form of night vision */ bool has_nv(); diff --git a/src/monster.h b/src/monster.h index 326562c0483b..c9da8ac3828e 100644 --- a/src/monster.h +++ b/src/monster.h @@ -165,7 +165,7 @@ class monster : public Creature, public JsonSerializer, public JsonDeserializer int calc_movecost( const tripoint &f, const tripoint &t ) const; int calc_climb_cost( const tripoint &f, const tripoint &t ) const; - virtual bool is_immune_field( const field_id fid ) const; + virtual bool is_immune_field( const field_id fid ) const override; /** * Attempt to move to p. From fb4455c5579390c45d7b80bd37df8e9ed10cc628 Mon Sep 17 00:00:00 2001 From: sethsimon Date: Thu, 2 Jun 2016 19:25:46 -0400 Subject: [PATCH 27/42] Update Character::can_pickVolume for stacked items Because of previous changes to the volume of stacked items, the volume added by picking something up is not a function of the item's volume, but a function of the current inventory and the item being picked up. - Change the function's signature to receive a const item & rather than an int - Update the callers of this function to match the changed signature --- src/activity_item_handling.cpp | 2 +- src/character.cpp | 8 +++++--- src/character.h | 2 +- src/crafting.cpp | 2 +- src/defense.cpp | 2 +- src/game.cpp | 2 +- src/mutation.cpp | 2 +- src/npc.cpp | 4 ++-- src/npcmove.cpp | 13 ++++++------- src/npctalk.cpp | 4 ++-- src/pickup.cpp | 6 +++--- 11 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 13c9509e70bb..09ab50d0b172 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -373,7 +373,7 @@ static void move_items( const tripoint &src, bool from_vehicle, // Check that we can pick it up. if( !temp_item->made_of( LIQUID ) ) { // Is it too bulky? We'll have to use our hands, then. - if( !g->u.can_pickVolume( temp_item->volume() ) && g->u.is_armed() ) { + if( !g->u.can_pickVolume( *temp_item ) && g->u.is_armed() ) { g->u.moves -= 20; // Pretend to be unwielding our gun. } diff --git a/src/character.cpp b/src/character.cpp index acf53ecfa348..82bd69ab7b22 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -647,7 +647,7 @@ bool Character::i_add_or_drop(item& it, int qty) { inv.assign_empty_invlet(it); for (int i = 0; i < qty; ++i) { if (!drop && (!can_pickWeight(it.weight(), !OPTIONS["DANGEROUS_PICKUPS"]) - || !can_pickVolume(it.volume()))) { + || !can_pickVolume( it ) ) ) { drop = true; } if( drop ) { @@ -836,9 +836,11 @@ int Character::volume_capacity() const return ret; } -bool Character::can_pickVolume( int volume, bool ) const +bool Character::can_pickVolume( const item &it, bool ) const { - return volume_carried() + volume <= volume_capacity(); + inventory projected = inv; + projected.add_item( it ); + return projected.volume() <= volume_capacity(); } bool Character::can_pickWeight( int weight, bool safe ) const diff --git a/src/character.h b/src/character.h index 002ec0b31cc2..fed906ad7d9e 100644 --- a/src/character.h +++ b/src/character.h @@ -403,7 +403,7 @@ class Character : public Creature, public visitable int volume_carried() const; int weight_capacity() const override; int volume_capacity() const; - bool can_pickVolume(int volume, bool safe = false) const; + bool can_pickVolume( const item &it, bool safe = false ) const; bool can_pickWeight(int weight, bool safe = true) const; virtual void drop_inventory_overflow(); diff --git a/src/crafting.cpp b/src/crafting.cpp index 1a241ba9da43..766962af316e 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -913,7 +913,7 @@ void set_item_inventory( item &newit ) } else { g->u.inv.assign_empty_invlet( newit ); // We might not have space for the item - if( !g->u.can_pickVolume( newit.volume() ) ) { //Accounts for result_mult + if( !g->u.can_pickVolume( newit ) ) { //Accounts for result_mult add_msg( _( "There's no room in your inventory for the %s, so you drop it." ), newit.tname().c_str() ); g->m.add_item_or_charges( g->u.pos(), newit ); diff --git a/src/defense.cpp b/src/defense.cpp index 6e41bba2d206..f049e862006a 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -1104,7 +1104,7 @@ Press %s to buy everything in your cart, %s to buy nothing."), } for (int j = 0; j < item_count[0][i]; j++) { - if (g->u.can_pickVolume(tmp.volume()) && g->u.can_pickWeight(tmp.weight())) { + if ( g->u.can_pickVolume( tmp ) && g->u.can_pickWeight( tmp.weight() ) ) { g->u.i_add(tmp); } else { // Could fit it in the inventory! dropped_some = true; diff --git a/src/game.cpp b/src/game.cpp index 6fc4b67acbef..5cb5da7e0831 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -11427,7 +11427,7 @@ bool add_or_drop_with_msg( player &u, item &it ) g->consume_liquid( it, 1 ); return it.charges <= 0; } - if( !u.can_pickVolume( it.volume() ) ) { + if( !u.can_pickVolume( it ) ) { add_msg( _( "There's no room in your inventory for the %s, so you drop it." ), it.tname().c_str() ); g->m.add_item_or_charges( u.pos(), it ); diff --git a/src/mutation.cpp b/src/mutation.cpp index faea3da5bc56..ed9b745c5f97 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -421,7 +421,7 @@ void player::activate_mutation( const std::string &mut ) return; } else if (mut == "VINES3"){ item newit( "vine_30", calendar::turn ); - if (!can_pickVolume(newit.volume())) { //Accounts for result_mult + if ( !can_pickVolume( newit ) ) { //Accounts for result_mult add_msg_if_player(_("You detach a vine but don't have room to carry it, so you drop it.")); g->m.add_item_or_charges(pos(), newit); } else if (!can_pickWeight(newit.weight(), !OPTIONS["DANGEROUS_PICKUPS"])) { diff --git a/src/npc.cpp b/src/npc.cpp index 1430b3544852..77a5f2cb5e17 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -901,7 +901,7 @@ std::list starting_inv( npc *me, npc_class type ) int qty = 1 + ( type == NC_COWBOY || type == NC_BOUNTY_HUNTER ); qty = rng( qty, qty * 2 ); - while ( qty-- != 0 && me->can_pickVolume( ammo.volume() ) ) { + while ( qty-- != 0 && me->can_pickVolume( ammo ) ) { // @todo give NPC a default magazine instead res.push_back( ammo ); } @@ -921,7 +921,7 @@ std::list starting_inv( npc *me, npc_class type ) if( !one_in( 3 ) && tmp.has_flag( "VARSIZE" ) ) { tmp.item_tags.insert( "FIT" ); } - if( me->can_pickVolume( tmp.volume() ) ) { + if( me->can_pickVolume( tmp ) ) { res.push_back( tmp ); } } diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 6902419847de..99c0cd615491 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1776,9 +1776,9 @@ void npc::find_item() continue; } int itval = value( elem ); - int wgt = elem.weight(), vol = elem.volume(); + int wgt = elem.weight(); if( itval > best_value && - ( can_pickWeight( wgt, true ) && can_pickVolume( vol, true ) ) ) { + ( can_pickWeight( wgt, true ) && can_pickVolume( elem, true ) ) ) { wanted_item_pos = p; wanted = &( elem ); best_value = itval; @@ -1848,21 +1848,20 @@ void npc::pick_up_item() // We're adjacent to the item; grab it! moves -= 100; fetching_item = false; - int total_volume = 0; + npc projected = *this; int total_weight = 0; // How much the items will add std::vector pickup; // Indices of items we want for( size_t i = 0; i < items.size(); i++ ) { const item &item = items[i]; int itval = value( item ); - int vol = item.volume(); int wgt = item.weight(); if ( itval >= minimum_item_value() && // (itval >= worst_item_value || - ( can_pickVolume( total_volume + vol, true ) && + ( projected.can_pickVolume( item, true ) && can_pickWeight( total_weight + wgt, true ) ) && !item.made_of( LIQUID ) ) { pickup.push_back( i ); - total_volume += vol; + projected.i_add(item); total_weight += wgt; } } @@ -2599,7 +2598,7 @@ void npc::mug_player(player &mark) invslice slice = mark.inv.slice(); for (size_t i = 0; i < slice.size(); i++) { if( value(slice[i]->front()) >= best_value && - can_pickVolume( slice[i]->front().volume(), true ) && + can_pickVolume( slice[i]->front(), true ) && can_pickWeight( slice[i]->front().weight(), true ) ) { best_value = value(slice[i]->front()); item_index = i; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 7c65c43a3614..63465cdce166 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -4541,7 +4541,7 @@ std::string give_item_to( npc &p, bool allow_use, bool allow_carry ) } if( !taken && allow_carry && - p.can_pickVolume( given.volume() ) && + p.can_pickVolume( given ) && p.can_pickWeight( given.weight() ) ) { taken = true; p.i_add( given ); @@ -4573,7 +4573,7 @@ std::string give_item_to( npc &p, bool allow_use, bool allow_carry ) } } if( allow_carry ) { - if( !p.can_pickVolume( given.volume() ) ) { + if( !p.can_pickVolume( given ) ) { const int free_space = p.volume_capacity() - p.volume_carried(); reason << std::endl; reason << string_format( _("I have no space to store it.") ); diff --git a/src/pickup.cpp b/src/pickup.cpp index 826e902971b3..e7a1120285fe 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -291,7 +291,7 @@ pickup_answer handle_problematic_pickup( const item &it, bool &offered_swap, con if( it.is_armor() ) { amenu.addentry( WEAR, u.can_wear( it ), 'W', _("Wear %s"), it.display_name().c_str() ); } - if( !it.is_container_empty() && u.can_pickVolume( it.volume() ) ) { + if( !it.is_container_empty() && u.can_pickVolume( it ) ) { amenu.addentry( SPILL, true, 's', _("Spill %s, then pick up %s"), it.contents.front().tname().c_str(), it.display_name().c_str() ); } @@ -349,7 +349,7 @@ void Pickup::pick_one_up( const tripoint &pickup_target, item &newit, vehicle *v option = NUM_ANSWERS; } if( newit.charges > 0 ) { - if( !u.can_pickVolume( newit.volume() ) ) { + if( !u.can_pickVolume( newit ) ) { if( !autopickup ) { // Silence some messaging if we're doing autopickup. add_msg(m_info, ngettext("There's no room in your inventory for the %s.", @@ -374,7 +374,7 @@ void Pickup::pick_one_up( const tripoint &pickup_target, item &newit, vehicle *v } else { option = CANCEL; } - } else if( !u.can_pickVolume( newit.volume() ) ) { + } else if( !u.can_pickVolume( newit ) ) { if( !autopickup ) { const std::string &explain = string_format( _("Not enough capacity to stash %s"), newit.display_name().c_str() ); From bd1eb868eb11777eee128fb53a2e3dac32883de7 Mon Sep 17 00:00:00 2001 From: sethsimon Date: Thu, 2 Jun 2016 20:57:48 -0400 Subject: [PATCH 28/42] Refactor Character::can_pickWeight In the previous commit, the function signature of Character::can_pickVolume was changed to address a bug. Because of the similarity of the purposes of these functions, it would be inconsistent and ugly for the callers if their signatures were different. - Change the signature of Character::can_pickWeight to accept a const item & rather than an int - Update this function's callers to reflect the changed signature --- src/activity_item_handling.cpp | 2 +- src/character.cpp | 8 ++++---- src/character.h | 2 +- src/crafting.cpp | 2 +- src/defense.cpp | 2 +- src/game.cpp | 2 +- src/mutation.cpp | 2 +- src/npcmove.cpp | 10 +++------- src/npctalk.cpp | 4 ++-- src/pickup.cpp | 2 +- 10 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 09ab50d0b172..57cf4fe989e9 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -378,7 +378,7 @@ static void move_items( const tripoint &src, bool from_vehicle, } // Is it too heavy? It'll take a while... - if( !g->u.can_pickWeight( temp_item->weight(), true ) ) { + if( !g->u.can_pickWeight( *temp_item, true ) ) { int overweight = temp_item->weight() - ( g->u.weight_capacity() - g->u.weight_carried() ); // ...like one move cost per 100 grams over your leftover carry capacity. diff --git a/src/character.cpp b/src/character.cpp index 82bd69ab7b22..acca1fcd9772 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -646,7 +646,7 @@ bool Character::i_add_or_drop(item& it, int qty) { bool drop = false; inv.assign_empty_invlet(it); for (int i = 0; i < qty; ++i) { - if (!drop && (!can_pickWeight(it.weight(), !OPTIONS["DANGEROUS_PICKUPS"]) + if ( !drop && ( !can_pickWeight( it, !OPTIONS["DANGEROUS_PICKUPS"] ) || !can_pickVolume( it ) ) ) { drop = true; } @@ -843,16 +843,16 @@ bool Character::can_pickVolume( const item &it, bool ) const return projected.volume() <= volume_capacity(); } -bool Character::can_pickWeight( int weight, bool safe ) const +bool Character::can_pickWeight( const item &it, bool safe ) const { if (!safe) { // Character can carry up to four times their maximum weight - return (weight_carried() + weight <= weight_capacity() * 4); + return ( weight_carried() + it.weight() <= weight_capacity() * 4 ); } else { - return (weight_carried() + weight <= weight_capacity()); + return ( weight_carried() + it.weight() <= weight_capacity() ); } } diff --git a/src/character.h b/src/character.h index fed906ad7d9e..34914a75928a 100644 --- a/src/character.h +++ b/src/character.h @@ -404,7 +404,7 @@ class Character : public Creature, public visitable int weight_capacity() const override; int volume_capacity() const; bool can_pickVolume( const item &it, bool safe = false ) const; - bool can_pickWeight(int weight, bool safe = true) const; + bool can_pickWeight( const item &it, bool safe = true ) const; virtual void drop_inventory_overflow(); diff --git a/src/crafting.cpp b/src/crafting.cpp index 766962af316e..463d9072d06e 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -917,7 +917,7 @@ void set_item_inventory( item &newit ) add_msg( _( "There's no room in your inventory for the %s, so you drop it." ), newit.tname().c_str() ); g->m.add_item_or_charges( g->u.pos(), newit ); - } else if( !g->u.can_pickWeight( newit.weight(), !OPTIONS["DANGEROUS_PICKUPS"] ) ) { + } else if( !g->u.can_pickWeight( newit, !OPTIONS["DANGEROUS_PICKUPS"] ) ) { add_msg( _( "The %s is too heavy to carry, so you drop it." ), newit.tname().c_str() ); g->m.add_item_or_charges( g->u.pos(), newit ); diff --git a/src/defense.cpp b/src/defense.cpp index f049e862006a..7c65f6faec07 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -1104,7 +1104,7 @@ Press %s to buy everything in your cart, %s to buy nothing."), } for (int j = 0; j < item_count[0][i]; j++) { - if ( g->u.can_pickVolume( tmp ) && g->u.can_pickWeight( tmp.weight() ) ) { + if ( g->u.can_pickVolume( tmp ) && g->u.can_pickWeight( tmp ) ) { g->u.i_add(tmp); } else { // Could fit it in the inventory! dropped_some = true; diff --git a/src/game.cpp b/src/game.cpp index 5cb5da7e0831..27fdd68b0226 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -11431,7 +11431,7 @@ bool add_or_drop_with_msg( player &u, item &it ) add_msg( _( "There's no room in your inventory for the %s, so you drop it." ), it.tname().c_str() ); g->m.add_item_or_charges( u.pos(), it ); - } else if( !u.can_pickWeight( it.weight(), !OPTIONS["DANGEROUS_PICKUPS"] ) ) { + } else if( !u.can_pickWeight( it, !OPTIONS["DANGEROUS_PICKUPS"] ) ) { add_msg( _( "The %s is too heavy to carry, so you drop it." ), it.tname().c_str() ); g->m.add_item_or_charges( u.pos(), it ); } else { diff --git a/src/mutation.cpp b/src/mutation.cpp index ed9b745c5f97..a6d1dc77bbf0 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -424,7 +424,7 @@ void player::activate_mutation( const std::string &mut ) if ( !can_pickVolume( newit ) ) { //Accounts for result_mult add_msg_if_player(_("You detach a vine but don't have room to carry it, so you drop it.")); g->m.add_item_or_charges(pos(), newit); - } else if (!can_pickWeight(newit.weight(), !OPTIONS["DANGEROUS_PICKUPS"])) { + } else if ( !can_pickWeight( newit, !OPTIONS["DANGEROUS_PICKUPS"] ) ) { add_msg_if_player(_("Your freshly-detached vine is too heavy to carry, so you drop it.")); g->m.add_item_or_charges(pos(), newit); } else { diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 99c0cd615491..2f4205793aec 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1776,9 +1776,8 @@ void npc::find_item() continue; } int itval = value( elem ); - int wgt = elem.weight(); if( itval > best_value && - ( can_pickWeight( wgt, true ) && can_pickVolume( elem, true ) ) ) { + ( can_pickWeight( elem, true ) && can_pickVolume( elem, true ) ) ) { wanted_item_pos = p; wanted = &( elem ); best_value = itval; @@ -1849,20 +1848,17 @@ void npc::pick_up_item() moves -= 100; fetching_item = false; npc projected = *this; - int total_weight = 0; // How much the items will add std::vector pickup; // Indices of items we want for( size_t i = 0; i < items.size(); i++ ) { const item &item = items[i]; int itval = value( item ); - int wgt = item.weight(); if ( itval >= minimum_item_value() && // (itval >= worst_item_value || ( projected.can_pickVolume( item, true ) && - can_pickWeight( total_weight + wgt, true ) ) && + projected.can_pickWeight( item, true ) ) && !item.made_of( LIQUID ) ) { pickup.push_back( i ); projected.i_add(item); - total_weight += wgt; } } // Describe the pickup to the player @@ -2599,7 +2595,7 @@ void npc::mug_player(player &mark) for (size_t i = 0; i < slice.size(); i++) { if( value(slice[i]->front()) >= best_value && can_pickVolume( slice[i]->front(), true ) && - can_pickWeight( slice[i]->front().weight(), true ) ) { + can_pickWeight( slice[i]->front(), true ) ) { best_value = value(slice[i]->front()); item_index = i; } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 63465cdce166..65782e52da3d 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -4542,7 +4542,7 @@ std::string give_item_to( npc &p, bool allow_use, bool allow_carry ) if( !taken && allow_carry && p.can_pickVolume( given ) && - p.can_pickWeight( given.weight() ) ) { + p.can_pickWeight( given ) ) { taken = true; p.i_add( given ); } @@ -4585,7 +4585,7 @@ std::string give_item_to( npc &p, bool allow_use, bool allow_carry ) reason << string_format( _("...or to store anything else for that matter.") ); } } - if( !p.can_pickWeight( given.weight() ) ) { + if( !p.can_pickWeight( given ) ) { reason << std::endl; reason << string_format( _("It is too heavy for me to carry.") ); } diff --git a/src/pickup.cpp b/src/pickup.cpp index e7a1120285fe..437dc3054843 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -335,7 +335,7 @@ void Pickup::pick_one_up( const tripoint &pickup_target, item &newit, vehicle *v if( newit.made_of(LIQUID) ) { got_water = true; - } else if (!u.can_pickWeight(newit.weight(), false)) { + } else if ( !u.can_pickWeight( newit, false ) ) { add_msg(m_info, _("The %s is too heavy!"), newit.display_name().c_str()); } else if( newit.is_ammo() && (newit.ammo_type() == "arrow" || newit.ammo_type() == "bolt")) { // @todo Make quiver code generic so that ammo pouches can use it too From 337fa1dee5e62348a0c34a550cdf9b51466a4b5f Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Fri, 3 Jun 2016 16:13:44 +0200 Subject: [PATCH 29/42] Warn about bad non-charged items --- src/item_factory.cpp | 7 +++++++ src/iuse.h | 8 ++++++++ src/iuse_actor.cpp | 20 ++++++++++++++++++++ src/iuse_actor.h | 1 + 4 files changed, 36 insertions(+) diff --git a/src/item_factory.cpp b/src/item_factory.cpp index faadf392e16f..2a3e0e6ae2be 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -170,6 +170,13 @@ void Item_factory::finalize() { } } } + + for( use_function &use_fun : obj.use_methods ) { + iuse_actor *actor = use_fun.get_actor_ptr(); + if( actor != nullptr ) { + actor->finalize( obj.id ); + } + } } } diff --git a/src/iuse.h b/src/iuse.h index 9fe014a03f97..e2a9b1e1e3c4 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -12,6 +12,7 @@ class player; class JsonObject; class MonsterGenerator; struct iteminfo; +typedef std::string itype_id; // iuse methods returning a bool indicating whether to consume a charge of the item being used. class iuse @@ -245,6 +246,13 @@ class iuse_actor { * Returns the translated name of the action. It is used for the item action menu. */ virtual std::string get_name() const; + + /** + * Finalizes the actor. Must be called after all items are loaded. + * Returns a string describing errors in the json such as missing item definitions. + * Empty return string means no errors. + */ + virtual std::string finalize( const itype_id &/*my_item_type*/ ) { return ""; } }; struct use_function { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index f0ceaf41426a..0130d51862b3 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -142,6 +142,26 @@ std::string iuse_transform::get_name() const return iuse_actor::get_name(); } +std::string iuse_transform::finalize( const itype_id & ) +{ + if( !item::type_is_defined( target ) ) { + debugmsg( "Invalid transform target: %s", target.c_str() ); + } + + if( !container.empty() ) { + if( !item::type_is_defined( container ) ) { + debugmsg( "Invalid transform container: %s", container.c_str() ); + } + + item dummy( target ); + if( !dummy.count_by_charges() ) { + debugmsg( "Transform target with container must be an item with charges, got non-charged: %s", target.c_str() ); + } + } + + return ""; +} + explosion_iuse::~explosion_iuse() { } diff --git a/src/iuse_actor.h b/src/iuse_actor.h index c5fc60763cc4..66690ff4b7d7 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -79,6 +79,7 @@ class iuse_transform : public iuse_actor virtual long use(player *, item *, bool, const tripoint& ) const override; virtual iuse_actor *clone() const override; std::string get_name() const override; + virtual std::string finalize( const itype_id &my_item_type ) override; }; /** From 716075da25181ac1af628ca0298178ec17be69fc Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Fri, 3 Jun 2016 17:14:04 +0200 Subject: [PATCH 30/42] Fix jar bug --- data/json/items/comestibles.json | 14 ++++++++++---- src/iuse.h | 4 +--- src/iuse_actor.cpp | 20 +++++++++++--------- src/iuse_actor.h | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/data/json/items/comestibles.json b/data/json/items/comestibles.json index 413d006b4278..b91818bb1a55 100644 --- a/data/json/items/comestibles.json +++ b/data/json/items/comestibles.json @@ -8444,6 +8444,7 @@ "material" : "flesh", "volume" : 2, "charges" : 1, + "stack_size" : 2, "fun" : 2 }, { @@ -8463,8 +8464,9 @@ "description" : "This mushy pile of vegetable matter was boiled and canned in an earlier life. Better eat it before it oozes through your fingers.", "price" : 250, "material" : "veggy", - "volume" : 1, + "volume" : 2, "charges" : 1, + "stack_size" : 2, "fun" : 0 }, { @@ -8484,8 +8486,9 @@ "description" : "This sodden mass of preserved fruit was boiled and canned in an earlier life. Bland, mushy and losing color.", "price" : 220, "material" : "fruit", - "volume" : 1, + "volume" : 2, "charges" : 1, + "stack_size" : 2, "fun" : 1 }, { @@ -8505,8 +8508,9 @@ "description" : "Low-sodium preserved human meat. It was boiled and canned. Contains most of the nutrition, but little of the savor of cooked meat.", "price" : 0, "material" : "hflesh", - "volume" : 1, + "volume" : 2, "charges" : 1, + "stack_size" : 2, "fun" : 2 }, { @@ -8870,6 +8874,7 @@ "material" : "veggy", "volume" : 1, "charges" : 1, + "stack_size" : 4, "fun" : -2 }, { @@ -11480,8 +11485,9 @@ "description" : "Canned tomato. A staple in many pantries, and useful for many recipes.", "price" : 350, "material" : "veggy", - "volume" : 1, + "volume" : 2, "charges" : 1, + "stack_size" : 2, "fun" : 0 }, { diff --git a/src/iuse.h b/src/iuse.h index e2a9b1e1e3c4..53c1b1526ee7 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -249,10 +249,8 @@ class iuse_actor { /** * Finalizes the actor. Must be called after all items are loaded. - * Returns a string describing errors in the json such as missing item definitions. - * Empty return string means no errors. */ - virtual std::string finalize( const itype_id &/*my_item_type*/ ) { return ""; } + virtual void finalize( const itype_id &/*my_item_type*/ ) { } }; struct use_function { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 0130d51862b3..63df26de5682 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -61,6 +61,11 @@ void iuse_transform::load( JsonObject &obj ) obj.read( "container", container ); obj.read( "target_charges", ammo_qty ); obj.read( "target_ammo", ammo_type ); + + if( !ammo_type.empty() && !container.empty() ) { + obj.throw_error( "Transform actor specified both ammo type and container type", "target_ammo" ); + } + obj.read( "active", active ); obj.read( "moves", moves ); @@ -120,13 +125,12 @@ long iuse_transform::use(player *p, item *it, bool t, const tripoint &pos ) cons item *obj; if( container.empty() ) { obj = &it->convert( target ); + if( ammo_qty >= 0 ) { + obj->ammo_set( ammo_type.empty() ? obj->ammo_current() : ammo_type, ammo_qty ); + } } else { it->convert( container ); - obj = &it->emplace_back( target ); - } - - if( ammo_qty >= 0 ) { - obj->ammo_set( ammo_type.empty() ? obj->ammo_current() : ammo_type, ammo_qty ); + obj = &it->emplace_back( item( target, calendar::turn, ammo_qty >= 0 ? ammo_qty : 1 ) ) ; } obj->active = active; @@ -142,7 +146,7 @@ std::string iuse_transform::get_name() const return iuse_actor::get_name(); } -std::string iuse_transform::finalize( const itype_id & ) +void iuse_transform::finalize( const itype_id & ) { if( !item::type_is_defined( target ) ) { debugmsg( "Invalid transform target: %s", target.c_str() ); @@ -154,12 +158,10 @@ std::string iuse_transform::finalize( const itype_id & ) } item dummy( target ); - if( !dummy.count_by_charges() ) { + if( ammo_qty > 1 && !dummy.count_by_charges() ) { debugmsg( "Transform target with container must be an item with charges, got non-charged: %s", target.c_str() ); } } - - return ""; } explosion_iuse::~explosion_iuse() diff --git a/src/iuse_actor.h b/src/iuse_actor.h index 66690ff4b7d7..c8206dd67daf 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -79,7 +79,7 @@ class iuse_transform : public iuse_actor virtual long use(player *, item *, bool, const tripoint& ) const override; virtual iuse_actor *clone() const override; std::string get_name() const override; - virtual std::string finalize( const itype_id &my_item_type ) override; + virtual void finalize( const itype_id &my_item_type ) override; }; /** From 110965fdab65db6a99026450d066b7478a8d8c4c Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Fri, 3 Jun 2016 23:53:44 +0200 Subject: [PATCH 31/42] Clean up a bit --- src/iuse_actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 63df26de5682..72e47879f0df 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -130,7 +130,7 @@ long iuse_transform::use(player *p, item *it, bool t, const tripoint &pos ) cons } } else { it->convert( container ); - obj = &it->emplace_back( item( target, calendar::turn, ammo_qty >= 0 ? ammo_qty : 1 ) ) ; + obj = &it->emplace_back( target, calendar::turn, std::max( ammo_qty, 1l ) ); } obj->active = active; From 39262344f7bd824c9b1cca3dc027d0a69eca3749 Mon Sep 17 00:00:00 2001 From: sethsimon Date: Fri, 3 Jun 2016 16:58:19 -0400 Subject: [PATCH 32/42] Update class_definitions.lua --- lua/class_definitions.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/class_definitions.lua b/lua/class_definitions.lua index ecb1360ee414..7e19ff7a02d1 100644 --- a/lua/class_definitions.lua +++ b/lua/class_definitions.lua @@ -146,10 +146,10 @@ classes = { { name = "add_traits", rval = nil, args = { } }, { name = "aim_per_time", rval = "int", args = { "item", "int" } }, { name = "bloodType", rval = "field_id", args = { } }, - { name = "can_pickVolume", rval = "bool", args = { "int" } }, - { name = "can_pickVolume", rval = "bool", args = { "int", "bool" } }, - { name = "can_pickWeight", rval = "bool", args = { "int" } }, - { name = "can_pickWeight", rval = "bool", args = { "int", "bool" } }, + { name = "can_pickVolume", rval = "bool", args = { "item&" } }, + { name = "can_pickVolume", rval = "bool", args = { "item&", "bool" } }, + { name = "can_pickWeight", rval = "bool", args = { "item&" } }, + { name = "can_pickWeight", rval = "bool", args = { "item&", "bool" } }, { name = "die", rval = nil, args = { "Creature" } }, { name = "empty_skills", rval = nil, args = { } }, { name = "empty_traits", rval = nil, args = { } }, @@ -1431,7 +1431,7 @@ classes = { furn_t = { int_id = "furn_id", string_id = "furn_str_id", - + attributes = { close = { type = "furn_str_id", writable = true }, id = { type = "furn_str_id" }, From 493425ecb62bbf98ffcecdb117a34fb0569cd071 Mon Sep 17 00:00:00 2001 From: sethsimon Date: Fri, 3 Jun 2016 20:08:00 -0400 Subject: [PATCH 33/42] Remove erroneous ampersands from class_definitions.lua --- lua/class_definitions.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/class_definitions.lua b/lua/class_definitions.lua index 7e19ff7a02d1..c57f10e4b38f 100644 --- a/lua/class_definitions.lua +++ b/lua/class_definitions.lua @@ -146,10 +146,10 @@ classes = { { name = "add_traits", rval = nil, args = { } }, { name = "aim_per_time", rval = "int", args = { "item", "int" } }, { name = "bloodType", rval = "field_id", args = { } }, - { name = "can_pickVolume", rval = "bool", args = { "item&" } }, - { name = "can_pickVolume", rval = "bool", args = { "item&", "bool" } }, - { name = "can_pickWeight", rval = "bool", args = { "item&" } }, - { name = "can_pickWeight", rval = "bool", args = { "item&", "bool" } }, + { name = "can_pickVolume", rval = "bool", args = { "item" } }, + { name = "can_pickVolume", rval = "bool", args = { "item", "bool" } }, + { name = "can_pickWeight", rval = "bool", args = { "item" } }, + { name = "can_pickWeight", rval = "bool", args = { "item", "bool" } }, { name = "die", rval = nil, args = { "Creature" } }, { name = "empty_skills", rval = nil, args = { } }, { name = "empty_traits", rval = nil, args = { } }, From 589814d43415111c398538c8302dc73923fdd065 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Fri, 3 Jun 2016 19:51:04 +0000 Subject: [PATCH 34/42] Astyle fix. --- src/monmove.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index 1fab29dfaeb7..8dac173f8ebf 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -90,7 +90,7 @@ bool monster::can_move_to( const tripoint &p ) const const ter_id target = g->m.ter( p ); const field &target_field = g->m.field_at( p ); - const trap &target_trap = g->m.tr_at(p); + const trap &target_trap = g->m.tr_at( p ); // Various avoiding behaviors if( has_flag( MF_AVOID_DANGER_1 ) || has_flag( MF_AVOID_DANGER_2 ) ) { // Don't enter lava ever From 39b0c3e71e80f3f6c5c36b5d53e12fa07a0483c8 Mon Sep 17 00:00:00 2001 From: Cyrano7 Date: Fri, 3 Jun 2016 13:44:11 -0700 Subject: [PATCH 35/42] Add trader avoid flag to lit glowstick, kiln, battle torch and flare --- data/json/items/tools.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/json/items/tools.json b/data/json/items/tools.json index b24d72420678..0d2d0a362e9c 100644 --- a/data/json/items/tools.json +++ b/data/json/items/tools.json @@ -777,7 +777,7 @@ "description": "This is an active glowstick and is producing light. It will last for a few hours before burning out.", "price": 0, "material": "plastic", - "flags": "LIGHT_8", + "flags": [ "LIGHT_8", "TRADER_AVOID" ], "weight": 29, "volume": 1, "to_hit": -1, @@ -834,7 +834,7 @@ "description": "This burning magnesium flare is producing light. It will last for about a half hour before burning out.", "price": 0, "material": ["paper", "plastic"], - "flags": ["FIRE", "LIGHT_240", "CHARGEDIM", "FLAMING"], + "flags": ["FIRE", "LIGHT_240", "CHARGEDIM", "FLAMING", "TRADER_AVOID"], "weight": 128, "volume": 1, "bashing": 2, @@ -4818,7 +4818,7 @@ "color" : "red", "symbol" : "/", "material" : ["wood", "nomex"], - "flags": ["FIRE", "LIGHT_310", "CHARGEDIM", "FLAMING", "DURABLE_MELEE"], + "flags": ["FIRE", "LIGHT_310", "CHARGEDIM", "FLAMING", "DURABLE_MELEE", "TRADER_AVOID"], "techniques" : ["WBLOCK_1"], "volume" : 8, "bashing" : 18, @@ -6904,7 +6904,7 @@ "color": "brown", "name": "lit charcoal kiln", "description": "A kiln full of wood that has been lit; better drop it!", - "flags": ["LIGHT_8"], + "flags": ["LIGHT_8", "TRADER_AVOID"], "price": 100, "material": ["steel", "wood"], "weight": 15142, From 90ab71898a35734b46eac38d8c9656109c0dc5da Mon Sep 17 00:00:00 2001 From: Cyrano7 Date: Fri, 3 Jun 2016 14:01:37 -0700 Subject: [PATCH 36/42] Add spaces remove price for glowstick lit --- data/json/items/tools.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/data/json/items/tools.json b/data/json/items/tools.json index 0d2d0a362e9c..9e9a15e069b0 100644 --- a/data/json/items/tools.json +++ b/data/json/items/tools.json @@ -775,7 +775,6 @@ "color": "light_blue", "name": "active glowstick", "description": "This is an active glowstick and is producing light. It will last for a few hours before burning out.", - "price": 0, "material": "plastic", "flags": [ "LIGHT_8", "TRADER_AVOID" ], "weight": 29, @@ -4818,7 +4817,7 @@ "color" : "red", "symbol" : "/", "material" : ["wood", "nomex"], - "flags": ["FIRE", "LIGHT_310", "CHARGEDIM", "FLAMING", "DURABLE_MELEE", "TRADER_AVOID"], + "flags": [ "FIRE", "LIGHT_310", "CHARGEDIM", "FLAMING", "DURABLE_MELEE", "TRADER_AVOID" ], "techniques" : ["WBLOCK_1"], "volume" : 8, "bashing" : 18, @@ -4864,7 +4863,7 @@ "description": "This is a thick candle. It doesn't provide very much light, but it can burn for quite a long time. This candle is lit.", "price": 0, "material": "veggy", - "flags": ["LIGHT_8", "TRADER_AVOID"], + "flags": [ "LIGHT_8", "TRADER_AVOID" ], "weight": 100, "volume": 1, "to_hit": -2, @@ -6904,7 +6903,7 @@ "color": "brown", "name": "lit charcoal kiln", "description": "A kiln full of wood that has been lit; better drop it!", - "flags": ["LIGHT_8", "TRADER_AVOID"], + "flags": [ "LIGHT_8", "TRADER_AVOID" ], "price": 100, "material": ["steel", "wood"], "weight": 15142, From a0c3caf07a55394eec3955f125e73a9ebdaa638d Mon Sep 17 00:00:00 2001 From: Angela Graves Date: Thu, 2 Jun 2016 21:03:12 -0600 Subject: [PATCH 37/42] A few grammar fixes for arrows. --- data/json/items/archery.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/json/items/archery.json b/data/json/items/archery.json index d541cba4ec70..2319758fd598 100644 --- a/data/json/items/archery.json +++ b/data/json/items/archery.json @@ -88,7 +88,7 @@ "name" : "unfletched fire-hardened wooden arrow", "symbol" : "=", "color" : "green", - "description" : "A simple arrow shaft that has had a point carved into it and then fire-hardened. Needs fletching to be worth firing from a bow.", + "description" : "A simple arrow shaft that has had a point carved into it and then fire-hardened. It needs fletching to be worth firing from a bow.", "material" : "wood", "volume" : 1, "weight" : 42, @@ -352,7 +352,7 @@ "name" : "unfletched sharpened metal arrow", "symbol" : "=", "color" : "green", - "description" : "This metal shaft has been carefully sharpened so that it has a crude point at the end. Needs fletching to be worth firing from a bow.", + "description" : "This metal shaft has been carefully sharpened so that it has a crude point at the end. It needs fletching to be worth firing from a bow.", "material" : "steel", "volume" : 1, "weight" : 55, From 0a31d594448138413c3ef76fb5994c092a887f66 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 4 Jun 2016 00:09:25 +0200 Subject: [PATCH 38/42] Correct grammar in telescopic eyes description --- data/json/bionics.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/bionics.json b/data/json/bionics.json index 3d0faa123884..cf3b0b2ef126 100644 --- a/data/json/bionics.json +++ b/data/json/bionics.json @@ -242,7 +242,7 @@ "occupied_bodyparts": [ [ "EYES", 2 ] ], - "description": "Much of the material in your inner eye has been removed and replaced with an array of high-powered, auto-focusing lenses. You can now see much farther and more clearer than before, any vision problems you might have had are now gone." + "description": "Much of the material in your inner eye has been removed and replaced with an array of high-powered, auto-focusing lenses. You can now see much farther and more clearly than before, any vision problems you might have had are now gone." },{ "type": "bionic", "id": "bio_targeting", From 506bfebc1bf2c2947d94243edfa2435c4154b725 Mon Sep 17 00:00:00 2001 From: Cyrano7 Date: Fri, 3 Jun 2016 16:44:13 -0700 Subject: [PATCH 39/42] update --- data/json/items/tools.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/data/json/items/tools.json b/data/json/items/tools.json index 9e9a15e069b0..bb82c11fb0fc 100644 --- a/data/json/items/tools.json +++ b/data/json/items/tools.json @@ -831,9 +831,8 @@ "color": "white", "name": "active flare", "description": "This burning magnesium flare is producing light. It will last for about a half hour before burning out.", - "price": 0, "material": ["paper", "plastic"], - "flags": ["FIRE", "LIGHT_240", "CHARGEDIM", "FLAMING", "TRADER_AVOID"], + "flags": [ "FIRE", "LIGHT_240", "CHARGEDIM", "FLAMING", "TRADER_AVOID" ], "weight": 128, "volume": 1, "bashing": 2, @@ -4863,7 +4862,7 @@ "description": "This is a thick candle. It doesn't provide very much light, but it can burn for quite a long time. This candle is lit.", "price": 0, "material": "veggy", - "flags": [ "LIGHT_8", "TRADER_AVOID" ], + "flags": ["LIGHT_8", "TRADER_AVOID"], "weight": 100, "volume": 1, "to_hit": -2, From fcb6337ce6fdec0d0b2b3498b77474c72a18519b Mon Sep 17 00:00:00 2001 From: Angela Graves Date: Fri, 3 Jun 2016 22:48:14 -0500 Subject: [PATCH 40/42] Formatting fix in armor.json. --- data/json/items/armor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/armor.json b/data/json/items/armor.json index fe10d9f5ffa7..bdf8c7f0da35 100644 --- a/data/json/items/armor.json +++ b/data/json/items/armor.json @@ -6617,7 +6617,7 @@ "color" : "brown", "covers" : ["TORSO"], "symbol" : "[", - "description" : "A large leather quiver trimmed with metal, worn on the back, that can hold 60 arrows.\nHistorically used by horse archers, rather than foot archers, but neither of THEM had to fight zombies. Activate to store arrows.", + "description" : "A large leather quiver trimmed with metal, worn on the back, that can hold 60 arrows. Historically used by horse archers, rather than foot archers, but neither of THEM had to fight zombies. Activate to store arrows.", "price" : 8800, "material" : ["leather", "steel"], "volume" : 6, From 92f18e0e6064f1428415138c80b3a1d9c164bd0d Mon Sep 17 00:00:00 2001 From: Mugling Date: Sat, 4 Jun 2016 19:53:46 +0100 Subject: [PATCH 41/42] Fix null contents when specifying ammo with integral magazines --- src/item_group.cpp | 4 ++-- src/vehicle.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index b11dc92e95b2..32a017dfa09b 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -345,10 +345,10 @@ Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) c for( auto& e : result ) { if( e.is_tool() || e.is_gun() || e.is_magazine() ) { - bool spawn_ammo = rng( 0, 99 ) < with_ammo && e.ammo_remaining() == 0 && e.ammo_type() != "NULL"; + bool spawn_ammo = rng( 0, 99 ) < with_ammo && e.ammo_remaining() == 0; bool spawn_mag = rng( 0, 99 ) < with_magazine && !e.magazine_integral() && !e.magazine_current(); - if( spawn_mag || spawn_ammo ) { + if( spawn_mag ) { e.contents.emplace_back( e.magazine_default(), e.bday ); } if( spawn_ammo ) { diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 2fb9af0ce534..06acf0bf17ac 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -5097,10 +5097,10 @@ void vehicle::place_spawn_items() e.damage = rng( 1, MAX_ITEM_DAMAGE ); } if( e.is_tool() || e.is_gun() || e.is_magazine() ) { - bool spawn_ammo = rng( 0, 99 ) < spawn.with_ammo && e.ammo_remaining() == 0 && e.ammo_type() != "NULL"; + bool spawn_ammo = rng( 0, 99 ) < spawn.with_ammo && e.ammo_remaining() == 0; bool spawn_mag = rng( 0, 99 ) < spawn.with_magazine && !e.magazine_integral() && !e.magazine_current(); - if( spawn_mag || spawn_ammo ) { + if( spawn_mag ) { e.contents.emplace_back( e.magazine_default(), e.bday ); } if( spawn_ammo ) { From 77b732d271a9c0b68f5f2d9676d7cb32d5af5e74 Mon Sep 17 00:00:00 2001 From: Mugling Date: Sat, 4 Jun 2016 19:56:08 +0100 Subject: [PATCH 42/42] Make ammo_set() more strict for null ammo types --- src/item.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index ca7d6395192f..bfa047e80e5a 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -241,9 +241,11 @@ item& item::ammo_set( const itype_id& ammo, long qty ) } // handle reloadable tools and guns with no specific ammo type as special case - if( ( is_tool() || is_gun() ) && magazine_integral() && ammo == "null" && ammo_type() == "NULL" ) { - curammo = nullptr; - charges = std::min( qty, ammo_capacity() ); + if( ammo == "null" && ammo_type() == "NULL" ) { + if( ( is_tool() || is_gun() ) && magazine_integral() ) { + curammo = nullptr; + charges = std::min( qty, ammo_capacity() ); + } return *this; }