- Joined
- Jul 10, 2007
- Messages
- 6,306
Ok, so I've been writing lots of little scripts and detailed examples into Encoder Framework for how to do various things from simple things to complicated things ^)^.
Here's what I'm planning to cover-
Item Catalogs
General, Shared between Heroes, Hero Specific, Item Charges, Shared between Heroes with Hero Specific and Item Charges, Items specific to slots (like a chestplate slot)
Hero Catalogs
Saving an inventory (two techniques)
Saving multiple units (two techniques)
Saving multiple units that may or may not exist (like pets)
Saving resources
Saving experience and level
Each topic will include the catalog (if it merits one), how to save it, how to load it, and how to write the Encoder object code for it complete with detailed descriptions. Of all of those topics above, the item catalogs with shared items between heroes + hero specific items + item charges + items specific to slots is the most complex, but I break it up so that it is easy (though still tedious and huge).
Here is a preview-
What others would you guys like me to cover?
Here's what I'm planning to cover-
Item Catalogs
General, Shared between Heroes, Hero Specific, Item Charges, Shared between Heroes with Hero Specific and Item Charges, Items specific to slots (like a chestplate slot)
Hero Catalogs
Saving an inventory (two techniques)
Saving multiple units (two techniques)
Saving multiple units that may or may not exist (like pets)
Saving resources
Saving experience and level
Each topic will include the catalog (if it merits one), how to save it, how to load it, and how to write the Encoder object code for it complete with detailed descriptions. Of all of those topics above, the item catalogs with shared items between heroes + hero specific items + item charges + items specific to slots is the most complex, but I break it up so that it is easy (though still tedious and huge).
Here is a preview-
JASS:
struct Items extends array
//with item specific catalog, the best way to determine whether a class can have an item
//or not is with flags
//first set up your flag table
//item classes
/*
0 -------------------------- Misc
1 -------------------------- Clothes
2 -------------------------- Leather
3 -------------------------- Chain
4 -------------------------- Plated
5 -------------------------- One Handed Sword/Axe/Hammer
6 -------------------------- Two Handed Sword/Axe/Hammer
7 -------------------------- Dagger
8 -------------------------- Fist
9 -------------------------- Wand/Staff
10 -------------------------- Bow/Crossbow
*/
//item class constants
private static constant integer MISC = 0
private static constant integer CLOTHES = 1
private static constant integer LEATHER = 2
private static constant integer CHAIN = 3
private static constant integer PLATED = 4
private static constant integer ONE_HAND = 5
private static constant integer TWO_HAND = 6
private static constant integer DAGGER = 7
private static constant integer FIST = 8
private static constant integer MAGIC = 9
private static constant integer RANGED = 10
//each item class needs its own catalog, so need an array of catalogs
private static integer array itemClassCatalogs
private static integer array groupCatalogs
private static Table hero2Group = 0
implement Catalog
private static method onInit takes nothing returns nothing
//create the item class catalogs
set itemClassCatalogs[MISC]=CatalogCreate()
set itemClassCatalogs[CLOTHES]=CatalogCreate()
set itemClassCatalogs[LEATHER]=CatalogCreate()
set itemClassCatalogs[CHAIN]=CatalogCreate()
set itemClassCatalogs[PLATED]=CatalogCreate()
set itemClassCatalogs[ONE_HAND]=CatalogCreate()
set itemClassCatalogs[TWO_HAND]=CatalogCreate()
set itemClassCatalogs[DAGGER]=CatalogCreate()
set itemClassCatalogs[FIST]=CatalogCreate()
set itemClassCatalogs[MAGIC]=CatalogCreate()
set itemClassCatalogs[RANGED]=CatalogCreate()
//now determine which classes can equip which items
/*
all classes
MISC
warrior, knight, paladin
CHAIN, PLATED, ONE_HAND, TWO_HAND, DAGGER, FIST
ranger
LEATHER, ONE_HAND, CHAIN, RANGED, DAGGER
wizard
CLOTHES, LEATHER, MAGIC
*/
//create one catalog for each group
set groupCatalogs[0]=CatalogCreate() //warrior, knight, paladin
set groupCatalogs[1]=CatalogCreate() //ranger
set groupCatalogs[2]=CatalogCreate() //wizard
//add items to various catalogs
call CatalogAdd(itemClassCatalogs[MISC],'1000')
call CatalogAdd(itemClassCatalogs[MISC],'1001')
call CatalogAdd(itemClassCatalogs[MISC],'1002')
call CatalogAdd(itemClassCatalogs[CLOTHES],'1100')
call CatalogAdd(itemClassCatalogs[CLOTHES],'1101')
call CatalogAdd(itemClassCatalogs[CLOTHES],'1102')
call CatalogAdd(itemClassCatalogs[LEATHER],'1200')
call CatalogAdd(itemClassCatalogs[LEATHER],'1201')
call CatalogAdd(itemClassCatalogs[LEATHER],'1202')
call CatalogAdd(itemClassCatalogs[CHAIN],'1300')
call CatalogAdd(itemClassCatalogs[CHAIN],'1301')
call CatalogAdd(itemClassCatalogs[CHAIN],'1302')
call CatalogAdd(itemClassCatalogs[PLATED],'1400')
call CatalogAdd(itemClassCatalogs[PLATED],'1401')
call CatalogAdd(itemClassCatalogs[PLATED],'1402')
call CatalogAdd(itemClassCatalogs[ONE_HAND],'1500')
call CatalogAdd(itemClassCatalogs[ONE_HAND],'1501')
call CatalogAdd(itemClassCatalogs[ONE_HAND],'1502')
call CatalogAdd(itemClassCatalogs[TWO_HAND],'1600')
call CatalogAdd(itemClassCatalogs[TWO_HAND],'1601')
call CatalogAdd(itemClassCatalogs[TWO_HAND],'1602')
call CatalogAdd(itemClassCatalogs[DAGGER],'1700')
call CatalogAdd(itemClassCatalogs[DAGGER],'1701')
call CatalogAdd(itemClassCatalogs[DAGGER],'1702')
call CatalogAdd(itemClassCatalogs[FIST],'1800')
call CatalogAdd(itemClassCatalogs[FIST],'1801')
call CatalogAdd(itemClassCatalogs[FIST],'1802')
call CatalogAdd(itemClassCatalogs[MAGIC],'1900')
call CatalogAdd(itemClassCatalogs[MAGIC],'1901')
call CatalogAdd(itemClassCatalogs[MAGIC],'1902')
call CatalogAdd(itemClassCatalogs[RANGED],'2000')
call CatalogAdd(itemClassCatalogs[RANGED],'2001')
call CatalogAdd(itemClassCatalogs[RANGED],'2002')
//add various catalogs to group catalogs
//warrior, knight, paladin
//CHAIN, PLATED, ONE_HAND, TWO_HAND, DAGGER, FIST, MISC
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[CHAIN])
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[PLATED])
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[ONE_HAND])
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[TWO_HAND])
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[DAGGER])
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[FIST])
call CatalogAddCatalog(groupCatalogs[0],itemClassCatalogs[MISC])
//ranger
//LEATHER, ONE_HAND, CHAIN, RANGED, DAGGER, MISC
call CatalogAddCatalog(groupCatalogs[1],itemClassCatalogs[LEATHER])
call CatalogAddCatalog(groupCatalogs[1],itemClassCatalogs[ONE_HAND])
call CatalogAddCatalog(groupCatalogs[1],itemClassCatalogs[CHAIN])
call CatalogAddCatalog(groupCatalogs[1],itemClassCatalogs[RANGED])
call CatalogAddCatalog(groupCatalogs[1],itemClassCatalogs[DAGGER])
call CatalogAddCatalog(groupCatalogs[1],itemClassCatalogs[MISC])
//wizard
//CLOTHES, LEATHER, MAGIC, MISC
call CatalogAddCatalog(groupCatalogs[2],itemClassCatalogs[CLOTHES])
call CatalogAddCatalog(groupCatalogs[2],itemClassCatalogs[LEATHER])
call CatalogAddCatalog(groupCatalogs[2],itemClassCatalogs[MAGIC])
call CatalogAddCatalog(groupCatalogs[2],itemClassCatalogs[MISC])
/**********************************************************************
*
* for hero specific items, you can create a catalog for the hero
* -> set heroCatalogs[warriorCatalog] = CatalogCreate()
* and add the group catalog to it
* -> call CatalogAddCatalog(heroCatalogs[warriorCatalog], groupCatalogs[0])
* this allows you to add hero specific gear
* -> call CatalogAdd(warriorCatalog, 'war1')
*
**********************************************************************/
//now need a way to get group from hero
set hero2Group = Table.create()
set hero2Group[warriorTypeId]=0
set hero2Group[knightTypeId]=0
set hero2Group[paladinTypeId]=0
set hero2Group[rangerTypeId]=1
set hero2Group[wizardTypeId]=2
//keep in mind that with hero specific catalogs, a hero only needs to point to its
//hero specific catalog
//hero2Group[warriorTypeId] = warriorCatalog
endmethod
//now need to add public properties for the save/load
static method operator [] takes integer heroId returns thistype
return hero2Group[heroId]
endmethod
method raw takes integer itemId returns integer
return CatalogRaw(groupCatalogs[this],itemId)
endmethod
method id takes integer itemRaw returns integer
return CatalogId(groupCatalogs[this],itemRaw)
endmethod
//and the above would turn into this
//raw = Items[warriorTypeId].raw(axeCatalogId)
//id = Items[warriorTypeId].id(GetUnitTypeId(axe))
endstruct
What others would you guys like me to cover?