[Solved/Item/Spell] Way to tell if party is underwater?
Posted: Thu Nov 06, 2014 11:30 pm
Is there any way to tell if the party is underwater? I want to try and make a potion of water breathing or some sort of equipment that would work by constantly restoring energy but only if the party is underwater.
LoG2 has the Zarchton Harpoon that still works underwater, so I think there might be some trait on it that lets it be used underwater. However, it is also important to be able to tell if the party is not above water as then the party would be restoring energy when they shouldn't be which I am not sure if there is something that does that right now.
Any help will be appreciated.
Edit: With the help of a few people, I've put together the following spell and potion.
The spell will provide the entire party with the ability to breath underwater for the duration. You may want to adjust this duration depending on your needs. The potion will provide water breathing to whoever drinks it.
The following code will go into you spells.lua and provides the Water Breathing spell.
The requirements are currently commented out for testing purposes, but once you want the requirements just remove the "--" before requirement = {...}, and you can adjust the requirements by changing the numbers.
Cast it with:

The next code include the Potion of Waterbreathing and a recipe to craft it. The recipe requires 2 Etherweed and 1 Falconskyre, as well as level 3 alchemy.
The potion has a placeholder image of the Water Flask currently.
LoG2 has the Zarchton Harpoon that still works underwater, so I think there might be some trait on it that lets it be used underwater. However, it is also important to be able to tell if the party is not above water as then the party would be restoring energy when they shouldn't be which I am not sure if there is something that does that right now.
Any help will be appreciated.
Edit: With the help of a few people, I've put together the following spell and potion.
The spell will provide the entire party with the ability to breath underwater for the duration. You may want to adjust this duration depending on your needs. The potion will provide water breathing to whoever drinks it.
The following code will go into you spells.lua and provides the Water Breathing spell.
The requirements are currently commented out for testing purposes, but once you want the requirements just remove the "--" before requirement = {...}, and you can adjust the requirements by changing the numbers.
Cast it with:

Code: Select all
defineSpell{
name = "water_breathing",
uiName = "Water Breathing",
skill = "water_magic",
--requirements = {"water_magic", 4, "air_magic", 3,},
gesture = 96325, -- Bottom Right > Top Right > Top Middle > Middle
manaCost = 30,
icon = 28, --7 14 28
spellIcon = 13, --13 19
description = "Gives the body the ability to breathe water.",
onCast = function(champion, x, y, direction, elevation, skillLevel)
playSound("generic_spell")
for i = 1, 4, 1 do
if party.party:getChampion(i):isAlive() then
party.party:getChampion(i):setCondition("water_breathing", skillLevel*10)
end
end
end,
}
The potion has a placeholder image of the Water Flask currently.
Code: Select all
defineRecipe {
name = "potion_water_breathing_recipe",
level = 3,
ingredients = 224, -- Leechweed, Leechweed, Falconskrye
potion = "potion_water_breathing",
}
defineObject{
name = "potion_water_breathing",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Potion of Water Breathing",
gfxIndex = 144,
description = "A potion that gives you the ability to breathe underwater.",
weight = 0.3,
stackable = true,
},
{
class = "UsableItem",
sound = "consume_potion",
onUseItem = function(self,champion)
champion:setCondition("water_breathing", 30)
end,
}
},
}