My first mod

Hello everyone! 
I do modostroeniya by The Fall relatively recently, there have been various attempts to make it a fashion,
and all hands did not reach. Since the information in Russian on modostroeniya relatively small, I decided
document their fixes, so to speak, for those who want, but can not figure out. I took as a basis version
Russobita from 1.10 to established Derfflinger v.7.4 and Freedom 2.0

In this article I will try to put on a character belt!
We all know that times are character can not wear because nowhere.
So, take as a basis the easiest times are: 

its code scripts/itemdata/

objects.set_attribute(object='SET_BELT', attribute = "name", value = globaltext.SET_BELT_NAME)
objects.set_attribute (object = 'SET_BELT', attribute = "hint", value = globaltext.SET_BELT_HINT)
objects.set_attribute (object = 'SET_BELT', attribute = "resourceui", value = 'RES_ITEM65X32_MISCITEM_BELT')
objects.set_attribute (object = 'SET_BELT', attribute = "resource3d", value = 'RES3D_BELT')
objects.set_attribute (object = 'SET_BELT', attribute = "value", value = 2.0)
objects.set_attribute (object = 'SET_BELT', attribute = "weight", value = 0.2)
objects.set_attribute (object = 'SET_BELT', attribute = "stacking ", value = 1)

The next line specifies which slot it will be put on:
objects.set_attribute (object = 'SET_BELT', attribute =" occupied_slots ", value = [" belt "]) < br>
And now you can put it in the game. But we sense from the belt if no useful it does not carry?
Let it gives us at least 10 strength 5 Agility and 30 medicine. Belt countries, yes. :) 

Come up with something otbaldovoe:
objects.set_attribute (object = 'SET_BELT', attribute = "eq_effect", value = {"strength": 10, "agility": 5, "medicine ": 30})

in scripts / has two great features: on_equip and on_unequip. The first is triggered when the thing
dress, the second - when the shoot. 

first wanted to write the handler, after I realized that you can modify the existing DR_recalculate_bonus.
Hang handler on_equip at the very end:

if objects.get_attribute (itemtype, "eq_effect"):
DR_recalculate_bonus (objectid, "eq_effect", itemtype)
on_unequip And also at the very end:
if objects.get_attribute (itemtype, " eq_effect "):
DR_recalculate_bonus (objectid," eq_effect ", None)

modify the f-th DR_recalculate_bonus:
def DR_recalculate_bonus (character_id, object_type, itemtype):
if character_id == None or object_type == None:
bonus.remove_temp_bonus (character_id, object_type)
if object_type == "armor_effect":
properity_table = DR_armor_bonus_calculator (character_id)
elif object_type == "implantant ":
properity_table = objects.get_att (itemtype," implantant_effect ")
elif object_type ==" eq_effect ":
properity_table = objects.get_att (itemtype," eq_effect ")
properity_table = None
if properity_table:
bonus.add_temp_bonuses (character_id, properity_table, object_type)

Our "eq_effect" will apply not only to the belt, and to any itemu having attribute "eq_effect" .

Never in the game did not raise setting body. Considered it useless. Indeed, good cannon
our characters almost ogrebayut. There were at least a little idea to make it useful.
In scripts / modifitsruem calculation load capacity: 

def strength_max_load (strength, constitution):
"" "Returns max load (ie, max. Added weight of all inventory items) in kg.

Chars can carry more than max load, but they get penalties.

strength - Strength value.
constitution - Constitution value.
"" "
assert strength & gt; = 1
assert constitution & gt; = 1

weight = (strength * 3)
weight + = (constitution * 1.5)

return weight
Since the function arguments popribavilos we need to add a second where I f-called
particularly in the scripts / 

def update_speed (character_id):
strength = objects.get_attribute (object = character_id, attribute = "strength")
constitution = objects.get_attribute (object = character_id, attribute = "constitution")
if strength == 0: rel_load = 0
else: rel_load = load / skill_tables.strength_max_load (strength, constitution)

def get_load_text (character_id):
constitution = objects.get_attribute (object = character_id, attribute = "constitution")

if strength & gt; 0:
relload = load / skill_tables.strength_max_load (strength, constitution)

In the same way, it can be more useful intellect, in particular for influencing mechanics conversation
trade. While on this thought :) 

