time, weather, stats, room sorting and a bit of being a noob
Elexxorine
20 Feb 2005, 12:24hi i've been busy for a while but i'm back now.
i know i'm going to sound like a noob but i cant get the timers to work. i want a timer every second to add 1 to 'mins' which is minutes, when mins equals 60 its to be set to 0 and 'hrs' (hours) to be added by 1. when hrs equals 24 it goes to 0. then it adds 1 to the date and so on.....
this can be used to run shops which open and close at certain times, AND people can wander around on a daily cycle (beeing somewhere at a certain time!). the describtion can change at night (saying it dark, etc).
~~~~~~~
i'd like to create a weather system where every hour it picks a random number (1-100) if its below 50 it says the same weather as before (no change), 50-60 sunny, 60-70 rain, 70-80 windy, 80-90 snow, 90-100 really stupidly hot, or whatever, but i don't know how to make random numbers and use them in this way.
~~~~~~~
i've got lots and status variables and the viewing window for these is TINY. so i've been trying to make it so if the player types 'stats' it says something like:
hit points: 50 / 129. mana: 0 / 100.
gold: 1,957,382,000. stamina: 9 / 32.
armour: mithril chainmail ( 12 armour points)
weapon: iron wakasashi ( 4-9 damage )
clothes: cloth.
etc.......
but i cant get it to put the variables in to the text.
~~~~~~~
also is there a way to sort all the hundreds of rooms most good games have. cos you can give them names like: 'area' / 'townorplace' / 'roomname' but if you need to add one in the middle, your stuck arent you it goes on the bottom and everything get out of order! would it work if you opened the game in textpad and copied the rooms so theyre in the right order?
any help appreciated.....
i know i'm going to sound like a noob but i cant get the timers to work. i want a timer every second to add 1 to 'mins' which is minutes, when mins equals 60 its to be set to 0 and 'hrs' (hours) to be added by 1. when hrs equals 24 it goes to 0. then it adds 1 to the date and so on.....
this can be used to run shops which open and close at certain times, AND people can wander around on a daily cycle (beeing somewhere at a certain time!). the describtion can change at night (saying it dark, etc).
~~~~~~~
i'd like to create a weather system where every hour it picks a random number (1-100) if its below 50 it says the same weather as before (no change), 50-60 sunny, 60-70 rain, 70-80 windy, 80-90 snow, 90-100 really stupidly hot, or whatever, but i don't know how to make random numbers and use them in this way.
~~~~~~~
i've got lots and status variables and the viewing window for these is TINY. so i've been trying to make it so if the player types 'stats' it says something like:
hit points: 50 / 129. mana: 0 / 100.
gold: 1,957,382,000. stamina: 9 / 32.
armour: mithril chainmail ( 12 armour points)
weapon: iron wakasashi ( 4-9 damage )
clothes: cloth.
etc.......
but i cant get it to put the variables in to the text.
~~~~~~~
also is there a way to sort all the hundreds of rooms most good games have. cos you can give them names like: 'area' / 'townorplace' / 'roomname' but if you need to add one in the middle, your stuck arent you it goes on the bottom and everything get out of order! would it work if you opened the game in textpad and copied the rooms so theyre in the right order?
any help appreciated.....

Shadowalker
20 Feb 2005, 12:56Hi there: Just recently, I was also interested in creating a kind of "clock." Let me tell ya, it was a lot of work...for me at least. But lucky you, you don't have to do any work. I'll give you my code if you want. I'll paste it. Then you can just cut it and paste it into your game. But I'll need to do it later, as I'm in kind of a hurry right now.
As for the weather, I think I know how to do that. Again, I'm in a rush, so I can't do it right now, but if I check back later and no one told you how, I'll tell you, and perhaps make a demo.
Stats...I've done that exact thing before too....I'll post that later also....
Rooms: lol. Again, I had the same problems. And you have the right answer. Just open up the file in wordpad or something, find the room you want to move, cut it, (from the "define room" to the "end define") and paste it right below the room you want to move it next to.
Hope I've helped
As for the weather, I think I know how to do that. Again, I'm in a rush, so I can't do it right now, but if I check back later and no one told you how, I'll tell you, and perhaps make a demo.
Stats...I've done that exact thing before too....I'll post that later also....

