Skip to content
This repository has been archived by the owner on Nov 12, 2018. It is now read-only.

Commit

Permalink
Add teleportation.
Browse files Browse the repository at this point in the history
  • Loading branch information
linewriter1024 committed Jan 7, 2017
1 parent 47ef855 commit 0560f30
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kingdoms/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ kingdoms.config.default_level_talk = 1 -- Talk in the kingdom's main channel.

-- A corestone extends in a radius of <corestone_radius>.
kingdoms.config.corestone_radius = 32
kingdoms.config.corestone_overlap_multiplier = 4
kingdoms.config.corestone_overlap_multiplier = 3
-- A corestone can be placed only above <corestone_miny>.
kingdoms.config.corestone_miny = -32

Expand Down
11 changes: 9 additions & 2 deletions magic/crystals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ magic.crystals = {
{
name = "area",
desc = "Area",
color = "#0CC",
color = "#033",
light = 8,
},
{
name = "warp",
desc = "Warp",
color = "#0CC",
light = 13,
rarity = 0.5,
},
{
name = "control",
desc = "Control",
Expand Down Expand Up @@ -136,7 +143,7 @@ function magic.register_crystal(def, nocraft)
sounds = default.node_sound_stone_defaults(),
})

kingdoms.at_mod_load("kingdoms", function() kingdoms.register_dungeon_node("magic:concentrated_crystal_"..def.name, 4 / #magic.crystals) end)
kingdoms.at_mod_load("kingdoms", function() kingdoms.register_dungeon_node("magic:concentrated_crystal_"..def.name, (4 / #magic.crystals) * (def.rarity or 1)) end)

minetest.register_craftitem("magic:"..def.name.."_essence", {
description = def.desc.." Essence",
Expand Down
4 changes: 3 additions & 1 deletion magic/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ magic.config.mana_fast_regen = 2

-- Search radius of a missile turret.
magic.config.turret_missile_radius = 24

-- Block radius of a defense turret.
magic.config.turret_shield_radius = 5

-- Delay before actually teleporting.
magic.config.teleportation_delay = 5
1 change: 1 addition & 0 deletions magic/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ domodfile("turrets.lua")
domodfile("spells/action.lua")
domodfile("spells/attack.lua")
domodfile("spells/defense.lua")
domodfile("spells/teleportation.lua")

magic.log("action", "Loaded.")
kingdoms.mod_ready("magic")
8 changes: 8 additions & 0 deletions magic/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ function magic.register_spell(name, def)
if not docost(player) then return end
return f(itemstack, player, pointed_thing)
end
elseif def.type == "action" then
function item_def.on_use(itemstack, player, pointed_thing)
if not docost(player) then return end
if def.on_use(itemstack, player, pointed_thing) then
itemstack:take_item()
end
return itemstack
end
elseif def.type == "shield" then
-- magic.damage_obj handles shields.
else
Expand Down
92 changes: 92 additions & 0 deletions magic/spells/teleportation.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
local teleporting = {}
minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local tp = teleporting[name]
if tp then
tp.timer = tp.timer + dtime
if vector.distance(player:getpos(), tp.start) > 0.1 then
magic.cancel_teleportation(name)
elseif tp.timer >= tp.delay then
minetest.registered_items[tp.item].original.go(player)
teleporting[name] = nil
end
end
end
end)

function magic.start_teleportation(player, item, delay)
local name = player:get_player_name()
if teleporting[name] then
magic.cancel_teleportation(name)
end
teleporting[name] = {
timer = 0,
delay = delay,
item = item,
start = player:getpos(),
}
minetest.chat_send_player(name, "Teleportation will occur in "..tostring(delay).." seconds. Remain still.")
end

function magic.cancel_teleportation(name)
minetest.chat_send_player(name, "Teleportation has been canceled.")
teleporting[name] = nil
end

minetest.register_on_leaveplayer(function(player)
magic.cancel_teleportation(player:get_player_name())
end)

magic.register_spell("magic:spell_teleport_spawn", {
description = "Spawn Teleportation Spell",
type = "action",
color = "#0A0",
emblem = "action",
cost = 15,
on_use = function(itemstack, player)
magic.start_teleportation(player, itemstack:get_name(), magic.config.teleportation_delay)
return true
end,
go = function(player)
if not kingdoms.db.servercorestone then
minetest.chat_send_player(player:get_player_name(), "There is no destination.")
return
end
player:setpos(vector.add(kingdoms.db.servercorestone, {x=0, y=1, z=0}))
end,
})
minetest.register_craft({
output = "magic:spell_teleport_spawn",
recipe = {
{"magic:concentrated_warp_essence", "magic:control_essence"},
{"group:minor_spellbinding", "default:sapling"},
},
})

magic.register_spell("magic:spell_teleport_kingdom", {
description = "Kingdom Teleportation Spell",
type = "action",
color = "#FA0",
emblem = "action",
cost = 15,
on_use = function(itemstack, player)
magic.start_teleportation(player, itemstack:get_name(), magic.config.teleportation_delay)
return true
end,
go = function(player)
local kingdom = kingdoms.player.kingdom(player:get_player_name())
if not kingdom or not kingdom.corestone.pos then
minetest.chat_send_player(player:get_player_name(), "There is no destination.")
return
end
player:setpos(vector.add(kingdom.corestone.pos, {x=0, y=1, z=0}))
end,
})
minetest.register_craft({
output = "magic:spell_teleport_kingdom",
recipe = {
{"magic:concentrated_warp_essence", "magic:control_essence"},
{"group:minor_spellbinding", "default:junglesapling"},
},
})
1 change: 1 addition & 0 deletions magic/throwing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function magic.register_missile(name, texture, def, item_def)

local ent_def = {
physical = false,
hp_max = math.ceil(def.cost / 2),
timer=0,
particletimer = 0,
visual = "sprite",
Expand Down
8 changes: 4 additions & 4 deletions manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Either way you join a kindom, you will be greeted with the standard kingdoms int

## Claiming Land

Without a land claim, you would be forced to hide from other players who would have unrestricted ability to destroy your work. This is solved by the presence of *Corestones*, which, once placed, claim a 50x50x50 cube of land where nobody else can build or access devices unless they have an appropriate level in the kingdom.
These claims cannot overlap with other claims, and must be spaced with at least 50 nodes between their areas so that there is plenty of neutral land that cannot be claimed. They also cannot be placed below -32y, avoiding claiming of mining zones.
Without a land claim, you would be forced to hide from other players who would have unrestricted ability to destroy your work. This is solved by the presence of *Corestones*, which, once placed, claim a 64x64x64 cube of land where nobody else can build or access devices unless they have an appropriate level in the kingdom.
These claims cannot overlap with other claims, and must be spaced with at least 64 nodes between their areas so that there is plenty of neutral land that cannot be claimed. They also cannot be placed below -32y, avoiding claiming of mining zones.

50x50x50 is somewhat restrictive, however, and even the neutral area around a corestone could be consumed by larger kingdoms. Outside of the neutral area, there is a possibility that a new corestone could be placed, undermining all the building you have done there. To counter this, you can place *Claim wards*, which prevent corestones from being placed if the ward would land inside the claimed zone.
64x64x64 is somewhat restrictive, however, and even the neutral area around a corestone could be consumed by larger kingdoms. Outside of the neutral area, there is a possibility that a new corestone could be placed, undermining all the building you have done there. To counter this, you can place *Claim wards*, which prevent corestones from being placed if the ward would land inside the claimed zone.

## Defending Land

Expand All @@ -21,7 +21,7 @@ Defending a neutral area, or even preventing enemies from entering your clamied

## Destroying a Corestone

The ability to take over another kingdom's claim is a large part of the game, and this is facilitated by *Core Disruptors*. When placed within a 75x75x75 cube centered around the target corestone, the target's *corestone score* will begin to decrease slowly, lowering faster depending on how many disruptors you can place. When this score reaches zero, the corestone will vanish and you can pillage the now-unprotected area.
The ability to take over another kingdom's claim is a large part of the game, and this is facilitated by *Core Disruptors*. When placed within a 96x96x96 cube centered around the target corestone, the target's *corestone score* will begin to decrease slowly, lowering faster depending on how many disruptors you can place. When this score reaches zero, the corestone will vanish and you can pillage the now-unprotected area.

### Defense

Expand Down

0 comments on commit 0560f30

Please sign in to comment.