Skip to content

Commit

Permalink
Merge pull request #7 from CleverRaven/master
Browse files Browse the repository at this point in the history
Update #7
  • Loading branch information
Xenomorph-III authored Oct 26, 2019
2 parents a217d42 + e50a4e1 commit 3f6337e
Show file tree
Hide file tree
Showing 28 changed files with 360 additions and 214 deletions.
7 changes: 5 additions & 2 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,12 @@
"id": "bio_nanobots",
"type": "bionic",
"name": "Repair Nanobots",
"description": "Inside your body is a fleet of tiny dormant robots. While activated they will flit about your body, repairing damage at 1 HP/s and stopping bleeding at the cost of power.",
"description": "Inside your body is a fleet of tiny dormant robots. While activated they will flit about your body, repairing damage at 1 HP per minute and stopping bleeding at the cost of extra power and stored calories.",
"occupied_bodyparts": [ [ "TORSO", 10 ] ],
"flags": [ "BIONIC_TOGGLED", "BIONIC_NPC_USABLE" ]
"flags": [ "BIONIC_TOGGLED", "BIONIC_NPC_USABLE" ],
"act_cost": "80 J",
"react_cost": "4 J",
"time": 1
},
{
"id": "bio_night",
Expand Down
2 changes: 2 additions & 0 deletions data/json/items/melee/swords_and_blades.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@
"type": "GENERIC",
"symbol": "/",
"color": "light_gray",
"looks_like": "arming_sword",
"name": "arming sword",
"description": "This is a dull, cheaply made replica of a classic medieval sword, just the right size to use one-handed.",
"price": 10000,
Expand All @@ -685,6 +686,7 @@
"type": "TOOL",
"symbol": "/",
"color": "light_gray",
"looks_like": "arming_sword",
"name": "arming sword",
"description": "This is a classic medieval sword, just the right size to use one-handed. This one doesn't seem to have been made right.",
"price": 100000,
Expand Down
7 changes: 7 additions & 0 deletions data/json/player_activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@
"rooted": true,
"based_on": "time"
},
{
"id": "ACT_HEATING",
"type": "activity_type",
"activity_level": "NO_EXERCISE",
"verb": "heating",
"based_on": "time"
},
{
"id": "ACT_VIBE",
"type": "activity_type",
Expand Down
10 changes: 5 additions & 5 deletions data/mods/Magiclysm/monsters/monsters.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
"flags": [ "HEARS", "GOODHEARING", "NOHEAD", "POISON", "NO_BREATHE", "ACIDPROOF" ]
},
{
"id": "mon_nothic",
"name": "nothic",
"description": "A baleful eye peers out from the darkness, its gleam hinting at a weird intelligence and unnerving malevolence.",
"symbol": "N",
"id": "mon_krabgek",
"name": "krabgek",
"description": "A large baleful eye peers out from the darkness, its gleam hinting at a weird intelligence and unnerving malevolence. The eye oozes some pinkish liquid, and the weirdly humanoid figure is covered in sharp blue-black triangular plates.",
"symbol": "K",
"color": "dark_gray",
"type": "MONSTER",
"flags": [ "SEES", "HEARS", "SMELLS", "KEENNOSE", "PATH_AVOID_DANGER_1", "WARM" ],
Expand Down Expand Up @@ -105,7 +105,7 @@
"cooldown": 1,
"damage_max_instance": [ { "damage_type": "cut", "amount": 25, "armor_multiplier": 1.2 } ]
},
{ "type": "spell", "spell_id": "necrotic_gaze", "cooldown": 5, "monster_message": "The nothic gazes at %3$s!" }
{ "type": "spell", "spell_id": "necrotic_gaze", "cooldown": 5, "monster_message": "The krabgek gazes at %3$s!" }
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Magiclysm/worldgen/used_bookstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"d": "f_dumpster",
"C": "f_counter"
},
"monster": { "O": { "monster": "mon_nothic", "chance": 100 }, "z": { "monster": "mon_nothic", "chance": 33 } },
"monster": { "O": { "monster": "mon_krabgek", "chance": 100 }, "z": { "monster": "mon_krabgek", "chance": 33 } },
"toilets": { "&": { } },
"items": { "M": { "item": "spellbook_loot_1", "chance": 60 }, "N": { "item": "novels", "chance": 60, "repeat": [ 1, 3 ] } }
}
Expand Down
50 changes: 40 additions & 10 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ activity_handlers::finish_functions = {
{ activity_id( "ACT_CRACKING" ), cracking_finish },
{ activity_id( "ACT_OPEN_GATE" ), open_gate_finish },
{ activity_id( "ACT_REPAIR_ITEM" ), repair_item_finish },
{ activity_id( "ACT_HEATING" ), heat_item_finish },
{ activity_id( "ACT_MEND_ITEM" ), mend_item_finish },
{ activity_id( "ACT_GUNMOD_ADD" ), gunmod_add_finish },
{ activity_id( "ACT_TOOLMOD_ADD" ), toolmod_add_finish },
Expand Down Expand Up @@ -1769,7 +1770,7 @@ void activity_handlers::pulp_do_turn( player_activity *act, player *p )
p->practice( skill_survival, 2, 2 );
}

