Skip to content

Commit

Permalink
Add u_buy_monster talk effect (CleverRaven#33446)
Browse files Browse the repository at this point in the history
* Add u_buy_monster talk effect

* Update u_buy_monster name to be translatable
  • Loading branch information
ralreegorganon authored and misterprimus committed Sep 21, 2019
1 parent a1b52dd commit eae3abc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/NPCs.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ Effect | Description
`add_debt: mod_list` | Increases the NPC's debt to the player by the values in the `mod_list`.<br/>The following would increase the NPC's debt to the player by 1500x the NPC's altruism and 1000x the NPC's opinion of the player's value: `{ "effect": { "add_debt": [ [ "ALTRUISM", 3 ], [ "VALUE", 2 ], [ "TOTAL", 500 ] ] } }`
`u_consume_item`, `npc_consume_item: item_string`, (*optional* `count: count_num`) | You or the NPC will delete the item or `count_num` copies of the item from their inventory.<br/>This effect will fail if the you or NPC does not have at least `count_num` copies of the item, so it should be checked with `u_has_items` or `npc_has_items`.
`u_remove_item_with`, `npc_remove_item_with: item_string` | You or the NPC will delete any instances of item in inventory.<br/>This is an unconditional remove and will not fail if you or the NPC does not have the item.
`u_buy_monster: monster_type_string`, (*optional* `cost: cost_num`, *optional* `count: count_num`, *optional* `name: name_string`, *optional* `pacified: pacified_bool`) | The NPC will give your character `count_num` (default 1) instances of the monster as pets and will subtract `cost_num` from `op_of_u.owed` if specified. If the `op_o_u.owed` is less than `cost_num`, the trade window will open and the player will have to trade to make up the difference; the NPC will not give the player the item unless `cost_num` is satisfied.<br/>If cost isn't present, the NPC gives your character the item at no charge.<br/>If `name_string` is specified the monster(s) will have the specified name. If `pacified_bool` is set to true, the monster will have the pacified effect applied.


#### Behaviour / AI

Expand Down
9 changes: 9 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "json.h"
#include "line.h"
#include "map.h"
#include "map_iterator.h"
#include "mapgen_functions.h"
#include "martialarts.h"
#include "messages.h"
Expand Down Expand Up @@ -2303,6 +2304,14 @@ void talk_effect_t::parse_sub_effect( JsonObject jo )
subeffect_fun.set_npc_cbm_recharge_rule( setting );
} else if( jo.has_member( "mapgen_update" ) ) {
subeffect_fun.set_mapgen_update( jo, "mapgen_update" );
} else if( jo.has_string( "u_buy_monster" ) ) {
const std::string &monster_type_id = jo.get_string( "u_buy_monster" );
const int cost = jo.get_int( "cost", 0 );
const int count = jo.get_int( "count", 1 );
const bool pacified = jo.get_bool( "pacified", false );
translation name;
jo.read( "name", name );
subeffect_fun.set_u_buy_monster( monster_type_id, cost, count, pacified, name );
} else {
jo.throw_error( "invalid sub effect syntax :" + jo.str() );
}
Expand Down

0 comments on commit eae3abc

Please sign in to comment.