Update turrets
This commit is contained in:
parent
a2e41623e6
commit
64022c69c0
@ -127,19 +127,7 @@ minetest.register_chatcommand("join", {
|
|||||||
params = "team name",
|
params = "team name",
|
||||||
description = "Add to team",
|
description = "Add to team",
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local player = cf.player(name)
|
cf.join(name, param, false)
|
||||||
|
|
||||||
if not player then
|
|
||||||
player = {name=name}
|
|
||||||
end
|
|
||||||
|
|
||||||
if not cf.setting("players_can_change_team") and (not player.team or player.team=="") then
|
|
||||||
minetest.chat_send_player(name,"You are not allowed to switch teams, traitor!",false)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cf.add_user(param,player) == true then
|
|
||||||
minetest.chat_send_all(name.." has joined team "..param)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
minetest.register_chatcommand("list_teams", {
|
minetest.register_chatcommand("list_teams", {
|
||||||
|
@ -111,8 +111,32 @@ function cf.player(name)
|
|||||||
return cf.players[name]
|
return cf.players[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add a user to a team
|
-- Player joins team
|
||||||
function cf.add_user(team,user)
|
function cf.join(name, team, force)
|
||||||
|
if not name or name == "" or not team or team == "" then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local player = cf.player(name)
|
||||||
|
|
||||||
|
if not player then
|
||||||
|
player = {name = name}
|
||||||
|
end
|
||||||
|
|
||||||
|
if not force and not cf.setting("players_can_change_team") and (not player.team or player.team == "") then
|
||||||
|
minetest.chat_send_player(name, "You are not allowed to switch teams, traitor!")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if cf.add_user(team, player) == true then
|
||||||
|
minetest.chat_send_all(name.." has joined team "..team)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add a player to a team in data structures
|
||||||
|
function cf.add_user(team, user)
|
||||||
local _team = cf.team(team)
|
local _team = cf.team(team)
|
||||||
local _user = cf.player(user.name)
|
local _user = cf.player(user.name)
|
||||||
if _team and user and user.name then
|
if _team and user and user.name then
|
||||||
|
1
mods/capturetheflag/ctf_turret/depends.txt
Normal file
1
mods/capturetheflag/ctf_turret/depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
ctf
|
@ -1,6 +1,6 @@
|
|||||||
ARROW_DAMAGE = 2
|
ARROW_DAMAGE = 2
|
||||||
ARROW_VELOCITY = 2
|
ARROW_VELOCITY = 2
|
||||||
minetest.register_node("turret:turret", {
|
minetest.register_node("ctf_turret:turret", {
|
||||||
description = "Team Turret",
|
description = "Team Turret",
|
||||||
tiles = {
|
tiles = {
|
||||||
"default_stone.png",
|
"default_stone.png",
|
||||||
@ -40,7 +40,7 @@ minetest.register_node("turret:turret", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"turret:turret"},
|
nodenames = {"ctf_turret:turret"},
|
||||||
interval = 0.25,
|
interval = 0.25,
|
||||||
chance = 4,
|
chance = 4,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
@ -82,7 +82,7 @@ minetest.register_abm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Create bullet entity
|
-- Create bullet entity
|
||||||
local bullet=minetest.env:add_entity({x=pos.x,y=pos.y+0.5,z=pos.z}, "turret:arrow_entity")
|
local bullet=minetest.env:add_entity({x=pos.x,y=pos.y+0.5,z=pos.z}, "ctf_turret:arrow_entity")
|
||||||
|
|
||||||
-- Set velocity
|
-- Set velocity
|
||||||
bullet:setvelocity({x=calc.x * ARROW_VELOCITY,y=calc.y * ARROW_VELOCITY,z=calc.z * ARROW_VELOCITY})
|
bullet:setvelocity({x=calc.x * ARROW_VELOCITY,y=calc.y * ARROW_VELOCITY,z=calc.z * ARROW_VELOCITY})
|
||||||
@ -102,36 +102,35 @@ THROWING_ARROW_ENTITY={
|
|||||||
textures = {"bullet.png"},
|
textures = {"bullet.png"},
|
||||||
lastpos={},
|
lastpos={},
|
||||||
collisionbox = {-0.17,-0.17,-0.17,0.17,0.17,0.17},
|
collisionbox = {-0.17,-0.17,-0.17,0.17,0.17,0.17},
|
||||||
}
|
on_step = function(self, dtime)
|
||||||
-- Arrow_entity.on_step()--> called when arrow is moving
|
self.timer=self.timer+dtime
|
||||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
local pos = self.object:getpos()
|
||||||
self.timer=self.timer+dtime
|
if self.timer > 2 then
|
||||||
local pos = self.object:getpos()
|
self.object:remove()
|
||||||
local node = minetest.env:get_node(pos)
|
end
|
||||||
if self.timer > 2 then
|
|
||||||
self.object:remove()
|
if self.timer > 0.2 then
|
||||||
end
|
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
|
||||||
-- When arrow is away from player (after 0.2 seconds): Cause damage to mobs and players
|
for k, obj in pairs(objs) do
|
||||||
if self.timer>0.2 then
|
if obj:is_player() then
|
||||||
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
|
obj:set_hp(obj:get_hp() - ARROW_DAMAGE)
|
||||||
for k, obj in pairs(objs) do
|
self.object:remove()
|
||||||
if obj:is_player() then
|
end
|
||||||
obj:set_hp(obj:get_hp()-ARROW_DAMAGE)
|
|
||||||
self.object:remove()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local node = minetest.env:get_node(pos)
|
||||||
|
if node.name ~= "air" and node.name ~= "ctf_turret:turret" then
|
||||||
|
--minetest.env:add_item(self.lastpos, "throwing:arrow")
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
}
|
||||||
if node.name ~= "air" and node.name ~= "turret:turret" then
|
|
||||||
minetest.env:add_item(self.lastpos, 'throwing:arrow')
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity("turret:arrow_entity", THROWING_ARROW_ENTITY)
|
minetest.register_entity("ctf_turret:arrow_entity", THROWING_ARROW_ENTITY)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "turret:turret",
|
output = "ctf_turret:turret",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"},
|
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"},
|
||||||
{"default:gold_ingot", "default:mese_crystal", "default:gold_ingot"},
|
{"default:gold_ingot", "default:mese_crystal", "default:gold_ingot"},
|
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
@ -1,2 +0,0 @@
|
|||||||
default
|
|
||||||
capturetheflag
|
|
Loading…
x
Reference in New Issue
Block a user