Prevent Movement While Resting?
-
- Posts: 6
- Joined: Wed Jan 16, 2013 7:23 am
Prevent Movement While Resting?
I am making my first map and am slightly familiar with the coding but I haven't found out if there is a way to prevent the player from moving while they are resting just in a part because I want it to have the feeling of being "knocked out"
Re: Prevent Movement While Resting?
Not sure if this will work, but it is close.
Make a counter in your dungeon called cMove, then insert this script to your init.lua
Make a counter in your dungeon called cMove, then insert this script to your init.lua
SpoilerShow
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onMove = function(self, dir)
if (cMove:getValue() == 0) then
return false
end
return true
end,
onRest = function(party)
cMove: decrement()
end,
onWakeUp = function(party)
cMove: increment()
end,
}
Currently conspiring with many modders on the "Legends of the Northern Realms"project.
"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
-
- Posts: 6
- Joined: Wed Jan 16, 2013 7:23 am
Re: Prevent Movement While Resting?
I put the code in my init.lua but I don't know what to do with the counter.. this is my current code...
I want the blackout to last about 5 seconds..
SpoilerShow
function RestPhase()
party:shakeCamera(1,.5)
hudPrint("Oomph...")
playSound("damage_human_male")
party:rest()
end
party:shakeCamera(1,.5)
hudPrint("Oomph...")
playSound("damage_human_male")
party:rest()
end
Re: Prevent Movement While Resting?
you simply place the counter anywhere and rename it to cMove. Not sure how to get the 5 seconds for you right now, im tired (waaay past bedtime), if it doesn't work, post what happened/went wrong, and one of the gentlemen around here will have you fixed up before long.
ps. you can now use hidden plates to decrement the cMove and freeze party for dialogue etc, and a timer to increment cMove to release them at will.
ps. you can now use hidden plates to decrement the cMove and freeze party for dialogue etc, and a timer to increment cMove to release them at will.
Last edited by msyblade on Wed Jan 16, 2013 9:07 am, edited 1 time in total.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.
"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
-
- Posts: 6
- Joined: Wed Jan 16, 2013 7:23 am
Re: Prevent Movement While Resting?
alright thanks for the help
Re: Prevent Movement While Resting?
Personally, I like to keep my hooks as drop dead simple as possible and do all coding in the dungeon, so I would do something like this:
in objects.lua:
in dungeon place script entity called oomphScript:
You'll need to place a timer called koTimer in the dungeon and set to around 20s (since sleep time is 5X speed of wake time), and connect it to the oomphScript to koOff(), and also connect it to itself to deactivate itself.
(most of this code is untested, just written off the cuff, so there may be mistakes)
in objects.lua:
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onWakeUp = function(party)
oomphScript.toWake()
end,
}
Code: Select all
knockedOut = false
function restPhase()
party:shakeCamera(1,.5)
hudPrint("Oomph...")
partyHurt()
party:rest()
knockedOut = true
koTimer:activate()
end
function toWake()
if knockedOut then
return false
end
end
function koOff()
knockedOut = false
party:wakeUp(false)
hudPrint("Uuugh, what happened?")
end
function hurtSounds()
for i=1,4 do
if party:getChampion(i):getEnabled() and
party:getChampion(i):isAlive() then
party:getChampion(i):playDamageSound()
end
end
end
(most of this code is untested, just written off the cuff, so there may be mistakes)
Finished Dungeons - complete mods to play
Re: Useful scripts repository
Hey Komag you are great. Simple but perfect functions.
But I have a problem with the Human Male sound when get hurt, it seems it is a female sound. Can it be that there is a bug in the sound files? Or is it only me and I hear a female where is a male sound?
Edit: But this issue has nothing to do with your functions, even when I play the Human Male sound directly, it seems that it is a female voice.
But I have a problem with the Human Male sound when get hurt, it seems it is a female sound. Can it be that there is a bug in the sound files? Or is it only me and I hear a female where is a male sound?
Edit: But this issue has nothing to do with your functions, even when I play the Human Male sound directly, it seems that it is a female voice.
My first LoG-Mod: Abandoned Places 2
Re: Prevent Movement While Resting?
Thanks! I moved this out of the script repository (we just have scripts there, no comments).
I don't know if maybe your sound files have a problem, or maybe it's just you and your opinion of the sounds. Did you try the female sound also? Does it maybe sound "more" female than the male sound to you?
I don't know if maybe your sound files have a problem, or maybe it's just you and your opinion of the sounds. Did you try the female sound also? Does it maybe sound "more" female than the male sound to you?
Finished Dungeons - complete mods to play
-
- Posts: 6
- Joined: Wed Jan 16, 2013 7:23 am
Re: Prevent Movement While Resting?
I did all of the stuff you told me with the codes but it still lets me move when I am resting..?
Re: Prevent Movement While Resting?
hmm, I didn't test it myself, and now I can't remember if the hook needs another "return" in front of the script.function
you can always also put the code right in the hook, to check if oomphScript.knockedOut then return false
you can always also put the code right in the hook, to check if oomphScript.knockedOut then return false
Finished Dungeons - complete mods to play