AI shopping?

RavianGamingIndustries
21 Nov 2016, 03:11

Is there a way you can have a shop generate credits without the player spending credits at the shop? Basically simulating NPCs shopping at a story without the player needing to be in the same room, is that possible?


TinFoilMkIV
21 Nov 2016, 05:52

Yes it is absolutely possible. The questions you'll need to answer are what are the conditions for a shop to generate credits, when/how will the game check the conditions, and how often do you want to generate them.


RavianGamingIndustries
21 Nov 2016, 19:37

If the income was turn based, what would the coding fir that look like?


RavianGamingIndustries
21 Nov 2016, 19:38

And the conditions are it has to be bought by the player before it will start generating income per turn


TinFoilMkIV
21 Nov 2016, 20:45

The most basic version I can think of at the moment would be to give each shop an income attribute, or whatever you want to call it, then each turn add that value to the credits the shop is currently holding. You wont have to worry about disabling it before the shop is allowed to generate income if you set it to 0 to start, it will try to generate it but wont have any effect since it's trying to gain nothing. I would modify the income value during the script for whatever action you have triggering that income. So with your conditions, it would be during the sequence where the player buys the item, add a first time script that adds the desired value to the shops income.

So code would be something like
//this goes in the turn script of the room
this.credits_held + this.credits_held + this.income

that part of the code is pretty simple, it's more in how you handle modifying the income.

I haven't actually played with room specific turn scripts much so I'm not sure if they fire without the players presence. If they do, then simply add the income into that script. Otherwise you'd have to put the turn script on the game itself. which will be slightly trickier but shouldn't be too bad, you then just have to run through a list of the stores then do the income calculations per store.


hegemonkhan
22 Nov 2016, 06:43

my understanding is that local Turnscripts/Timers are just that, local... if you're not in the same room, they're (or you're) out of scope of them --- they're only active if you're in the same room as them (and they're also enabled too --- obviously). It makes sense that the game uses the 'game.pov' for scope... ingenius design... now that I'm thinking about it. As this may be why quest requires there to be and always be a Player Object contained within a Room Object (or maybe just an Object --- not sure if it has to be a Room Object).

http://docs.textadventures.co.uk/quest/asl_requirements.html