Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow remote deployment of place_monster items, throwable manhacks #4174

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 37 additions & 26 deletions data/json/items/corpses/inactive_bots.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"id": "bot_EMP_hack",
"type": "TOOL",
"name": { "str": "inactive EMP hack" },
"description": "This is an inactive EMP hack. EMP hacks are fist-sized robots that fly through the air. This one contains an EMP grenade and attacks by flying at its target and detonating. Use this item to reprogram and release the EMP hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "3750 g",
"description": "This is an inactive EMP hack. EMP hacks are fist-sized robots that fly through the air. This one contains an EMP grenade and attacks by flying at its target and detonating. Use or throw this item to reprogram and release the EMP hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "2 kg",
"volume": "750 ml",
"price": "645 USD",
"price_postapoc": "30 USD",
Expand All @@ -23,14 +23,15 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_c4_hack",
"type": "TOOL",
"name": { "str": "inactive C-4 hack" },
"description": "This is an inactive C-4 hack. C-4 hacks are fist-sized robots that fly through the air. This one contains some C-4 and attacks by flying at its target and detonating. Use this item to reprogram and activate the C-4 hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "4920 g",
"description": "This is an inactive C-4 hack. C-4 hacks are fist-sized robots that fly through the air. This one contains some C-4 and attacks by flying at its target and detonating. Use or throw this item to reprogram and activate the C-4 hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "3200 g",
"volume": "1500 ml",
"price": "675 USD",
"price_postapoc": "30 USD",
Expand All @@ -49,14 +50,15 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_flashbang_hack",
"type": "TOOL",
"name": { "str": "inactive flashbang hack" },
"description": "This is an inactive flashbang hack. Flashbang hacks are fist-sized robots that fly through the air. This one contains a flashbang and attacks by flying at its target and detonating. Use this item to reprogram and activate the flashbang hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "3590 g",
"description": "This is an inactive flashbang hack. Flashbang hacks are fist-sized robots that fly through the air. This one contains a flashbang and attacks by flying at its target and detonating. Use or throw this item to reprogram and activate the flashbang hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "1800 g",
"volume": "750 ml",
"price": "595 USD",
"price_postapoc": "5 USD",
Expand All @@ -75,14 +77,15 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_gasbomb_hack",
"type": "TOOL",
"name": { "str": "inactive tear gas hack" },
"description": "This is an inactive tear gas hack. Tear gas hacks are fist-sized robots that fly through the air. This one contains a tear gas canister and attacks by flying at its target and releasing tear gas. Use this item to reprogram and activate the tear gas hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "4410 g",
"description": "This is an inactive tear gas hack. Tear gas hacks are fist-sized robots that fly through the air. This one contains a tear gas canister and attacks by flying at its target and releasing tear gas. Use or throw this item to reprogram and activate the tear gas hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "2700 g",
"volume": "750 ml",
"price": "605 USD",
"price_postapoc": "5 USD",
Expand All @@ -101,14 +104,15 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_grenade_hack",
"type": "TOOL",
"name": { "str": "inactive grenade hack" },
"description": "This is an inactive grenade hack. Grenade hacks are fist-sized robots that fly through the air. This one contains a grenade and attacks by flying at its target and detonating. Use this item to reprogram and activate the grenade hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "3750 g",
"description": "This is an inactive grenade hack. Grenade hacks are fist-sized robots that fly through the air. This one contains a grenade and attacks by flying at its target and detonating. Use or throw this item to reprogram and activate the grenade hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "2800 g",
"volume": "750 ml",
"price": "600 USD",
"price_postapoc": "10 USD",
Expand All @@ -127,7 +131,8 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_laserturret",
Expand Down Expand Up @@ -155,8 +160,8 @@
"id": "bot_manhack",
"type": "TOOL",
"name": { "str": "inactive manhack" },
"description": "This is an inactive manhack. Manhacks are fist-sized robots that fly through the air. They are covered with whirring blades and attack by throwing themselves against their target. Use this item to reprogram and activate the manhack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "4450 g",
"description": "This is an inactive manhack. Manhacks are fist-sized robots that fly through the air. They are covered with whirring blades and attack by throwing themselves against their target. Use or throw this item to reprogram and activate the manhack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "2700 g",
"volume": "750 ml",
"price": "600 USD",
"price_postapoc": "5 USD",
Expand All @@ -175,15 +180,16 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_mininuke_hack",
"type": "TOOL",
"name": { "str": "inactive mininuke hack" },
"description": "This is an inactive mininuke hack. Many times as large as a normal manhack, a mininuke hack contains a mininuke and attack by flying at their target and detonating. Use this item to reprogram and activate the mininuke hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully.",
"weight": "26370 g",
"volume": "18750 ml",
"description": "This is an inactive mininuke hack. Many times as large as a normal manhack, a mininuke hack contains a mininuke and attack by flying at their target and detonating. Use this item to reprogram and activate the mininuke hack. Electronics and computer skill determines if the targeting matrix is reprogrammed successfully. An inhumanly strong user could also deploy it remotely by throwing it, which might give you a head start if it's programmed incorrectly.",
"weight": "24600 g",
"volume": "18550 ml",
"price": "26775 USD",
"price_postapoc": "100 USD",
"to_hit": -3,
Expand All @@ -201,7 +207,9 @@
"moves": 60,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"//": "Good luck tossing this one, but sure why not",
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_turret_riot",
Expand Down Expand Up @@ -428,9 +436,9 @@
"looks_like": "broken_eyebot",
"type": "TOOL",
"name": { "str": "inactive eyebot" },
"description": "This is an inactive eyebot. Using this item involves turning it on and launching the UAV. If reprogrammed and rewired successfully the eyebot will then keep watch for intruders.",
"weight": "40750 g",
"volume": "30 L",
"description": "This is an inactive eyebot. Using this item involves turning it on and launching the UAV. If reprogrammed and rewired successfully the eyebot will then keep watch for intruders. An inhumanly strong user could also deploy it remotely by throwing it.",
"weight": "9400 g",
"volume": "20 L",
"price": "100 USD",
"price_postapoc": "5 USD",
"to_hit": -3,
Expand All @@ -446,8 +454,11 @@
"//": "Like most surveillance tech these likely have poor security. Secure the wifi!",
"difficulty": 1,
"moves": 100,
"place_randomly": true,
"skills": [ "electronics", "computer" ]
}
},
"//": "Few character will have the strength for this, but allow trying it anyway",
"flags": [ "ACT_ON_RANGED_HIT" ]
},
{
"id": "bot_hazmatbot",
Expand Down
18 changes: 9 additions & 9 deletions data/json/items/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@
"price": "10 USD",
"price_postapoc": "10 cent",
"material": [ "steel", "plastic" ],
"weight": "31520 g",
"weight": "7050 g",
"volume": "15 L",
"bashing": 6,
"cutting": 6,
Expand Down Expand Up @@ -1240,7 +1240,7 @@
"price": "10 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "4440 g",
"weight": "2700 g",
"volume": "750 ml",
"bashing": 6,
"cutting": 6,
Expand All @@ -1258,7 +1258,7 @@
"price": "90 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "3340 g",
"weight": "2800 g",
"volume": "750 ml",
"bashing": 6,
"cutting": 6,
Expand All @@ -1276,8 +1276,8 @@
"price": "180 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "3350 g",
"volume": "18750 ml",
"weight": "24600 g",
"volume": "18550 ml",
"bashing": 6,
"cutting": 6,
"to_hit": -3,
Expand All @@ -1294,7 +1294,7 @@
"price": "90 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "3340 g",
"weight": "2700 g",
"volume": "750 ml",
"bashing": 6,
"cutting": 6,
Expand All @@ -1312,7 +1312,7 @@
"price": "90 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "3340 g",
"weight": "2 kg",
"volume": "750 ml",
"bashing": 6,
"cutting": 6,
Expand All @@ -1330,7 +1330,7 @@
"price": "90 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "3340 g",
"weight": "1800 g",
"volume": "750 ml",
"bashing": 6,
"cutting": 6,
Expand All @@ -1348,7 +1348,7 @@
"price": "90 USD",
"price_postapoc": "10 cent",
"material": [ "aluminum", "plastic" ],
"weight": "3340 g",
"weight": "3200 g",
"volume": "750 ml",
"bashing": 6,
"cutting": 6,
Expand Down
2 changes: 2 additions & 0 deletions data/json/monsters/drones.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
"type": "MONSTER",
"name": { "str": "mininuke hack" },
"description": "Many times as large as a normal manhack, this flying quadcopter drone appears to have a mininuke inside. If this is targeting you… Run.",
"weight": "24600 g",
"volume": "18550 ml",
"diff": 40,
"hp": 20,
"speed": 150,
Expand Down
4 changes: 2 additions & 2 deletions data/json/monsters/utility_bot.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"default_faction": "cop_bot",
"species": [ "ROBOT" ],
"diff": 2,
"volume": "30000 ml",
"weight": "40750 g",
"weight": "9400 g",
"volume": "20 L",
"hp": 20,
"speed": 120,
"material": [ "steel" ],
Expand Down
4 changes: 3 additions & 1 deletion data/json/recipes/electronic/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@
[ [ "processor", 1 ] ],
[ [ "scrap", 1 ] ],
[ [ "quad_rotors", 1 ] ],
[ [ "lens", 1 ] ]
[ [ "lens", 1 ] ],
[ [ "omnicamera", 1 ] ],
[ [ "sheet_metal_small", 24 ], [ "sheet_metal", 1 ] ]
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion data/json/uncraft/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@
[ [ "processor", 1 ] ],
[ [ "scrap", 1 ] ],
[ [ "quad_rotors", 1 ] ],
[ [ "lens", 1 ] ]
[ [ "lens", 1 ] ],
[ [ "omnicamera", 1 ] ],
[ [ "sheet_metal_small", 24 ] ]
]
},
{
Expand Down
14 changes: 11 additions & 3 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,16 +1017,20 @@ void place_monster_iuse::load( const JsonObject &obj )
}
}

