Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

duh i need a flashlight script
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Valigarmander
Bye-Bye




Joined: 04 Mar 2006
Posts: 750
Location: Nowhere

PostPosted: Thu Jun 29, 2006 11:29 pm    Post subject: duh i need a flashlight script Reply with quote

Sup. It's the n00b you love to hate. With a really long name. Meh. Anyway, I am not very experienced in plotscripting and am having a bit of a hard time working on something with my scripts for my game Revelations. You see, I want to implement a flashlight script for the game to make it a bit more creepy. But I'm having a hard time with that, as stated before. I want the flashlight to be on all the time, with a battery of about 250 units, one unit depleting each step you take. I want it to be sort of like in that game by Shadowiii that I can't remember the name of at the moment (damn). Perfect Dark or something like that. But I can't figure out the scripts and I was hoping to get it ready by the day I said I'd release the demo which is TODAY OMG1 Help, please?
Back to top
View user's profile Send private message Send e-mail
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Fri Jun 30, 2006 10:26 am    Post subject: Reply with quote

You have to tell more about the flashlight and the game, at least a little. Is the flashlight on for the WHOLE game, for EVERY map of the game? Should it illuminate the whole screen, or just a part of the screen? What should be happening as the units decrease? Should it dim, or should it just suddenly go out? Should the player be able to see how many units are left?

Without knowing these things, I'll try to give some general guidelines (since I have to go soon, and won't be able to help this weekend). If the flashlight is to be on for the whole game, then I think that there should be a 'new game script' (in the general game data menu in custom) that sets the units (declared as a global variable in your script file) to 250, or whatever. There should be another 'each step script' (in the map editor part of custom) that is set to decrement the value of this variable. In this 'each step script' should also be an if check along the lines of:

if(units==0),then
begin
#whatever happens when the flashlight goes out
end

If the flashlight is to illuminate the whole screen, this should be enough, more or less. If not, you have a much more complicated problem on your hands. If the flashlight going out ends the game, then you can simply put a game over in the if block above. If you want the game to continue in the pitch dark, you will need to do some map tweaking. Something like:

variable (var1, var2)

for(var1 ,0, 200), do #the limits for the variables should coincide
#with the map's dimensions
begin
for(var2, 0, 200),do
begin
writemapblock(var1,var2,("the number of an enitrely black maptile") )
writepassblock(var1,var2,readpassblock(var1,var2)+overheadtile)
end
end

I hope that this helps.
Back to top
View user's profile Send private message Visit poster's website
Valigarmander
Bye-Bye




Joined: 04 Mar 2006
Posts: 750
Location: Nowhere

PostPosted: Fri Jun 30, 2006 10:31 am    Post subject: Reply with quote

Thanks, and yes, that does help. Sorry I wasn't more clear, I was tired. Hopefully I'll be able to get something to work by tonight...
Back to top
View user's profile Send private message Send e-mail
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Fri Jun 30, 2006 5:46 pm    Post subject: Reply with quote

msw188 wrote:
You have to tell more about the flashlight and the game, at least a little. Is the flashlight on for the WHOLE game, for EVERY map of the game? Should it illuminate the whole screen, or just a part of the screen? What should be happening as the units decrease? Should it dim, or should it just suddenly go out? Should the player be able to see how many units are left?

Without knowing these things, I'll try to give some general guidelines (since I have to go soon, and won't be able to help this weekend). If the flashlight is to be on for the whole game, then I think that there should be a 'new game script' (in the general game data menu in custom) that sets the units (declared as a global variable in your script file) to 250, or whatever. There should be another 'each step script' (in the map editor part of custom) that is set to decrement the value of this variable. In this 'each step script' should also be an if check along the lines of:

if(units==0),then
begin
#whatever happens when the flashlight goes out
end

If the flashlight is to illuminate the whole screen, this should be enough, more or less. If not, you have a much more complicated problem on your hands. If the flashlight going out ends the game, then you can simply put a game over in the if block above. If you want the game to continue in the pitch dark, you will need to do some map tweaking. Something like:

variable (var1, var2)

for(var1 ,0, 200), do #the limits for the variables should coincide
#with the map's dimensions
begin
for(var2, 0, 200),do
begin
writemapblock(var1,var2,("the number of an enitrely black maptile") )
writepassblock(var1,var2,readpassblock(var1,var2)+overheadtile)
end
end

I hope that this helps.


The problem with that script is that it destroys the map. My fix would be simple: Tilesets use the top half (the first 80 tiles), and the bottom half is all black. Then, making a tile black is easy, and saves what tile it actually is:

Code:
writemapblock(var1, var2, readmapblock(var1, var2) + 80)

_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Sat Jul 01, 2006 12:56 pm    Post subject: Reply with quote

Or, if your maps are small, you can save the entire maptile data to global variables.
This will allow you to use the entire maptile set and only use one black tile.

