Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Counting tags... (http://forums.wolflair.com/showthread.php?t=58945)

vrimage August 11th, 2017 03:12 PM

Counting tags...
 
This might be a bit more complex than the title suggests :o

I am working on advances right now for my earthdawn system, and have run into a little problem. Let me explain:

Various classed get various abilities at various levels, and since it is possible to have more than one class, It is possible to get the same ability at different class levels. The levels they are aquired on is represented by adding a number of tags to the ability equal to that level.

When increasing an ability, the price of that advance is calculated based on what level it was aquired and the order of the learned classed.

to simplify, the cost could have been something like:
100 * ability rank * learned level * (2 for the first class or 4 for the second)

So I need a way to go through all classes and check if they get the ability, and on what level they get it.

All the abilities are bootstrapped from the classes, using a condition to set the level, and adding one tag for each level.

I was trying to use something like this:
Code:

                if (parent.tagis[AdvanceId.advTalent]<>0) then
                        var circle as number
                        circle=1
                        startcost=100
                        foreach pick in hero where "Discipline.?"
                                if (eachpick.tagis[Component.Discipline]<>0) then
                                       
                                        startcost=linkage[basis].tagcount[Discipline.#childname[eachpick]]
                                endif
                        nexteach
                       
                        incval=linkage[basis].field[trtUser].value + linkage[basis].field[trtBonus].value                       
                endif

Nothing inside the foreach works, just using it to give an idea of my thoughts.


Any advice?

thx

Mathias August 11th, 2017 04:05 PM

Are you getting an error message from this script? I would expect
Code:

tagcount[Discipline.#childname[eachpick]
to report a run-time error, because you should have to use tagcountstr to evaluate a string that's being built during run-time like that.

Why not use "foreach pick in hero from Discipline", instead of running the foreach without a component specified and then checking for a component before doing anything else?

At first reading, tag counts seem like a weird way to handle this, and I'm thinking there will be a better option.

Are these abilities that a class will always have, or that a class may choose to get? Or is it a combination - class X will always get this at a certain level, and class Y can choose this same ability from among a list of options at a certain level?

How large a level can a class have? Are classes in this system something like Pathfinder, with a large number of levels (say 20) allowed for any one class, or are they like Numenera, with only 6 levels allowed for each class? There's a solution I'm thinking of (numbered identity tags for each class) that will work well for a system with a small number of levels allowed for each class, but not if every class needs 20 identity tags (one for each of its 20 levels).

If more than one of the classes the character currently has offers this ability, does it matter which one took the ability? Are there limits on the class as to how many abilities may be taken from that class' own list, for example?


And in your script, please make it more readable by using only 2 spaces at each indentation, not the 6 or 8 I'm seeing there.

Could you add comments to your code, please? I don't understand what each of those lines is trying to accomplish, and more importantly, why each line is doing what it's doing - why does each piece of the code have to be there?

Alternatively, skip the code, and explain the rules you're trying to implement more completely, with some examples, and then I can try to figure out if this is the best way to go about this. What's really important here are the corner cases - what are the weird combinations of classes and abilities that are going to occur, so that we can make sure the code catches the corner cases.

vrimage August 11th, 2017 05:00 PM

I will try to explain in detail how it works. :D

A character can have several classes. When reaching a certain level in the first class he is able to select a second class, then a third and so on. To increase a level in a class, he must have at least a specific number of skill-like abilities of at least a certain level, where at least one of those must be from among those that became available when he gained the last level in that class.

Example:
To reach level 4 in a class, he must have at least 7 abilities at level 4 where one of those must be one he gained at level 3.

In this system, the experience awarded is used to increase the ability levels, not to determine a class level, and the cost increases based on which level the class got access to the ability.

Example:
A character with a warrior type class would get the Melee Weapon ability at level one, and would then have to pay 100 xp for the first level.
A mage type character would perhaps learn that ability at level 9, and would then have to pay 300 xp for that first level.
A character with mage as a second class would have to pay 500 xp for the ability, and for a warrior second class it would cost 200 xp.
Then we could have a character with his first class being a mage, and his fourth class being a warrior (if we ignore those in between), that character would pay 300 xp for his first level in Melee Weapons from his mage class, or 500 xp from his warrior class.

Any ability obtained from his first class would automatically count against his needed abilities in his other classes, and so forth.


Thx

vrimage August 11th, 2017 05:46 PM

Got it working. What I needed was tagcountstr and "foreach pick in hero from Discipline"

so thank you. :D

Mathias August 12th, 2017 10:13 AM

Is there a limited spread of costs that are actually used? For example, only 100, 200, 300, 400 and 500?

If that's the case, I'd create 5 identity tags for these abilities - <identity group="AdvCst100"/>, etc.

Then, the classes can be assigned a tag for each ability they grant, at the cost they grant it at, and each class pushes all their AdvCst### tags to the hero.

Then, the advancements search for their own identity tags on the hero - looking in order from cheapest to most expensive, so that if there's more than one option available for that ability, the cheapest one is the one used for that cost:
Code:

if (hero.isidentity[AdvCst100] <> 0) then
    cost = 100
elseif (hero.isidentity[AdvCst200] <> 0) then
    cost = 200
etc.


Mathias August 12th, 2017 10:19 AM

Also, create another identity tag group on abilities - HasAbility, for example.

Each ability pushes that tag to the hero when it's learned:
Code:

perform hero.pushtags[HasAbility.?]
Each class will duplicate each of its cost tags and convert them to a HasAbility tag while duplicating them:

Code:

perform pushtags[AdvCst100.?,HasAbility]
perform pushtags[AdvCst200.?,HasAbility]
etc.

Then, when the class needs to ask "how many of my abilities have been added?" here's the test it can perform:

Code:

thecount = hero.intersect[HasAbility,HasAbility,counttarget]

Mathias August 12th, 2017 10:26 AM

Oops - missed the fact that you can take the same ability multiple times, and that you expect to find more than one cost option, and you should always use the least expensive that's left over.

In that case, there's a second identity tag for each cost - AdvUsed100, AdvUsed200, etc.

And the test for which cost each advancement should use looks for the count of used tags as opposed to the count of available tags:

Code:

if (hero.countidentity[AdvCost100] - hero.countidentity[AdvUsed100] > 0) then
    cost = 100
elseif (hero.countidentity[AdvCost200] - hero.countidentity[AdvUsed200] > 0) then
    cost = 200
etc.

perform hero.assignstr["AdvUsed." & cost]

It's important that the AdvUsed tag be added to the hero in the same script that is calculating the cost of each advancement. The same script will be calculating the cost on each advancement, and because advancements are set up with an order (the order the user added them in), that script will be run in that same order.

This way, each advancement figures out its cost, and then marks the cost it used as having been used up, and then the next advancement of the same ability comes in and calculates its cost, and it will end up using the next most expensive option.


All times are GMT -8. The time now is 03:53 PM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.