Help needed please...
dragoncymru
31 Mar 2010, 21:40I'm trying to set up a game and what I need should be easy I think. I can think of ways to do it Using flags but there must be a more elegant solution... some kind of string??
The game has several linked scenarios.
Each scenario has between 7 -10 rooms.
when a player enters the scenario the game needs to randomly place objects (from a 'storage' room for that scenario) in the scenario rooms. It could be done all at once or it could be done as a player explores (taking a number of objects from the storage room each time)
Eg if playing cluedo the rooms would be Kitchen, Billiard Room, Study etc. The objects would be Miss scarlet, Colonel Mustard, the gun, the rope etc
So when the player steps into the hallway all the objects (say 12) are placed randomly in the 9 rooms.
So...can this be done? can the no. of objects be greater than the number of rooms? Or can the number of rooms be greater than the number of objects? can i specify some rooms having 2 objects and others just 1? Do all the objects have to be placed? Can i then get Character objects (suspects) to move between rooms but objects like the gun to stay still?
many thanks in advance for any suggestions
The game has several linked scenarios.
Each scenario has between 7 -10 rooms.
when a player enters the scenario the game needs to randomly place objects (from a 'storage' room for that scenario) in the scenario rooms. It could be done all at once or it could be done as a player explores (taking a number of objects from the storage room each time)
Eg if playing cluedo the rooms would be Kitchen, Billiard Room, Study etc. The objects would be Miss scarlet, Colonel Mustard, the gun, the rope etc
So when the player steps into the hallway all the objects (say 12) are placed randomly in the 9 rooms.
So...can this be done? can the no. of objects be greater than the number of rooms? Or can the number of rooms be greater than the number of objects? can i specify some rooms having 2 objects and others just 1? Do all the objects have to be placed? Can i then get Character objects (suspects) to move between rooms but objects like the gun to stay still?
many thanks in advance for any suggestions
MaDbRiT
01 Apr 2010, 12:51Dragoncymru asked...
Yup!
Yup!
Yup!
Well you could, but that would mean tweaking about with your random placement code (because of course it would no longer be truly random).
No, that's entirely up to you to decide, you might even randomize the ones that are not placed, but be sure not to 'not place' anything vital to solving the game.
Yes you can.
I think I'd approach this by means of assigning properties to objects & rooms (first part of the question). Say rooms and objects for scenario one might have a property called 'scenario' set to 1. You can then run a 'for-each' over all the objects in your scenario 1 storage room and randomly allocate the objects to other rooms with a matching scenario property. You could tweak this quite easily so that some (random) items are not placed at all should you wish to.
I'd also use a boolean property (called 'mobile') for objects you want to move around the rooms, you can then use an 'afterturn' script to move just those objects that have the 'mobile' property set. If you dig through the archives of this board you'll find some very old code of mine which has a cat that wanders around a house (respecting doorways, not to do so is a mistake, I'll explain why if you wish) The code is out of date, but the principle behind it is still valid.
Best of luck
Al
a.k.a. "MaDbRiT"
So...can this be done?
Yup!
can the no. of objects be greater than the number of rooms?
Yup!
[Or] can the number of rooms be greater than the number of objects?
Yup!
can i specify some rooms having 2 objects and others just 1?
Well you could, but that would mean tweaking about with your random placement code (because of course it would no longer be truly random).
Do all the objects have to be placed?
No, that's entirely up to you to decide, you might even randomize the ones that are not placed, but be sure not to 'not place' anything vital to solving the game.
Can i then get Character objects (suspects) to move between rooms but objects like the gun to stay still?
Yes you can.
I think I'd approach this by means of assigning properties to objects & rooms (first part of the question). Say rooms and objects for scenario one might have a property called 'scenario' set to 1. You can then run a 'for-each' over all the objects in your scenario 1 storage room and randomly allocate the objects to other rooms with a matching scenario property. You could tweak this quite easily so that some (random) items are not placed at all should you wish to.
I'd also use a boolean property (called 'mobile') for objects you want to move around the rooms, you can then use an 'afterturn' script to move just those objects that have the 'mobile' property set. If you dig through the archives of this board you'll find some very old code of mine which has a cat that wanders around a house (respecting doorways, not to do so is a mistake, I'll explain why if you wish) The code is out of date, but the principle behind it is still valid.
Best of luck
Al
a.k.a. "MaDbRiT"
dragoncymru
01 Apr 2010, 15:54Thnaks for the reply.
Okay I give all my rooms in scenario1 a 'scen1' property.
But what then?
What's this 'for each' code - how's it done?
Basically I want to model a boardgame where you enter a room and pick an encounter card (or two) from a deck; when you start a new scenario it's a new deck etc..
Okay I give all my rooms in scenario1 a 'scen1' property.
But what then?
What's this 'for each' code - how's it done?
Basically I want to model a boardgame where you enter a room and pick an encounter card (or two) from a deck; when you start a new scenario it's a new deck etc..
MaDbRiT
01 Apr 2010, 19:38The syntax for a for-each is explained in the reference manual thus;
You would be using something like this in your afterturn script (maybe entering the appropriate room causing this code to execute)
Obviously once this has run, you don't really need to worry about flagging it as a completed task, there will most likely be nothing for it to do after being run a couple of times anway (all the objects will have gone)
This is all pretty to do if you are a manual coder, somewhat more tricky if you rely on QDK (I neglected to ask!)
Al "MaDbRiT" B
for each { object | room | exit } in { game | <room name> } script
Executes the specified script for each object/room/exit, either in the whole game or in the specified room. Each time the loop script is executed, the current object/room/exit is returned in the #quest.thing# string variable.
You would be using something like this in your afterturn script (maybe entering the appropriate room causing this code to execute)
for each object in <storageroom1> {
if property <#quest.thing#;scen1> then {
set numeric <move;$rand(1;7)$>
if <%move%;6> then move <#quest.thing#,library>
if <%move%;5> then move <#quest.thing#,kitchen>
[and so on - note that allowing the random number function to generate a number not in use to move an object means the object isn't moved... ]
}
}
Obviously once this has run, you don't really need to worry about flagging it as a completed task, there will most likely be nothing for it to do after being run a couple of times anway (all the objects will have gone)
This is all pretty to do if you are a manual coder, somewhat more tricky if you rely on QDK (I neglected to ask!)
Al "MaDbRiT" B