(now that I think about it, I will implement the torch effect into my dragon warrior game this way)

Of course there should be a script in the begining of each map that loads the data into globals.
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Sat Jul 01, 2006 1:37 pm    Post subject: Reply with quote

Well, that will only work for maps with an area less than 1000, assuming you don't use any globals for anything else.
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Sat Jul 01, 2006 5:00 pm    Post subject: Reply with quote

Here I will jump in just to be a jerk and mention that the maximum is actually 1200, I think. (This number should really be in the HSpeak specification. I'm putting it there. Correct it if I'm wrong.)
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Sat Jul 01, 2006 7:10 pm    Post subject: Reply with quote

Actually, no.

game.bas, line 190 wrote:
DIM script(4096), heap(2048), global(1024), astack(512), scrat(128, 14), retvals(32), plotstring$(31), plotstrX(31), plotstrY(31), plotstrCol(31), plotstrBGCol(31), plotstrBits(31)


I highlighted the relavent part. It's actually (technically) 1025 (0 to 1024), but hspeak doesn't allow #0 (I believe), bringing the final count to 1024 (which I reflected in the wiki)
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Sat Jul 01, 2006 10:04 pm    Post subject: Reply with quote

Thanks. It's needed to be there for a long time.

Incidentally, 1024 is quite an arbitrary number for something that doesn't need to be bit-aligned (or even byte-aligned).
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Sun Jul 02, 2006 8:13 am    Post subject: Reply with quote

Oh, yeah, it's quite arbitrary. But, already, that's 2k of memory being used by globals alone. Any more, and James would've had to cut something else out, and less, and he'd have to say "well, globals use 1.95k"
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Mon Jul 03, 2006 9:48 am    Post subject: Reply with quote

I'm not sure how it is that my idea 'destroys' the map. What use are the tiles themselves, if they cannot be seen? The important things at that point (it would seem) are the walls, the foemap, the placement of NPCs, etc, all of which would be retained by my idea. Furthermore, if you don't make the tiles overhead, you will still be able to see the heroes and NPCs (which I assume you do not want to happen).
Back to top
View user's profile Send private message Visit poster's website
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Mon Jul 03, 2006 12:19 pm    Post subject: Reply with quote

Let's say that the flashlight is shining. The non-lit tiles are set to black (all tile 0). Now, let's say the character turns, so different tiles are lit up. The formerly lit tiles are set to black, but- oops! How do we know what the newly lit tiles are, since they're all tile 0!
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Tue Jul 04, 2006 10:29 am    Post subject: Reply with quote

Oh, I meant for blacking out the screen when the flashlight goes out. Anyway, your idea is still better as long as you remember to overhead the tiles, since it can be used for both.
Back to top
View user's profile Send private message Visit poster's website
Mr B




Joined: 20 Mar 2003
Posts: 382

PostPosted: Tue Jul 04, 2006 10:51 am    Post subject: Reply with quote

Um...if you got fancy about it you could probably just black out the visible tiles, using globals to remember them.

PB1 was very simple, as all I did was modify the master palette.

PB2 was more complicated. I created two versions of each tile; one was illuminated, one was darkened. I then used a horrendously overcomplicated script to swap them from one to the other depending on where the character was.

Heh, I did the same thing with NPCs...I don't know if Shadowiii actually had any, but there were rat NPCs that wandered randomly when they were in the dark. If they walked into the illuminated area (or the illuminated area came over them), they were swapped to another NPC ID that was illuminated and fled the player. Once it fled outside of the lit area it reverted to its original, dark, wandering NPC ID.
Back to top
View user's profile Send private message
Valigarmander
Bye-Bye




Joined: 04 Mar 2006
Posts: 750
Location: Nowhere

PostPosted: Wed Nov 08, 2006 12:36 pm    Post subject: Wow, when did all of these replies come in? Reply with quote

Anywho, I am working on a new game by now, called They Hunger, and it is in the same alley as Revelations was. I am hoping to implement a flashlight script. It does not illuminate the entire room, but in a manner similar to this diagram I just pulled out of my arse.



The green space represents the player, the red, orange and yellow tiles representing different shades of lighting. This is if the player is facing west, of course. If he were facing north, the screen would be lit in a different fashion. The problem is, I know next to nothing about plotscripting and I have no idea if this is even possible. I guess what I'm asking for is the easiest way to make this happen, and if there isn't one all that easy, I'll take whatever I can get.

More information, the flashlight will have a limited battery, which will be displayed on the screen somewhere. You should also be able to turn the flashlight on and off whenever you want to save energy by pressing a key (probably the spacebar or something). Once the battery runs out, the flashlight shuts off immediately, and cannot be reactivated unless you find some more power. I want the dark area to be very dark, but not so dark that you can't see a damn thing.

Well, that's all I have for now, I hope for some input here, and hopefully They Hunger will have a working flashlight script. Peace out.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group