Difference between revisions of "User:Ivan/Configurable object"
From VCMI Project Wiki
(→Current version of JSON config) |
|||
Line 99: | Line 99: | ||
"removeObject" : true | "removeObject" : true | ||
} | } | ||
− | <syntaxhighlight | + | </syntaxhighlight> |
= Classes in process of replacing = | = Classes in process of replacing = | ||
* CGPickable | * CGPickable | ||
Line 130: | Line 130: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Note that right now these describe objects that visitor must have, these objects will not be removed unless removed as part of "reward" (or some other mechanism). | Note that right now these describe objects that visitor must have, these objects will not be removed unless removed as part of "reward" (or some other mechanism). | ||
+ | |||
= Rewardables = | = Rewardables = | ||
Object that visitor may receive (or lose, for negative amounts) | Object that visitor may receive (or lose, for negative amounts) |
Revision as of 20:46, 16 May 2014
This page describes work-in-progress draft of support for configurable object that should replace majority of bonusing objects
Contents
Current version of JSON config
{
"onSelectMessage" : "Please choose your reward",
"onVisitedMessage" : "Sorry, you've already been here",
"onEmptyMessage" : "You found already looted object or can not receive anything here",
"soundID" : 123,
/// Determines how reward will be chosen among those available to visitor
/// first - first applicable reward will be granted
/// player - visitor will be allowed to choose what he wants
/// random - reward will be selected randomly
"selectMode" : "first",
/// Determines what makes object "visited". Possible values:
/// unlimited - no limitations. Example: Idol of Fortune
/// once - object can be visited only once. Example: Skeleton
/// hero - each hero may visit object once. Example: Arena
/// player - each player may visit once. Example: Keymaster
"visitMode" : "unlimited",
/// If non-zero, object will be reset each # days
"resetDuration" : 0,
/// If true, hero can refuse visiting an object (Tree or Tomb)
"canRefuse" : false
/// Rewards that describe what can be granted and when
"rewards" : [ { ... }, { ... } ]
}
{
/// Message that will be displayed when reward is granted to hero
"message" : "You've found something!",
/// Limiter. Rewards will be granted to hero only if he satisfies requirements
/// Note: this is only a check - it won't remove anything from hero/player
"limiter" : {
/// how many times this reward can be granted, 0 for unlimited
"numOfGrants" : 0,
/// day of week, unused if 0, 1-7 will test for current day of week
"dayOfWeek" : 0,
/// level that hero needs to have
"minLevel" : 0,
/// resources player needs to have in order to trigger reward
"resources" : { "gold" : 500 },
/// skills hero needs to have
"primary" : { "attack" : 3 },
"secondary" : { "diplomacy" : "basic" },
/// artifacts that hero needs to have (equipped or in backpack) to trigger this
/// Note: will fail when checking for multiple copies of the same art
"artifacts" : [ "grail", "spellbook" ],
/// creatures that hero needs to have
"creatures" : { "angel" : 1 }
},
/// resources that will be given to player (or taken from)
"resources" : { "gold" : -500 },
/// received experience
"gainedExp" : 1000,
/// received levels (converted into XP during grant)
"gainedLevels" : 1,
/// mana given to/taken from hero, fixed value
"manaDiff" : 10,
/// fixed value, in form of percentage from max
"manaPercentage" : 100,
/// movement points, only for current day. ( 100 = 1 tile )
"movePoints" : 1000,
/// fixed value, in form of percentage from max
"movePercentage" : 0,
/// list of bonuses, e.g. morale/luck
"bonuses" : [ { <bonus format> } ],
/// skills that hero may receive or lose
"primary" : { "attack" : 2 },
"secondary" : { "diplomacy" : 1 },
/// objects that hero may receive
"artifacts" : [ "grail" ],
"spells" : [ "iceBolt" ],
"creatures" { "archer" : 10 },
/// list of components that will be added to reward description.
"extraComponents" : [ { "type" : "primarySkill", "subtype" : "attack", "value": 1} ],
/// if set to true, object will be removed after granting this reward
"removeObject" : true
}
Classes in process of replacing
- CGPickable
- CGBonusingObject
- CGOnceVisitable
- CGVisitableOPH
- CGVisitableOPW
- CGMagicSpring
Reward limiters
Requirements that must be fulfilled by visitor to receive reward
/// how many times this reward can be granted, 0 for unlimited
int numOfGrants;
/// day of week, unused if 0, 1-7 will test for current day of week
int dayOfWeek;
/// resources player needs to have in order to trigger reward
TResources resources;
/// skills hero needs to have
std::vector<si32> primary;
std::map<SecondarySkill, si32> secondary;
/// artifacts that hero needs to have (equipped or in backpack) to trigger this
std::vector<ArtifactID> artifacts;
/// creatures that hero needs to have
std::vector<CStackBasicDescriptor> creatures;
Note that right now these describe objects that visitor must have, these objects will not be removed unless removed as part of "reward" (or some other mechanism).
Rewardables
Object that visitor may receive (or lose, for negative amounts)
/// resources that will be given to player
TResources resources;
/// received experience
ui32 gainedExp;
/// received levels (converted into XP during grant)
ui32 gainedLevels;
/// mana given to/taken from hero
si32 manaDiff;
/// movement points, only for current day. Bonuses should be used to grant MP on any other day
si32 movePoints;
/// list of bonuses, e.g. morale/luck
std::vector<Bonus> bonuses;
/// skills that hero may receive or lose
std::vector<si32> primary;
std::map<SecondarySkill, si32> secondary;
/// objects that hero may receive
std::vector<ArtifactID> artifacts;
std::vector<SpellID> spells;
std::vector<CStackBasicDescriptor> creatures;
Properties of rewardable object
enum ESelectMode
{
SELECT_FIRST, // first reward that matches limiters
SELECT_PLAYER, // player can select from all allowed rewards
SELECT_RANDOM, // reward will be selected from allowed randomly
SELECT_ALL // all available rewards will be granted to player
};
enum EVisitMode
{
VISIT_UNLIMITED, // any number of times
VISIT_ONCE, // only once, first to visit get all the rewards
VISIT_HERO, // every hero can visit object once
VISIT_PLAYER // every player can visit object once
};
/// MetaString's that contain text for messages for specific situations
MetaString onGrant;
MetaString onVisited;
MetaString onEmpty;
/// sound that will be played alongside with *any* message
ui16 soundID;
/// how reward will be selected, uses ESelectMode enum
ui8 selectMode;
/// contols who can visit an object, uses EVisitMode enum
ui8 visitMode;
/// object visitability info will be reset each resetDuration days
ui16 resetDuration;
Note: this does not includes some internal members - only those that may become configurable
Not yet handled situations
- Some objects must be removed after visit
- Some objects block movement to visitable tile (blockVisit property)
- Different messages for different rewards (e.g. Stables)
- Auto-upgrade for stables (or keep it hardcoded)
- Possibility to refuse visit (e.g. Tomb)
Limitations
Known limitations of current approach, all of these are largely "works as intended", although may be changed in future if nice solution will be found.
- As of now it is impossible to specify *ranges* of possible rewards - their values must be fixed. Situations like Windmill (3-6 of random resource) can be implemented as large list of every possible reward.
- To properly handle cases like Tomb of Warrior and for H3-like selection of one reward from multiple (e.g. School of Magic) visitor will have to select reward based on one visible component of these rewards. This should result in behavior identical to H3 but may not work as desired for mod objects. Examples:
- In Tomb visitor will have two "rewards": single-use "-3 morale + artifact" and multiple use "-3 morale". To hide actual reward from visitor only first component (-3 morale) will be visible in selection dialog for both cases.
- In School of Magic player have two rewards to choice from "+1 to Spellpower and -1000 to gold" and "+1 to Knowledge and -1000 to gold". However only one component will be known to player (change to primary skill).
- Note: AI will still be able to evaluate rewards properly based on generic object description, human player will be able to evaluate rewards only based on visit message and past experience.
Planned changes
Essential
- Move some properties to rewards (e.g. grant message)
- Finish rewrite of current set of objects
- Proper support for AI
Planned
- Extend system to support more objects:
- Events/Pandora Boxes
- Seer Huts/Quest Guards
- Banks/Pyramid (at least for actual reward)
Possible
- Extend for several related objects:
- Keymaster/Border Guards
- Town buildings