rubik
Squire
For example:
def set_item_difficulty():
item_difficulty = [] # create an empty list: item_difficulty
for i_item in xrange(len(items)): # do a loop in the list items
item_difficulty.append((item_set_slot, i_item, slot_item_difficulty, get_difficulty(items[i_item][6]))) # append Module System sentences to the list
return item_difficulty[:] # return the whole list with all MS sentences above
# the function get_difficulty is already defined in header_items.py, I just call it here.
It was used to set items' difficulties. Then we can use (item_get_slot,<destination>, <item_id>, slot_item_difficulty) to get items' difficulties easily.
Of course we also need to write some codes to call this PYTHON function.
First we need to add the flowing script to call it.
("init_item_difficulties", set_item_difficulty()),
Then add the flowing to the script of game_start to call the script of init_item_difficulties.
(call_script, "script_init_item_difficulties"),
I almost forget that, you must define slot_item_difficulty in module_constants.py before you use it.
Now, you can get any static data in Module System and assign it to a slot, not only items' difficulties.
Another example:
Judge whether an item can use on horseback or not.
def judge_item_cant_use_on_horseback():
cant_use_on_horseback = [] # create an empty list: cant_use_on_horseback
for i_item in xrange(len(items)): # do a loop in the list items
if items[i_item][3] & itp_cant_use_on_horseback == itp_cant_use_on_horseback: # if can't use
cant_use_on_horseback.append((item_set_slot, i_item, slot_cant_use_on_horseback, 1)) # append Module System sentences to the list
return cant_use_on_horseback[:] # return the whole list with all MS sentences above
In the same way, you can Judge whether an item is itp_unique or not, can reload on horseback or not, penalty with shield or not and so on.
What's more, I want to point out that the following in module_items.py is only a list. You can creat a new list and do some related operation yourself.
items = [
# item_name, mesh_name, item_properties, item_capabilities, slot_no, cost, bonus_flags, weapon_flags, scale, view_dir, pos_offset
["no_item","INVALID ITEM", [("practice_sword",0)], itp_type_one_handed_wpn|itp_primary|itp_secondary, itc_longsword, 3,weight(1.5)|spd_rtng(103)|weapon_length(90)|swing_damage(16,blunt)|thrust_damage(10,blunt),imodbits_none],
["horse_meat","Horse Meat", [("raw_meat",0)], itp_type_goods|itp_consumable|itp_food, 0, 12,weight(40)|food_quality(30)|max_ammo(40),imodbits_none],
# Items before this point are hardwired and their order should not be changed!
["practice_sword","Practice Sword", [("practice_sword",0)], itp_type_one_handed_wpn|itp_primary|itp_secondary|itp_wooden_parry|itp_wooden_attack, itc_longsword, 3,weight(1.5)|spd_rtng(103)|weapon_length(90)|swing_damage(16,blunt)|thrust_damage(10,blunt),imodbits_none],
.................................
.................................
.................................
.................................
["rabati", "Rabati", [("rabati",0)], itp_type_head_armor ,0, 278 , weight(2)|abundance(100)|head_armor(20)|body_armor(0)|leg_armor(0) ,imodbits_cloth ],
]
Such as the following list I wrote:
modifiers = [
(imod_plain, 100, 0),
(imod_cracked, 50, -1),
(imod_rusty, 55, -1),
(imod_bent, 65, -1),
(imod_chipped, 72, -1),
(imod_battered, 75, -1),
(imod_poor, 80, -1),
(imod_crude, 83, -1),
(imod_old, 86, -1),
(imod_cheap, 90, -1),
(imod_fine, 190, 1),
(imod_well_made, 250, 1),
(imod_sharp, 160, 1),
(imod_balanced, 350, 1),
(imod_tempered, 670, 1),
(imod_deadly, 850, 1),
(imod_exquisite, 1450, 1),
(imod_masterwork, 1750, 1),
(imod_heavy, 190, 1),
(imod_strong, 490, 1),
(imod_powerful, 320, 1),
(imod_tattered, 50, -1),
(imod_ragged, 70, -1),
(imod_rough, 60, -1),
(imod_sturdy, 170, 1),
(imod_thick, 260, 1),
(imod_hardened, 390, 1),
(imod_reinforced, 650, 1),
(imod_superb, 250, 1),
(imod_lordly, 1150, 1),
(imod_lame, 40, -1),
(imod_swaybacked, 60, -1),
(imod_stubborn, 90, 1),
(imod_timid, 180, -1),
(imod_meek, 180, -1),
(imod_spirited, 650, 1),
(imod_champion, 1450, 1),
(imod_fresh, 100, 1),
(imod_day_old, 100, -1),
(imod_two_day_old, 90, -1),
(imod_smelling, 40, -1),
(imod_rotten, 5, -1),
(imod_large_bag, 190, 1)
]
This is a new list I created to record something about every modifier. The first one in every tuple is the ID of the modifier, the second one is the price multiplier(need to divide 100 at last), the third one is the quality of the modifier(1 for good modifier, -1 for bad modifier).
You may have a question that how to use the new list?
Just use it like the list items.
Look at the folowing PYTHON function.
def set_item_modifier_multiplier():
modifier_multiplier = []
for i_modifier in xrange(len(modifiers)):
modifier_multiplier.append((item_set_slot, i_modifier, slot_item_modifier_multiplier, modifiers[i_modifier][1]))
return modifier_multiplier[:]
This function assign the price multiplier to slot_item_modifier_multiplier for every modifier.
Some related code:
("init_item_modifier_quality", set_item_modifier_quality()),
(call_script, "script_init_item_modifier_quality"),
Now, the script of get_item_value_with_imod in autoloot can be rewrited as following:
("get_item_value_with_imod",
[# returns the sell price based on the item's money value and its imod
(store_script_param, ":item", 1),
(store_script_param, ":imod", 2),
(store_item_value, ":score", ":item"),
(item_get_slot, ":imod_multiplier", ":imod", slot_item_modifier_multiplier),
(val_mul, ":score", ":imod_multiplier"),
(assign, reg0, ":score"),
]),
At last, all above are only examples. You should open your mind to create more things.
def set_item_difficulty():
item_difficulty = [] # create an empty list: item_difficulty
for i_item in xrange(len(items)): # do a loop in the list items
item_difficulty.append((item_set_slot, i_item, slot_item_difficulty, get_difficulty(items[i_item][6]))) # append Module System sentences to the list
return item_difficulty[:] # return the whole list with all MS sentences above
# the function get_difficulty is already defined in header_items.py, I just call it here.
It was used to set items' difficulties. Then we can use (item_get_slot,<destination>, <item_id>, slot_item_difficulty) to get items' difficulties easily.
Of course we also need to write some codes to call this PYTHON function.
First we need to add the flowing script to call it.
("init_item_difficulties", set_item_difficulty()),
Then add the flowing to the script of game_start to call the script of init_item_difficulties.
(call_script, "script_init_item_difficulties"),
I almost forget that, you must define slot_item_difficulty in module_constants.py before you use it.
Now, you can get any static data in Module System and assign it to a slot, not only items' difficulties.
Another example:
Judge whether an item can use on horseback or not.
def judge_item_cant_use_on_horseback():
cant_use_on_horseback = [] # create an empty list: cant_use_on_horseback
for i_item in xrange(len(items)): # do a loop in the list items
if items[i_item][3] & itp_cant_use_on_horseback == itp_cant_use_on_horseback: # if can't use
cant_use_on_horseback.append((item_set_slot, i_item, slot_cant_use_on_horseback, 1)) # append Module System sentences to the list
return cant_use_on_horseback[:] # return the whole list with all MS sentences above
In the same way, you can Judge whether an item is itp_unique or not, can reload on horseback or not, penalty with shield or not and so on.
What's more, I want to point out that the following in module_items.py is only a list. You can creat a new list and do some related operation yourself.
items = [
# item_name, mesh_name, item_properties, item_capabilities, slot_no, cost, bonus_flags, weapon_flags, scale, view_dir, pos_offset
["no_item","INVALID ITEM", [("practice_sword",0)], itp_type_one_handed_wpn|itp_primary|itp_secondary, itc_longsword, 3,weight(1.5)|spd_rtng(103)|weapon_length(90)|swing_damage(16,blunt)|thrust_damage(10,blunt),imodbits_none],
["horse_meat","Horse Meat", [("raw_meat",0)], itp_type_goods|itp_consumable|itp_food, 0, 12,weight(40)|food_quality(30)|max_ammo(40),imodbits_none],
# Items before this point are hardwired and their order should not be changed!
["practice_sword","Practice Sword", [("practice_sword",0)], itp_type_one_handed_wpn|itp_primary|itp_secondary|itp_wooden_parry|itp_wooden_attack, itc_longsword, 3,weight(1.5)|spd_rtng(103)|weapon_length(90)|swing_damage(16,blunt)|thrust_damage(10,blunt),imodbits_none],
.................................
.................................
.................................
.................................
["rabati", "Rabati", [("rabati",0)], itp_type_head_armor ,0, 278 , weight(2)|abundance(100)|head_armor(20)|body_armor(0)|leg_armor(0) ,imodbits_cloth ],
]
Such as the following list I wrote:
modifiers = [
(imod_plain, 100, 0),
(imod_cracked, 50, -1),
(imod_rusty, 55, -1),
(imod_bent, 65, -1),
(imod_chipped, 72, -1),
(imod_battered, 75, -1),
(imod_poor, 80, -1),
(imod_crude, 83, -1),
(imod_old, 86, -1),
(imod_cheap, 90, -1),
(imod_fine, 190, 1),
(imod_well_made, 250, 1),
(imod_sharp, 160, 1),
(imod_balanced, 350, 1),
(imod_tempered, 670, 1),
(imod_deadly, 850, 1),
(imod_exquisite, 1450, 1),
(imod_masterwork, 1750, 1),
(imod_heavy, 190, 1),
(imod_strong, 490, 1),
(imod_powerful, 320, 1),
(imod_tattered, 50, -1),
(imod_ragged, 70, -1),
(imod_rough, 60, -1),
(imod_sturdy, 170, 1),
(imod_thick, 260, 1),
(imod_hardened, 390, 1),
(imod_reinforced, 650, 1),
(imod_superb, 250, 1),
(imod_lordly, 1150, 1),
(imod_lame, 40, -1),
(imod_swaybacked, 60, -1),
(imod_stubborn, 90, 1),
(imod_timid, 180, -1),
(imod_meek, 180, -1),
(imod_spirited, 650, 1),
(imod_champion, 1450, 1),
(imod_fresh, 100, 1),
(imod_day_old, 100, -1),
(imod_two_day_old, 90, -1),
(imod_smelling, 40, -1),
(imod_rotten, 5, -1),
(imod_large_bag, 190, 1)
]
This is a new list I created to record something about every modifier. The first one in every tuple is the ID of the modifier, the second one is the price multiplier(need to divide 100 at last), the third one is the quality of the modifier(1 for good modifier, -1 for bad modifier).
You may have a question that how to use the new list?
Just use it like the list items.
Look at the folowing PYTHON function.
def set_item_modifier_multiplier():
modifier_multiplier = []
for i_modifier in xrange(len(modifiers)):
modifier_multiplier.append((item_set_slot, i_modifier, slot_item_modifier_multiplier, modifiers[i_modifier][1]))
return modifier_multiplier[:]
This function assign the price multiplier to slot_item_modifier_multiplier for every modifier.
Some related code:
("init_item_modifier_quality", set_item_modifier_quality()),
(call_script, "script_init_item_modifier_quality"),
Now, the script of get_item_value_with_imod in autoloot can be rewrited as following:
("get_item_value_with_imod",
[# returns the sell price based on the item's money value and its imod
(store_script_param, ":item", 1),
(store_script_param, ":imod", 2),
(store_item_value, ":score", ":item"),
(item_get_slot, ":imod_multiplier", ":imod", slot_item_modifier_multiplier),
(val_mul, ":score", ":imod_multiplier"),
(assign, reg0, ":score"),
]),
At last, all above are only examples. You should open your mind to create more things.