float stamina_ratio = static_cast<float>( p->stamina ) / p->get_stamina_max();
float stamina_ratio = static_cast<float>( p->get_stamina() ) / p->get_stamina_max();
moves += 100 / std::max( 0.25f, stamina_ratio );
if( stamina_ratio < 0.33 || p->is_npc() ) {
p->moves = std::min( 0, p->moves - moves );
Expand Down Expand Up @@ -2483,6 +2484,35 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p )
act->moves_left = actor->move_cost;
}

void activity_handlers::heat_item_finish( player_activity *act, player *p )
{
act->set_to_null();
if( act->targets.size() != 1 ) {
debugmsg( "invalid arguments to ACT_HEATING" );
return;
}
item_location &loc = act->targets[ 0 ];
item *heat = loc.get_item();
if( heat == nullptr ) {
return;
}
item &target = heat->is_food_container() ? heat->contents.front() : *heat;
if( target.item_tags.count( "FROZEN" ) ) {
target.apply_freezerburn();
if( target.has_flag( "EATEN_COLD" ) ) {
target.cold_up();
p->add_msg_if_player( m_info,
_( "You defrost the food, but don't heat it up, since you enjoy it cold." ) );
} else {
target.heat_up();
p->add_msg_if_player( m_info, _( "You defrost and heat up the food." ) );
}
} else {
target.heat_up();
p->add_msg_if_player( m_info, _( "You heat up the food." ) );
}
}

