SiENcE wrote:
How do you did the questsystem? I mean how do you organize the quests and the dependecies from other quests, npcs and items.
Actually, I need to start the quest system, but i got some pseudocode and the how to implement it.
Basically, quests are given by NPCs when talking to them, or by events when triggered by the player.
I call a procedure to check the possible quest. This quest may have up to two requisites: a quest requisite or an item requisite. When the player triggers the event or the dialog, the game executes that procedure, which will check if the quest to be given mets both requirements.
For example, an NPC dialog calls the procedure to give the quest BBBBB, but this quest requires that the player had completed quest AAAA before, and that the player has CCCCC item in inventory. If any of those conditions are not met, then the quest is not given, and the NPC will trigger some other dialog such as "I'm sorry, I don't have anything to say to you" or whatever other dialog I define.
Quest completed by the player are saved in a table as a simple quest code text string, for example player.quests = {"quest1", "quest2", "quest3", ...}
When I need to check if quest BBB requires "quest1" to be completed first, it is just only to check that table and know if "quest1" is there.
For item requisitesis the same, just run through all inventory slots and check if there is such item.
Requisites are stored in the quest data itself.
Something like this
quest = {questID = "BBBB", questRequire = "quest1", itemRequire = "Bloody Ring"}
SiENcE wrote:For item i use an "component based object system" similar to this
post.
I already implemented all items the next way:
(sorry if the explanation is a bit long)
Items are defined by a alphanumerical string in this fashion:
(the "|" are separators to show each part of the string)
TT | 00 | SSS | 000
where:
TT = item type or cathegory, such as weapon, defense, consumable, jewel, material, crafting, etc, for example, WP for weapon, DF for defense, and so on
00 = item weight, from 0 to 99.
SSS = item sub type or sub category such as short sword, plate mail, diamond ring or copper ore, for example, CSS may be Copper Short Sword, or SHM could be Smithing HaMer. You may note here that you can find different items with the same sub type. It doesn't mind, since different item categories discard similar subcategories, for example, you may have CSS with WP, wich will be WeaPon > Copper Short Sword, but you may also have CSS with TL (Tl = tools), which could be Carbon Smithing Sharpener, for example.
000 = item quality, going from 001 to 200, in my game. This acts as a efficiency multiplier. For example, a short sword with 100 quality will deal 3 damage, but with 200% quality will deal 6. Quality =/= durability. Quality = overall efficiency. Can't be modified
An example:
WP02SDG050 = Weapon | 2 pounds weight | Steel DaGger | 50% quality
Once I got the item code, it is just a matter of substring it and return the values.
When I show items in inventory, I only need the item type, subtype and weight.
All other data is stored in the base item itself, not in the item code. This is, there is a table with all possible item types and subtypes with all needed data such as image, damage, defense vendor value, and so on.
Inventory slots is just a 2-dimension table/array where the item codes are saved.
When using item from the inventory, there are only two controls: arrows to move cursor, and RETURN key to use the item.
Because the item types or categories (weapon, defense, jewel, consumable etc...) are limited (actually 6 or 7 only), I only need to call the "use_item" function with the item code. This function gets the item category and executes the appropriate actions, that would be equip weapons, drink/eat consumables, show crafting window when using tools, and so on.
I hope that is what you were asking for.