Adventure Creator original thread

Tips, techniques and tutorials about creation tools.

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Sat, 13May18 22:21

Tlaero,

Another scenario for you. Is there a way currently in AC to support achievements with variables that persist between games, but do not show up on the Achievement counter?

Take for example, an achievement called "Total Loser" and store it in an achievement variable called "loser". But to get the achievement, the player must find every way to lose the game. If we assume there are 5 unique ways to lose, the player would have to play a minimum of five times, assuming they didn't accidentally "win" a game in the interim, or lose the same way twice. I would have 5 variables, (one for each unique loss condition: lose1, lose2, lose3, lose4, and lose5) that once all 5 are set would set the "Total Loser" achievement. Same thing if I wanted a "Winner" or "Master Gamer" or "Total Pervert" achievement that was a summation of activates across multiple playthroughs.

If I tracked all 5 losses as Achievement variables, I would see 6 total achievements in the Achievement counter, when really there is only one intended. How do I track these type of events through multiple playthroughs without them showing up as independent events on the Achievement total? Is there an easy naming convention and filter I could use in the scoring line?

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Sat, 13May18 23:18

The current system doesn't support that. Let me think about the best way to do it.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby tlaero » Sun, 13May26 18:53

I just uploaded version 3.6 of AdventureCreator. Only changes are in the exe, not in the examples or javascript.
https://hotfile.com/dl/224583591/5e34bb ... r.zip.html

I made some changes for me and some changes for Wolf.

Changes in 3.6
There are now buttons labeled "->" as well as a "Follow Link" menu item on the area context menu. Clicking any of these follows the HREF and opens that page in AdventureCreator. This provides another way to open pages, along with "File->Open" and Game View.

The File menu now has a "Browse HTML" button which opens the current page in your browser.

Added a shortcut "Ctrl + H" to the Hide Image menu item.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Sun, 13May26 21:13

Thanks Tlaero!

Perfect timing. I'm about to start the debug/balance pass on the 2nd half of BEW Day-1, and this will make it a lot easier! Already loaded it up and took it through it's paces and it works great. I had mapped "edit html" to actually open in the browser, but now I've mapped it back to notepad++ and use the now built-in function to open in the browser. Awesome work as always!

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Thu, 13May30 07:58

I just changed AC to update all broken links when you save a file. I was getting annoyed by the red links for files I had added later. It always did that when you said "Show Game View" but now it does it on save too.

What do you folks think about this idea? If you follow a broken link ("->" button) it creates a new page with that name. Would that be helpful or annoying?

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Thu, 13May30 08:03

tlaero wrote:I just changed AC to update all broken links when you save a file. I was getting annoyed by the red links for files I had added later. It always did that when you said "Show Game View" but now it does it on save too.

That is awesome. I too was getting annoyed by the red links. :)

tlaero wrote:What do you folks think about this idea? If you follow a broken link ("->" button) it creates a new page with that name. Would that be helpful or annoying?

I think that would be both helpful, and annoying. Helpful when I have the entry correct. Annoying when I spawn stray pages when I have it wrong...but then again, I do the same thing now anyway in the file field, so in the end, I think much more helpful than annoying. I vote to include the feature. [img]images/icones/icon7.gif[/img]

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Thu, 13May30 17:51

I've been brainstorming the sub achievement question and came up with an idea. Keep in mind this is only brainstorming, I have no idea if JS can do it.

Have a second set of persistent variables called sub achievements. At the simplest, I could then write a function that checks if all the sub achievements have been set, and if so, set the main one, although that's a little clunky.

More complex would be to have a function like setSubAchieve(subAchievement,achievement).

pseudocode for that function would be something like:

--------
game.js variables
----------
Achievement Variables: "barAll", "office" // to be set once the player finds all endings for a particular scene, for example.

subAchievement Variables: "barAllFaith", "barAllEmily", "barAllBoth", "officeTrash", "officeMoreTrash" //naming convention is achievement and subachivement to make it work.

-------
In AC
-------
setSubAchieve("barAllEmily","barAll") //entered into preload in ac