Rooms: lol. Again, I had the same problems. And you have the right answer. Just open up the file in wordpad or something, find the room you want to move, cut it, (from the "define room" to the "end define") and paste it right below the room you want to move it next to.
Hope I've helped
Christopher
21 Feb 2005, 03:28I think I can help. First, for time I've done almost the same thing in my own game... here's the sample code
All you need to do is inc <minute; #> at the end of each turn, replacing # with the number on minutes.
Try using the $rand(lowestnumber;highestnumber)$ function then check if the number is (say) lower than 60 and higher than 50, set a weather variable to Sunny
Try printing a text block that has that, something like:
and so on, inserting your variable names along the way.
I find that annoying too, but there isn't any real way around it other than what you suggested, cutting and pasting in a text editor.
Hope that help, and good luck with your game!
if ( %minute% >= 60 ) then {
dec <minute; 60>
inc <hour; 1>
}
if ( %hour% >= 24 ) then {
dec <hour; 24>
inc <day; 1>
}
if ( %hour% < 6 ) or ( %hour% >= 18 ) then flag on <night> else flag off <night>
All you need to do is inc <minute; #> at the end of each turn, replacing # with the number on minutes.
Try using the $rand(lowestnumber;highestnumber)$ function then check if the number is (say) lower than 60 and higher than 50, set a weather variable to Sunny
Try printing a text block that has that, something like:
Hit points: %hp%/%max.hp%. Mana: %mana%/%maxmana%
gold: %gold%
and so on, inserting your variable names along the way.
I find that annoying too, but there isn't any real way around it other than what you suggested, cutting and pasting in a text editor.
Hope that help, and good luck with your game!
Shadowalker
21 Feb 2005, 09:49Hi elexxorine: Here is a DEMO I made. It contains a clock system, a weather-changing system, and a "stats" code. For the weather system, I made it change every 5 seconds so that you don't actually have to wait to see the effects. If you use the code for your game, just change the weather timer to 60 seconds (which is an hour in my code) instead of 5. Also, you wanted to make the system pick a number between 1 and a 100 to determine the weather; I thought it would make it much simpler to simply have, for example, 6 random numbers. So 1 would be windy, 2 rainy, 3 cold, 4 hot, 5 stays the same, and so on. Because if you have it pick a number from one to 100, the weather-random-number-chooser will have more numbers to choose from, meaning that the weather may be less varied. Anyway, I hope you find this code useful.
' "Weather/Clock/StatsDEMO"
' Created with QDK 3.53 - UNREGISTERED VERSION
define game <Weather/Clock/StatsDEMO>
asl-version <350>
gametype singleplayer
start <Start>
game author <>
game version <1.0>
game copyright <© Artistic Productions 2005>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
default fontname <Cuckoo>
default fontsize <12>
background <black>
foreground <yellow>
startscript {
msg <|jc>
exec <about>
wait <Press any key to continue...>
clear
msg <|s17In this |bDEMO|xb, there is the following:|n|n|i***A clock|n|n***The weather randomly changes every 5 seconds|n|n***You pick stats, and can view them by entering the command "stats." Originally, I had them displayed in the variables window, but for some reason Quest displays string variables first, and also doesn't display them in the proper order, so it looked horrible. So in the meantime, this DEMO only has stats able to be viewed by entering that command.|n|n***You can reset time by typing in "t." However, I would not recommend this in a normal game, because if you have stores that open at a certain time, it will mess them up, unless you tweak the code|xi|n|n|jcEnjoy!!|n|jl>
wait <Press any key to begin...>
msg <|s00>
clear
choose <armor>
}
command <t> {
msg <What would you like the hour to be? (ENTER A NUMBER FROM 1-12)|n|n>
enter <hour>
if ( #hour# = 1 ) or ( #hour# = 2 ) or ( #hour# = 3 ) or ( #hour# = 4 ) or ( #hour# = 5 ) or ( #hour# = 6 ) or ( #hour# = 7 ) or ( #hour# = 8 ) or ( #hour# = 9 ) or ( #hour# = 10 ) or ( #hour# = 11 ) or ( #hour# = 12 ) then {
set <hours; #hour#>
msg <Ok, the hour is now: %hours%.|n>
pause <1500>
msg <Would would you like the minute(s) to be? (PLEASE ENTER A NUMBER FROM 1-59)|n>
enter <minute>
if ( #minute# >= 1 ) and ( #minute# <= 59 ) then {
set <minutes; #minute#>
msg <The minute(s) is/are now: %minutes%.|n>
pause <1500>
msg <Would you like it to be A.M., or P.M.? (PLEASE ENTER "1" FOR A.M., OR "2" FOR P.M.)|n>
enter <a or p>
if ( #a or p# = 1 ) or ( #a or p# = 2 ) then {
if ( #a or p# = 1 ) then {
set <A.M.; 1>
set <P.M.; 0>
msg <It is now: A.M.|n>
pause <1500>
msg <Your new settings: |nHour: %hours%.|nMinute(s): %minutes%.|nM: A.M.|n>
}
if ( #a or p# = 2 ) then {
set <P.M.; 1>
set <A.M.; 0>
msg <It is now: P.M.|n>
pause <1500>
msg <Your new settings: |nHour: %hours%.|nMinute(s): %minutes%.|nM: P.M.|n>
}
}
else msg <I'm sorry, but you chose an invalid selection. Please try again later.|n>
}
else msg <I'm sorry, but that number is not valid. Please try again later.|n>
}
else msg <I'm sorry, but that number is not valid. Please try again later.|n>
}
command <stats> msg <Your stats are as follows:|n|nRace: #race#|nArmor: #armor#|nHP: %hp%|nMP: %mp%|n|nType in "stats" at any time to view them, or just look in the variable window.|n>
define variable <A.M.>
type numeric
value <1>
display nozero < A.M.>
end define
define variable <P.M.>
type numeric
value <0>
display nozero < P.M.>
end define
define variable <hours>
type numeric
value <12>
display <Hour: !>
end define
define variable <minutes>
type numeric
value <00>
display <Minute*s*: !>
onchange {
if ( %minutes% = 60 ) then {
dec <minutes; 60>
do <Increment Hour>
}
if ( %minutes% = 59 ) then do <A.M. and P.M.>
}
end define
define variable <weather>
type string
value <Sunny>
display <It is [ ! ] outside>
onchange msg <It is |cr#weather#|cb outside.|n>
end define
define variable <race>
type string
end define
define variable <armor>
type string
end define
define variable <hp>
type numeric
value <0>
end define
define variable <mp>
type numeric
value <0>
end define
end define
define synonyms
end define
define room <Start>
look <This is the room you start off in.>
description {
msg <You are in the |crStarting|cb room.|n>
msg <#quest.lookdesc#|n>
}
end define
define procedure <Increment Hour>
if ( %hours% = 12 ) then dec <hours; 11> else inc <hours; 1>
end define
define procedure <Kol Tuv Open?>
if got <Kol Tuv Open> then {
msg <You enter Kol Tuv.|n>
goto <Kol Tuv(The Room)>
create exit out <Kol Tuv(The Room); Start>
}
else msg <A sign on the door says |cl"CLOSED." |cb Oh well.|n>
end define
define procedure <A.M. and P.M.>
if ( %hours% = 11 ) and ( %A.M.% = 1 ) then {
dec <A.M.; 1>
inc <P.M.; 1>
}
else {
if ( %hours% = 11 ) and ( %P.M.% = 1 ) then {
dec <P.M.; 1>
inc <A.M.; 1>
}
}
end define
define timer <minutes>
interval <1>
action set <minutes; %minutes%+1>
disabled
end define
define timer <Weather Changer>
interval <5>
action {
set numeric <weather2; $rand(1;6)$>
if ( %weather2% = 1 ) then set <weather; #weather#> else {if ( %weather2% = 2 ) then set <weather; Raining> else {if ( %weather2% = 3 ) then set <weather; Chilly> else {if ( %weather2% = 4 ) then set <weather; Extremely Hot> else {if ( %weather2% = 5 ) then set <weather; Windy> else {if ( %weather2% = 6 ) then set <weather; Sunny>}}}}}
}
disabled
end define
define text <intro>
end define
define text <win>
end define
define text <lose>
end define
define selection <armor>
info <Please choose your armor:>
choice <Metal of Heroes> {
set <armor; Metal of Heroes>
choose <race>
}
choice <Cloak of Magic> {
set <armor; Cloak of Magic>
choose <race>
}
choice <HELP> {
msg <In this particular demo, it makes no difference, (I'm just using it for the sake of what appears in stats) but in a real game, I'd set a "Defense" variable based on the chosen armor.|n>
pause <4000>
choose <armor>
}
end define
define selection <race>
info <Please choose a race. NOTE: Each race has a different MP and HP>
choice <Elvish> {
set <race; Elvish>
set <hp; 100>
set <mp; 200>
msg <Your stats are as follows:|n|nRace: #race#|nArmor: #armor#|nHP: %hp%|nMP: %mp%|n|nType in "stats" at any time to view them, or just look in the variable window.|n>
wait <Press any key to continue...>
timeron <minutes>
timeron <Weather Changer>
}
choice <Ogre> {
set <race; Ogre>
set <hp; 200>
set <mp; 100>
msg <Your stats are as follows:|n|nRace: #race#|nArmor: #armor#|nHP: %hp%|nMP: %mp%|n|nType in "stats" at any time to view them, or just look in the variable window.|n>
wait <Press any key to continue...>
timeron <minutes>
timeron <Weather Changer>
}
choice <HELP> {
msg <|cgELVISH: |cr100 HP |cl200 MP|n|n|cgOGRE: |cr200 HP |cl100 MP|cb|n>
pause <4000>
choose <race>
}
end define
Elexxorine
21 Feb 2005, 13:40thanx for the help i like the demo, its funny when the weather changes from extremely hot to freezing in 5 seconds lol.
Elexxorine
21 Feb 2005, 16:01ok been doing a hell of a lot of programin' and i've hit a few snags:
1. alignment does work. it runs on the basis of to values(align and align2), align2 is set is a number between 1 and 140, every 20 is a different alignment: 1-20 pure evil, 21-40 evil, 41-60 neutral/evil, 61-80 neutral, 81-100 neutral/good, 101-120 good, 121-140 pure good. align is set to the string which you see, align2 is the 'real' value and changes when you kill stuff etc. and starts at 70 (neutral). but it does work.
2. stats don't work. the stats strength and agility control your maxhitpoints and maxstamina (both working in the same way). they both start as 1. your mhp is always 2Xstr+4 (%str%+%str%+4) and your hp can never go over your mhp. in theory.
3. weather doesn't work. every 15 seconds a random number (1-10) is picked if 1-5 the weather stays the same, 6 sunny, 7 raining, 8 windy, 9 snow, 10 hot. (i used ebayfan414's demo as referance tho' QDK to do it but it doesn't work)
things which do work:
1. when you type 'stats' it shows all the stats (except weather and the bugs with alignment and hp/stamina)
2. the clock ticks away nicely (retype stats repeatedly to watch).
you'll probably ask for the code:
thanx for any help
1. alignment does work. it runs on the basis of to values(align and align2), align2 is set is a number between 1 and 140, every 20 is a different alignment: 1-20 pure evil, 21-40 evil, 41-60 neutral/evil, 61-80 neutral, 81-100 neutral/good, 101-120 good, 121-140 pure good. align is set to the string which you see, align2 is the 'real' value and changes when you kill stuff etc. and starts at 70 (neutral). but it does work.
2. stats don't work. the stats strength and agility control your maxhitpoints and maxstamina (both working in the same way). they both start as 1. your mhp is always 2Xstr+4 (%str%+%str%+4) and your hp can never go over your mhp. in theory.
3. weather doesn't work. every 15 seconds a random number (1-10) is picked if 1-5 the weather stays the same, 6 sunny, 7 raining, 8 windy, 9 snow, 10 hot. (i used ebayfan414's demo as referance tho' QDK to do it but it doesn't work)
things which do work:
1. when you type 'stats' it shows all the stats (except weather and the bugs with alignment and hp/stamina)
2. the clock ticks away nicely (retype stats repeatedly to watch).
you'll probably ask for the code:
' "TBC"
' Created with QDK 3.52 - UNREGISTERED VERSION
!include <Typelib.qlb>
define game <TBC>
asl-version <350>
gametype singleplayer
start <Astnia, traven>
game author <elexxorine>
game version <1.00 pre-alpha>
game info <Created with QDK 3.52 - UNREGISTERED EVALUATION VERSION.>
command <stats> msg <GENERAL:|nYou are #race#, #class# .|nhit points: %hp% / %mhp% .|nstamina: %sta% / %msta% .|nyou have %gold% pieces of gold.|n|nSTATS:|nstrength: %str% .|ndexterity: %dex% .|nagility: %agl% .|nintelligence: %int%.|nyou are level %level% with %exp% experience points.|nyou are |i#align#|xi .|n|nOUTSIDE WORLD:|nit is |i%hrs%|xi hours and |i%mins%|xi minutes of the clock, on day |i%day%|xi .|nit is |i#weather#|xi outside.>
define variable <race>
type string
value <elf>
end define
define variable <class>
type string
value <peasant>
end define
define variable <gold>
type numeric
value <90>
end define
define variable <level>
type numeric
value <1>
end define
define variable <exp>
type numeric
value <0>
end define
define variable <str>
type numeric
value <1>
end define
define variable <dex>
type numeric
value <1>
end define
define variable <agl>
type numeric
value <1>
end define
define variable <int>
type numeric
value <1>
end define
define variable <align>
type string
end define
define variable <mins>
type numeric
value <0>
end define
define variable <hrs>
type numeric
value <4>
end define
define variable <day>
type numeric
value <1>
end define
define variable <weather>
type string
onchange msg <It is #weather# outside.>
end define
define variable <weather2>
type numeric
value <6>
end define
define variable <hp>
type numeric
value <100>
end define
define variable <mhp>
type numeric
value <50>
end define
define variable <sta>
type numeric
value <50>
end define
define variable <msta>
type numeric
value <50>
end define
define variable <align2>
type numeric
value <70>
end define
end define
define synonyms
end define
define room <Astnia, traven>
alias <Drunken Druid Inn>
prefix <The>
look <A typical pub. People are sitting at tables drinking ale and sweet beer while sharing tales and swapping legonds. A fire is crakling in the corner warming every corner of the room, smoke and the smells of liquer waft in the air and calm you, it feels like home...>
define object <barkeep>
alt <barman; bar man; barkeeper; bar keeper; barkeep; bar keep>
look <The bar keeper is standing behind the counter, serving drinks.>
examine <He has short black hair, light brown eyes, greesy dark blue skin and a scowl. He is wearing an apron over his normal clothes and is quite short but tough looking.>
prefix <the>
displaytype <shop owner>
article <him>
gender <he>
type <TLTactor>
properties <not named>
end define
end define
define procedure <hrschange>
if ( %mins% >= 60 ) then {
set <hrs; %hrs%+1>
set <mins; 0>
}
if ( hrs >= 24 ) then {
set <hrs; 0>
set <day; %day%+1>
}
end define
define procedure <alignment>
if ( align2 >= 1 ) and ( align2 <= 20 ) then set <align; PURE EVIL!!!> else {if ( align2 >= 21 ) and ( align2 <= 40 ) then set <align; evil> else {if ( align2 >= 41 ) and ( align2 <= 60 ) then set <align; neutral/evil> else {if ( align2 >= 61 ) and ( align2 <= 80 ) then set <align; neutral> else {if ( align2 >= 81 ) and ( align2 <= 100 ) then set <align; neutral/good> else {if ( align2 >= 101 ) and ( align2 <= 120 ) then set <align; good> else {if ( align2 >= 121 ) and ( align2 <= 140 ) then set <align; PURE GOOD!!!>}}}}}}
end define
define procedure <mhit>
set <mhp; %str%+%str%+4>
end define
define procedure <mstam>
inc <msta; %agl%+%agl%+4>
end define
define procedure <mhit2>
if ( hp > mhp ) then set <hp; %mhp%>
end define
define procedure <mstam2>
if ( sta > msta ) then set <sta; %sta%>
end define
define timer <minutes>
interval <1>
action set <mins; %mins%+1>
enabled
end define
define timer <weatherchanger>
interval <15>
action {
set <weather2; $rand(1;10)$>
if ( weather2 = 1 ) or ( weather2 = 2 ) or ( weather2 = 3 ) or ( weather2 = 4 ) or ( weather2 = 5 ) then set <weather; #weather#> else {if ( weather2 = 6 ) then set <weather; sunny> else {if ( weather2 = 7 ) then set <weather; raining> else {if ( weather2 = 8 ) then set <weather; windy> else {if ( weather2 = 9 ) then set <weather; snowing> else {if ( weather2 = 10 ) then set <weather; very hot>}}}}}
}
enabled
end define
define text <intro>
end define
define text <win>
end define
define text <lose>
end define
define selection <shop_bar>
info <What would you like to buy?>
choice <Buy_Ale>
choice <Buy_Sweetbeer>
choice <?_Ale> {
msg <ALE:|n this bitter drink is served in almost every pub, it is dark brown, frothy and very alcoholic.|n USUAL PRICE: 6 gold pieces.>
wait <press any key....>
choose <shop_bar>
}
choice <?_Sweetbeer> {
msg <SWEETBEER:|n this refreshing drink is served in almost every pub, it is a teacle colour and favoured by most for its relaxing effects.|n USUAL PRICE: 9 gold pieces.>
wait <press any key....>
choose <shop_bar>
}
choice <Buy_Nothing>
end define
thanx for any help
