Difference between revisions of "User:Ivan/Victory conditions"

From VCMI Project Wiki
Jump to: navigation, search
(Created page with "== Main ideas == * Use logical expressions to allow construction of complex conditions out of simple ones * Keep "logical expression" part generic enough to allow its usage in...")
 
(List of victory/loss objectives)
 
(10 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
* Merge victory conditions with lose conditions - "do not lose hero" can be turned into more generic "control object(hero ID)" and "capture town" into more generic "control object(town ID)"
 
* Merge victory conditions with lose conditions - "do not lose hero" can be turned into more generic "control object(hero ID)" and "capture town" into more generic "control object(town ID)"
 
* Json format so it can be used in future with map editor/json map format
 
* Json format so it can be used in future with map editor/json map format
== Format ==
+
== Format considerarions ==
Example, using H3 victory condition "capture town or defeat all enemies in 60 days", with "does not applies to AI" flag set to true and "don't lose hero X" lose conditions.
+
Why I prefer this format (see next section) over others:
<syntaxhighlight lang="javascript">
 
"victory" :
 
[
 
    "anyOf",
 
    [ "standard" ],
 
    [ "allOf",
 
        [ "isHuman", { "value" : 1 } ],
 
        [ "control", { "position" : [10, 20, 0], "type" : "object.town" } ]
 
    ]
 
],
 
"lose" :
 
[
 
    "anyOf",
 
    [ "daysPassed", { "value" : 60 } ],
 
    [ "noneOf",
 
        [ "control", { "position" : [100, 200, 1], "type" : "object.hero" } ]
 
    ]
 
]
 
</syntaxhighlight>
 
Notes on why I prefer this format over others:
 
 
* I'm using prefix notation here to reduce probability of errors and to avoid thinking about operations priority which may be needed in case of mixing "or" with "and" in one expression:
 
* I'm using prefix notation here to reduce probability of errors and to avoid thinking about operations priority which may be needed in case of mixing "or" with "and" in one expression:
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
Line 48: Line 28:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
Standard conditions:
 +
<syntaxhighlight lang="javascript">
 +
"victory" :
 +
[
 +
    "standardWin"
 +
],
 +
"lose" :
 +
[
 +
    "daysWithoutTown", { "value" : 7 }
 +
]
 +
</syntaxhighlight>
 +
== Current format ==
 +
See [[Map format]]
 +
 +
== Possible improvements to triggered events==
 +
* Expand effects to cover all possibilities of Seer Huts/Town events/Timed map events
 +
* Add fields like "affected players" and "cooldown duration" similar to timed map events
 +
* Use it to "patch" map to fix remaining campaign issues like Mantis 1635
 +
* Possibility of multiple effects triggered by the same event
 +
* Some way to implement "7 days without town" as "7 days since event "no owned towns" triggered"
 
== List of victory/loss objectives ==
 
== List of victory/loss objectives ==
List of objectives that I have at the moment. Unless I missed something, should fully cover H3 objectives including campaigns
+
See [[List of all event conditions]]
===HAVE_ARTIFACT===
+
 
Any player hero must hold an artifact
+
=Other areas for logic expressions=
* position - N/A (TODO: hero that must obtain the artifact? Or even merge this with "transport"?)
+
==Mod dependencies==
* type - required artifact ID
+
Not really necessary right now but it is possible to use them to specify more complex set of dependencies, e.g.
* value - N/A
+
<syntaxhighlight lang="javascript">
===HAVE_CREATURES===
+
"requirements" :
Player must control certain number of creatures
+
[
* position - N/A
+
    "allOf",
* type - creature ID to collect
+
    [ "modA" ], // "normal" dependencies - this mod requires mod A
* value - required amount of creatures
+
    [
===HAVE_RESOURCES===
+
        "modB",  // dependencies with specific version limitations
Player must have certain amount of resources
+
        { "minimum" : "1.0.1", "maximum" : "1.2.9" }
* position - N/A
+
    ],
* type - resource ID
+
    [
* value - required amount of resource
+
        "anyOf"  // at least one mod out of this list should be installed
===HAVE_BUILDING===
+
        [ "modC" ],
Player must control certain building, also includes H3 "build Grail" condition
+
        [ "modD" ]
* position - town in which this structure must be built, optional
+
    ],
* type - building ID to construct
+
    [
* value - N/A
+
        "noneOf",  // essentially list of conflicts - none of these mods should be present
Note: if position is not set - building can be built in any town
+
        [ "modE" ]
===CONTROL===
+
    ]
Covers all conditions that require certain object(s) to be controlled by player
+
]
* position - position of object to control, optional
+
</syntaxhighlight>
* type - type of object to control.
+
==Building requirements==
* value - N/A
+
'''Already implemented in code'''
Note: If position is not set - all objects of this type must be captured
+
 
===DESTROY===
+
Something that was requested quite often, usually as part of alternative creatures in towns feature. Should be simple to implement compared to "main" area - campaigns. Will probably try to do this area first due to its small scale (less chance to mess up bigger systems).
Covers objections where player must destroy certain object(s)
+
 
* position - position of object to destroy, optional
+
Format is pretty much same as in previous cases:
* type - type of object to destroy
+
<syntaxhighlight lang="javascript">
* value - N/A
+
"requirements" :
Note: If position is not set - all objects of this type must be destroyed
+
[
===TRANSPORT===
+
    "allOf", // Normal H3 "build all" mode
Transport artifact in certain town
+
    [ "mageGuild1" ],
* position - town to which this artifact must be transported
+
    [
* type - artifact ID to transport
+
        "noneOf",  // available only if dwelling 5 "A" was not built
* value - N/A
+
        [ "dwelling5A" ],
===DAYS_PASSED===
+
        [ "dwelling5AUpgrade" ]
Player must survive or win in certain number of days
+
    ],
* position - N/A
+
    [
* type - N/A
+
        "anyOf", // at least one must be built
* value - number of days for this objective to trigger
+
        [ "tavern" ],
Note: covers both "win in X days" as well as "survive for X days" conditions, depending on block in which this objective will be placed.
+
        [ "blacksmith" ]
===IS_HUMAN===
+
    ]
Helper condition to allow ai-only or human-only conditions
+
]
* position - N/A
+
</syntaxhighlight>
* type - N/A
 
* value - 0 will trigger this objective for AI players, 1 will trigger it for humans
 
===STANDARD===
 
Standard condition - defeat all enemies
 
* position - N/A
 
* type - N/A
 
* value - N/A
 

Latest revision as of 12:56, 30 December 2013

Main ideas

  • Use logical expressions to allow construction of complex conditions out of simple ones
  • Keep "logical expression" part generic enough to allow its usage in other areas (e.g. requirements for town buildings or any other allow/deny triggers)
  • Merge victory conditions with lose conditions - "do not lose hero" can be turned into more generic "control object(hero ID)" and "capture town" into more generic "control object(town ID)"
  • Json format so it can be used in future with map editor/json map format

Format considerarions

Why I prefer this format (see next section) over others:

  • I'm using prefix notation here to reduce probability of errors and to avoid thinking about operations priority which may be needed in case of mixing "or" with "and" in one expression:
"victory" :
[
    "conditionA",
    "and"         // this can be evaluated first
    "conditionB"
    "or"          // or this one
    "conditionC"
]
  • Json Vectors are used almost everywhere since json does not allows values with equal keys. Something like this is more logical but is not a valid json code:
"victory" :
{
    "allOf" :
    {
        "control" : { "position" : [0, 0, 0] }, // don't lose hero 1
        "control" : { "position" : [1, 1, 1] }, // don't lost hero 2
    }
}

Standard conditions:

"victory" :
[
    "standardWin"
],
"lose" :
[
    "daysWithoutTown", { "value" : 7 }
]

Current format

See Map format

Possible improvements to triggered events

  • Expand effects to cover all possibilities of Seer Huts/Town events/Timed map events
  • Add fields like "affected players" and "cooldown duration" similar to timed map events
  • Use it to "patch" map to fix remaining campaign issues like Mantis 1635
  • Possibility of multiple effects triggered by the same event
  • Some way to implement "7 days without town" as "7 days since event "no owned towns" triggered"

List of victory/loss objectives

See List of all event conditions

Other areas for logic expressions

Mod dependencies

Not really necessary right now but it is possible to use them to specify more complex set of dependencies, e.g.

"requirements" :
[
    "allOf",
    [ "modA" ],  // "normal" dependencies - this mod requires mod A
    [
        "modB",  // dependencies with specific version limitations
        { "minimum" : "1.0.1", "maximum" : "1.2.9" }
    ],
    [
        "anyOf"  // at least one mod out of this list should be installed
        [ "modC" ],
        [ "modD" ]
    ],
    [
        "noneOf",  // essentially list of conflicts - none of these mods should be present
        [ "modE" ]
    ]
]

Building requirements

Already implemented in code

Something that was requested quite often, usually as part of alternative creatures in towns feature. Should be simple to implement compared to "main" area - campaigns. Will probably try to do this area first due to its small scale (less chance to mess up bigger systems).

Format is pretty much same as in previous cases:

"requirements" :
[
    "allOf", // Normal H3 "build all" mode
    [ "mageGuild1" ],
    [
        "noneOf",  // available only if dwelling 5 "A" was not built
        [ "dwelling5A" ],
        [ "dwelling5AUpgrade" ]
    ],
    [
        "anyOf", // at least one must be built
        [ "tavern" ],
        [ "blacksmith" ]
    ]
]