forked from MineClone5/MineClone5
Partially implement “Sniper Duel” achievement
This commit is contained in:
parent
edf3204393
commit
1fc98d74b9
|
@ -4,5 +4,4 @@ mcl_core
|
||||||
mcl_cake
|
mcl_cake
|
||||||
mcl_mobitems
|
mcl_mobitems
|
||||||
mcl_flowerpots
|
mcl_flowerpots
|
||||||
mcl_dispensers
|
|
||||||
intllib?
|
intllib?
|
||||||
|
|
|
@ -143,10 +143,19 @@ awards.register_achievement("mcl:onARail", {
|
||||||
icon = "default_rail.png",
|
icon = "default_rail.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Triggered in mcl_throwing
|
||||||
|
awards.register_achievement("mcl:snipeSkeleton", {
|
||||||
|
title = S("Sniper Duel"),
|
||||||
|
-- TODO: This achievement should be for killing, not hitting
|
||||||
|
description = S("Hit a skeleton, wither skeleton or stray by bow and arrow from a distance of at least 50 meters."),
|
||||||
|
icon = "mcl_throwing_bow.png",
|
||||||
|
})
|
||||||
|
|
||||||
-- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.)
|
-- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.)
|
||||||
|
|
||||||
awards.register_achievement("mcl:n_placeDispenser", {
|
awards.register_achievement("mcl:n_placeDispenser", {
|
||||||
title = S("Dispense With This"),
|
title = S("Dispense With This"),
|
||||||
|
description = S("Place a dispenser."),
|
||||||
icon = "mcl_dispensers_dispenser_front_horizontal.png",
|
icon = "mcl_dispensers_dispenser_front_horizontal.png",
|
||||||
trigger = {
|
trigger = {
|
||||||
type = "place",
|
type = "place",
|
||||||
|
|
|
@ -40,6 +40,7 @@ local THROWING_ARROW_ENTITY={
|
||||||
|
|
||||||
_timer=0,
|
_timer=0,
|
||||||
_lastpos={},
|
_lastpos={},
|
||||||
|
_startpos=nil,
|
||||||
_damage=1, -- Damage on impact
|
_damage=1, -- Damage on impact
|
||||||
_shooter=nil, -- ObjectRef of player or mob who shot it
|
_shooter=nil, -- ObjectRef of player or mob who shot it
|
||||||
}
|
}
|
||||||
|
@ -53,11 +54,20 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
if obj:get_luaentity() ~= nil then
|
if obj:get_luaentity() ~= nil then
|
||||||
if obj ~= self._shooter and obj:get_luaentity().name ~= "mcl_throwing:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
local entity_name = obj:get_luaentity().name
|
||||||
|
if obj ~= self._shooter and entity_name ~= "mcl_throwing:arrow_entity" and entity_name ~= "__builtin:item" then
|
||||||
obj:punch(self.object, 1.0, {
|
obj:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
damage_groups={fleshy=self._damage},
|
damage_groups={fleshy=self._damage},
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
|
-- Achievement for hitting skeleton, wither skeleton or stray (TODO) with an arrow at least 50 meters away
|
||||||
|
-- TODO: This achievement should be given for the kill, not just a hit
|
||||||
|
if self._shooter and self._shooter:is_player() and vector.distance(pos, self._startpos) >= 50 then
|
||||||
|
if (entity_name == "mobs_mc:skeleton" or entity_name == "mobs_mc:skeleton2") then
|
||||||
|
awards.unlock(self._shooter:get_player_name(), "mcl:snipeSkeleton")
|
||||||
|
end
|
||||||
|
end
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
elseif obj ~= self._shooter then
|
elseif obj ~= self._shooter then
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
mcl_core
|
mcl_core
|
||||||
|
mcl_achievements
|
||||||
|
|
|
@ -23,6 +23,7 @@ mcl_throwing.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, d
|
||||||
local le = obj:get_luaentity()
|
local le = obj:get_luaentity()
|
||||||
le._shooter = shooter
|
le._shooter = shooter
|
||||||
le._damage = damage
|
le._damage = damage
|
||||||
|
le._startpos = pos
|
||||||
minetest.sound_play("mcl_throwing_bow_shoot", {pos=pos})
|
minetest.sound_play("mcl_throwing_bow_shoot", {pos=pos})
|
||||||
if shooter ~= nil then
|
if shooter ~= nil then
|
||||||
if obj:get_luaentity().player == "" then
|
if obj:get_luaentity().player == "" then
|
||||||
|
|
Loading…
Reference in New Issue