Anyone know how to make a global timer ?
Is anyone kind enough to help me out, I need a little exe program a counter that countsdown in memory to the time that I specify like
(wait 200) without pausing my game then when the timer in memory reaches 0 the batch file can execute a codeblock to end the potion's duration effects..
Needed for: Potion of Mentor Double XP points for a short period of time,
Strength Tonic to Double HP for a short period of time.
Sleep is good for certain things, but not for things that need a duration time counter,
for sleep just pauses the whole game.
Certain Bad Statues like doom, petrify that still effect you no matter where you go in the screens.
So I need a realtime duration counter. And I can't code this in batch because I don't know how to code my counters to work in the batch file on the global level. Because when I put a timer counter in the batch file, the timer won't even update itself unless i refresh the screen manually and it only works for me on the local level
(one screen at a time)..
So I don't know how to do global counters in batch if they can be set up
in batch code..
example. take potion of mentor. The Effects of this last 3 minutes before it wears off. So if I had a little global timer counting down in memory it will allow me to go anywhere i want in the gameworld for 3 minutes before the timer reaches 0 and then it jumps to the batchcode to turn off the effects of whatever potion or magic was being used no matter where you are in the game world.
This seems like something that should be incorporated into the game itself instead of a separate executable. If you're doing top-down programming, a timer function can be injected into the main loop as long as there is nothing that truely HALTS the program's flow (ie. remove Pause, Wait, or Sleep commands and replace with alternatives that allow code to continue executing even if the game itself doesn't progress)
That is a lot of jargon, so if you need me to tone down the buzzwords, let me know and I can explain better.
imbedded timer functions aside, I could probably make a simple console executable that accepts a time parameter (in milliseconds) and a file path (whatever file you want it to execute when the time is up). would that do?
What language are you using? What operating system?
--Medicine Storm
I'm using windows vista. I don't know where the main loop is to allow me to affect all the other loops for setting up things like Potion of mentor, ect, because the code has been looped into all 500+ screens. And apart from a few bugs I've still to iron out, the game is little clunky but works.... and it is a complicated game because it involves lots of level thresholds as well.
It might have to be an executable because of the Limits I've reached with the Windows Batch language
set ptimer=150 (or 150000 if using miliseconds)
wait.exe %ptimer%
if %ptimer% EQU 20 echo. Warning Potion is wearing off. && goto maingame
if %ptimer% LEQ 0 goto mentoroff
:mentoroff
echo. Potion has now worn off.
set pmentor=0
if %mentor% LEQ 0 echo. You have no more mentor potions left...&& goto maingame.
set playerxp=%playerxp%
goto maingame.
:maingame
blablabla
oh interesting. Are you able to perform clock calculations? Like, just before the code that performs whatever moves the player is executing, it checks the current time against a potion timestamp.
When player drinks a potion that is supposed to last... 30 seconds, for example... it records the time when the potion should expire.
Then, just before the game executes the code that performs player action or anything that might be affected by the potion, you do a check to see if the potion is beyond expired
I don't know if this code will run. I haven't tested it.
I also don't understand how separately threaded executable will be able to update a value in the batch without also interrupting the code flow or requiring the batch to wait until the executable is done... which would defeat the purpose. Do you have a way for a separately executed program to inject values into the batch WHILE the batch is running?
--Medicine Storm
I also don't understand how separately threaded executable will be able to update a value in the batch without also interrupting the code flow or requiring the batch to wait until the executable is done... which would defeat the purpose. Do you have a way for a separately executed program to inject values into the batch WHILE the batch is running?
for /f "Tokens=1-2" %%a in ('bg mouse') do (
set /a X=%%b, Y=%%a
rem )
echo. X at %x%. %Y%
bg locate %Y% %X% & bg print 0A "01<- Click Here!"
if %X% EQU 22 if %Y% EQU 5 goto mmsa
So if I wanted to click at a certain spot on the screen like on an icon position.
if %X% GTR 103 if %Y% EQU 39 goto furyspell
if %X% EQU 103 if %Y% EQU 40 goto furyspell
if %X% EQU 103 if %Y% EQU 41 goto furyspell
if %X% EQU 104 if %Y% EQU 42 goto furyspell
very Crude way of trying to define a hotspot area but it worked somewhat....because I don't know how to program it to properly define the hotspot area all around the icon yet... It seems you can pass environment values to the executable program outside the batch using the tokens command..
But that's how the guy who made bg.exe got the mouse to work in batch file with an executable so that will allow me to hook the mouse code into any piece of code using a goto jump. But there is a downside, the way that he coded his exe, shuts down the keyboard while its waiting for the mouse button to be clicked in the console, and only if you click with the mouse on the hotspot does the keyboard return back to normal again again. he hasn't fixed that issue yet. I'm hoping he will fix it so I can use both the mouse and keyboard in the console.
Why are you doing this whole thing with batch? There are other things you could use that would allow you to be much more productive.
Are you aware of the excessive empty space after your posts?
Stay a while and listen.
Answer: Why write the game in batch code? Well because the game engines that I've looked at so far Ogre, Torg3d have NOT been flexible or customizable enough. Theres no import texture option in the terrain making tools in half of these engines to allow you to use your own custom made images. or have texture painting tools for painting your own custom bitmaps on the meshes, instead they just let you use the engine's default images or materials that are in the game project library for the customising.
And the way to get round this kind of limitation is just to cause you more problems because you have to convert all your materials into the format the engine wants and then drag it all into the engine's project directories manually yourself so there's precious hours and days getting wasted already in trying to set up all the game libraries just so the engine can use your stuff..
And more time is being wasted when these engines won't even support any batch scripting which is one of the most common languages used in windows but only support more complicated languages instead and just leave you with a headache the size of the Grand Canyon because there's no Bridge for the languages. So I expected a game engine to be C++ friendly for C++ experienced users or java script friendly for those experienced with Java but also windows batch script friendly as well so there's that's crucial bridge in place so there's not such a steep learning curve to waste If there's no bridge, then its just a big hole.
I've looked at Irrgbulder, and that engine has some issues. no import option at all for loading my game screens in for terrain materials or any 3d mesh paint tool to paint my game screens on the mesh with.and because the player controls moves so slow and sluggish at times it looks like there's a swingweight problem going on with the model rigging.....And may need to be all redone.......... Other Issues such as the FOV camera going too far forward beyond the player FOV or going straight through the model at times when changing from 3rd person to 1st person modes. That engine is going to be a dog if those issues are still going on with it.
Then you have Torque 3d, it also has some issues as well....... and one of them is it uses DTS and Collada files, for the meshes. And again causing another headache for the windows user just to be different from the industry. That alone makes that a dog of an engine to try to work with. That you can't use the common file formats and have to convert to the special file formats.
Other things like what would make me more productive. I lack knowledge in this area.
Is the game 2D or 3D (or both)? From the screenshots on the main thread, everything looks like 2D graphics.
Those other complicated languages may seem offputting, but it is well worth learning how they work. Object orientation is so valuable, it will make your work a lot easier. I don't know what your code looks like, but I imagine you have a lot of duplicate code used in each screen area.
Can you think of an example of a game that is similar to what you are doing?
Stay a while and listen.
The game at the moment uses 2d graphics for the screens even though they have a 3d perspective. the Pirate portrait pic is a 3d model. I find 3d models are more better for graphics.
"Can you think of an example of a game that is similar to what you are doing?"
If you mean moving screen by screen without use of a 3d engine to walk around the gameworld in Yes, old dos batch games or text adventure graphic games often copied the same code over and over and over to go screen to screen. to go north, to go west, to go south ect. ect ect.
The art I did with the GIMP brushes give my screens that 3d 2d isometrical look that's similar to Sacred. But this game is not Sacred,. The screens were all done with Custom GIMP brushes that came from Public Domain, Royalty Free Creative Common sources. Even the Pirate model was a Royalty Free blender model. That's why I put him in my game. Otherwise if he was not royalty free I would not use him.
What does my code look like? Oh well (its RATHER LONG) It's long because I'm dealing with alot of level thresholds.......
On this screen I've set up the overdrives, the displays, and set a couple of armors, but all the spells have yet to be installed... So not everything is all set up yet... There's alot of things to set up.......
:fregionc
rem ** Up to Mausoleumn entrance in forest region
title: Massive Rpg, Region: FOREST ENDS, Mausoleum Ruins, Sector 02
cls
set adv=0
mode con cols=172 lines=72
set killcount=%killcount%
rem Carrying on killcount from previous screen battle
if %adv% EQU 1 insertbmp /p:"portrait.bmp" /x:845 /y:45 /z:125
if %captscar% EQU 1 if %clothes% EQU 1 insertbmp /p:"porscar.bmp" /x:845 /y:45 /z:105
if %captscar% EQU 1 if %clothes% EQU 7 insertbmp /p:"porscarb1.bmp" /x:845 /y:45 /z:105
rem *********** Set All the Overdrive Jumps for number of Monster Kills *
rem Once the numbers been reached the overdrive jump is ready, jump into overdrive when player
rem goes into battle with Vampyr.
set killcount=%killcount%
if %killcount% EQU 5 insertbmp /p:"plasmared.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 10 insertbmp /p:"plasmaor.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 15 insertbmp /p:"plasblu.bmp" /x:1215 /y:20 /z:90 && start full.wav
if %killcount% EQU 20 insertbmp /p:"plasmagreen.bmp" /x:1215 /y:20 /z:90 && start full.wav && insertbmp /p:"overdrive.bmp" /x:955 /y:2 /z:100
if %killcount% EQU 25 insertbmp /p:"plasmared.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 30 insertbmp /p:"plasmaor.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 35 insertbmp /p:"plasblu.bmp" /x:1215 /y:20 /z:90 && start full.wav
if %killcount% EQU 40 insertbmp /p:"plasmagreen.bmp" /x:1215 /y:20 /z:90 && start full.wav && insertbmp /p:"overdrive.bmp" /x:955 /y:2 /z:100
if %killcount% EQU 45 insertbmp /p:"plasmared.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 55 insertbmp /p:"plasmaor.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 40 insertbmp /p:"plasblu.bmp" /x:1215 /y:20 /z:90 && start full.wav
if %killcount% EQU 45 insertbmp /p:"plasmagreen.bmp" /x:1215 /y:20 /z:90 && start full.wav && insertbmp /p:"overdrive.bmp" /x:955 /y:2 /z:100
if %killcount% EQU 55 insertbmp /p:"plasmared.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 65 insertbmp /p:"plasmaor.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 70 insertbmp /p:"plasblu.bmp" /x:1215 /y:20 /z:90 && start full.wav
if %killcount% EQU 80 insertbmp /p:"plasmagreen.bmp" /x:1215 /y:20 /z:90 && start full.wav && insertbmp /p:"overdrive.bmp" /x:955 /y:2 /z:100
if %killcount% EQU 85 insertbmp /p:"plasmared.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 90 insertbmp /p:"plasmaor.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 95 insertbmp /p:"plasblu.bmp" /x:1215 /y:20 /z:90 && start full.wav
if %killcount% EQU 105 insertbmp /p:"plasmagreen.bmp" /x:1215 /y:20 /z:90 && start full.wav && insertbmp /p:"overdrive.bmp" /x:955 /y:2 /z:100
if %killcount% EQU 110 insertbmp /p:"plasmared.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 115 insertbmp /p:"plasmaor.bmp" /x:1215 /y:20 /z:90 && start powerup.wav
if %killcount% EQU 120 insertbmp /p:"plasblu.bmp" /x:1215 /y:20 /z:90 && start full.wav
if %killcount% EQU 130 insertbmp /p:"plasmagreen.bmp" /x:1215 /y:20 /z:90 && start full.wav &&
ect. ect. the code is actually like the Great wall of China. It just goes on and on.
Wow, I did not even know that batch files can used to make games...
If you would be using any other language to create this kind of game you would need to write only once all those overdrive status, killcount, level up and so on. Also adding things like Potion of Mentor are far more trivial to do with simple timers in advanced languages.
You could start learning programing language simply making this game with that. Not immediately jump on ready made engine since learning them is much more work. This kind of game might be easy to do with Lazarus(http://lazarus.freepascal.org/) It has nice GUI which can used to design GUIs. Programming language is Pascal which has quite simple syntax although not so commonly used. Also any other programming language with ready made graphical components like Java Swing, .NET or Mono should work fine.
I just feel pain how much you need test when program is made with batch. For each screen you need to test each feature...
Well I'm one of those fast touch typists. So timewise that gives me an advantage to get alot of things done in a short amount of time. . I will have a look at this Lazarus engine. If you can point me to the script that allows the engine to display a picture on the screen and then use the cursor keys to scroll it around the screen as a map that could be useful to call up in the batch file when you hit View Map of Region. But you would properly need a map editor to piece together all the screens of the region
Wow I didn't mean post a wall of code lol
But yea all that looks quite messy and hard to maintain. If you are considering using a different language, then I would recommend Javascript. The language itself is relatively easy to learn and gives you a lot more features than you will currently have available to you with what you are using. You can manipulate graphics with a HTML canvas or with a framework like Pixi.js.
You seem to have atleast a basic understanding of programming concepts, so I think you could do it without much trouble.
You will learn a lot from it and you will gain a better understanding of how the guts of games work. It also makes your game much more accessible to potential players, which is what I assume you want?
I'm still not sure how the 3D fits in to your game. Are the character heads actual 3D models in the game or 2D renderings of 3D models?
Stay a while and listen.
If you decide to take that plunge, I recommend C++. Not because it is easy, but because- in my opinion- it is most useful across the board in all categories. Other languages may be more useful for specific things, but every one of those languages will be easier to learn BECAUSE you know C++.
Regardless, deciding to change your code platform is a major decision. I think a game writtin in batch is pretty interesting just for the proof-of-concept. As for answering your original question, give this a shot and let me know if it works as expected: (download expired)
(EDIT: Try "GlobalTimer.exe /?" for some breif instructions.)
--Medicine Storm
I got idea how global timer could be done. One program which has timer writes a some value for specific file. Value could Potion of Mentor = 1. As long effect is valid. When effect ends value is changed to 0. Then you could have another program which checks the value in specific file and gives return code what ever the value is.
Problem might be that Windows might lock file for one program and another one could not read it. But I am not that familiar with Windows file system so I could be wrong.
I still think C++ is uurgh when I see just how complicated the code looks. But I used some 3d perspective drawing in the game screens to give some depth and distance so it dosen't look so flat. The pirate guy is a 3d Blender Model with a 2d rendering of it. I actually prefer a 3d gameworld envrionment (gameplay wise) and prefer 3d models instead for sprites but its quite an huge undertaking to even consider turning everything into 3d from 2d.
Engine-wise I prefer an editor that has events and triggers system because I got so used to the Red Editor.
So f I turn the gameworld screens into 3d, then I have to know how many of those messhes I can piece together without breaking the memory or the engine, maybe the way to do it might be to make another copy of my 2d image and then greyscale it, and put in bits of white and light grey where there are raised surfaces or hills, then import that in to render a 3d terrain mesh with it and then dump the color 2d bitmap image down on top of the mesh.
I've never attempt anything like this before, but That might do it.
Now For the viewing of the regional map or the worldmap I would do a 2d view which I'm already started work on doing now for the Forest Ends Region to piece together the region. It looks a bit messed up in places at the moment because I'm still in the process of turning all the map segments seamless which has to be done manually by hand.. So there's about a couple of day's work here just to turn a 2d map into a seamless image.
For the enemies in the game, I might beable to just dump the 2d bitmap color enemy image down on an 3d grey mesh to turn them into 3d models meshes. There are some good free blender models around.
Making my own 3d levels and modding things in Red Faction's editor helped me to understand designing 3d worlds. But it was a very limited engine, designed for older machines only allowing 10500 faces for the geometry, everything had to be low-poly in that engine to stop lagging in frame rate.
Thanks for the progrm, ok I looked at it But Soon as I run the global timer program the batch file all freezes and passes control to the timer so I can't use the keyboard and when the time all runs down then control is handed back again to the batch file to allow me to move in the game.
But what about the mouse and keyboard program called bg.exe mouse, this program actually works in activating the mouse and allowing my batch file to run at the same time allowing me to click and clear screens or execute commands in the batch file with the mouse But at the same time it halts the keyboard operation all dead until you click with the mouse then control is returned back to the keyboard. If this is the limits of batchlanguage that I can have a mouse driver and batch file running at the same time but not have control also of the keyboard to type in commands while the exe program is running there might not be a way around it.
Sorry, Tozan. I suspected that would happen but thought you were saying you already had a way of dealing with it:
I don't know how bg.exe works and I don't know how to get batch files to hook in executable functions. Try using this as your command to start the timer:
Let me know if it still holds up the batch.
--Medicine Storm
Batch does have advantages, but also disadvantages so I will list them..
With bitmap graphics, it looks neat to have them in the console until another window gets in the way of the display and poof your graphics are gone and its back to textville.... It would've been better if the graphics stayed on the screen regrdless if a window was covering it or not until you manually hit return to clear the screen or CLS.
For I did have a start up crash issue going on in the first game region that prevented me from starting up the game through the worldgate screen the normal way. So I deleted my save, updated the save data routine values and the crash in the first region then stopped. So far so good, forgot to update the values for the save routine had caused that crash when I added new values to the code, forgot to add them to the save data code which corrupted the save file as a result. . Region 1 is now working again, But when I try to go into the 4th Region: Forest Ends Trading Store screen, up comes the '1 is unexpected crash again'. Hookay. Now I have to try to hunt down the cause of this one.... So the game is almost functioning right, but just not quite got that bug all out yet. I put the batch code also through batcodecheck to clear up any missing variables, goto labels.
Now as for Bg mouse.exe that don't work to allow mouse and keyboard to both be active at the same time in a batch file beause only the mouse is active and the keyboard is not..
But sound play (filename.wav) by the same guy, this tiny little exe program allows me to run my batch file and play the wav sounds without pausing the batch file. So maybe sound.exe taps into the windows sound driver to play the wav without needing to open any console window so it don't halt the batch file. And it works great except that it ignores all the IF statements in the batch loop you put it in so if you have a set of random sounds they play all at the same time. Not good if you have assigned 9 random sounds for combat and they all play all at once instead of randomly..... But if the programmer can fix up that little Ignore the IF line bug, then it will work better.
But If that's how he got sound.exe to work, to tap into the windows sound driver then I don't see why it shouldn't work with the keyboard and mouse drivers if you call them from windows, since windows has the drivers already loaded. Just as I can't see why Blender can't use the GIMP's layers feature to dump a 2d Bitmap texture on a 3d untextured mesh and just play around with the layers settings to bring the texture through the mesh just as the Gimp does it with layers in the Gimp using Dodge, Screen, Burn, Multiply, ect...
So I uploaded a screenshot of my forest ends region map (first sector) so you can see what the game is starting to shape into. There are issues also with the map screen of course since I aint a professional at making these maps.....
But the first thing I notice, half the forest is missing... I'll fix it later.
forestmap.jpg 376.8 Kb [0 download(s)]