What are the possibilities with the current mouse support in the OHR? I'm currently working on a Shadowgate like game and was curious if adding a cursor to the "viewport" would be possible? It's not necessary, but it would be a nice sidestep to relying on in-depth menus or scripting.
Basically, I'm wondering if it's possible to turn on/off the mouse with a menu button, use it to click/activate an NPC, and not effect the Hero's original position?
Mouse support is only possible via scripting; in other words, you can't use it in battles. You can use the mouse in menus, but it's a lot of trouble.
You basically need to script the entirety of the mouse functionality yourself. While the engine will track the position of the mouse as well as the button status, it won't display a cursor for you. Use slices to put a cursor on the screen.
In other words, you will not be able to sidestep scripting here
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
You basically need to script the entirety of the mouse functionality yourself. While the engine will track the position of the mouse as well as the button status, it won't display a cursor for you. Use slices to put a cursor on the screen.
In other words, you will not be able to sidestep scripting here
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
All that said, in answer to your question of:
The answer is yes, that should all be possible. But you're going to have to use scripting.
Quote:
Basically, I'm wondering if it's possible to turn on/off the mouse with a menu button, use it to click/activate an NPC, and not effect the Hero's original position?
The answer is yes, that should all be possible. But you're going to have to use scripting.
Alright, I've got a menu button that activates/deactivates the mouse, but I'm not sure how to go about making it do anything. I've been using the wiki page on how to do this, but the second part (red font) confuses me (variables ugh!?). all i want is to be able to click with the mouse, and directly activate whichever npc it touches. would that mean calling upon every npc available on the map in the script?
Quote:
include, plotscr.hsd
include, abyss.hsi
plotscript, mousesupport, begin
init mouse
while (true) do, begin
if (checktag(tag:mousesupport)) then, begin
put NPC (1, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse button(left button)) then, begin
variable (NPC, Num NPC, i)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
for (i,0,Num NPC -- 1) do, begin
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, i)
end
wait
end
end
include, abyss.hsi
plotscript, mousesupport, begin
init mouse
while (true) do, begin
if (checktag(tag:mousesupport)) then, begin
put NPC (1, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse button(left button)) then, begin
variable (NPC, Num NPC, i)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
for (i,0,Num NPC -- 1) do, begin
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, i)
end
wait
end
end
Which wiki article is that?
Your script was missing some 'end's. I strongly recommend to anyone learning to script: learn to indent your scripts. You will save yourself a great deal of time chasing compile errors, and the scripts become far easier to read.
Here is a fixed version of the script (I hope; untested):
In this version the mouse cursor is a slice. That's far better than using an NPC. For example it means that you won't normally get overlapping NPCs, so won't need a for loop unless you do something fancy. And I changed mousebutton to mouseclick.
BTW, if any of your maps use 'wrap around' you will run into trouble. Say so and that can be fixed (naturally I should update the wiki page with the fix for that too).
Your script was missing some 'end's. I strongly recommend to anyone learning to script: learn to indent your scripts. You will save yourself a great deal of time chasing compile errors, and the scripts become far easier to read.
Here is a fixed version of the script (I hope; untested):
Code:
include, plotscr.hsd
include, abyss.hsi
plotscript, mousesupport, begin
init mouse
variable (cursor)
cursor := load walkabout sprite (##) #change this
while (true) do, begin
if (checktag(tag:mousesupport)) then, begin
put slice (cursor, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse click(left button)) then, begin
variable (NPC, Num NPC)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
if (num NPC >= 1) then, begin
# Activate the first NPC at that position
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, 0)
use NPC (NPC)
end
end
end
wait
end
free slice (cursor)
end
include, abyss.hsi
plotscript, mousesupport, begin
init mouse
variable (cursor)
cursor := load walkabout sprite (##) #change this
while (true) do, begin
if (checktag(tag:mousesupport)) then, begin
put slice (cursor, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse click(left button)) then, begin
variable (NPC, Num NPC)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
if (num NPC >= 1) then, begin
# Activate the first NPC at that position
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, 0)
use NPC (NPC)
end
end
end
wait
end
free slice (cursor)
end
In this version the mouse cursor is a slice. That's far better than using an NPC. For example it means that you won't normally get overlapping NPCs, so won't need a for loop unless you do something fancy. And I changed mousebutton to mouseclick.
BTW, if any of your maps use 'wrap around' you will run into trouble. Say so and that can be fixed (naturally I should update the wiki page with the fix for that too).
TMC wrote:
Which wiki article is that?
Your script was missing some 'end's. I strongly recommend to anyone learning to script: learn to indent your scripts. You will save yourself a great deal of time chasing compile errors, and the scripts become far easier to read.
Here is a fixed version of the script (I hope; untested):
In this version the mouse cursor is a slice. That's far better than using an NPC. For example it means that you won't normally get overlapping NPCs, so won't need a for loop unless you do something fancy. And I changed mousebutton to mouseclick.
BTW, if any of your maps use 'wrap around' you will run into trouble. Say so and that can be fixed (naturally I should update the wiki page with the fix for that too).
Your script was missing some 'end's. I strongly recommend to anyone learning to script: learn to indent your scripts. You will save yourself a great deal of time chasing compile errors, and the scripts become far easier to read.
Here is a fixed version of the script (I hope; untested):
Code:
include, plotscr.hsd
include, abyss.hsi
plotscript, mousesupport, begin
init mouse
variable (cursor)
cursor := load walkabout sprite (##) #change this
while (true) do, begin
if (checktag(tag:mousesupport)) then, begin
put slice (cursor, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse click(left button)) then, begin
variable (NPC, Num NPC)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
if (num NPC >= 1) then, begin
# Activate the first NPC at that position
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, 0)
use NPC (NPC)
end
end
end
wait
end
free slice (cursor)
end
include, abyss.hsi
plotscript, mousesupport, begin
init mouse
variable (cursor)
cursor := load walkabout sprite (##) #change this
while (true) do, begin
if (checktag(tag:mousesupport)) then, begin
put slice (cursor, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse click(left button)) then, begin
variable (NPC, Num NPC)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
if (num NPC >= 1) then, begin
# Activate the first NPC at that position
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, 0)
use NPC (NPC)
end
end
end
wait
end
free slice (cursor)
end
In this version the mouse cursor is a slice. That's far better than using an NPC. For example it means that you won't normally get overlapping NPCs, so won't need a for loop unless you do something fancy. And I changed mousebutton to mouseclick.
BTW, if any of your maps use 'wrap around' you will run into trouble. Say so and that can be fixed (naturally I should update the wiki page with the fix for that too).
been using this article: http://rpg.hamsterrepublic.com/ohrrpgce/How_do_I_implement_mouse_input_in_my_game%3F
yeah, sorry. i had to use quote to emphasize which part i was having issues with (code doesn't allow color). that first half of my script works fine (the script is activated by a menu button, and is turned off by another), and seems fine without having used a new game or load game script (i'm not sure what the issues would be having done that?).
just loaded your script into the game and it works perfectly. thank you thank you thank you. slices are a much better choice. my only issue is that the slice doesn't disappear afterwards - how would i go about turning the slice off (invisible), after the tag (mousesupport) is turned off?
also, is there a way to suspend hero movement without also suspending menu activation? currently i'm faking it and using tags, blocking the hero in with invisible NPCs.
also also, is there any way to turn off the black fade between using doors?
Quote:
(the script is activated by a menu button, and is turned off by another)
I'm not sure what you mean by this. One menu item turns on the 'mouse support' tag and runs the script, and another turns off the tag?
So what you want is the ability to stop the script by toggling a tag. You could use this slightly modified version:
Code:
plotscript, mousesupport, begin
# If script is already running, don't start another copy
if (checktag(tag:mousesupport)) then (exit script)
init mouse
variable (cursor)
cursor := load walkabout sprite (##) #change this
settag(tag:mousesupport, on)
while (checktag(tag:mousesupport)) do, begin
put slice (cursor, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse click(left button)) then, begin
variable (NPC, Num NPC)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
if (num NPC >= 1) then, begin
# Activate the first NPC at that position
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, 0)
use NPC (NPC)
end
end
wait
end
free slice (cursor)
end
# If script is already running, don't start another copy
if (checktag(tag:mousesupport)) then (exit script)
init mouse
variable (cursor)
cursor := load walkabout sprite (##) #change this
settag(tag:mousesupport, on)
while (checktag(tag:mousesupport)) do, begin
put slice (cursor, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y)
if (mouse click(left button)) then, begin
variable (NPC, Num NPC)
num NPC := NPC at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, get count)
if (num NPC >= 1) then, begin
# Activate the first NPC at that position
NPC := npc at pixel (mouse pixel x + camera pixel x, mouse pixel y + camera pixel y, 0)
use NPC (NPC)
end
end
wait
end
free slice (cursor)
end
It turns on the 'mousesupport' tag itself. To start the script just run the script from a menu, don't set the tag. To stop the script, turn off the 'mousesupport' tag.
'suspend player' suspending the menu is a bit unfortunate. That could do with some cleanup. Right now the easiest thing to do is to suspend player and use a simple script with a while loop that does "open menu (0)" when a menu key is pressed. (Wanting to suspend menu use but not hero movement is far worse!)
There's no way to turn off the door fade. You could work around it by scripting your own doors. You can use the "get door X", "get door Y", "get door destination ID", "get door destination map" and "door exists" commands to check if the player is standing on a door and use "teleport to map" to move the player. Hmm, but you need some way to disable doors. I'll add a "suspend doors" command right now. Really there ought to be an easily solution. For a long time I've been wanting to add custom "door scripts" which replace the fade out (for example to let you show the hero walking off the map and onto the new map, like SoJ does).
TMC wrote:
I'm not sure what you mean by this. One menu item turns on the 'mouse support' tag and runs the script, and another turns off the tag?
Quote:
(the script is activated by a menu button, and is turned off by another)
I'm not sure what you mean by this. One menu item turns on the 'mouse support' tag and runs the script, and another turns off the tag?
I had a menu button named "move" that when enabled would turn tag 3 (mousesupport) on, disable/hide itself, and enable/show a menu item named "look". On its own it seemingly does nothing - but, if I have "move" also activate the "mousesupport" script it works. activating "look" after this, however, disables the mouse (good) but keeps the slice on the screen (bad).
TMC wrote:
So what you want is the ability to stop the script by toggling a tag. You could use this slightly modified version...
Just what I needed. Awesome. Thank you sooo much.
TMC wrote:
I'll try this and see where I get.
'suspend player' suspending the menu is a bit unfortunate. That could do with some cleanup. Right now the easiest thing to do is to suspend player and use a simple script with a while loop that does "open menu (0)" when a menu key is pressed. (Wanting to suspend menu use but not hero movement is far worse!)
TMC wrote:
Would it be possible/easier to use the mouse instead, and just abandon use of the keyboard (in terms of moving the hero walkabout)? something like: click door, get door destination, then teleport to that destination? I noticed there's no "door at pixel" command... so, probably not?
There's no way to turn off the door fade. You could work around it by scripting your own doors.
Yes, clicking on doors is easy; equally easy to detecting when you've stepped on a door and doing a "teleport to map" once I add a "suspend doors" command.
Checking whether there is a door at a tile can be done by looping through all of them (there are 200 doors per map), though you can't check whether a door is actually enabled/disabled by tag conditions. I'll just add a "door at tile" command shortly instead, good suggestion.
Checking whether there is a door at a tile can be done by looping through all of them (there are 200 doors per map), though you can't check whether a door is actually enabled/disabled by tag conditions. I'll just add a "door at tile" command shortly instead, good suggestion.