void activity_handlers::mend_item_finish( player_activity *act, player *p )
{
act->set_to_null();
Expand Down Expand Up @@ -2854,10 +2884,10 @@ void activity_handlers::read_do_turn( player_activity *act, player *p )
if( p->is_player() ) {
if( !act->str_values.empty() && act->str_values[0] == "martial_art" && one_in( 3 ) ) {
if( act->values.empty() ) {
act->values.push_back( p->stamina );
act->values.push_back( p->get_stamina() );
}
p->stamina = act->values[0] - 1;
act->values[0] = p->stamina;
p->set_stamina( act->values[0] - 1 );
act->values[0] = p->get_stamina();
}
} else {
p->moves = 0;
Expand Down Expand Up @@ -2949,10 +2979,10 @@ void activity_handlers::wait_stamina_do_turn( player_activity *act, player *p )
stamina_threshold = act->values[0];
// remember initial stamina, only for waiting-with-threshold
if( act->values.size() == 1 ) {
act->values.push_back( p->stamina );
act->values.push_back( p->get_stamina() );
}
}
if( p->stamina >= stamina_threshold ) {
if( p->get_stamina() >= stamina_threshold ) {
wait_stamina_finish( act, p );
}
}
Expand All @@ -2961,12 +2991,12 @@ void activity_handlers::wait_stamina_finish( player_activity *act, player *p )
{
if( !act->values.empty() ) {
const int stamina_threshold = act->values[0];
const int stamina_initial = ( act->values.size() > 1 ) ? act->values[1] : p->stamina;
if( p->stamina < stamina_threshold && p->stamina <= stamina_initial ) {
const int stamina_initial = ( act->values.size() > 1 ) ? act->values[1] : p->get_stamina();
if( p->get_stamina() < stamina_threshold && p->get_stamina() <= stamina_initial ) {
debugmsg( "Failed to wait until stamina threshold %d reached, only at %d. You may not be regaining stamina.",
act->values.front(), p->stamina );
act->values.front(), p->get_stamina() );
}
} else if( p->stamina < p->get_stamina_max() ) {
} else if( p->get_stamina() < p->get_stamina_max() ) {
p->add_msg_if_player( _( "You are bored of waiting, so you stop." ) );
} else {
p->add_msg_if_player( _( "You finish waiting and feel refreshed." ) );
Expand Down
1 change: 1 addition & 0 deletions src/activity_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ void mend_item_finish( player_activity *act, player *p );
void gunmod_add_finish( player_activity *act, player *p );
void toolmod_add_finish( player_activity *act, player *p );
void clear_rubble_finish( player_activity *act, player *p );
void heat_item_finish( player_activity *act, player *p );
void meditate_finish( player_activity *act, player *p );
void read_finish( player_activity *act, player *p );
void wait_finish( player_activity *act, player *p );
Expand Down
2 changes: 1 addition & 1 deletion src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ bool avatar::read( int inventory_position, const bool continuous )
// push an indentifier of martial art book to the action handling
if( it.type->use_methods.count( "MA_MANUAL" ) ) {

if( g->u.stamina < g->u.get_stamina_max() / 10 ) {
if( g->u.get_stamina() < g->u.get_stamina_max() / 10 ) {
add_msg( m_info, _( "You are too exhausted to train martial arts." ) );
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ bool avatar_action::fire( avatar &you, map &m )
you.mod_stat( "stamina", gun->get_min_str() * static_cast<int>( 0.002f *
get_option<int>( "PLAYER_MAX_STAMINA" ) ) );
// At low stamina levels, firing starts getting slow.
int sta_percent = ( 100 * you.stamina ) / you.get_stamina_max();
int sta_percent = ( 100 * you.get_stamina() ) / you.get_stamina_max();
reload_time += ( sta_percent < 25 ) ? ( ( 25 - sta_percent ) * 2 ) : 0;

// Update targeting data to include ammo's range bonus
Expand Down
57 changes: 45 additions & 12 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iterator>
#include <list>
#include <memory>
#include <forward_list>

#include "action.h"
#include "avatar.h"
Expand Down Expand Up @@ -987,15 +988,44 @@ void player::process_bionic( int b )
sounds::sound( pos(), 19, sounds::sound_t::activity, _( "HISISSS!" ), false, "bionic",
"bio_hydraulics" );
} else if( bio.id == "bio_nanobots" ) {
for( int i = 0; i < num_hp_parts; i++ ) {
if( get_power_level() >= 5_kJ && hp_cur[i] > 0 && hp_cur[i] < hp_max[i] ) {
heal( static_cast<hp_part>( i ), 1 );
mod_power_level( -5_kJ );
if( get_power_level() >= 40_J ) {
std::forward_list<int> bleeding_bp_parts;
for( const body_part bp : all_body_parts ) {
if( has_effect( effect_bleed, bp ) ) {
bleeding_bp_parts.push_front( static_cast<int>( bp ) );
}
}
}
for( const body_part bp : all_body_parts ) {
if( get_power_level() >= 2_kJ && remove_effect( effect_bleed, bp ) ) {
mod_power_level( -2_kJ );
std::vector<int> damaged_hp_parts;
for( int i = 0; i < num_hp_parts; i++ ) {
if( hp_cur[i] > 0 && hp_cur[i] < hp_max[i] ) {
damaged_hp_parts.push_back( i );
// only healed and non-hp parts will have a chance of bleeding removal
bleeding_bp_parts.remove( static_cast<int>( hp_to_bp( static_cast<hp_part>( i ) ) ) );
}
}
if( calendar::once_every( 60_turns ) ) {
bool try_to_heal_bleeding = true;
if( get_stored_kcal() >= 5 && damaged_hp_parts.size() > 0 ) {
const hp_part part_to_heal = static_cast<hp_part>( damaged_hp_parts[ rng( 0,
damaged_hp_parts.size() - 1 ) ] );
heal( part_to_heal, 1 );
mod_stored_kcal( -5 );
const body_part bp_healed = hp_to_bp( part_to_heal );
int hp_percent = float( hp_cur[part_to_heal] ) / hp_max[part_to_heal] * 100;
if( has_effect( effect_bleed, bp_healed ) && rng( 0, 100 ) < hp_percent ) {
remove_effect( effect_bleed, bp_healed );
try_to_heal_bleeding = false;
}
}

// if no bleed was removed, try to remove it on some other part
if( try_to_heal_bleeding && !bleeding_bp_parts.empty() && rng( 0, 1 ) == 1 ) {
remove_effect( effect_bleed, static_cast<body_part>( bleeding_bp_parts.front() ) );
}

}
if( !damaged_hp_parts.empty() || !bleeding_bp_parts.empty() ) {
mod_power_level( -40_J );
}
}
} else if( bio.id == "bio_painkiller" ) {
Expand Down Expand Up @@ -1252,7 +1282,8 @@ float player::bionics_adjusted_skill( const skill_id &most_important_skill,
return adjusted_skill;
}

int player::bionics_pl_skill( const skill_id &most_important_skill, const skill_id &important_skill,
int player::bionics_pl_skill( const skill_id &most_important_skill,
const skill_id &important_skill,
const skill_id &least_important_skill, int skill_level )
{
int pl_skill;
Expand Down Expand Up @@ -1634,7 +1665,8 @@ bool player::can_install_bionics( const itype &type, player &installer, bool aut
return true;
}

bool player::install_bionics( const itype &type, player &installer, bool autodoc, int skill_level )
bool player::install_bionics( const itype &type, player &installer, bool autodoc,
int skill_level )
{
if( !type.bionic ) {
debugmsg( "Tried to install NULL bionic" );
Expand Down Expand Up @@ -2057,7 +2089,8 @@ void reset_bionics()
faulty_bionics.clear();
}

static bool get_bool_or_flag( JsonObject &jsobj, const std::string &name, const std::string &flag,
static bool get_bool_or_flag( JsonObject &jsobj, const std::string &name,
const std::string &flag,
const bool fallback, const std::string &flags_node = "flags" )
{
bool value = fallback;
Expand Down Expand Up @@ -2264,7 +2297,7 @@ void bionic::deserialize( JsonIn &jsin )
}

void player::introduce_into_anesthesia( const time_duration &duration, player &installer,
bool needs_anesthesia ) //used by the Autodoc
bool needs_anesthesia ) //used by the Autodoc
{
installer.add_msg_player_or_npc( m_info,
_( "You set up the operation step-by-step, configuring the Autodoc to manipulate a CBM." ),
Expand Down
Loading

0 comments on commit 3f6337e

Please sign in to comment.