That's what I do not like cocktail molotov, more precisely in his craft - rags to it is necessary to look.
In his fashion, I want to increase my value to throw explosives itemov - it follows that they must be in the game
somewhere to take in sufficient quantities.
First, you need somewhere to grow roots rags under the cocktail, and since it is a cloth rag, then we cut clothes.
The one, the usual. For example: 

In what has become a code rags scripts/itemdata/
objects.set_attribute(object='SET_RAGS', attribute = "name", value = globaltext.SET_RAGS_NAME)
objects.set_attribute (object = 'SET_RAGS', attribute = "hint", value = globaltext.SET_RAGS_HINT)
objects.set_attribute (object = 'SET_RAGS', attribute = "resourceui", value = 'RES_ITEM65X32_MISCITEM_RAGS')
objects.set_attribute (object = 'SET_RAGS', attribute = "resource3d", value = 'RES3D_RAGS')
objects.set_attribute (object = 'SET_RAGS', attribute = "value", value = 1.0)
objects.set_attribute (object = 'SET_RAGS', attribute = "weight", value = 0.1)
objects.set_attribute (object = 'SET_RAGS', attribute = "stacking ", value = 10)
objects.set_attribute (object = 'SET_RAGS', attribute =" item_combination ", value = {
" difficulty_assemble ": COMBO_EVERYBODY,
" assemble_function ":" assemble_rags ",
cutting ([ 'SET_NORMAL_CLOTHES_1'  ,   'SET_NORMAL_CLOTHES_2'  ,   'SET_NORMAL_CLOTHES_3'  < span>,   'SET_NORMAL_CLOTHES_4'  ,   'SET_NORMAL_CLOTHES_5'  ,   'SET_NORMAL_CLOTHES_6' < / span> ,   'SET_LOW_SHOES' ])})
What I did to her? I increased the amount in the stack (at us it will be a lot!) And wrote a function (see below).
Are functions that it returns the stack of arrays consisting of cutlery and items
that need to be cut. I have plans to further cutting of different meats, sewing and many others, and copy all
cutting items tedious - now in one place can only add them.
We cut all the usual clothes and sneakers. In the code, I have a function that will process the data
craft kits:
"Assemble_function": "assemble_rags", 

This function is defined in the file scripts /
def assemble_rags (character_id, items, item):

new_count = 0
exp = 0

for act_item in items:
# Do not remove our tools
if objects.get_att (act_item, 'typeid') not in CUTTING_TOOLS:
              # Shoes smaller - get smaller rags 
if objects.get_att (act_item, 'typeid') == 'SET_LOW_SHOES':
new_count + = 3
new_count + = 5

# Each character gets chopped thing yedinichku experience.
exp + = 1
objects.remove_item_from_inventory (character_id, act_item)

while new_count & gt; 0:
objects.create_item_in_inventory (object = character_id, equipment = item)
new_count - = 1

character.add_experience (character_id, exp)
return True

The file scripts /
 #   List of cutlery 
 def   cutting  (array_of_objects): 
objs = []
for item in array_of_objects: < br> for tool in CUTTING_TOOLS:
objs.append ([item , tool])

return objs
calculates do to a time you could cut several things at once, but have not yet figured out how :)
More precisely, it is possible to do something like that in the definition of an item: 
Only it seems to me somehow krivokodem and I will not do that :)
Although dug code combining in, wanted to do everything through dictionaries (python),
but swears at boot itemov in memory. I think bypassed with time.

rags we provide for themselves, left to add combinations of cocktails:
create_throw_object_type (typeid = 'SET_MOLOTOV_COCKTAIL')
"combination_list": [

Looking for ideas that you can create in a fashion useful - read that in RT mod was such a feature,
as the expo for the application of skills (not for the first, and in general). A good trick, now realize it in our.
Here is an example of theft from the pockets. In scripts /
In def on_steal (target, operator) instead give_first_use_exp (operator, "steal_item"), type the following,
although the first theft can leave :) 
character.add_experience (operator, 10)
In RT modes as well expo depends on the skill, but if all undermining all steal - do not see the point,
For the expo is growing and so is very fast even with small values. 


comAT0Zz 16.01.2015 | Comments (15)

Development by Sergey A.Zhukov 2007-2012