I need to integrate python code in the fully integrated WRECK via plugin system. This code creates duplicate noswing weapons for motomotaru formations.
I don't know python well. So how can I do it? This code doesn't work.
I don't know python well. So how can I do it? This code doesn't work.
Python:
from copy import deepcopy
from compiler import *
register_plugin()
def preprocess_entities(glob):
# Create noswing weapons
add_item = deepcopy(glob['items'])
for i_item in range(1,len(add_item)):
type = add_item[i_item][3] & 0x000000ff
# if itp_type_one_handed_wpn <= type <= itp_type_polearm and add_item[i_item-1][3] & itp_next_item_as_melee == 0 and (get_thrust_damage(add_item[i_item][6]) % 256) > 0 and "tutorial" not in add_item[i_item][0] and #"arena" not in add_item[i_item][0] and "practice" not in add_item[i_item][0] and "tpe" not in add_item[i_item][0]:
if itp_type_one_handed_wpn <= type <= itp_type_polearm and (get_thrust_damage(add_item[i_item][6])&0xff) > 0 and "tutorial" not in add_item[i_item][0] and "arena" not in add_item[i_item][0] and "practice" not in add_item[i_item][0] and "tpe" not in add_item[i_item][0]:
#Above checks that it is a weapon with thrust damage; also checks that it isn't a tournament-type weapon by checking the item ID (just to prevent not-used items)
add_item[i_item][0] = 'noswing_'+add_item[i_item][0] #add noswing_ to the item's name
add_item[i_item][6] = add_item[i_item][6] & ~(ibf_damage_mask << iwf_swing_damage_bits) #should set new item's swing damage to 0
add_item[i_item][4] = add_item[i_item][4] & ~itcf_overswing_polearm #remove itcf_ capabilties to prevent swinging without damage
add_item[i_item][4] = add_item[i_item][4] & ~itcf_slashright_polearm
add_item[i_item][4] = add_item[i_item][4] & ~itcf_slashleft_polearm
add_item[i_item][4] = add_item[i_item][4] & ~itcf_overswing_onehanded
add_item[i_item][4] = add_item[i_item][4] & ~itcf_slashright_onehanded
add_item[i_item][4] = add_item[i_item][4] & ~itcf_slashleft_onehanded
add_item[i_item][4] = add_item[i_item][4] & ~itcf_overswing_twohanded
add_item[i_item][4] = add_item[i_item][4] & ~itcf_slashright_twohanded
add_item[i_item][4] = add_item[i_item][4] & ~itcf_slashleft_twohanded
if type == itp_type_polearm and add_item[i_item][3] & itp_two_handed == 0:
add_item[i_item][4] = add_item[i_item][4] | itcf_thrust_onehanded #so that the polearms use 'bent elbow' with shields, but normal without
add_item[i_item][3] = add_item[i_item][3] & ~itp_merchandise
#orig_items.append(add_item[i_item])
glob['items'].append(add_item[i_item])
def make_noswing_weapons(items):
noswing_weapons = []
for i_item in xrange(len(items)):
noswing_name = 'noswing_' + items[i_item][0]
i_noswing = find_object (items, noswing_name)
if i_noswing > -1:
noswing_weapons.append((item_set_slot, i_item, slot_item_alternate, i_noswing))
noswing_weapons.append((item_set_slot, i_noswing, slot_item_alternate, i_item))
return noswing_weapons[:]
scripts = [
("init_noswing_weapons", make_noswing_weapons(get_globals()['items'])),
]