[Solved/Item/Spell] Way to tell if party is underwater?
Re: [Solved/Item/Spell] Way to tell if party is underwater?
A counter & timer could hudPrint() the time remaining; [start/stop the timer in the item's equip/unequip hooks].
Make a dive_time counter, connect a timer to it set to 1 second interval and to decrement the counter. Set the counter to remove the water_breathing trait via script.
and use something like...
hudPrint("") hudPrint("") hudPrint("") hudPrint(tostring(dive_time.counter:getValue()).." seconds of air remaining")
...to print out the time that's left.
Make a dive_time counter, connect a timer to it set to 1 second interval and to decrement the counter. Set the counter to remove the water_breathing trait via script.
and use something like...
hudPrint("") hudPrint("") hudPrint("") hudPrint(tostring(dive_time.counter:getValue()).." seconds of air remaining")
...to print out the time that's left.
Re: [Solved/Item/Spell] Way to tell if party is underwater?
Using the same method I imagine you might be able to set the timer to a boss health bar too. Instead of printing out the timer value set the boss NPC's health to that value. I'm not sure on the specifics of boss timers but if you are able to add health to the enemy it should be fine.
Re: [Solved/Item/Spell] Way to tell if party is underwater?
I thought about that; it's more complex, but Skuggs has a tutorial for just that idea. https://www.youtube.com/watch?v=-YlAZwqcptcsps999 wrote:Using the same method I imagine you might be able to set the timer to a boss health bar too. Instead of printing out the timer value set the boss NPC's health to that value. I'm not sure on the specifics of boss timers but if you are able to add health to the enemy it should be fine.
*It involves an off-screen monster that gets damaged over time ~via script. The boss healthbar diminishes, just as an air meter would.
Re: [Solved/Item/Spell] Way to tell if party is underwater?
thanks for your answers:
I'm trying to do it, step by step:
pls can you tell me what is wrong in this script?
I got an error after equiping the helmet
diving_timer is the name of the timer I'm actually using
I'm trying to do it, step by step:
pls can you tell me what is wrong in this script?
I got an error after equiping the helmet
diving_timer is the name of the timer I'm actually using
Code: Select all
-- scuba gear
defineObject {
name = "diving_helmet",
baseObject = "full_helmet",
components = {
{
class="Item",
weight = 3.0,
uiName = "Diving Helmet",
gfxIndex = 93,
traits = { "helmet" },
onEquipItem=function(self,champion,slot)
if slot==3 then
champion:setCondition("water_breathing")
diving_timer:activate()
end
end,
onUnequipItem=function(self,champion,slot)
if slot==3 then
diving_timer:deactivate()
champion:removeCondition("water_breathing")
end
end
},
{
class = "EquipmentItem",
protection = 1,
},
}
}
Re: [Solved/Item/Spell] Way to tell if party is underwater?
diving_timer.timer:start()bongobeat wrote: pls can you tell me what is wrong in this script?
I got an error after equiping the helmet
diving_timer.timer:stop()
_______________________________________________________________
This should have been in the base game.
This is fun to use.
*Altered Script ... [Still gives no warning about the air supply running out.]
Code: Select all
-- scuba gear
defineObject {
name = "diving_helmet",
baseObject = "full_helmet",
components = {
{
class="Item",
weight = 3.0,
uiName = "Diving Helmet",
gfxIndex = 93,
traits = { "helmet" },
onEquipItem=function(self,champion,slot)
if slot==3 then
champion:setCondition("water_breathing")
diving_timer.timer:start()
end
end,
onUnequipItem=function(self,champion,slot)
if slot==3 then
diving_timer.timer:stop()
champion:removeCondition("water_breathing")
end
end
},
{
class = "EquipmentItem",
protection = 1,
},
}
}
https://www.dropbox.com/s/z6z9xlizhljyc ... g.avi?dl=0
It uses the diving_helm and the core concept of Skugg's firetrap tutorial to make an air meter.
Re: [Solved/Item/Spell] Way to tell if party is underwater?
waoww! this is awesome!
Re: [Solved/Item/Spell] Way to tell if party is underwater?
Isaac - that is amazing! Nice oneIsaac wrote:diving_timer.timer:start()bongobeat wrote: pls can you tell me what is wrong in this script?
I got an error after equiping the helmet
diving_timer.timer:stop()
_______________________________________________________________
This should have been in the base game.
This is fun to use.
*Altered Script ... [Still gives no warning about the air supply running out.]** I've been tinkering with this a bit more (beyond the script above)... It's not ready for prime time, but this is what it looks like so far:Code: Select all
-- scuba gear defineObject { name = "diving_helmet", baseObject = "full_helmet", components = { { class="Item", weight = 3.0, uiName = "Diving Helmet", gfxIndex = 93, traits = { "helmet" }, onEquipItem=function(self,champion,slot) if slot==3 then champion:setCondition("water_breathing") diving_timer.timer:start() end end, onUnequipItem=function(self,champion,slot) if slot==3 then diving_timer.timer:stop() champion:removeCondition("water_breathing") end end }, { class = "EquipmentItem", protection = 1, }, } }
https://www.dropbox.com/s/z6z9xlizhljyc ... g.avi?dl=0
It uses the diving_helm and the core concept of Skugg's firetrap tutorial to make an air meter.
I have a further question pertaining to the title of this thread - How to tell if the party is underwater???
I am planning on including Zarchtons as a custom race (they breath underwater! hehe)
It is easy enough just to give a Zarchton champ water breathing and leave them with that condition, however....
I was hoping I could come up with a way to setCondition("water_breathing") as soon as they move onto an underwater space and then remove it if they move onto a space not underwater...
@Nutjob, I think this is where you were heading with your earlier post (have you found a way to do this yet??)
My approach so far has been to use the onMove hook for the party and check for the automap tile connected to the space the party is moving to.
Problem is when moving to a space where the definition specifies automaptile = "water"
Eg
SpoilerShow
Code: Select all
defineTile{
name = "dungeon_floor_water",
editorIcon = 112,
color = {45,95,140,255},
builder = "dungeon",
floor = {
"dungeon_floor_dirt_01", 1,
},
ceiling = {
"dungeon_ceiling", 1,
},
wall = {
"dungeon_wall_01", 1,
},
pillar = {
"dungeon_pillar", 1,
},
underwater = true,
ceilingEdgeVariations = true,
ceilingShaft = "dungeon_ceiling_shaft",
automapTile = "water",
}
This is my script so far (init.lua)
SpoilerShow
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Party",
onMove = function(party,dir)
for i = 1,4 do
local c = party:getChampion(i)
local cRace = c:getRace()
if cRace == "zarchton" then
local tile = party.go.map:getAutomapTile(getForward(dir))
print(tile)
if tile == 3 then
if c:hasCondition("water_breathing") == false then
hudPrint(""..c:getName().." can breath underwater.")
c:setCondition("water_breathing")
end
else
if c:hasCondition("water_breathing") == true then
hudPrint(""..c:getName().." is not underwater.")
c:removeCondition("water_breathing")
end
end
end
end
end,
If you want to test this out yourself, you will need to change Zarchton to Human (or make a zarchton race)
Can anyone point out what I am doing wrong here??
Or if someone else has come up with a more efficient way of finding out if the party is underwater??
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: [Solved/Item/Spell] Way to tell if party is underwater?
That's great GoldenShadowGS, I appreciate your response...
but the point is my script is not recognising automaptile == 2
It will recognise pretty much most other automaptiles except water (2). WHY!!?
I suspect it may have something to do with the elevation??
but the point is my script is not recognising automaptile == 2
It will recognise pretty much most other automaptiles except water (2). WHY!!?
I suspect it may have something to do with the elevation??
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: [Solved/Item/Spell] Way to tell if party is underwater?
When I was figuring out how to do my script, I opened the dungeon script in notepad++ to discover how it worked. Try a new dungeon with a blank map and draw a smiley face with water tiles. Save it and open the dungeon .lua script in notepad++ see if you can find the section where you made the smiley face and see what number it was assigned.