forked from MT-CTF/capturetheflag
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes MT-CTF#1172, I nerfed it a little to make it more balanced, and hopefully farooq can use it to add his score thingy, but I tested it, and it works.
- Loading branch information
1 parent
48fcab4
commit bbf1561
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.47 KB
mods/ctf/ctf_modes/ctf_mode_classes/textures/ctf_mode_classes_thief_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
local robbery_cooldown = ctf_core.init_cooldowns() | ||
local ROBBERY_INTERVAL = 5 | ||
|
||
local function rob_player(player, robber) | ||
local inv = player:get_inventory() | ||
local stack = inv:get_stack("main", math.random(1, inv:get_size("main"))) | ||
local mode = ctf_modebase:get_current_mode() | ||
if mode and mode.stuff_provider then | ||
for _, item in ipairs(classes.get(player).items) do | ||
if stack:get_name() == item or stack:get_name() == "" then | ||
return "You didn't find anything to rob." | ||
end | ||
end | ||
if robber:get_inventory():room_for_item("main", stack) then | ||
inv:remove_item("main", stack) | ||
robber:get_inventory():add_item("main", stack) | ||
else | ||
local pos = player:get_pos() | ||
inv:remove_item("main", stack) | ||
minetest.add_item(pos, stack) | ||
end | ||
return string.format("You stole %s %s", stack:get_count(), stack:get_description()) | ||
end | ||
end | ||
|
||
minetest.register_on_punchplayer(function(punched, puncher) | ||
if puncher and puncher:is_player() and punched and punched:is_player() then | ||
local wielded_item = puncher:get_wielded_item() | ||
if puncher:get_wielded_item():get_name() == "" then | ||
if robbery_cooldown:get(puncher:get_player_name()) then | ||
hud_events.new(puncher, { | ||
text = "You can only rob every "..ROBBERY_INTERVAL.." seconds", | ||
color = "warning", | ||
quick = true, | ||
}) | ||
return | ||
end | ||
local msg = rob_player(punched, puncher) | ||
if msg then | ||
hud_events.new(puncher, { | ||
text = msg, | ||
color = "warning", | ||
quick = true, | ||
}) | ||
end | ||
robbery_cooldown:set(puncher, ROBBERY_INTERVAL) | ||
end | ||
end | ||
end) |