----
function pseudocode
----
function setSubAchieve(subachieve,achieve)

setSub(subachieve) //set's the sub achievement to 1, in this case barAllEmily

count = Count the number of barAll* sub achievements using a wildcard. //I don't know if JS can do this, from 'achieve' in the function. count the 3 barAll sub achievements, but not the office sub achievements.
sum = Sum the values of the barAll sub achievements using the wildcard //again, can JS do this? sum the barAll, but not the office.

If count = sum //If count equals sum, all the sub achievements have been set to 1. 3 barAll sub achievments, and the sum of them if they are all set would also be 3.

setAchieve("barAll") //set the main achievement if true.

Is this even in the ballpark of possible? :)

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby wagner » Fri, 13May31 00:33

You could always add some code at the bottom of setSubAchieve() or in some other script that is run on every page load that checks if a certain set of conditions is met, and if so, apply the primary achievement. If you have 32 or fewer sub-achievements, you could store them all as a bit array and do a simple, fancy bitmask to check. Lets say...

Code: Select all
var subachievements = 0x0638;  // 0b0000011000111000
var achievement1mask = 0x0028; // 0b0000000000101000
var achievement2mask = 0x0460; // 0b0000010001100000


From the above values, achievement 1 is completely satisfied, but achievement 2 is only partially satisfied. You could test for a partial match with...

Code: Select all
if(subachievements & achievement2mask) {

}


You could test for a complete match with...

Code: Select all
if((subachievements & achievement1mask) == achievement1mask) {

}


If you need more than 32 different subachievements, you could expand these checks out to several sets of binary variables, but it would quickly become unwieldy to code.
wagner
great white shark
 
Posts: 66
Joined: Tue, 12Jul31 18:42
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Fri, 13May31 02:56

Actually I was planning to do something with the persistent variables tonight. I think I have something really simple, I just need to try it out.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby tlaero » Fri, 13May31 04:34

Okay, here's how it's going to work when you get the next _functions.js.

Just add a gamePersists array to your _game.js. Ie:

var gamePersists = ["wins"];

You can treat anything in gamePersists the exact same as anything in gameVars. They're normal variables that you can varPlus1, readVar, etc on. The only difference is that they aren't cleared by initVars when you start a game. So they persist from play to play.

Importantly, you can't have the same variable name in gameVars and gamePersists.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Fri, 13May31 05:40

That should work great, Tlaero! Thanks for all the effort!

wagner wrote: If you have 32 or fewer sub-achievements, you could store them all as a bit array and do a simple, fancy bitmask to check. Lets say...

Appreciate the advice mate, and I like the way you're thinking, but that's way, way over my poor head. If I understand correctly, I think you are using numbers stored in binary as toggles, but not sure I have the braincells to actually pull it off. I will have 30-40 achievements, and anywhere from 1-10 sub achievements for each.

All I would need in my scenario are complete matches, which simplifies it a bit

The key factor, currently, is having variables that persist between games, but don't count toward achievement totals which Tlaero is updating in the tool. I can create a function to set each sub achievement, and then do an If statement to check if all the sub achievements are set, and if true, set the primary achievement. That's about the limit of my knowledge, but it's pretty easy to do.

The "nice to have" here would be a single function that I can tell the sub achievement I want to set, and the main achievement name, and it will set the sub achievement, then check to see if all the sub's for that main achievement have been met. Using my example from an above post, the wish is an automated function to be able to do something like, setSubAchieve("barAllFaith","barAll") to set the barAllFaith subachievement, and then check if barAll is met and set it too if applicable. Then later use setSubAchieve("officeTrash","office") to set the officeTrash sub achievement, and then check for completion of the "office" main achievement. The link being the naming convention, since I don't really know of another way to do it, unless maybe a two dimensional array, but that's a little over my head too.

In theory, I could write the function to do it, except I don't know how to filter and count the variable arrays in JS, or do the necessary string matching/manipulation, or even know if that's feasible with how AC is handling everything.

By the way, sometimes I get lucky and sound like I know what I'm talking about, but I really don't most of the time. I know just enough to be dangerous. [img]images/icones/icon10.gif[/img]

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Fri, 13May31 07:35