int place_monster_iuse::use( player &p, item &it, bool, const tripoint & ) const
int place_monster_iuse::use( player &p, item &it, bool, const tripoint &pos ) const
{
shared_ptr_fast<monster> newmon_ptr = make_shared_fast<monster>( mtypeid );
monster &newmon = *newmon_ptr;
newmon.init_from_item( it );
tripoint pnt = it.active ? pos : p.pos();
if( place_randomly ) {
// place_critter_around returns the same pointer as its parameter (or null)
if( !g->place_critter_around( newmon_ptr, p.pos(), 1 ) ) {
// Allow position to be different from the player for tossed or launched items
if( !g->place_critter_around( newmon_ptr, pnt, 1 ) ) {
p.add_msg_if_player( m_info, _( "There is no adjacent square to release the %s in!" ),
newmon.name() );
// If remotely triggered due to ACT_ON_RANGED_HIT, set it back to being inactive so it won't spawn infinitely
it.active = false;
return 0;
}
} else {
Expand All @@ -1041,7 +1045,11 @@ int place_monster_iuse::use( player &p, item &it, bool, const tripoint & ) const
return 0;
}
}
p.moves -= moves;
// If it's active then we know it was triggered by ACT_ON_RANGED_HIT and did not deactivate from lack of room earlier
// If so, don't drain moves from remote deployment since it would trigger after the throw
if( !it.active ) {
p.moves -= moves;
}
if( !newmon.has_flag( MF_INTERIOR_AMMO ) ) {
for( auto &amdef : newmon.ammo ) {
item &ammo_item = *item::spawn_temporary( amdef.first, calendar::start_of_cataclysm );
Expand Down
Loading