Version 3.7 uploaded. https://hotfile.com/dl/225138380/7aaeb5 ... r.zip.html

The exe has the broken link cleanup. I didn't implement the "follow creates a file" code yet. Maybe sometime in the future.

The _functions.js in the example contains the new gamePersists code, and the example shows how to use it to give the 4th achievement when the player wins 10 games.

I didn't get a chance to extensively test either feature, so you might find problems. Let me know if you do.

If you want to do the bitwise stuff wagner was talking about, there are examples in CfK and LwK. There are also helper functions in _functions.js. Your "nice to have" is certainly doable. I'll show you how this weekend.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Fri, 13May31 07:45

I would need extensive tutoring on the bitwise stuff. Most other stuff I can pretty much figure out on my own. :)

Thanks for this Tlaero. I'll take it for a test drive tomorrow and let you know if I run into problems. Thanks for being awesome. ;)

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby wagner » Sat, 13Jun01 03:57

With the bitwise stuff, you have a 32-bit integer to play with, which means 32 ones or zeros that can flag whether a task has completed or not. The two bitwise operations you would probably want to use are AND (&) and OR (|). If you AND two numbers, it goes bit-by-bit, and if both bits are on, the result bit is on, otherwise off. With OR, if either bit is on, the result is on.

Code: Select all
    0b00000000000000000000000000000000
AND 0b111111111111111111111111111111111
==  0b00000000000000000000000000000000

   0b00000000000000000000000000000000
OR 0b111111111111111111111111111111111
== 0b111111111111111111111111111111111


If a subachievement could potentially be applied to multiple achievements, using an AND will filter out only those bits your stored value has in common with your achievement, and if the result exactly matches the requirement for the achievement, then all the requirements have been fulfilled. If each subachievement is only used in a single achievement, there's no value to the bitwise operations. Just check to see if the value matches.
wagner
great white shark
 
Posts: 66
Joined: Tue, 12Jul31 18:42
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Sun, 13Jun02 03:59

I think I follow how the integer and masks work...barely. Essentially a 32 bit binary number using each position 1, 10, 100, etc... as a Boolean toggle for whether one of the sub-achievements is met, and there does seem to be an elegance to it. I also have a strong grasp of AND, OR, XOR, NAND etc... logic operations.

What I can't seem to wrap my head around is the practical application for this scenario. Probably because I'm missing something obvious.

If I have 30-50 achievements that have anywhere from 2-30 sub-achievements for each one, some of which overlap, is it practical to use bitwise to manage it? Essentially what I am doing now is toggling subachievement Boolean values between either Yes (1) or no (0), and if all the sub achievements are set to 1, then it changes the achievement value to 1.

I currently use a function like (not exact code, just enough to get the idea across):

function setSubAchieve(mainSubA)
{
manSubA = 1

If (mainSubA == 1 && mainSubB == 1 && mainSsubC == 1)
{
setAchive(main) //set's the main achievement to 1
}
}

So basically, with my current method, I have a function to set each sub achievement and check if all the other sub achievements are set. This method is simple, but a lot of coding if I try to use it for everything. That would probably be over 100 functions just to manage achievements.

What I am looking for is a single function, or a small group of functions, that will set the sub achievement, and check the other sub achievements associated with a main achievement, and if all the subs are set, it would set the main. Using named variables for the sub achievements also brings a benefit that it is easy to follow and keep track of.

I'm always ready and excited to learn something new, and I like the potential elegance of bitwise. Can you show how the bitwise technique would work with the following example? Keep in mind that multiple playthroughs may trigger the same sub achievement repeatedly, and there should be a facility to completely reset.

Achivement A
* Set when sub's FirstA, SecondA and ThirdA are set.

Achievement B
*Set when sub's FirstB, and SecondB are set.

I would appreciate the knowledge, even if I didn't use it for this exact purpose I may extrapolate it out for something else.

Thanks!
Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

PreviousNext

Return to The workshop of creators

Who is online

Users browsing this forum: No registered users and 7 guests

eXTReMe Tracker