missing project/build files
[client-tools.git] / src / game / server / database / item_conversion / hotfix_5.sql
blob32184fa06e9a940970015815185aadcb5f16ed8d
1 CREATE OR REPLACE PACKAGE  "HOTFIX_5" as
2         procedure StartItemConversion (rbs_to_use varchar2 default null, conversion_id number default 1);
3         procedure DoSingleObject (objectId number, conversion_id number default 1);
4 end;
7 CREATE OR REPLACE PACKAGE BODY  "HOTFIX_5" as
8         -- private type defs
9         type objVarType is record (
10                 object_id number := NULL,
11                 objvar_name varchar2(500) := NULL,
12                 objvar_type number := NULL,
13                 objvar_value varchar2(1000)  := NULL,
14                 objvar_name_id number := 0,
15                 old_objvar_name_id number := 0);
17         type objRowType is record (
18                 object_id number,
19                 object_template_id number,
20                 object_name varchar2(127), name_string_table varchar2(500), name_string_text varchar2(500),
21                 objvar_0_name varchar2(50), objvar_0_type number, objvar_0_value varchar2(50),
22                 objvar_1_name varchar2(50), objvar_1_type number, objvar_1_value varchar2(50),
23                 objvar_2_name varchar2(50), objvar_2_type number, objvar_2_value varchar2(50),
24                 objvar_3_name varchar2(50), objvar_3_type number, objvar_3_value varchar2(50),
25                 objvar_4_name varchar2(50), objvar_4_type number, objvar_4_value varchar2(50),
26                 objvar_5_name varchar2(50), objvar_5_type number, objvar_5_value varchar2(50),
27                 objvar_6_name varchar2(50), objvar_6_type number, objvar_6_value varchar2(50),
28                 objvar_7_name varchar2(50), objvar_7_type number, objvar_7_value varchar2(50),
29                 objvar_8_name varchar2(50), objvar_8_type number, objvar_8_value varchar2(50),
30                 objvar_9_name varchar2(50), objvar_9_type number, objvar_9_value varchar2(50),
31                 objvar_10_name varchar2(50), objvar_10_type number, objvar_10_value varchar2(50),
32                 objvar_11_name varchar2(50), objvar_11_type number, objvar_11_value varchar2(50),
33                 objvar_12_name varchar2(50), objvar_12_type number, objvar_12_value varchar2(50),
34                 objvar_13_name varchar2(50), objvar_13_type number, objvar_13_value varchar2(50),
35                 objvar_14_name varchar2(50), objvar_14_type number, objvar_14_value varchar2(50),
36                 objvar_15_name varchar2(50), objvar_15_type number, objvar_15_value varchar2(50),
37                 objvar_16_name varchar2(50), objvar_16_type number, objvar_16_value varchar2(50),
38                 objvar_17_name varchar2(50), objvar_17_type number, objvar_17_value varchar2(50),
39                 objvar_18_name varchar2(50), objvar_18_type number, objvar_18_value varchar2(50),
40                 objvar_19_name varchar2(50), objvar_19_type number, objvar_19_value varchar2(50),
41                 scriptlist  varchar2(2000));
43         type objVarRowType is record (
44                 object_id number,
45                 objvar_name_id number,
46                 objvar_name varchar2(500), 
47                 objvar_type number, 
48                 objvar_value varchar2(1000));
49                 
50         type weaponRowType is record (
51                 object_id number,
52                 min_damage number,
53                 max_damage number,
54                 attack_speed float,
55                 wound_chance float,
56                 accuracy number,
57                 attack_cost number,
58                 min_range float,
59                 max_range float,
60                 damage_type number,
61                 elemental_type number,
62                 elemental_value number);
63         
64         type manfSchematicRowType is record (
65                 object_id number,
66                 draft_schematic number);
67                 
68         type manfAttributeRowType is record (
69                 object_id number,
70                 attribute varchar2(500),
71                 value float);
73         type rangeType is varray(4) of number;
75         type rangeTableType is table of rangeType;
77         type numTable is table of number;
78         
79         type varcharTable is table of varchar2(500);
81         type numTableVarchar is table of number
82                 index by varchar2(500);
83                 
84         type varcharTableNum is table of varchar2(500)
85                 index by binary_integer;
87         type objectObjVarArray is varray(20) of objVarType;
89         type objVarTable is table of objVarType
90                 index by varchar2(500);
92         type dotObjVarTable is table of objVarType
93                 index by varchar2(10);
95         type dotArrayVarchar is table of dotObjVarTable
96                 index by varchar2(500);
98         type numTableNumber is table of number 
99                  index by binary_integer;
101         type dotsMatrixType is table of numTableNumber index by varchar2(50);
102         
103         type manfAttributesTable is table of manfAttributeRowType
104                 index by varchar2(500);
106         -- private global containers
107         use_rbs                 varchar2(50);
108         object_id       number;
109         free_slots      numTable;                               -- empty OBJECTS ObjVar columns
110         slot_map        numTableVarchar;                -- map from ObjVar name to OBJECTS slot
111         Obj_ObjVars     objectObjVarArray;              -- array of ObjVars in OBJECTS
112         OV_ObjVars      objVarTable;                    -- map by name of ObjVars in OBJECT_VARIABLES
113         dot_list        dotArrayVarchar;                -- map from extracted DoT name and class to ObjVar
114                                                                                         -- example: dot_list('actionShot1')('type')
115         isObjModified   boolean;                                -- tracks if any of the OBJECTS data has changed
116         updated_objvars varcharTable;                   -- list of updated ObjVar names in OBJECT_VARIABLES
117         deleted_objvars varcharTable;                   -- list of deleted ObjVar names in OBJECT_VARIABLES
118         added_objvars   varcharTable;                   -- list of added ObjVar names in OBJECT_VARIABLES
119         isWeaponObj     boolean;                                -- tracks if the object has WEAPON_OBJECTS data
120         isSchematic     boolean;                                -- tracks if the object has MANF_SCHEMATIC_OBJECTS data
121         isFactory       boolean;
122         script_list     varchar2(2000);
123         object_name     varchar2(127);
124         name_table      varchar2(500);
125         name_text       varchar2(500);
126         template_id     number;
127         new_template_id number;
128         new_schematic_id number;
129         err_num                 number;
130         weapon_attribs  weaponRowType;                  -- record for weapon attributes for current object
131         manf_attributes manfAttributesTable;    -- map of attributes in MANF_SCHEMATIC_ATTRIBUTES
132         updated_attribs varcharTable;                   -- list of updated attributes in MANF_SCHEMATIC_ATTRIBUTES
133         deleted_attribs varcharTable;                   -- list of deleted attributes in MANF_SCHEMATIC_ATTRIBUTES
134         added_attribs   varcharTable;                   -- list of added attributes in MANF_SCHEMATIC_ATTRIBUTES
135         
136         -- private lookup tables
137         templateIdSet   numTableNumber;                 -- set of template ids to be converted
138         objvarNameIdMap numTableVarchar;                -- map from ObjVar name to OBJECT_VARIABLES_NAMES ID
139         dots_matrix     dotsMatrixType;                 -- map from DoT type and attribute to ObjVar
140                                                                                         -- example: dots_matrix('fire')(6)
141         schematic_map   numTableNumber;                 -- map of schematic to created template
142         templateNameTable varcharTableNum;              -- map of new template ids to string_name_table
143         templateNameText  varcharTableNum;              -- map of new template ids to string_name_text
144         
145         
146         -- private constants
147         blankObjVar     objVarType;                             -- can't use CONSTANT properly with records :(
148         
149         -- private function declaration
150         procedure DoItemConversionBatch(start_objectid number, end_objectid number, conversion_id number);
151         function InitializeData return boolean;
152         
153         procedure AddObjVar (objvar_name varchar2, objvar_type number, objvar_value varchar2);
154         procedure DeleteObjVar (objVarName in varchar2);
155         procedure ModifyObjVar (oldObjVarName varchar2, objvar_name varchar2, objvar_type number, objvar_value varchar2);
156         procedure ModifyObjVar (oldObjVarName varchar2, objvar_name varchar2, objvar_type number, rangeTable rangeTableType);
157         procedure RenameObjVar (oldObjVarName varchar2, objvar_name varchar2);
158         function GetObjVarValue (objvar_name varchar2) return varchar2;
159         procedure AddScript (newScript varchar2);
160         procedure RemoveScript (oldScript varchar2);
161         procedure SetNewTemplateId (newTemplateId number);
162         procedure SetTemplateText (newTemplateId number);
163         procedure InvalidateSchematic;
164         procedure AddAttrib (attrib_name varchar2, attrib_value float);
165         procedure DeleteAttrib (attrib_name in varchar2);
166         procedure ModifyAttrib (old_attrib_name varchar2, attrib_name varchar2, attrib_value float);
168         procedure DeleteOldArmorObjvars;
169         procedure SetGenProtection(rangeTable rangeTableType);
170         procedure SetArmorCondLevelCat(condition varchar2, lev varchar2, category varchar2);
171         procedure SetArmorLevel(lev varchar);
172         procedure SetArmorCategory(category varchar2);
173         procedure SetGpAndCond(gp_name varchar2, gp_val varchar2, cond_name varchar2, cond_val varchar2);
174         
175         procedure DeleteCraftingComponents;
176         procedure CopySchematicAttributes;
177         procedure HandleFoodSchematic;
178         procedure HandleFoodCrate;
179         procedure ConvertToStimpack(stim_template number,healing_power number, combat_level number);
180         procedure ConvertToEnhancer(enh_template number, enh_name varchar2, enh_power number);
181         procedure ConvertToPetStimpack(stim_template number,healing_power number);
182         procedure ConvertSpice(spice_name varchar2);
183         
184         procedure HandleWeaponDots;
185         procedure SetWeaponBaseStats(attack number, acc number, minrange number, maxrange number, damagetype number);
186         procedure SetMinDamage (min_damage number);
187         procedure SetMaxDamage (max_damage number);
188         procedure SetAttackSpeed (attack_speed number);
189         procedure SetWoundChance (wound_chance number);
190         procedure SetAccuracy (accuracy number);
191         procedure SetAttackCost (attack_cost number);
192         procedure SetMinRange (min_range number);
193         procedure SetMaxRange (max_range number);
194         procedure SetDamageType (dmg_type number);
195         procedure SetElementalType (ele_type number);
196         procedure SetElementalValue (ele_value number);
197         procedure ConvertAttribValue(attribute varchar2, rangeTable rangeTableType);
198         procedure ConvertMinDamage (rangeTable rangeTableType);
199         procedure ConvertMaxDamage (rangeTable rangeTableType);
200         procedure ConvertAttackSpeed (rangeTable rangeTableType);
201         procedure ConvertWoundChance (rangeTable rangeTableType);
202         
203         procedure ConvertRangedPowerup;
204         procedure ConvertMeleePowerup;
205         procedure ConvertMinePowerup;
207         function ConvertValue (oldvalue number, rangeTable rangeTableType) return number;
209         procedure CheckObjVarForDot (objvar objVarType);
211         function DotsMatrix(dot_type varchar2, dot_attrib number)
212                 return number;
213         function SchematicMap(schematic_id number)
214                 return number;
216         -- public function definitions
217         procedure StartItemConversion (rbs_to_use varchar2, conversion_id number)
218         is
219                 maxObjectId number;
220                 startObjectId number := 0;
221                 endObjectId number;
222                 starttime date := sysdate;
223         begin
224                 use_rbs := rbs_to_use;
225                 if use_rbs is not null then
226                         execute immediate 'set transaction use rollback segment ' || use_rbs;
227                 end if;
228                 if (InitializeData) then
229                         -- loop through all objects in batches
230                         select max(object_id) into maxObjectId from objects;
231                         while startObjectId < maxObjectId loop
232                                 dbms_output.put_line('starting batch: ' || startObjectId || ' time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
233                                 endObjectId := startObjectId + 19999999999;
234                                 if endObjectId > maxObjectId then
235                                         endObjectId := maxObjectId;
236                                 end if;
237                                 DoItemConversionBatch(startObjectId, startObjectId + 19999999999, conversion_id);
238                                 commit;
239                                 if use_rbs is not null then
240                                         execute immediate 'set transaction use rollback segment ' || use_rbs;
241                                 end if;
242                                 startObjectId := startObjectId + 20000000000;
243                         end loop;
244                 end if;
245                 dbms_output.put_line('start time = ' || to_char(starttime, 'MM/DD/YY HH24:MI:SS'));
246                 dbms_output.put_line('final time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
247                 dbms_output.put_line('total time = ' || to_char(trunc((sysdate - starttime)*24*60)) || ' mins');
248         exception
249                 when others then
250                         err_num := SQLCODE;
251                         dbms_output.put_line('Error in StartItemConversion - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
252                         db_error_logger.dblogerror(err_num, 'Error in StartItemConversion');
253         end;
255         procedure DoSingleObject (objectId number, conversion_id number)
256         is
257         begin
258                 if (InitializeData) then
259                         DoItemConversionBatch(objectId, objectId, conversion_id);
260                 end if;
261         exception
262                 when others then
263                         err_num := SQLCODE;
264                         dbms_output.put_line('Error in DoSingleObject - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
265                         db_error_logger.dblogerror(err_num, 'Error in ObjVarUpdates');
266         end;
268         -- private function definitions
269         procedure DoItemConversionBatch(start_objectid number, end_objectid number, conversion_id number)
270         is
271                 -- cursors
272                 objRow objRowType;
273                 cursor objCursor (start_id number, end_id number) is
274                 select
275                         o.object_id,
276                         o.object_template_id,
277                         o.object_name, o.name_string_table, o.name_string_text,
278                         o.objvar_0_name, o.objvar_0_type, o.objvar_0_value,
279                         o.objvar_1_name, o.objvar_1_type, o.objvar_1_value,
280                         o.objvar_2_name, o.objvar_2_type, o.objvar_2_value,
281                         o.objvar_3_name, o.objvar_3_type, o.objvar_3_value,
282                         o.objvar_4_name, o.objvar_4_type, o.objvar_4_value,
283                         o.objvar_5_name, o.objvar_5_type, o.objvar_5_value,
284                         o.objvar_6_name, o.objvar_6_type, o.objvar_6_value,
285                         o.objvar_7_name, o.objvar_7_type, o.objvar_7_value,
286                         o.objvar_8_name, o.objvar_8_type, o.objvar_8_value,
287                         o.objvar_9_name, o.objvar_9_type, o.objvar_9_value,
288                         o.objvar_10_name, o.objvar_10_type, o.objvar_10_value,
289                         o.objvar_11_name, o.objvar_11_type, o.objvar_11_value,
290                         o.objvar_12_name, o.objvar_12_type, o.objvar_12_value,
291                         o.objvar_13_name, o.objvar_13_type, o.objvar_13_value,
292                         o.objvar_14_name, o.objvar_14_type, o.objvar_14_value,
293                         o.objvar_15_name, o.objvar_15_type, o.objvar_15_value,
294                         o.objvar_16_name, o.objvar_16_type, o.objvar_16_value,
295                         o.objvar_17_name, o.objvar_17_type, o.objvar_17_value,
296                         o.objvar_18_name, o.objvar_18_type, o.objvar_18_value,
297                         o.objvar_19_name, o.objvar_19_type, o.objvar_19_value,
298                         script_list
299                 from objects o
300                 where object_id between start_id and end_id
301                 and object_template_id in
302                                 (-1264335626,
303                                 -1464343893,
304                                 -1674079888,
305                                 -171018882,
306                                 -1839044042,
307                                 -2022305605,
308                                 -38886533,
309                                 -470906696,
310                                 -589817340,
311                                 -613110139,
312                                 -965865145,
313                                 1193294311,
314                                 162889564,
315                                 1120303977,
316                                 1740191859,
317                                 188520444,
318                                 2144735852,
319                                 237854314,
320                                 344340565,
321                                 810379093,
322                                 981227534,
323                                 -144833342,
324                                 -817576610,
325                                 -200781577,
326                                 -1966544754, 
327                                 -754298423,
328                                 -1207917085)
329                 order by object_id;
331                 objVarRow objVarRowType;
332                 cursor objVarCursor (start_id number, end_id number) is
333                 select
334                         v.object_id,
335                         v.name_id,
336                         nvl(n.name, to_char(n.id)),
337                         v.type,
338                         v.value
339                 from object_variables v, object_variable_names n
340                 where v.object_id between start_id and end_id
341                         and nvl(v.detached,0) = 0
342                         and v.name_id = n.id
343                 order by v.object_id;
345                 weaponRow weaponRowType;
346                 cursor weaponCursor (start_id number, end_id number) is
347                 select
348                         object_id,
349                         min_damage,
350                         max_damage,
351                         attack_speed,
352                         wound_chance,
353                         accuracy,
354                         attack_cost,
355                         min_range,
356                         max_range,
357                         damage_type,
358                         elemental_type,
359                         elemental_value
360                 from weapon_objects
361                 where object_id between start_id and end_id
362                 order by object_id;
364                 manfSchematicRow manfSchematicRowType;
365                 cursor schematicCursor (start_id number, end_id number) is
366                 select
367                         object_id,
368                         draft_schematic
369                 from manf_schematic_objects
370                 where object_id between start_id and end_id
371                 order by object_id;
373                 manfAttributeRow manfAttributeRowType;
374                 cursor attributeCursor (start_id number, end_id number) is
375                 select
376                         object_id,
377                         attribute_type,
378                         value
379                 from manf_schematic_attributes
380                 where object_id between start_id and end_id
381                 order by object_id;
383                 -- local variables
384                 i          number;
385                 n          number;
386                 idx        number := 0;
387                 cnt        number := 0;
388                 cvt        number := 0;
389                 bool       boolean;
390                 tempObjVar objVarType;
391                 stmt       varchar2(4000);
392                 prefix     varchar2(100);
393         begin
394                 dbms_output.put_line('start time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
395                 open objCursor (start_objectid, end_objectid);
396                 fetch objCursor into objRow;
397                 dbms_output.put_line('object cursor time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
398                 open objVarCursor (start_objectid, end_objectid);
399                 fetch objVarCursor into objVarRow;
400                 dbms_output.put_line('objvar cursor time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
401                 open weaponCursor (start_objectid, end_objectid);
402                 fetch weaponCursor into weaponRow;
403                 dbms_output.put_line('weapon cursor time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
404                 open schematicCursor (start_objectid, end_objectid);
405                 fetch schematicCursor into manfSchematicRow;
406                 dbms_output.put_line('schematic cursor time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
407                 open attributeCursor (start_objectid, end_objectid);
408                 fetch attributeCursor into manfAttributeRow;
409                 dbms_output.put_line('attribute cursor time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
411                 while objCursor%found loop
412                         begin
413                         if templateIdSet.exists(objRow.object_template_id) then
414                                 -- Clear Data
415                                 free_slots.delete;
416                                 free_slots := numTable(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
417                                 slot_map.delete;
418                                 for i in 1..20 loop
419                                         Obj_ObjVars(i) := blankObjVar;
420                                 end loop;
421                                 OV_ObjVars.delete;
422                                 dot_list.delete;
423                                 updated_objvars.trim(updated_objvars.count);
424                                 deleted_objvars.trim(deleted_objvars.count);
425                                 added_objvars.trim(added_objvars.count);
426                                 manf_attributes.delete;
427                                 updated_attribs.trim(updated_attribs.count);
428                                 deleted_attribs.trim(deleted_attribs.count);
429                                 added_attribs.trim(added_attribs.count);
430                                 isObjModified := FALSE;
431                                 isWeaponObj := FALSE;
432                                 isSchematic := FALSE;
433                                 isFactory := FALSE;
434                                 prefix := 'crafting_components.';
435                                 new_schematic_id := 0;
436                                 weapon_attribs := null;
437                                 
438                                 -- Load the data into variables
439                                 object_id := objRow.object_id;
440                                 script_list := objRow.scriptList;
441                                 object_name := objRow.object_name;
442                                 name_table := objRow.name_string_table;
443                                 name_text := objRow.name_string_text;
444                                 template_id := objRow.object_template_id;
445                                 new_template_id := template_id;
447                                 Obj_ObjVars(1).object_id := objRow.object_id;    -- might be able to eliminate
448                                 Obj_ObjVars(1).objvar_name := objRow.objvar_0_name;
449                                 Obj_ObjVars(1).objvar_type := objRow.objvar_0_type;
450                                 Obj_ObjVars(1).objvar_value := objRow.objvar_0_value;
451                                 if ((objRow.objvar_0_name is not null) and (objRow.objvar_0_type != -1))then
452                                         slot_map(objRow.objvar_0_name) := 1;
453                                         CheckObjVarForDot(Obj_ObjVars(1));
454                                         free_slots.delete(1);
455                                 end if;
457                                 Obj_ObjVars(2).object_id := objRow.object_id;
458                                 Obj_ObjVars(2).objvar_name := objRow.objvar_1_name;
459                                 Obj_ObjVars(2).objvar_type := objRow.objvar_1_type;
460                                 Obj_ObjVars(2).objvar_value := objRow.objvar_1_value;
461                                 if ((objRow.objvar_1_name is not null) and (objRow.objvar_1_type != -1))then
462                                         slot_map(objRow.objvar_1_name) := 2;
463                                         CheckObjVarForDot(Obj_ObjVars(2));
464                                         free_slots.delete(2);
465                                 end if;
467                                 Obj_ObjVars(3).object_id := objRow.object_id;
468                                 Obj_ObjVars(3).objvar_name := objRow.objvar_2_name;
469                                 Obj_ObjVars(3).objvar_type := objRow.objvar_2_type;
470                                 Obj_ObjVars(3).objvar_value := objRow.objvar_2_value;
471                                 if ((objRow.objvar_2_name is not null) and (objRow.objvar_2_type != -1))then
472                                         slot_map(objRow.objvar_2_name) := 3;
473                                         CheckObjVarForDot(Obj_ObjVars(3));
474                                         free_slots.delete(3);
475                                 end if;
477                                 Obj_ObjVars(4).object_id := objRow.object_id;
478                                 Obj_ObjVars(4).objvar_name := objRow.objvar_3_name;
479                                 Obj_ObjVars(4).objvar_type := objRow.objvar_3_type;
480                                 Obj_ObjVars(4).objvar_value := objRow.objvar_3_value;
481                                 if ((objRow.objvar_3_name is not null) and (objRow.objvar_3_type != -1))then
482                                         slot_map(objRow.objvar_3_name) := 4;
483                                         CheckObjVarForDot(Obj_ObjVars(4));
484                                         free_slots.delete(4);
485                                 end if;
487                                 Obj_ObjVars(5).object_id := objRow.object_id;
488                                 Obj_ObjVars(5).objvar_name := objRow.objvar_4_name;
489                                 Obj_ObjVars(5).objvar_type := objRow.objvar_4_type;
490                                 Obj_ObjVars(5).objvar_value := objRow.objvar_4_value;
491                                 if ((objRow.objvar_4_name is not null) and (objRow.objvar_4_type != -1))then
492                                         slot_map(objRow.objvar_4_name) := 5;
493                                         CheckObjVarForDot(Obj_ObjVars(5));
494                                         free_slots.delete(5);
495                                 end if;
497                                 Obj_ObjVars(6).object_id := objRow.object_id;
498                                 Obj_ObjVars(6).objvar_name := objRow.objvar_5_name;
499                                 Obj_ObjVars(6).objvar_type := objRow.objvar_5_type;
500                                 Obj_ObjVars(6).objvar_value := objRow.objvar_5_value;
501                                 if ((objRow.objvar_5_name is not null) and (objRow.objvar_5_type != -1))then
502                                         slot_map(objRow.objvar_5_name) := 6;
503                                         CheckObjVarForDot(Obj_ObjVars(6));
504                                         free_slots.delete(6);
505                                 end if;
507                                 Obj_ObjVars(7).object_id := objRow.object_id;
508                                 Obj_ObjVars(7).objvar_name := objRow.objvar_6_name;
509                                 Obj_ObjVars(7).objvar_type := objRow.objvar_6_type;
510                                 Obj_ObjVars(7).objvar_value := objRow.objvar_6_value;
511                                 if ((objRow.objvar_6_name is not null) and (objRow.objvar_6_type != -1))then
512                                         slot_map(objRow.objvar_6_name) := 7;
513                                         CheckObjVarForDot(Obj_ObjVars(7));
514                                         free_slots.delete(7);
515                                 end if;
517                                 Obj_ObjVars(8).object_id := objRow.object_id;
518                                 Obj_ObjVars(8).objvar_name := objRow.objvar_7_name;
519                                 Obj_ObjVars(8).objvar_type := objRow.objvar_7_type;
520                                 Obj_ObjVars(8).objvar_value := objRow.objvar_7_value;
521                                 if ((objRow.objvar_7_name is not null) and (objRow.objvar_7_type != -1))then
522                                         slot_map(objRow.objvar_7_name) := 8;
523                                         CheckObjVarForDot(Obj_ObjVars(8));
524                                         free_slots.delete(8);
525                                 end if;
527                                 Obj_ObjVars(9).object_id := objRow.object_id;
528                                 Obj_ObjVars(9).objvar_name := objRow.objvar_8_name;
529                                 Obj_ObjVars(9).objvar_type := objRow.objvar_8_type;
530                                 Obj_ObjVars(9).objvar_value := objRow.objvar_8_value;
531                                 if ((objRow.objvar_8_name is not null) and (objRow.objvar_8_type != -1))then
532                                         slot_map(objRow.objvar_8_name) := 9;
533                                         CheckObjVarForDot(Obj_ObjVars(9));
534                                         free_slots.delete(9);
535                                 end if;
537                                 Obj_ObjVars(10).object_id := objRow.object_id;
538                                 Obj_ObjVars(10).objvar_name := objRow.objvar_9_name;
539                                 Obj_ObjVars(10).objvar_type := objRow.objvar_9_type;
540                                 Obj_ObjVars(10).objvar_value := objRow.objvar_9_value;
541                                 if ((objRow.objvar_9_name is not null) and (objRow.objvar_9_type != -1))then
542                                         slot_map(objRow.objvar_9_name) := 10;
543                                         CheckObjVarForDot(Obj_ObjVars(10));
544                                         free_slots.delete(10);
545                                 end if;
547                                 Obj_ObjVars(11).object_id := objRow.object_id;
548                                 Obj_ObjVars(11).objvar_name := objRow.objvar_10_name;
549                                 Obj_ObjVars(11).objvar_type := objRow.objvar_10_type;
550                                 Obj_ObjVars(11).objvar_value := objRow.objvar_10_value;
551                                 if ((objRow.objvar_10_name is not null) and (objRow.objvar_10_type != -1))then
552                                         slot_map(objRow.objvar_10_name) := 11;
553                                         CheckObjVarForDot(Obj_ObjVars(11));
554                                         free_slots.delete(11);
555                                 end if;
557                                 Obj_ObjVars(12).object_id := objRow.object_id;
558                                 Obj_ObjVars(12).objvar_name := objRow.objvar_11_name;
559                                 Obj_ObjVars(12).objvar_type := objRow.objvar_11_type;
560                                 Obj_ObjVars(12).objvar_value := objRow.objvar_11_value;
561                                 if ((objRow.objvar_11_name is not null) and (objRow.objvar_11_type != -1))then
562                                         slot_map(objRow.objvar_11_name) := 12;
563                                         CheckObjVarForDot(Obj_ObjVars(12));
564                                         free_slots.delete(12);
565                                 end if;
567                                 Obj_ObjVars(13).object_id := objRow.object_id;
568                                 Obj_ObjVars(13).objvar_name := objRow.objvar_12_name;
569                                 Obj_ObjVars(13).objvar_type := objRow.objvar_12_type;
570                                 Obj_ObjVars(13).objvar_value := objRow.objvar_12_value;
571                                 if ((objRow.objvar_12_name is not null) and (objRow.objvar_12_type != -1))then
572                                         slot_map(objRow.objvar_12_name) := 13;
573                                         CheckObjVarForDot(Obj_ObjVars(13));
574                                         free_slots.delete(13);
575                                 end if;
577                                 Obj_ObjVars(14).object_id := objRow.object_id;
578                                 Obj_ObjVars(14).objvar_name := objRow.objvar_13_name;
579                                 Obj_ObjVars(14).objvar_type := objRow.objvar_13_type;
580                                 Obj_ObjVars(14).objvar_value := objRow.objvar_13_value;
581                                 if ((objRow.objvar_13_name is not null) and (objRow.objvar_13_type != -1))then
582                                         slot_map(objRow.objvar_13_name) := 14;
583                                         CheckObjVarForDot(Obj_ObjVars(14));
584                                         free_slots.delete(14);
585                                 end if;
587                                 Obj_ObjVars(15).object_id := objRow.object_id;
588                                 Obj_ObjVars(15).objvar_name := objRow.objvar_14_name;
589                                 Obj_ObjVars(15).objvar_type := objRow.objvar_14_type;
590                                 Obj_ObjVars(15).objvar_value := objRow.objvar_14_value;
591                                 if ((objRow.objvar_14_name is not null) and (objRow.objvar_14_type != -1))then
592                                         slot_map(objRow.objvar_14_name) := 15;
593                                         CheckObjVarForDot(Obj_ObjVars(15));
594                                         free_slots.delete(15);
595                                 end if;
597                                 Obj_ObjVars(16).object_id := objRow.object_id;
598                                 Obj_ObjVars(16).objvar_name := objRow.objvar_15_name;
599                                 Obj_ObjVars(16).objvar_type := objRow.objvar_15_type;
600                                 Obj_ObjVars(16).objvar_value := objRow.objvar_15_value;
601                                 if ((objRow.objvar_15_name is not null) and (objRow.objvar_15_type != -1))then
602                                         slot_map(objRow.objvar_15_name) := 16;
603                                         CheckObjVarForDot(Obj_ObjVars(16));
604                                         free_slots.delete(16);
605                                 end if;
607                                 Obj_ObjVars(17).object_id := objRow.object_id;
608                                 Obj_ObjVars(17).objvar_name := objRow.objvar_16_name;
609                                 Obj_ObjVars(17).objvar_type := objRow.objvar_16_type;
610                                 Obj_ObjVars(17).objvar_value := objRow.objvar_16_value;
611                                 if ((objRow.objvar_16_name is not null) and (objRow.objvar_16_type != -1))then
612                                         slot_map(objRow.objvar_16_name) := 17;
613                                         CheckObjVarForDot(Obj_ObjVars(17));
614                                         free_slots.delete(17);
615                                 end if;
617                                 Obj_ObjVars(18).object_id := objRow.object_id;
618                                 Obj_ObjVars(18).objvar_name := objRow.objvar_17_name;
619                                 Obj_ObjVars(18).objvar_type := objRow.objvar_17_type;
620                                 Obj_ObjVars(18).objvar_value := objRow.objvar_17_value;
621                                 if ((objRow.objvar_17_name is not null) and (objRow.objvar_17_type != -1))then
622                                         slot_map(objRow.objvar_17_name) := 18;
623                                         CheckObjVarForDot(Obj_ObjVars(18));
624                                         free_slots.delete(18);
625                                 end if;
627                                 Obj_ObjVars(19).object_id := objRow.object_id;
628                                 Obj_ObjVars(19).objvar_name := objRow.objvar_18_name;
629                                 Obj_ObjVars(19).objvar_type := objRow.objvar_18_type;
630                                 Obj_ObjVars(19).objvar_value := objRow.objvar_18_value;
631                                 if ((objRow.objvar_18_name is not null) and (objRow.objvar_18_type != -1))then
632                                         slot_map(objRow.objvar_18_name) := 19;
633                                         CheckObjVarForDot(Obj_ObjVars(19));
634                                         free_slots.delete(19);
635                                 end if;
637                                 Obj_ObjVars(20).object_id := objRow.object_id;
638                                 Obj_ObjVars(20).objvar_name := objRow.objvar_19_name;
639                                 Obj_ObjVars(20).objvar_type := objRow.objvar_19_type;
640                                 Obj_ObjVars(20).objvar_value := objRow.objvar_19_value;
641                                 if ((objRow.objvar_19_name is not null) and (objRow.objvar_19_type != -1))then
642                                         slot_map(objRow.objvar_19_name) := 20;
643                                         CheckObjVarForDot(Obj_ObjVars(20));
644                                         free_slots.delete(20);
645                                 end if;
648                                 while (objVarCursor%found and objVarRow.object_id <= objRow.object_id) loop
649                                         if objVarRow.object_id = objRow.object_id then
650                                                 tempObjVar := blankObjVar;
651                                                 tempObjVar.object_id := objVarRow.object_id;
652                                                 tempObjVar.objvar_name := objVarRow.objvar_name;
653                                                 tempObjVar.objvar_type := objVarRow.objvar_type;
654                                                 tempObjVar.objvar_value := objVarRow.objvar_value;
655                                                 tempObjVar.objvar_name_id := objVarRow.objvar_name_id;
656                                                 OV_ObjVars(objVarRow.objvar_name) := tempObjVar;
657                                                 slot_map(objVarRow.objvar_name) := 21;
658                                                 CheckObjVarForDot(tempObjVar);
659                                         end if;
660                                         fetch objVarCursor into objVarRow;
661                                 end loop;
663                                 while (weaponCursor%found and weaponRow.object_id <= objRow.object_id) loop
664                                         if weaponRow.object_id = objRow.object_id then
665                                                 weapon_attribs := weaponRow;
666                                                 isWeaponObj := TRUE;
667                                         end if;
668                                         fetch weaponCursor into weaponRow;
669                                 end loop;
671                                 -- check to see if it is a manufacturing schematic
672                                 if template_id = -144833342 then
673                                         while (schematicCursor%found and manfSchematicRow.object_id <= objRow.object_id) loop
674                                                 if manfSchematicRow.object_id = objRow.object_id then
675                                                         template_id := SchematicMap(manfSchematicRow.draft_schematic);
676                                                         if template_id != 0 then
677                                                                 isSchematic := TRUE;
678                                                                 prefix := 'crafting_attributes.crafting:';
679                                                         end if;
680                                                 end if;
681                                                 fetch schematicCursor into manfSchematicRow;
682                                         end loop;
683                                         while (attributeCursor%found and manfAttributeRow.object_id <= objRow.object_id) loop
684                                                 if manfAttributeRow.object_id = objRow.object_id then
685                                                         manf_attributes(manfAttributeRow.attribute) := manfAttributeRow;
686                                                 end if;
687                                                 fetch attributeCursor into manfAttributeRow;
688                                         end loop;
689                                 -- check to see if it a weapon (162889564) or armor (1120303977) factory crate
690                                 -- or food (-200781577) or chemicals (-1966544754)
691                                 -- or electronics (-754298423) or clothing (-1207917085)
692                                 elsif template_id = 162889564 or template_id = 1120303977 
693                                                 or template_id = -200781577 or template_id = -1966544754 
694                                                 or template_id = -754298423 or template_id = -1207917085 then
695                                         if slot_map.exists('draftSchematic') then
696                                                 if slot_map('draftSchematic') < 21 then
697                                                         template_id := SchematicMap(to_number(Obj_ObjVars(slot_map('draftSchematic')).objvar_value));
698                                                 else
699                                                         template_id := SchematicMap(to_number(OV_ObjVars('draftSchematic').objvar_value));
700                                                 end if;
701                                                 isFactory := TRUE;
702                                                 prefix := 'crafting_attributes.crafting:';
703                                                 DeleteObjVar('ingr.*');
704                                         end if;
705                                 end if;
707                                 -- Do the conversions
708                                 --object/tangible/component/armor/shield_generator_personal.iff
709                                 if template_id = -817576610 then
710                                         if isSchematic = FALSE then
711                                                 if isFactory = TRUE then
712                                                         RenameObjVar('crafting_components.layer13','crafting_attributes.crafting:special_protection');
713                                                         RenameObjVar('crafting_components.recharge_rate','crafting_attributes.crafting:recharge_rate');
714                                                 else
715                                                         AddObjVar('armor.layer13',2,'0.4444');
716                                                         AddObjVar('armor.recharge_rate',2,'60');
717                                                 end if;
718                                         end if;
719                                 --object/tangible/component/armor/shield_generator_personal_b.iff
720                                 elsif template_id = -38886533 then
721                                         if isSchematic = FALSE then
722                                                 if isFactory = TRUE then
723                                                         RenameObjVar('crafting_components.layer13','crafting_attributes.crafting:special_protection');
724                                                         RenameObjVar('crafting_components.recharge_rate','crafting_attributes.crafting:recharge_rate');
725                                                 else
726                                                         AddObjVar('armor.layer13',2,'0.54545');
727                                                         AddObjVar('armor.recharge_rate',2,'60');
728                                                 end if;
729                                         end if;
730                                 --object/tangible/component/armor/shield_generator_personal_c.iff
731                                 elsif template_id = -1264335626 then
732                                         if isSchematic = FALSE then
733                                                 if isFactory = TRUE then
734                                                         RenameObjVar('crafting_components.layer13','crafting_attributes.crafting:special_protection');
735                                                         RenameObjVar('crafting_components.recharge_rate','crafting_attributes.crafting:recharge_rate');
736                                                 else
737                                                         AddObjVar('armor.layer13',2,'0.759167');
738                                                         AddObjVar('armor.recharge_rate',2,'60');
739                                                 end if;
740                                         end if;
741                                 --object/tangible/component/armor/shield_generator_personal_imperial_test.iff
742                                 elsif template_id = 2144735852 then
743                                         if isSchematic = FALSE then
744                                                 if isFactory = TRUE then
745                                                         RenameObjVar('crafting_components.layer13','crafting_attributes.crafting:special_protection');
746                                                         RenameObjVar('crafting_components.recharge_rate','crafting_attributes.crafting:recharge_rate');
747                                                 else
748                                                         AddObjVar('armor.layer13',2,'0.759167');
749                                                         AddObjVar('armor.recharge_rate',2,'65');
750                                                 end if;
751                                         end if;
752                                 --object/tangible/component/armor/armor_segment_enhancement_brackaset.iff
753                                 elsif template_id = 981227534 then
754                                         AddObjVar('attribute.bonus.0',0,'5');
755                                 --object/tangible/component/armor/armor_segment_enhancement_fambaa.iff
756                                 elsif template_id = -613110139 then
757                                         AddObjVar('attribute.bonus.0',0,'5');
758                                 --object/tangible/component/armor/armor_segment_enhancement_janta.iff
759                                 elsif template_id = 188520444 then
760                                         AddObjVar('attribute.bonus.0',0,'10');
761                                 --object/tangible/component/armor/armor_segment_enhancement_kimogila.iff
762                                 elsif template_id = -589817340 then
763                                         AddObjVar('attribute.bonus.0',0,'10');
764                                 --object/tangible/component/armor/armor_segment_enhancement_krayt.iff
765                                 elsif template_id = 1740191859 then
766                                         AddObjVar('attribute.bonus.0',0,'15');
767                                 --object/tangible/component/armor/armor_segment_enhancement_nightsister.iff
768                                 elsif template_id = -1464343893 then
769                                         AddObjVar('attribute.bonus.0',0,'15');
770                                 --object/tangible/component/armor/armor_segment_enhancement_rancor.iff
771                                 elsif template_id = -2022305605 then
772                                         AddObjVar('attribute.bonus.0',0,'15');
773                                 --object/tangible/component/armor/armor_segment_enhancement_sharnaff.iff
774                                 elsif template_id = 810379093 then
775                                         AddObjVar('attribute.bonus.0',0,'5');
776                                 --object/tangible/component/armor/armor_segment_enhancement_voritor_lizard.iff
777                                 elsif template_id = -965865145 then
778                                         AddObjVar('attribute.bonus.0',0,'5');
779                                 --pet_stimpack
780                                 elsif template_id = -171018882 then
781                                         RemoveScript('item.comestible.pet_med');
782                                         AddScript('item.medicine.stimpack_pet');
783                                 --pet_stimpack
784                                 elsif template_id = 237854314 then
785                                         RemoveScript('item.comestible.pet_med');
786                                         AddScript('item.medicine.stimpack_pet');
787                                 --pet_stimpack
788                                 elsif template_id = 1193294311 then
789                                         RemoveScript('item.comestible.pet_med');
790                                         AddScript('item.medicine.stimpack_pet');
791                                 --pet_stimpack
792                                 elsif template_id = -1674079888 then
793                                         RemoveScript('item.comestible.pet_med');
794                                         AddScript('item.medicine.stimpack_pet');
795                                 --object/draft_schematic/weapon/component/blade_vibro_unit.iff
796                                 elsif template_id = -470906696 then
797                                         ModifyObjVar(prefix || 'minDamage',prefix || 'minDamage',2,rangeTableType(rangeType(8,15,8,14),rangeType(15,24,14,16)));
798                                         ModifyObjVar(prefix || 'maxDamage',prefix || 'maxDamage',2,rangeTableType(rangeType(11,23,21,26),rangeType(23,54,26,30)));
799                                         SetWoundChance(0);
800                                         SetAttackCost(-3);                                      
801                                 --object/draft_schematic/weapon/component/blade_vibro_unit_advanced.iff
802                                 elsif template_id = 344340565 then
803                                         ModifyObjVar(prefix || 'minDamage',prefix || 'minDamage',2,rangeTableType(rangeType(22,28,13,26),rangeType(28,38,26,30)));
804                                         ModifyObjVar(prefix || 'maxDamage',prefix || 'maxDamage',2,rangeTableType(rangeType(32,42,42,53),rangeType(42,69,53,60)));
805                                         ModifyObjVar(prefix || 'attackSpeed',prefix || 'attackSpeed',2,rangeTableType(rangeType(-15,0,-20,0)));
806                                         SetWoundChance(0);
807                                         SetAttackCost(-6);                                      
808                                 --carbine_e11_mk2 from quest
809                                 elsif template_id = -1839044042 then
810                                         HandleWeaponDots;
811                                         ConvertMinDamage(rangeTableType(rangeType(99,189,255,486),rangeType(189,216,486,556)));
812                                         ConvertMaxDamage(rangeTableType(rangeType(297,378,763,971),rangeType(378,432,971,1110)));
813                                         ConvertWoundChance(rangeTableType(rangeType(1,13,2,25),rangeType(13,15.6,25,30)));
814                                         SetWeaponBaseStats(94,0,0,50,2);
815                                         if isSchematic = TRUE or isFactory = TRUE then
816                                                 DeleteCraftingComponents;
817                                                 if isSchematic = TRUE then
818                                                         DeleteObjVar('crafting_attributes.crafting:*');
819                                                         new_schematic_id := -1108671633;
820                                                 else
821                                                         ModifyObjVar('draftSchematic','draftSchematic',0,-1108671633);
822                                                 end if;
823                                                 SetTemplateText(-746051337);
824                                         else
825                                                 SetNewTemplateId(-746051337);  --convert to E11 Mark II
826                                                 AddScript('systems.combat.combat_weapon');
827                                         end if;
828                                 end if;
830                                 -- Save the changes
831                                 if isObjModified = TRUE then
832                                         begin
833                                                 stmt := 'update objects set '
834                                                         || 'objvar_0_name = :o0n, objvar_0_type = :o0t, objvar_0_value = :o0v, '
835                                                         || 'objvar_1_name = :o1n, objvar_1_type = :o1t, objvar_1_value = :o1v, '
836                                                         || 'objvar_2_name = :o2n, objvar_2_type = :o2t, objvar_2_value = :o2v, '
837                                                         || 'objvar_3_name = :o3n, objvar_3_type = :o3t, objvar_3_value = :o3v, '
838                                                         || 'objvar_4_name = :o4n, objvar_4_type = :o4t, objvar_4_value = :o4v, '
839                                                         || 'objvar_5_name = :o5n, objvar_5_type = :o5t, objvar_5_value = :o5v, '
840                                                         || 'objvar_6_name = :o6n, objvar_6_type = :o6t, objvar_6_value = :o6v, '
841                                                         || 'objvar_7_name = :o7n, objvar_7_type = :o7t, objvar_7_value = :o7v, '
842                                                         || 'objvar_8_name = :o8n, objvar_8_type = :o8t, objvar_8_value = :o8v, '
843                                                         || 'objvar_9_name = :o9n, objvar_9_type = :o9t, objvar_9_value = :o9v, '
844                                                         || 'objvar_10_name = :o10n, objvar_10_type = :o10t, objvar_10_value = :o10v, '
845                                                         || 'objvar_11_name = :o11n, objvar_11_type = :o11t, objvar_11_value = :o11v, '
846                                                         || 'objvar_12_name = :o12n, objvar_12_type = :o12t, objvar_12_value = :o12v, '
847                                                         || 'objvar_13_name = :o13n, objvar_13_type = :o13t, objvar_13_value = :o13v, '
848                                                         || 'objvar_14_name = :o14n, objvar_14_type = :o14t, objvar_14_value = :o14v, '
849                                                         || 'objvar_15_name = :o15n, objvar_15_type = :o15t, objvar_15_value = :o15v, '
850                                                         || 'objvar_16_name = :o16n, objvar_16_type = :o16t, objvar_16_value = :o16v, '
851                                                         || 'objvar_17_name = :o17n, objvar_17_type = :o17t, objvar_17_value = :o17v, '
852                                                         || 'objvar_18_name = :o18n, objvar_18_type = :o18t, objvar_18_value = :o18v, '
853                                                         || 'objvar_19_name = :o19n, objvar_19_type = :o19t, objvar_19_value = :o19v, '
854                                                         || 'script_list = :sl, object_template_id = :otid, '
855                                                         || 'object_name = :obn, name_string_table = :nstb, name_string_text = :nstx, '
856                                                         || 'conversion_id = :version '
857                                                         || 'where object_id = :id';
859                                                 execute immediate stmt using
860                                                         Obj_ObjVars(1).objvar_name, Obj_ObjVars(1).objvar_type, Obj_ObjVars(1).objvar_value,
861                                                         Obj_ObjVars(2).objvar_name, Obj_ObjVars(2).objvar_type, Obj_ObjVars(2).objvar_value,
862                                                         Obj_ObjVars(3).objvar_name, Obj_ObjVars(3).objvar_type, Obj_ObjVars(3).objvar_value,
863                                                         Obj_ObjVars(4).objvar_name, Obj_ObjVars(4).objvar_type, Obj_ObjVars(4).objvar_value,
864                                                         Obj_ObjVars(5).objvar_name, Obj_ObjVars(5).objvar_type, Obj_ObjVars(5).objvar_value,
865                                                         Obj_ObjVars(6).objvar_name, Obj_ObjVars(6).objvar_type, Obj_ObjVars(6).objvar_value,
866                                                         Obj_ObjVars(7).objvar_name, Obj_ObjVars(7).objvar_type, Obj_ObjVars(7).objvar_value,
867                                                         Obj_ObjVars(8).objvar_name, Obj_ObjVars(8).objvar_type, Obj_ObjVars(8).objvar_value,
868                                                         Obj_ObjVars(9).objvar_name, Obj_ObjVars(9).objvar_type, Obj_ObjVars(9).objvar_value,
869                                                         Obj_ObjVars(10).objvar_name, Obj_ObjVars(10).objvar_type, Obj_ObjVars(10).objvar_value,
870                                                         Obj_ObjVars(11).objvar_name, Obj_ObjVars(11).objvar_type, Obj_ObjVars(11).objvar_value,
871                                                         Obj_ObjVars(12).objvar_name, Obj_ObjVars(12).objvar_type, Obj_ObjVars(12).objvar_value,
872                                                         Obj_ObjVars(13).objvar_name, Obj_ObjVars(13).objvar_type, Obj_ObjVars(13).objvar_value,
873                                                         Obj_ObjVars(14).objvar_name, Obj_ObjVars(14).objvar_type, Obj_ObjVars(14).objvar_value,
874                                                         Obj_ObjVars(15).objvar_name, Obj_ObjVars(15).objvar_type, Obj_ObjVars(15).objvar_value,
875                                                         Obj_ObjVars(16).objvar_name, Obj_ObjVars(16).objvar_type, Obj_ObjVars(16).objvar_value,
876                                                         Obj_ObjVars(17).objvar_name, Obj_ObjVars(17).objvar_type, Obj_ObjVars(17).objvar_value,
877                                                         Obj_ObjVars(18).objvar_name, Obj_ObjVars(18).objvar_type, Obj_ObjVars(18).objvar_value,
878                                                         Obj_ObjVars(19).objvar_name, Obj_ObjVars(19).objvar_type, Obj_ObjVars(19).objvar_value,
879                                                         Obj_ObjVars(20).objvar_name, Obj_ObjVars(20).objvar_type, Obj_ObjVars(20).objvar_value,
880                                                         script_list, new_template_id,
881                                                         object_name, name_table, name_text,
882                                                         conversion_id,
883                                                         object_id;
884                                         exception
885                                                 when others then
886                                                         err_num := SQLCODE;
887                                                         dbms_output.put_line('Error in object update(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
888                                                         db_error_logger.dblogerror(err_num, 'Error in object update');
889                                         end;
890                                 end if;
892                                 if isWeaponObj = TRUE then
893                                         begin
894                                                 stmt := 'update weapon_objects set '
895                                                         || 'min_damage = :mindam, '
896                                                         || 'max_damage = :maxdam, '
897                                                         || 'attack_speed = :spd, '
898                                                         || 'wound_chance = :wnd, '
899                                                         || 'accuracy = :accuracy, '
900                                                         || 'attack_cost = :ac, '
901                                                         || 'min_range = :mindrng, '
902                                                         || 'max_range = :maxrng, '
903                                                         || 'damage_type = :dmgtype, '
904                                                         || 'elemental_type = :eletype, '
905                                                         || 'elemental_value = :elevalue '
906                                                         || 'where object_id = :id';
908                                                 execute immediate stmt using
909                                                         weapon_attribs.min_damage,
910                                                         weapon_attribs.max_damage,
911                                                         weapon_attribs.attack_speed,
912                                                         weapon_attribs.wound_chance,
913                                                         weapon_attribs.accuracy,
914                                                         weapon_attribs.attack_cost,
915                                                         weapon_attribs.min_range,
916                                                         weapon_attribs.max_range,                               
917                                                         weapon_attribs.damage_type,                             
918                                                         weapon_attribs.elemental_type,                          
919                                                         weapon_attribs.elemental_value,                         
920                                                         object_id;
921                                         exception
922                                                 when others then
923                                                         err_num := SQLCODE;
924                                                         dbms_output.put_line('Error in weapon update(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
925                                                         db_error_logger.dblogerror(err_num, 'Error in weapon update');
926                                         end;
927                                 end if;
929                                 i := deleted_objvars.first;
930                                 while i is not null loop
931                                         begin
932                                                 stmt := 'delete from object_variables '
933                                                         || 'where object_id = :id and name_id = :oldname';
935                                                 execute immediate stmt using
936                                                         object_id,
937                                                         OV_ObjVars(deleted_objvars(i)).old_objvar_name_id;
939                                                 i := deleted_objvars.next(i);
940                                         exception
941                                                 when others then
942                                                         err_num := SQLCODE;
943                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with deleted_objvars(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
944                                                         db_error_logger.dblogerror(err_num, 'Error with deleted_objvars');
945                                                         i := deleted_objvars.next(i);
946                                         end;
947                                 end loop;
949                                 i := added_objvars.first;
950                                 while i is not null loop
951                                         begin
952                                                 stmt := 'insert into object_variables values '
953                                                         || '(:id, :name, :type, :value, 0)';
955                                                 execute immediate stmt using
956                                                         object_id,
957                                                         OV_ObjVars(added_objvars(i)).objvar_name_id,
958                                                         OV_ObjVars(added_objvars(i)).objvar_type,
959                                                         OV_ObjVars(added_objvars(i)).objvar_value;
961                                                 i := added_objvars.next(i);
962                                         exception
963                                                 when others then
964                                                         err_num := SQLCODE;
965                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with added_objvars(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
966                                                         db_error_logger.dblogerror(err_num, 'Error with added_objvars');
967                                                 i := added_objvars.next(i);
968                                         end;
969                                 end loop;
971                                 i := updated_objvars.first;
972                                 while i is not null loop
973                                         begin
974                                                 stmt := 'update object_variables set '
975                                                         || 'name_id = :name, type = :type, value = :value '
976                                                         || 'where object_id = :id and name_id = :oldname';
978                                                 execute immediate stmt using
979                                                         objvarNameIdMap(OV_ObjVars(updated_objvars(i)).objvar_name),
980                                                         OV_ObjVars(updated_objvars(i)).objvar_type,
981                                                         OV_ObjVars(updated_objvars(i)).objvar_value,
982                                                         object_id,
983                                                         OV_ObjVars(updated_objvars(i)).old_objvar_name_id;
985                                                 i := updated_objvars.next(i);
986                                         exception
987                                                 when others then
988                                                         err_num := SQLCODE;
989                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with updated_objvars(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
990                                                         db_error_logger.dblogerror(err_num, 'Error with updated_objvars');
991                                                         i := updated_objvars.next(i);
992                                         end;
993                                 end loop;
995                                 i := deleted_attribs.first;
996                                 while i is not null loop
997                                         begin
998                                                 stmt := 'delete from manf_schematic_attributes '
999                                                         || 'where object_id = :id and attribute_type = :attribute';
1001                                                 execute immediate stmt using
1002                                                         object_id,
1003                                                         deleted_attribs(i);
1005                                                 i := deleted_attribs.next(i);
1006                                         exception
1007                                                 when others then
1008                                                         err_num := SQLCODE;
1009                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with  deleted_attribs(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1010                                                         db_error_logger.dblogerror(err_num, 'Error with  deleted_attribs');
1011                                                         i := deleted_attribs.next(i);
1012                                         end;
1013                                 end loop;
1015                                 i := added_attribs.first;
1016                                 while i is not null loop
1017                                         begin
1018                                                 stmt := 'insert into manf_schematic_attributes values '
1019                                                         || '(:id, :attrib, :value)';
1021                                                 execute immediate stmt using
1022                                                         object_id,
1023                                                         manf_attributes(added_attribs(i)).attribute,
1024                                                         manf_attributes(added_attribs(i)).value;
1026                                                 i := added_attribs.next(i);
1027                                         exception
1028                                                 when others then
1029                                                         err_num := SQLCODE;
1030                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with  added_attribs(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1031                                                         db_error_logger.dblogerror(err_num, 'Error with  added_attribs');
1032                                                 i := added_attribs.next(i);
1033                                         end;
1034                                 end loop;
1036                                 i := updated_attribs.first;
1037                                 while i is not null loop
1038                                         begin
1039                                                 stmt := 'update manf_schematic_attributes set '
1040                                                         || 'attribute_type = :attribute, value = :value '
1041                                                         || 'where object_id = :id and attribute_type = :oldname';
1043                                                 execute immediate stmt using
1044                                                         manf_attributes(updated_attribs(i)).attribute,
1045                                                         manf_attributes(updated_attribs(i)).value,
1046                                                         object_id,
1047                                                         updated_attribs(i);
1049                                                 i := updated_attribs.next(i);
1050                                         exception
1051                                                 when others then
1052                                                         err_num := SQLCODE;
1053                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with  updated_attribs(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1054                                                         db_error_logger.dblogerror(err_num, 'Error with  updated_attribs');
1055                                                         i := updated_attribs.next(i);
1056                                         end;
1057                                 end loop;
1058                                 
1059                                 if (isSchematic = TRUE) and (new_schematic_id != 0) then
1060                                         begin
1061                                                 stmt := 'update manf_schematic_objects set '
1062                                                         || 'draft_schematic = :new_id '
1063                                                         || 'where object_id = :id';
1065                                                 execute immediate stmt using
1066                                                         new_schematic_id,
1067                                                         object_id;
1068                                         exception
1069                                                 when others then
1070                                                         err_num := SQLCODE;
1071                                                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') with  update_schematic(' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1072                                                         db_error_logger.dblogerror(err_num, 'Error with  update_schematic');
1073                                                         i := updated_attribs.next(i);
1074                                         end;
1075                                 end if;
1077                                 cvt := cvt + 1;
1078                         end if;
1079                                 idx := idx + 1;
1080                                 -- commit every 100,000 records
1081                                 if idx > 99999 then
1082                                         commit;
1083                                         if use_rbs is not null then
1084                                                 execute immediate 'set transaction use rollback segment ' || use_rbs;
1085                                         end if;
1086                                         dbms_output.put_line('100,000 rows = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1087                                         cnt := cnt + idx;
1088                                         idx := 0;
1089                                 end if;                                 
1090                         end;
1091                         fetch objCursor into objRow;
1092                 end loop;
1093                 --commit;
1094                 close attributeCursor;
1095                 close schematicCursor;
1096                 close weaponCursor;
1097                 close objVarCursor;
1098                 close objCursor;
1099                 cnt := cnt + idx;
1100                 dbms_output.put_line('end time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1101                 dbms_output.put_line('converted = ' || to_char(cvt));
1102                 dbms_output.put_line('total count = ' || to_char(cnt));
1103         exception
1104                 when others then
1105                         err_num := SQLCODE;
1106                         dbms_output.put_line('Error (' || SQLERRM(err_num) || ') in DoItemConversionBatch (' || object_id || ') - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
1107                         db_error_logger.dblogerror(err_num, 'Error in DoItemConversionBatch');
1108         end;
1110         function InitializeData return boolean
1111         is
1112                 objvarNameIdRow object_variable_names%rowtype;
1113                 -- ALL added/updated objvar names MUST be in this list
1114                 cursor objvarNameIdCursor is
1115                 select id, name from object_variable_names
1116                 where name in (
1117                         'armor.armorCategory',
1118                         'armor.armorLevel',
1119                         'armor.armorencumbrance',
1120                         'armor.condition',
1121                         'armor.effectiveness',
1122                         'armor.encumbrance',
1123                         'armor.encumbranceSplit',
1124                         'armor.general_protection',
1125                         'armor.layer0',
1126                         'armor.layer13',
1127                         'armor.layer14',
1128                         'armor.layer15',
1129                         'armor.mandDeconstruct',
1130                         'armor.rating',
1131                         'armor.recharge_rate',
1132                         'armor.risDeconstruct',
1133                         'armor.special.1',
1134                         'armor.special.1024',
1135                         'armor.special.128',
1136                         'armor.special.16',
1137                         'armor.special.2',
1138                         'armor.special.2048',
1139                         'armor.special.256',
1140                         'armor.special.32',
1141                         'armor.special.4',
1142                         'armor.special.4096',
1143                         'armor.special.512',
1144                         'armor.special.64',
1145                         'armor.special.8',
1146                         'armor.vulnerability',
1147                         'armorCategory',
1148                         'armorLevel',
1149                         'biolink.faction_points',
1150                         'blindChance',
1151                         'blindDuration',
1152                         'buff_name',
1153                         'burnDuration',
1154                         'burnIntensity',
1155                         'crafting_attributes.crafting:accuracy',
1156                         'crafting_attributes.crafting:armor_condition',
1157                         'crafting_attributes.crafting:armor_general_protection',
1158                         'crafting_attributes.crafting:armor_layer0',
1159                         'crafting_attributes.crafting:armor_layer1',
1160                         'crafting_attributes.crafting:armor_layer2',
1161                         'crafting_attributes.crafting:armor_layer4',
1162                         'crafting_attributes.crafting:armor_layer5',
1163                         'crafting_attributes.crafting:armor_layer6',
1164                         'crafting_attributes.crafting:armor_layer7',
1165                         'crafting_attributes.crafting:armor_layer12',
1166                         'crafting_attributes.crafting:attackActionCost',
1167                         'crafting_attributes.crafting:attackCost',
1168                         'crafting_attributes.crafting:attackHealthCost',
1169                         'crafting_attributes.crafting:attackMindCost',
1170                         'crafting_attributes.crafting:attackSpeed',
1171                         'crafting_attributes.crafting:condition',
1172                         'crafting_attributes.crafting:damageType',
1173                         'crafting_attributes.crafting:effect',
1174                         'crafting_attributes.crafting:efficiency',
1175                         'crafting_attributes.crafting:elementalType',
1176                         'crafting_attributes.crafting:elementalValue',
1177                         'crafting_attributes.crafting:flavor',
1178                         'crafting_attributes.crafting:general_protection',
1179                         'crafting_attributes.crafting:hitPoints',
1180                         'crafting_attributes.crafting:maxDamage',
1181                         'crafting_attributes.crafting:maxRange',
1182                         'crafting_attributes.crafting:maxRangeMod',
1183                         'crafting_attributes.crafting:midRange',
1184                         'crafting_attributes.crafting:midRangeMod',
1185                         'crafting_attributes.crafting:minDamage',
1186                         'crafting_attributes.crafting:minRange',
1187                         'crafting_attributes.crafting:minRangeMod',
1188                         'crafting_attributes.crafting:nutrition',
1189                         'crafting_attributes.crafting:power',
1190                         'crafting_attributes.crafting:recharge_rate',
1191                         'crafting_attributes.crafting:special_protection',
1192                         'crafting_attributes.crafting:woundChance',
1193                         'crafting_attributes.crafting:zeroRangeMod',
1194                         'crafting_components.accuracy',
1195                         'crafting_components.armor_armorencumbrance',
1196                         'crafting_components.armor_condition',
1197                         'crafting_components.armor_general_protection',
1198                         'crafting_components.armor_layer0',
1199                         'crafting_components.armor_layer1',
1200                         'crafting_components.armor_layer2',
1201                         'crafting_components.armor_layer4',
1202                         'crafting_components.armor_layer5',
1203                         'crafting_components.armor_layer6',
1204                         'crafting_components.armor_layer7',
1205                         'crafting_components.armor_layer12',
1206                         'crafting_components.attackActionCost',
1207                         'crafting_components.attackCost',
1208                         'crafting_components.attackHealthCost',
1209                         'crafting_components.attackMindCost',
1210                         'crafting_components.attackSpeed',
1211                         'crafting_components.attribute.bonus.0',
1212                         'crafting_components.attribute.bonus.1',
1213                         'crafting_components.attribute.bonus.2',
1214                         'crafting_components.attribute.bonus.3',
1215                         'crafting_components.attribute.bonus.4',
1216                         'crafting_components.attribute.bonus.5',
1217                         'crafting_components.attribute.bonus.6',
1218                         'crafting_components.attribute.bonus.7',
1219                         'crafting_components.attribute.bonus.8',
1220                         'crafting_components.condition',
1221                         'crafting_components.damageType',
1222                         'crafting_components.elementalType',
1223                         'crafting_components.elementalValue',
1224                         'crafting_components.general_protection',
1225                         'crafting_components.hitPoints',
1226                         'crafting_components.layer13',
1227                         'crafting_components.layer14',
1228                         'crafting_components.layer15',
1229                         'crafting_components.maxDamage',
1230                         'crafting_components.maxRange',
1231                         'crafting_components.maxRangeMod',
1232                         'crafting_components.midRange',
1233                         'crafting_components.midRangeMod',
1234                         'crafting_components.minDamage',
1235                         'crafting_components.minRange',
1236                         'crafting_components.minRangeMod',
1237                         'crafting_components.recharge_rate',
1238                         'crafting_components.woundChance',
1239                         'crafting_components.zeroRangeMod',
1240                         'draftSchematic',
1241                         'duration',
1242                         'effect_class',
1243                         'effectiveness',
1244                         'filling',
1245                         'ImAnInvalidSchematic',
1246                         'intAOEDamagePercent',
1247                         'intWeaponType',
1248                         'jedi.crystal.stats.accuracy',
1249                         'jedi.crystal.stats.attack_cost',
1250                         'jedi.crystal.stats.damage_type',
1251                         'jedi.crystal.stats.elemental_type',
1252                         'jedi.crystal.stats.elemental_value',
1253                         'jedi.crystal.stats.force',
1254                         'jedi.crystal.stats.max_dmg',
1255                         'jedi.crystal.stats.max_rng',
1256                         'jedi.crystal.stats.min_dmg',
1257                         'jedi.crystal.stats.min_rng',
1258                         'jedi.crystal.stats.speed',
1259                         'jedi.crystal.stats.wound',
1260                         'jedi.saber.base_stats.accuracy',
1261                         'jedi.saber.base_stats.attack_cost',
1262                         'jedi.saber.base_stats.damage_type',
1263                         'jedi.saber.base_stats.elemental_type',
1264                         'jedi.saber.base_stats.elemental_value',
1265                         'jedi.saber.base_stats.force',
1266                         'jedi.saber.base_stats.max_dmg',
1267                         'jedi.saber.base_stats.max_rng',
1268                         'jedi.saber.base_stats.min_dmg',
1269                         'jedi.saber.base_stats.min_rng',
1270                         'jedi.saber.base_stats.speed',
1271                         'jedi.saber.base_stats.wound',
1272                         'jedi.saber.force',
1273                         'healing.power',
1274                         'powerup.accuracy',
1275                         'powerup.actionCost',
1276                         'powerup.damage',
1277                         'powerup.effect',
1278                         'powerup.efficiency',
1279                         'powerup.speed',
1280                         'powerup.usesLeft',
1281                         'powerup.wound',
1282                         'reuseTimer',
1283                         'skillmod.bonus.pistol_speed',
1284                         'slowDuration',
1285                         'slowIntensity',
1286                         'spice.name',
1287                         'strWeaponType',
1288                         'weapon.intNoCertRequired',
1289                         'weaponType'
1290                 );
1291                 maxNameId number;
1292                 
1293                 schematicRow schematic_templates%rowtype;
1294                 cursor schematicCursor is
1295                 select schematic_id, object_template_id
1296                 from schematic_templates;
1297                 
1298                 v varchar2(500);
1299                 stmt varchar2(4000);
1300         begin
1301                 -- initialize
1302                 free_slots  := numTable(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
1303                 Obj_ObjVars := objectObjVarArray();
1304                 Obj_Objvars.extend(20);
1305                 updated_objvars  := varcharTable();
1306                 deleted_objvars := varcharTable();
1307                 added_objvars   := varcharTable();
1308                 updated_attribs  := varcharTable();
1309                 deleted_attribs := varcharTable();
1310                 added_attribs   := varcharTable();
1311                 -- Data Table for relative weapon DoT powers
1312                 dots_matrix('fire')(6) := 12;
1313                 dots_matrix('fire')(0) := 9;
1314                 dots_matrix('fire')(3) := 6;
1315                 dots_matrix('poison')(6) := 11;
1316                 dots_matrix('poison')(0) := 8;
1317                 dots_matrix('poison')(3) := 5;
1318                 dots_matrix('disease')(6) := 10;
1319                 dots_matrix('disease')(0) := 7;
1320                 dots_matrix('disease')(3) := 4;
1321                 dots_matrix('bleeds')(6) := 3;
1322                 dots_matrix('bleeds')(0) := 2;
1323                 dots_matrix('bleeds')(3) := 1;
1325                 objvarNameIdMap('armor.armorCategory') := 0;
1326                 objvarNameIdMap('armor.armorLevel') := 0;
1327                 objvarNameIdMap('armor.armorencumbrance') := 0;
1328                 objvarNameIdMap('armor.condition') := 0;
1329                 objvarNameIdMap('armor.effectiveness') := 0;
1330                 objvarNameIdMap('armor.encumbrance') := 0;
1331                 objvarNameIdMap('armor.encumbranceSplit') := 0;
1332                 objvarNameIdMap('armor.general_protection') := 0;
1333                 objvarNameIdMap('armor.layer0') := 0;
1334                 objvarNameIdMap('armor.layer14') := 0;
1335                 objvarNameIdMap('armor.layer13') := 0;
1336                 objvarNameIdMap('armor.layer15') := 0;
1337                 objvarNameIdMap('armor.mandDeconstruct') := 0;
1338                 objvarNameIdMap('armor.rating') := 0;
1339                 objvarNameIdMap('armor.recharge_rate') := 0;
1340                 objvarNameIdMap('armor.risDeconstruct') := 0;
1341                 objvarNameIdMap('armor.special.1') := 0;
1342                 objvarNameIdMap('armor.special.1024') := 0;
1343                 objvarNameIdMap('armor.special.128') := 0;
1344                 objvarNameIdMap('armor.special.16') := 0;
1345                 objvarNameIdMap('armor.special.2') := 0;
1346                 objvarNameIdMap('armor.special.2048') := 0;
1347                 objvarNameIdMap('armor.special.256') := 0;
1348                 objvarNameIdMap('armor.special.32') := 0;
1349                 objvarNameIdMap('armor.special.4') := 0;
1350                 objvarNameIdMap('armor.special.4096') := 0;
1351                 objvarNameIdMap('armor.special.512') := 0;
1352                 objvarNameIdMap('armor.special.64') := 0;
1353                 objvarNameIdMap('armor.special.8') := 0;
1354                 objvarNameIdMap('armor.vulnerability') := 0;
1355                 objvarNameIdMap('armorCategory') := 0;
1356                 objvarNameIdMap('armorLevel') := 0;
1357                 objvarNameIdMap('biolink.faction_points') := 0;
1358                 objvarNameIdMap('blindChance') := 0;
1359                 objvarNameIdMap('blindDuration') := 0;
1360                 objvarNameIdMap('buff_name') := 0;
1361                 objvarNameIdMap('burnDuration') := 0;
1362                 objvarNameIdMap('burnIntensity') := 0;
1363                 objvarNameIdMap('crafting_attributes.crafting:accuracy') := 0;
1364                 objvarNameIdMap('crafting_attributes.crafting:armor_general_protection') := 0;
1365                 objvarNameIdMap('crafting_attributes.crafting:armor_condition') := 0;
1366                 objvarNameIdMap('crafting_attributes.crafting:armor_layer0') := 0;
1367                 objvarNameIdMap('crafting_attributes.crafting:armor_layer1') := 0;
1368                 objvarNameIdMap('crafting_attributes.crafting:armor_layer2') := 0;
1369                 objvarNameIdMap('crafting_attributes.crafting:armor_layer4') := 0;
1370                 objvarNameIdMap('crafting_attributes.crafting:armor_layer5') := 0;
1371                 objvarNameIdMap('crafting_attributes.crafting:armor_layer6') := 0;
1372                 objvarNameIdMap('crafting_attributes.crafting:armor_layer7') := 0;
1373                 objvarNameIdMap('crafting_attributes.crafting:armor_layer12') := 0;
1374                 objvarNameIdMap('crafting_attributes.crafting:attackActionCost') := 0;
1375                 objvarNameIdMap('crafting_attributes.crafting:attackCost') := 0;
1376                 objvarNameIdMap('crafting_attributes.crafting:attackHealthCost') := 0;
1377                 objvarNameIdMap('crafting_attributes.crafting:attackMindCost') := 0;
1378                 objvarNameIdMap('crafting_attributes.crafting:attackSpeed') := 0;
1379                 objvarNameIdMap('crafting_attributes.crafting:condition') := 0;
1380                 objvarNameIdMap('crafting_attributes.crafting:damageType') := 0;
1381                 objvarNameIdMap('crafting_attributes.crafting:effect') := 0;
1382                 objvarNameIdMap('crafting_attributes.crafting:efficiency') := 0;
1383                 objvarNameIdMap('crafting_attributes.crafting:elementalType') := 0;
1384                 objvarNameIdMap('crafting_attributes.crafting:elementalValue') := 0;
1385                 objvarNameIdMap('crafting_attributes.crafting:flavor') := 0;
1386                 objvarNameIdMap('crafting_attributes.crafting:general_protection') := 0;
1387                 objvarNameIdMap('crafting_attributes.crafting:hitPoints') := 0;
1388                 objvarNameIdMap('crafting_attributes.crafting:maxDamage') := 0;
1389                 objvarNameIdMap('crafting_attributes.crafting:maxRange') := 0;
1390                 objvarNameIdMap('crafting_attributes.crafting:maxRangeMod') := 0;
1391                 objvarNameIdMap('crafting_attributes.crafting:midRange') := 0;
1392                 objvarNameIdMap('crafting_attributes.crafting:midRangeMod') := 0;
1393                 objvarNameIdMap('crafting_attributes.crafting:minDamage') := 0;
1394                 objvarNameIdMap('crafting_attributes.crafting:minRange') := 0;
1395                 objvarNameIdMap('crafting_attributes.crafting:minRangeMod') := 0;
1396                 objvarNameIdMap('crafting_attributes.crafting:nutrition') := 0;
1397                 objvarNameIdMap('crafting_attributes.crafting:power') := 0;
1398                 objvarNameIdMap('crafting_attributes.crafting:recharge_rate') := 0;
1399                 objvarNameIdMap('crafting_attributes.crafting:special_protection') := 0;
1400                 objvarNameIdMap('crafting_attributes.crafting:woundChance') := 0;
1401                 objvarNameIdMap('crafting_attributes.crafting:zeroRangeMod') := 0;
1402                 objvarNameIdMap('crafting_components.accuracy') := 0;
1403                 objvarNameIdMap('crafting_components.armor_armorencumbrance') := 0;
1404                 objvarNameIdMap('crafting_components.armor_condition') := 0;
1405                 objvarNameIdMap('crafting_components.armor_general_protection') := 0;
1406                 objvarNameIdMap('crafting_components.armor_layer0') := 0;
1407                 objvarNameIdMap('crafting_components.armor_layer1') := 0;
1408                 objvarNameIdMap('crafting_components.armor_layer2') := 0;
1409                 objvarNameIdMap('crafting_components.armor_layer4') := 0;
1410                 objvarNameIdMap('crafting_components.armor_layer5') := 0;
1411                 objvarNameIdMap('crafting_components.armor_layer6') := 0;
1412                 objvarNameIdMap('crafting_components.armor_layer7') := 0;
1413                 objvarNameIdMap('crafting_components.armor_layer12') := 0;
1414                 objvarNameIdMap('crafting_components.attackActionCost') := 0;
1415                 objvarNameIdMap('crafting_components.attackCost') := 0;
1416                 objvarNameIdMap('crafting_components.attackHealthCost') := 0;
1417                 objvarNameIdMap('crafting_components.attackMindCost') := 0;
1418                 objvarNameIdMap('crafting_components.attackSpeed') := 0;
1419                 objvarNameIdMap('crafting_components.attribute.bonus.0') := 0;
1420                 objvarNameIdMap('crafting_components.attribute.bonus.1') := 0;
1421                 objvarNameIdMap('crafting_components.attribute.bonus.2') := 0;
1422                 objvarNameIdMap('crafting_components.attribute.bonus.3') := 0;
1423                 objvarNameIdMap('crafting_components.attribute.bonus.4') := 0;
1424                 objvarNameIdMap('crafting_components.attribute.bonus.5') := 0;
1425                 objvarNameIdMap('crafting_components.attribute.bonus.6') := 0;
1426                 objvarNameIdMap('crafting_components.attribute.bonus.7') := 0;
1427                 objvarNameIdMap('crafting_components.attribute.bonus.8') := 0;
1428                 objvarNameIdMap('crafting_components.condition') := 0;
1429                 objvarNameIdMap('crafting_components.damageType') := 0;
1430                 objvarNameIdMap('crafting_components.elementalType') := 0;
1431                 objvarNameIdMap('crafting_components.elementalValue') := 0;
1432                 objvarNameIdMap('crafting_components.general_protection') := 0;
1433                 objvarNameIdMap('crafting_components.hitPoints') := 0;
1434                 objvarNameIdMap('crafting_components.layer13') := 0;
1435                 objvarNameIdMap('crafting_components.layer14') := 0;
1436                 objvarNameIdMap('crafting_components.layer15') := 0;
1437                 objvarNameIdMap('crafting_components.maxDamage') := 0;
1438                 objvarNameIdMap('crafting_components.maxRange') := 0;
1439                 objvarNameIdMap('crafting_components.maxRangeMod') := 0;
1440                 objvarNameIdMap('crafting_components.midRange') := 0;
1441                 objvarNameIdMap('crafting_components.midRangeMod') := 0;
1442                 objvarNameIdMap('crafting_components.minDamage') := 0;
1443                 objvarNameIdMap('crafting_components.minRange') := 0;
1444                 objvarNameIdMap('crafting_components.minRangeMod') := 0;
1445                 objvarNameIdMap('crafting_components.recharge_rate') := 0;
1446                 objvarNameIdMap('crafting_components.woundChance') := 0;
1447                 objvarNameIdMap('crafting_components.zeroRangeMod') := 0;
1448                 objvarNameIdMap('draftSchematic') := 0;
1449                 objvarNameIdMap('duration') := 0;
1450                 objvarNameIdMap('effect_class') := 0;
1451                 objvarNameIdMap('effectiveness') := 0;
1452                 objvarNameIdMap('filling') := 0;
1453                 objvarNameIdMap('ImAnInvalidSchematic') := 0;
1454                 objvarNameIdMap('intAOEDamagePercent') := 0;
1455                 objvarNameIdMap('intWeaponType') := 0;
1456                 objvarNameIdMap('jedi.crystal.stats.accuracy') := 0;
1457                 objvarNameIdMap('jedi.crystal.stats.attack_cost') := 0;
1458                 objvarNameIdMap('jedi.crystal.stats.damage_type') := 0;
1459                 objvarNameIdMap('jedi.crystal.stats.elemental_type') := 0;
1460                 objvarNameIdMap('jedi.crystal.stats.elemental_value') := 0;
1461                 objvarNameIdMap('jedi.crystal.stats.force') := 0;
1462                 objvarNameIdMap('jedi.crystal.stats.max_dmg') := 0;
1463                 objvarNameIdMap('jedi.crystal.stats.max_rng') := 0;
1464                 objvarNameIdMap('jedi.crystal.stats.min_dmg') := 0;
1465                 objvarNameIdMap('jedi.crystal.stats.min_rng') := 0;
1466                 objvarNameIdMap('jedi.crystal.stats.speed') := 0;
1467                 objvarNameIdMap('jedi.crystal.stats.wound') := 0;
1468                 objvarNameIdMap('jedi.saber.base_stats.accuracy') := 0;
1469                 objvarNameIdMap('jedi.saber.base_stats.attack_cost') := 0;
1470                 objvarNameIdMap('jedi.saber.base_stats.damage_type') := 0;
1471                 objvarNameIdMap('jedi.saber.base_stats.elemental_type') := 0;
1472                 objvarNameIdMap('jedi.saber.base_stats.elemental_value') := 0;
1473                 objvarNameIdMap('jedi.saber.base_stats.force') := 0;
1474                 objvarNameIdMap('jedi.saber.base_stats.max_dmg') := 0;
1475                 objvarNameIdMap('jedi.saber.base_stats.max_rng') := 0;
1476                 objvarNameIdMap('jedi.saber.base_stats.min_dmg') := 0;
1477                 objvarNameIdMap('jedi.saber.base_stats.min_rng') := 0;
1478                 objvarNameIdMap('jedi.saber.base_stats.speed') := 0;
1479                 objvarNameIdMap('jedi.saber.base_stats.wound') := 0;
1480                 objvarNameIdMap('jedi.saber.force') := 0;
1481                 objvarNameIdMap('healing.power') := 0;
1482                 objvarNameIdMap('powerup.accuracy') := 0;
1483                 objvarNameIdMap('powerup.actionCost') := 0;
1484                 objvarNameIdMap('powerup.damage') := 0;
1485                 objvarNameIdMap('powerup.effect') := 0;
1486                 objvarNameIdMap('powerup.efficiency') := 0;
1487                 objvarNameIdMap('powerup.speed') := 0;
1488                 objvarNameIdMap('powerup.usesLeft') := 0;
1489                 objvarNameIdMap('powerup.wound') := 0;
1490                 objvarNameIdMap('reuseTimer') := 0;
1491                 objvarNameIdMap('skillmod.bonus.pistol_speed') := 0;
1492                 objvarNameIdMap('slowDuration') := 0;
1493                 objvarNameIdMap('slowIntensity') := 0;
1494                 objvarNameIdMap('spice.name') := 0;
1495                 objvarNameIdMap('strWeaponType') := 0;
1496                 objvarNameIdMap('weapon.intNoCertRequired') := 0;
1497                 objvarNameIdMap('weaponType') := 0;
1499                 open objvarNameIdCursor;
1500                 fetch objvarNameIdCursor into objvarNameIdRow;
1501                 while objvarNameIdCursor%found loop
1502                           objvarNameIdMap(objvarNameIdRow.name) := objvarNameIdRow.id;
1503                           fetch objvarNameIdCursor into objvarNameIdRow;
1504                 end loop;
1505                 close objvarNameIdCursor;
1507                 select max(id) into maxNameId from object_variable_names;
1509                 v := objvarNameIdMap.first;
1510                 while v is not null loop
1511                         if objvarNameIdMap(v) = 0 then
1512                                 maxNameId := maxNameId + 1;
1513                                 stmt := 'insert into object_variable_names values (:id, :name)';
1514                                 execute immediate stmt using maxNameId, v;
1515                                 objvarNameIdMap(v) := maxNameId;
1516                         end if;
1517                         v := objvarNameIdMap.next(v);
1518                 end loop;
1519                 commit;
1520                 if use_rbs is not null then
1521                         execute immediate 'set transaction use rollback segment ' || use_rbs;
1522                 end if;
1524                 open schematicCursor;
1525                 fetch schematicCursor into schematicRow;
1526                 while schematicCursor%found loop
1527                           schematic_map(schematicRow.schematic_id) := schematicRow.object_template_id;
1528                           fetch schematicCursor into schematicRow;
1529                 end loop;
1530                 close schematicCursor;
1531         
1532 -- ****** BEGIN TEMPLATE ID SET ******
1533                 templateIdSet(1386184862) := 1386184862;
1534                 templateIdSet(575325453) := 575325453;
1535                 templateIdSet(1652891098) := 1652891098;
1536                 templateIdSet(1185807341) := 1185807341;
1537                 templateIdSet(913882750) := 913882750;
1538                 templateIdSet(1994709940) := 1994709940;
1539                 templateIdSet(-1489599533) := -1489599533;
1540                 templateIdSet(301359835) := 301359835;
1541                 templateIdSet(-913758478) := -913758478;
1542                 templateIdSet(306929321) := 306929321;
1543                 templateIdSet(1654528826) := 1654528826;
1544                 templateIdSet(-1981228116) := -1981228116;
1545                 templateIdSet(-1493844838) := -1493844838;
1546                 templateIdSet(-702482167) := -702482167;
1547                 templateIdSet(1360182635) := 1360182635;
1548                 templateIdSet(605165771) := 605165771;
1549                 templateIdSet(-1831667261) := -1831667261;
1550                 templateIdSet(701587845) := 701587845;
1551                 templateIdSet(-1634646786) := -1634646786;
1552                 templateIdSet(819427966) := 819427966;
1553                 templateIdSet(1073889261) := 1073889261;
1554                 templateIdSet(1449316778) := 1449316778;
1555                 templateIdSet(-1418664428) := -1418664428;
1556                 templateIdSet(-609901689) := -609901689;
1557                 templateIdSet(-1782480140) := -1782480140;
1558                 templateIdSet(-2016614241) := -2016614241;
1559                 templateIdSet(822872471) := 822872471;
1560                 templateIdSet(609499915) := 609499915;
1561                 templateIdSet(1026806068) := 1026806068;
1562                 templateIdSet(1306956967) := 1306956967;
1563                 templateIdSet(1503133620) := 1503133620;
1564                 templateIdSet(2115381959) := 2115381959;
1565                 templateIdSet(247689044) := 247689044;
1566                 templateIdSet(725211246) := 725211246;
1567                 templateIdSet(1252870946) := 1252870946;
1568                 templateIdSet(-59921878) := -59921878;
1569                 templateIdSet(-248317992) := -248317992;
1570                 templateIdSet(-171534277) := -171534277;
1571                 templateIdSet(-2062295640) := -2062295640;
1572                 templateIdSet(-127140925) := -127140925;
1573                 templateIdSet(-253929242) := -253929242;
1574                 templateIdSet(-2146951819) := -2146951819;
1575                 templateIdSet(1042717208) := 1042717208;
1576                 templateIdSet(1128757147) := 1128757147;
1577                 templateIdSet(-175663469) := -175663469;
1578                 templateIdSet(2147059193) := 2147059193;
1579                 templateIdSet(748768172) := 748768172;
1580                 templateIdSet(1551109695) := 1551109695;
1581                 templateIdSet(1302427111) := 1302427111;
1582                 templateIdSet(-1537444864) := -1537444864;
1583                 templateIdSet(-729206381) := -729206381;
1584                 templateIdSet(1231025524) := 1231025524;
1585                 templateIdSet(590525838) := 590525838;
1586                 templateIdSet(-1779280762) := -1779280762;
1587                 templateIdSet(729327903) := 729327903;
1588                 templateIdSet(-255400918) := -255400918;
1589                 templateIdSet(-2146197063) := -2146197063;
1590                 templateIdSet(-1390425255) := -1390425255;
1591                 templateIdSet(-412867955) := -412867955;
1592                 templateIdSet(-1749981410) := -1749981410;
1593                 templateIdSet(1756768751) := 1756768751;
1594                 templateIdSet(1478831607) := 1478831607;
1595                 templateIdSet(-286929665) := -286929665;
1596                 templateIdSet(1749090194) := 1749090194;
1597                 templateIdSet(183123522) := 183123522;
1598                 templateIdSet(2050980817) := 2050980817;
1599                 templateIdSet(2062241693) := 2062241693;
1600                 templateIdSet(1837916498) := 1837916498;
1601                 templateIdSet(492381377) := 492381377;
1602                 templateIdSet(108052567) := 108052567;
1603                 templateIdSet(-1552027109) := -1552027109;
1604                 templateIdSet(364712723) := 364712723;
1605                 templateIdSet(-492258227) := -492258227;
1606                 templateIdSet(1926737359) := 1926737359;
1607                 templateIdSet(33744988) := 33744988;
1608                 templateIdSet(1205005532) := 1205005532;
1609                 templateIdSet(-1767695347) := -1767695347;
1610                 templateIdSet(-428451426) := -428451426;
1611                 templateIdSet(-1520174324) := -1520174324;
1612                 templateIdSet(2132891736) := 2132891736;
1613                 templateIdSet(-907953840) := -907953840;
1614                 templateIdSet(428327186) := 428327186;
1615                 templateIdSet(-1877836182) := -1877836182;
1616                 templateIdSet(-523813895) := -523813895;
1617                 templateIdSet(66083222) := 66083222;
1618                 templateIdSet(523674485) := 523674485;
1619                 templateIdSet(1974187109) := 1974187109;
1620                 templateIdSet(92205558) := 92205558;
1621                 templateIdSet(856491201) := 856491201;
1622                 templateIdSet(-91264646) := -91264646;
1623                 templateIdSet(811367898) := 811367898;
1624                 templateIdSet(1082734665) := 1082734665;
1625                 templateIdSet(1193819287) := 1193819287;
1626                 templateIdSet(-1082613563) := -1082613563;
1627                 templateIdSet(-1640376935) := -1640376935;
1628                 templateIdSet(1584198075) := 1584198075;
1629                 templateIdSet(783922216) := 783922216;
1630                 templateIdSet(-2133834359) := -2133834359;
1631                 templateIdSet(-268107750) := -268107750;
1632                 templateIdSet(1631264204) := 1631264204;
1633                 templateIdSet(-1047768279) := -1047768279;
1634                 templateIdSet(2001515041) := 2001515041;
1635                 templateIdSet(267688086) := 267688086;
1636                 templateIdSet(1065077663) := 1065077663;
1637                 templateIdSet(57117299) := 57117299;
1638                 templateIdSet(866000377) := 866000377;
1639                 templateIdSet(1129011306) := 1129011306;
1640                 templateIdSet(-279689267) := -279689267;
1641                 templateIdSet(-1618935202) := -1618935202;
1642                 templateIdSet(-1377743586) := -1377743586;
1643                 templateIdSet(1440200840) := 1440200840;
1644                 templateIdSet(-485009024) := -485009024;
1645                 templateIdSet(1617992402) := 1617992402;
1646                 templateIdSet(246676033) := 246676033;
1647                 templateIdSet(2120662994) := 2120662994;
1648                 templateIdSet(-1169656734) := -1169656734;
1649                 templateIdSet(659297422) := 659297422;
1650                 templateIdSet(1469665565) := 1469665565;
1651                 templateIdSet(-1785454855) := -1785454855;
1652                 templateIdSet(522917746) := 522917746;
1653                 templateIdSet(-1469527663) := -1469527663;
1654                 templateIdSet(824817548) := 824817548;
1655                 templateIdSet(-434656188) := -434656188;
1656                 templateIdSet(-1765611049) := -1765611049;
1657                 templateIdSet(1139078028) := 1139078028;
1658                 templateIdSet(1622923855) := 1622923855;
1659                 templateIdSet(275685340) := 275685340;
1660                 templateIdSet(-2109263964) := -2109263964;
1661                 templateIdSet(1513782916) := 1513782916;
1662                 templateIdSet(-319119476) := -319119476;
1663                 templateIdSet(-274790576) := -274790576;
1664                 templateIdSet(-1751431536) := -1751431536;
1665                 templateIdSet(1928484082) := 1928484082;
1666                 templateIdSet(36114785) := 36114785;
1667                 templateIdSet(2125025189) := 2125025189;
1668                 templateIdSet(-1285938931) := -1285938931;
1669                 templateIdSet(-1014012770) := -1014012770;
1670                 templateIdSet(-698743461) := -698743461;
1671                 templateIdSet(-226902841) := -226902841;
1672                 templateIdSet(1152998863) := 1152998863;
1673                 templateIdSet(1014955026) := 1014955026;
1674                 templateIdSet(-1762554943) := -1762554943;
1675                 templateIdSet(-433795502) := -433795502;
1676                 templateIdSet(1463740430) := 1463740430;
1677                 templateIdSet(-2101932344) := -2101932344;
1678                 templateIdSet(-1721490790) := -1721490790;
1679                 templateIdSet(1777643552) := 1777643552;
1680                 templateIdSet(-385048649) := -385048649;
1681                 templateIdSet(-761139333) := -761139333;
1682                 templateIdSet(-932988328) := -932988328;
1683                 templateIdSet(525967921) := 525967921;
1684                 templateIdSet(1871505314) := 1871505314;
1685                 templateIdSet(-963800801) := -963800801;
1686                 templateIdSet(-2050710967) := -2050710967;
1687                 templateIdSet(-183375910) := -183375910;
1688                 templateIdSet(689622929) := 689622929;
1689                 templateIdSet(1301374465) := 1301374465;
1690                 templateIdSet(-78543095) := -78543095;
1691                 templateIdSet(182484822) := 182484822;
1692                 templateIdSet(1051253941) := 1051253941;
1693                 templateIdSet(-954052477) := -954052477;
1694                 templateIdSet(-1208543984) := -1208543984;
1695                 templateIdSet(-1630155612) := -1630155612;
1696                 templateIdSet(-911886824) := -911886824;
1697                 templateIdSet(-1183779957) := -1183779957;
1698                 templateIdSet(-343994769) := -343994769;
1699                 templateIdSet(1263770558) := 1263770558;
1700                 templateIdSet(-40666442) := -40666442;
1701                 templateIdSet(1182886663) := 1182886663;
1702                 templateIdSet(774778471) := 774778471;
1703                 templateIdSet(1593535476) := 1593535476;
1704                 templateIdSet(-306804975) := -306804975;
1705                 templateIdSet(582714478) := 582714478;
1706                 templateIdSet(1382990333) := 1382990333;
1707                 templateIdSet(-1832625049) := -1832625049;
1708                 templateIdSet(-974187136) := -974187136;
1709                 templateIdSet(1932522632) := 1932522632;
1710                 templateIdSet(-1382065807) := -1382065807;
1711                 templateIdSet(1841408054) := 1841408054;
1712                 templateIdSet(487910821) := 487910821;
1713                 templateIdSet(-185039936) := -185039936;
1714                 templateIdSet(-2077374893) := -2077374893;
1715                 templateIdSet(303274938) := 303274938;
1716                 templateIdSet(1657200169) := 1657200169;
1717                 templateIdSet(1224577523) := 1224577523;
1718                 templateIdSet(-30363750) := -30363750;
1719                 templateIdSet(-1897534967) := -1897534967;
1720                 templateIdSet(567515627) := 567515627;
1721                 templateIdSet(1362436589) := 1362436589;
1722                 templateIdSet(1746127589) := 1746127589;
1723                 templateIdSet(-556586003) := -556586003;
1724                 templateIdSet(1630705486) := 1630705486;
1725                 templateIdSet(1897165445) := 1897165445;
1726                 templateIdSet(-2065356471) := -2065356471;
1727                 templateIdSet(487215056) := 487215056;
1728                 templateIdSet(-483121900) := -483121900;
1729                 templateIdSet(-1813946233) := -1813946233;
1730                 templateIdSet(830219516) := 830219516;
1731                 templateIdSet(1425531172) := 1425531172;
1732                 templateIdSet(606250167) := 606250167;
1733                 templateIdSet(-1175884434) := -1175884434;
1734                 templateIdSet(-1659123451) := -1659123451;
1735                 templateIdSet(-606913477) := -606913477;
1736                 templateIdSet(619388150) := 619388150;
1737                 templateIdSet(-2061397693) := -2061397693;
1738                 templateIdSet(-914141938) := -914141938;
1739                 templateIdSet(-653428823) := -653428823;
1740                 templateIdSet(-1993339022) := -1993339022;
1741                 templateIdSet(1855229351) := 1855229351;
1742                 templateIdSet(275564031) := 275564031;
1743                 templateIdSet(-247678631) := -247678631;
1744                 templateIdSet(1261688149) := 1261688149;
1745                 templateIdSet(-779152232) := -779152232;
1746                 templateIdSet(-1587916533) := -1587916533;
1747                 templateIdSet(-1424733636) := -1424733636;
1748                 templateIdSet(500476724) := 500476724;
1749                 templateIdSet(-320086751) := -320086751;
1750                 templateIdSet(678412834) := 678412834;
1751                 templateIdSet(1436153762) := 1436153762;
1752                 templateIdSet(-177674793) := -177674793;
1753                 templateIdSet(-1886457751) := -1886457751;
1754                 templateIdSet(569575162) := 569575162;
1755                 templateIdSet(-392461625) := -392461625;
1756                 templateIdSet(-1500071681) := -1500071681;
1757                 templateIdSet(-420003189) := -420003189;
1758                 templateIdSet(309375847) := 309375847;
1759                 templateIdSet(-98746218) := -98746218;
1760                 templateIdSet(1289593246) := 1289593246;
1761                 templateIdSet(103036882) := 103036882;
1762                 templateIdSet(416123005) := 416123005;
1763                 templateIdSet(-469920034) := -469920034;
1764                 templateIdSet(-817576610) := -817576610;
1765                 templateIdSet(-38886533) := -38886533;
1766                 templateIdSet(-1264335626) := -1264335626;
1767                 templateIdSet(2144735852) := 2144735852;
1768                 templateIdSet(1875688539) := 1875688539;
1769                 templateIdSet(192857538) := 192857538;
1770                 templateIdSet(-442303678) := -442303678;
1771                 templateIdSet(-2072795932) := -2072795932;
1772                 templateIdSet(983989372) := 983989372;
1773                 templateIdSet(490845618) := 490845618;
1774                 templateIdSet(-983864428) := -983864428;
1775                 templateIdSet(2086609620) := 2086609620;
1776                 templateIdSet(110363758) := 110363758;
1777                 templateIdSet(-1424880637) := -1424880637;
1778                 templateIdSet(-448030425) := -448030425;
1779                 templateIdSet(-786663538) := -786663538;
1780                 templateIdSet(-702291727) := -702291727;
1781                 templateIdSet(50152844) := 50152844;
1782                 templateIdSet(-132357748) := -132357748;
1783                 templateIdSet(1590091204) := 1590091204;
1784                 templateIdSet(-212848001) := -212848001;
1785                 templateIdSet(1415954991) := 1415954991;
1786                 templateIdSet(1401689522) := 1401689522;
1787                 templateIdSet(1656768558) := 1656768558;
1788                 templateIdSet(944293988) := 944293988;
1789                 templateIdSet(-1764803069) := -1764803069;
1790                 templateIdSet(2026707684) := 2026707684;
1791                 templateIdSet(1741906969) := 1741906969;
1792                 templateIdSet(1862066444) := 1862066444;
1793                 templateIdSet(981227534) := 981227534;
1794                 templateIdSet(-613110139) := -613110139;
1795                 templateIdSet(188520444) := 188520444;
1796                 templateIdSet(-589817340) := -589817340;
1797                 templateIdSet(1740191859) := 1740191859;
1798                 templateIdSet(-1464343893) := -1464343893;
1799                 templateIdSet(-2022305605) := -2022305605;
1800                 templateIdSet(810379093) := 810379093;
1801                 templateIdSet(-965865145) := -965865145;
1802                 templateIdSet(775748867) := 775748867;
1803                 templateIdSet(-1876464536) := -1876464536;
1804                 templateIdSet(-483088632) := -483088632;
1805                 templateIdSet(901906289) := 901906289;
1806                 templateIdSet(-2134198239) := -2134198239;
1807                 templateIdSet(-1655034745) := -1655034745;
1808                 templateIdSet(1080722273) := 1080722273;
1809                 templateIdSet(1220774872) := 1220774872;
1810                 templateIdSet(1141198733) := 1141198733;
1811                 templateIdSet(-309965447) := -309965447;
1812                 templateIdSet(-1316687033) := -1316687033;
1813                 templateIdSet(-1322827874) := -1322827874;
1814                 templateIdSet(810339444) := 810339444;
1815                 templateIdSet(1102511316) := 1102511316;
1816                 templateIdSet(1804298795) := 1804298795;
1817                 templateIdSet(1505456979) := 1505456979;
1818                 templateIdSet(-90182809) := -90182809;
1819                 templateIdSet(-1915271095) := -1915271095;
1820                 templateIdSet(-1188519487) := -1188519487;
1821                 templateIdSet(-1173568585) := -1173568585;
1822                 templateIdSet(1906195493) := 1906195493;
1823                 templateIdSet(-1958737672) := -1958737672;
1824                 templateIdSet(665098706) := 665098706;
1825                 templateIdSet(-1170494820) := -1170494820;
1826                 templateIdSet(831150616) := 831150616;
1827                 templateIdSet(1762601318) := 1762601318;
1828                 templateIdSet(-764562064) := -764562064;
1829                 templateIdSet(-480153985) := -480153985;
1830                 templateIdSet(-784284994) := -784284994;
1831                 templateIdSet(444888474) := 444888474;
1832                 templateIdSet(1618598853) := 1618598853;
1833                 templateIdSet(461512847) := 461512847;
1834                 templateIdSet(2138127220) := 2138127220;
1835                 templateIdSet(1938675644) := 1938675644;
1836                 templateIdSet(-1378772674) := -1378772674;
1837                 templateIdSet(-1109531580) := -1109531580;
1838                 templateIdSet(155551742) := 155551742;
1839                 templateIdSet(-623854688) := -623854688;
1840                 templateIdSet(-617341983) := -617341983;
1841                 templateIdSet(443295551) := 443295551;
1842                 templateIdSet(-1554492115) := -1554492115;
1843                 templateIdSet(201334650) := 201334650;
1844                 templateIdSet(78081465) := 78081465;
1845                 templateIdSet(1261011254) := 1261011254;
1846                 templateIdSet(227937004) := 227937004;
1847                 templateIdSet(-1185633502) := -1185633502;
1848                 templateIdSet(-1920361299) := -1920361299;
1849                 templateIdSet(349677024) := 349677024;
1850                 templateIdSet(1210744947) := 1210744947;
1851                 templateIdSet(1369190307) := 1369190307;
1852                 templateIdSet(-1438464920) := -1438464920;
1853                 templateIdSet(702649693) := 702649693;
1854                 templateIdSet(34919568) := 34919568;
1855                 templateIdSet(-1565904814) := -1565904814;
1856                 templateIdSet(-778602894) := -778602894;
1857                 templateIdSet(-1382616459) := -1382616459;
1858                 templateIdSet(-900058289) := -900058289;
1859                 templateIdSet(-1566891826) := -1566891826;
1860                 templateIdSet(-1474613882) := -1474613882;
1861                 templateIdSet(590597969) := 590597969;
1862                 templateIdSet(6493761) := 6493761;
1863                 templateIdSet(2132239519) := 2132239519;
1864                 templateIdSet(-721077210) := -721077210;
1865                 templateIdSet(320220025) := 320220025;
1866                 templateIdSet(-225492986) := -225492986;
1867                 templateIdSet(1995174592) := 1995174592;
1868                 templateIdSet(403078591) := 403078591;
1869                 templateIdSet(-269033971) := -269033971;
1870                 templateIdSet(-651693115) := -651693115;
1871                 templateIdSet(-1571384798) := -1571384798;
1872                 templateIdSet(716551990) := 716551990;
1873                 templateIdSet(1944034997) := 1944034997;
1874                 templateIdSet(1855721592) := 1855721592;
1875                 templateIdSet(981088834) := 981088834;
1876                 templateIdSet(-637703116) := -637703116;
1877                 templateIdSet(-1779174489) := -1779174489;
1878                 templateIdSet(1840338268) := 1840338268;
1879                 templateIdSet(237038605) := 237038605;
1880                 templateIdSet(653612816) := 653612816;
1881                 templateIdSet(1608037452) := 1608037452;
1882                 templateIdSet(-613167286) := -613167286;
1883                 templateIdSet(-245341807) := -245341807;
1884                 templateIdSet(-1019635633) := -1019635633;
1885                 templateIdSet(-449112830) := -449112830;
1886                 templateIdSet(-526113597) := -526113597;
1887                 templateIdSet(589649861) := 589649861;
1888                 templateIdSet(-20005656) := -20005656;
1889                 templateIdSet(257663710) := 257663710;
1890                 templateIdSet(-639753330) := -639753330;
1891                 templateIdSet(-730685311) := -730685311;
1892                 templateIdSet(-130243512) := -130243512;
1893                 templateIdSet(1756821101) := 1756821101;
1894                 templateIdSet(-1501822488) := -1501822488;
1895                 templateIdSet(-132487792) := -132487792;
1896                 templateIdSet(1982554682) := 1982554682;
1897                 templateIdSet(-913097330) := -913097330;
1898                 templateIdSet(-402333683) := -402333683;
1899                 templateIdSet(-1811261900) := -1811261900;
1900                 templateIdSet(-1178706532) := -1178706532;
1901                 templateIdSet(-1137089652) := -1137089652;
1902                 templateIdSet(-473813792) := -473813792;
1903                 templateIdSet(-718648728) := -718648728;
1904                 templateIdSet(238936831) := 238936831;
1905                 templateIdSet(1358850609) := 1358850609;
1906                 templateIdSet(-1088166271) := -1088166271;
1907                 templateIdSet(102348899) := 102348899;
1908                 templateIdSet(-673780945) := -673780945;
1909                 templateIdSet(213992376) := 213992376;
1910                 templateIdSet(-1330392160) := -1330392160;
1911                 templateIdSet(1834662895) := 1834662895;
1912                 templateIdSet(-1781845673) := -1781845673;
1913                 templateIdSet(1214765971) := 1214765971;
1914                 templateIdSet(-1213235742) := -1213235742;
1915                 templateIdSet(-1498919413) := -1498919413;
1916                 templateIdSet(-1109444980) := -1109444980;
1917                 templateIdSet(-379196495) := -379196495;
1918                 templateIdSet(648215202) := 648215202;
1919                 templateIdSet(-279076105) := -279076105;
1920                 templateIdSet(-2138350593) := -2138350593;
1921                 templateIdSet(-1839044042) := -1839044042;
1922                 templateIdSet(-1601393927) := -1601393927;
1923                 templateIdSet(418740352) := 418740352;
1924                 templateIdSet(1778522271) := 1778522271;
1925                 templateIdSet(764829944) := 764829944;
1926                 templateIdSet(-627137144) := -627137144;
1927                 templateIdSet(100102071) := 100102071;
1928                 templateIdSet(949442296) := 949442296;
1929                 templateIdSet(180006972) := 180006972;
1930                 templateIdSet(-926822510) := -926822510;
1931                 templateIdSet(-633473500) := -633473500;
1932                 templateIdSet(451466626) := 451466626;
1933                 templateIdSet(-82570045) := -82570045;
1934                 templateIdSet(-860173634) := -860173634;
1935                 templateIdSet(252668529) := 252668529;
1936                 templateIdSet(1866781530) := 1866781530;
1937                 templateIdSet(-245080147) := -245080147;
1938                 templateIdSet(1684501073) := 1684501073;
1939                 templateIdSet(-1925049902) := -1925049902;
1940                 templateIdSet(-837691545) := -837691545;
1941                 templateIdSet(-1792584100) := -1792584100;
1942                 templateIdSet(-1340116130) := -1340116130;
1943                 templateIdSet(-1400940656) := -1400940656;
1944                 templateIdSet(1980615506) := 1980615506;
1945                 templateIdSet(1687234741) := 1687234741;
1946                 templateIdSet(-2032619870) := -2032619870;
1947                 templateIdSet(1070818136) := 1070818136;
1948                 templateIdSet(322519616) := 322519616;
1949                 templateIdSet(129228399) := 129228399;
1950                 templateIdSet(-1929515589) := -1929515589;
1951                 templateIdSet(1691705957) := 1691705957;
1952                 templateIdSet(-1919723538) := -1919723538;
1953                 templateIdSet(-937385248) := -937385248;
1954                 templateIdSet(685231719) := 685231719;
1955                 templateIdSet(-1340981329) := -1340981329;
1956                 templateIdSet(-1238955746) := -1238955746;
1957                 templateIdSet(-656409820) := -656409820;
1958                 templateIdSet(-67541093) := -67541093;
1959                 templateIdSet(1223042704) := 1223042704;
1960                 templateIdSet(1646698389) := 1646698389;
1961                 templateIdSet(-1930572145) := -1930572145;
1962                 templateIdSet(-1437726662) := -1437726662;
1963                 templateIdSet(-2118141076) := -2118141076;
1964                 templateIdSet(-1354942232) := -1354942232;
1965                 templateIdSet(709369610) := 709369610;
1966                 templateIdSet(-205520309) := -205520309;
1967                 templateIdSet(-603889252) := -603889252;
1968                 templateIdSet(-1321212581) := -1321212581;
1969                 templateIdSet(397924793) := 397924793;
1970                 templateIdSet(-1148251186) := -1148251186;
1971                 templateIdSet(2069010987) := 2069010987;
1972                 templateIdSet(-1374316705) := -1374316705;
1973                 templateIdSet(-1428709338) := -1428709338;
1974                 templateIdSet(-2024883534) := -2024883534;
1975                 templateIdSet(-896708611) := -896708611;
1976                 templateIdSet(1325615183) := 1325615183;
1977                 templateIdSet(1007504804) := 1007504804;
1978                 templateIdSet(1775069676) := 1775069676;
1979                 templateIdSet(-1629773375) := -1629773375;
1980                 templateIdSet(1333331720) := 1333331720;
1981                 templateIdSet(869624722) := 869624722;
1982                 templateIdSet(247923643) := 247923643;
1983                 templateIdSet(-631441882) := -631441882;
1984                 templateIdSet(-1328960537) := -1328960537;
1985                 templateIdSet(1327818409) := 1327818409;
1986                 templateIdSet(-2117547605) := -2117547605;
1987                 templateIdSet(352903310) := 352903310;
1988                 templateIdSet(130303407) := 130303407;
1989                 templateIdSet(1006954225) := 1006954225;
1990                 templateIdSet(-1957995430) := -1957995430;
1991                 templateIdSet(200431483) := 200431483;
1992                 templateIdSet(1219521873) := 1219521873;
1993                 templateIdSet(1567297626) := 1567297626;
1994                 templateIdSet(1062687370) := 1062687370;
1995                 templateIdSet(-1774596602) := -1774596602;
1996                 templateIdSet(1530854406) := 1530854406;
1997                 templateIdSet(-255701924) := -255701924;
1998                 templateIdSet(735438027) := 735438027;
1999                 templateIdSet(1658356550) := 1658356550;
2000                 templateIdSet(-1724143534) := -1724143534;
2001                 templateIdSet(-801714209) := -801714209;
2002                 templateIdSet(-181151130) := -181151130;
2003                 templateIdSet(774140657) := 774140657;
2004                 templateIdSet(1730745724) := 1730745724;
2005                 templateIdSet(-1664467352) := -1664467352;
2006                 templateIdSet(431995434) := 431995434;
2007                 templateIdSet(-1029172547) := -1029172547;
2008                 templateIdSet(-1952090832) := -1952090832;
2009                 templateIdSet(1883659812) := 1883659812;
2010                 templateIdSet(-980521968) := -980521968;
2011                 templateIdSet(-306844601) := -306844601;
2012                 templateIdSet(-2039935369) := -2039935369;
2013                 templateIdSet(-23647699) := -23647699;
2014                 templateIdSet(-1933405050) := -1933405050;
2015                 templateIdSet(-1329737896) := -1329737896;
2016                 templateIdSet(144581616) := 144581616;
2017                 templateIdSet(-1122191702) := -1122191702;
2018                 templateIdSet(22306368) := 22306368;
2019                 templateIdSet(281064494) := 281064494;
2020                 templateIdSet(-1320167407) := -1320167407;
2021                 templateIdSet(1061303036) := 1061303036;
2022                 templateIdSet(507210122) := 507210122;
2023                 templateIdSet(-88500234) := -88500234;
2024                 templateIdSet(1472463975) := 1472463975;
2025                 templateIdSet(2080884324) := 2080884324;
2026                 templateIdSet(-2052487231) := -2052487231;
2027                 templateIdSet(-528877582) := -528877582;
2028                 templateIdSet(-135648971) := -135648971;
2029                 templateIdSet(230572551) := 230572551;
2030                 templateIdSet(1057167832) := 1057167832;
2031                 templateIdSet(536694865) := 536694865;
2032                 templateIdSet(437634302) := 437634302;
2033                 templateIdSet(2054517358) := 2054517358;
2034                 templateIdSet(-1337924041) := -1337924041;
2035                 templateIdSet(1353161551) := 1353161551;
2036                 templateIdSet(-2137759113) := -2137759113;
2037                 templateIdSet(179201581) := 179201581;
2038                 templateIdSet(-322799884) := -322799884;
2039                 templateIdSet(1599302627) := 1599302627;
2040                 templateIdSet(-1655466225) := -1655466225;
2041                 templateIdSet(993643963) := 993643963;
2042                 templateIdSet(428493251) := 428493251;
2043                 templateIdSet(1834531933) := 1834531933;
2044                 templateIdSet(1664157751) := 1664157751;
2045                 templateIdSet(-1989431522) := -1989431522;
2046                 templateIdSet(-237557333) := -237557333;
2047                 templateIdSet(-400228634) := -400228634;
2048                 templateIdSet(1550199637) := 1550199637;
2049                 templateIdSet(-1129312673) := -1129312673;
2050                 templateIdSet(1602372839) := 1602372839;
2051                 templateIdSet(2036727535) := 2036727535;
2052                 templateIdSet(-2066158902) := -2066158902;
2053                 templateIdSet(1706352715) := 1706352715;
2054                 templateIdSet(-821627577) := -821627577;
2055                 templateIdSet(1731904862) := 1731904862;
2056                 templateIdSet(1492257317) := 1492257317;
2057                 templateIdSet(1543376981) := 1543376981;
2058                 templateIdSet(-453063519) := -453063519;
2059                 templateIdSet(-1135348098) := -1135348098;
2060                 templateIdSet(-180524642) := -180524642;
2061                 templateIdSet(-1234286053) := -1234286053;
2062                 templateIdSet(-966588406) := -966588406;
2063                 templateIdSet(391653777) := 391653777;
2064                 templateIdSet(1833668435) := 1833668435;
2065                 templateIdSet(-1632342596) := -1632342596;
2066                 templateIdSet(1468700561) := 1468700561;
2067                 templateIdSet(1186404816) := 1186404816;
2068                 templateIdSet(-1236344303) := -1236344303;
2069                 templateIdSet(870515892) := 870515892;
2070                 templateIdSet(-609603936) := -609603936;
2071                 templateIdSet(-108612773) := -108612773;
2072                 templateIdSet(-723081254) := -723081254;
2073                 templateIdSet(-1482529718) := -1482529718;
2074                 templateIdSet(-702596630) := -702596630;
2075                 templateIdSet(-191532605) := -191532605;
2076                 templateIdSet(1368313349) := 1368313349;
2077                 templateIdSet(-1149904183) := -1149904183;
2078                 templateIdSet(-104858180) := -104858180;
2079                 templateIdSet(1901385280) := 1901385280;
2080                 templateIdSet(-519120500) := -519120500;
2081                 templateIdSet(-1030442907) := -1030442907;
2082                 templateIdSet(-272947641) := -272947641;
2083                 templateIdSet(1239922273) := 1239922273;
2084                 templateIdSet(920119228) := 920119228;
2085                 templateIdSet(1460469297) := 1460469297;
2086                 templateIdSet(1098635748) := 1098635748;
2087                 templateIdSet(1461830070) := 1461830070;
2088                 templateIdSet(-1864503130) := -1864503130;
2089                 templateIdSet(1801195805) := 1801195805;
2090                 templateIdSet(-410420377) := -410420377;
2091                 templateIdSet(877344239) := 877344239;
2092                 templateIdSet(1434285776) := 1434285776;
2093                 templateIdSet(558263029) := 558263029;
2094                 templateIdSet(22531863) := 22531863;
2095                 templateIdSet(1828317055) := 1828317055;
2096                 templateIdSet(-1670164093) := -1670164093;
2097                 templateIdSet(284923026) := 284923026;
2098                 templateIdSet(-250957874) := -250957874;
2099                 templateIdSet(1454424858) := 1454424858;
2100                 templateIdSet(51214754) := 51214754;
2101                 templateIdSet(540146307) := 540146307;
2102                 templateIdSet(-635575777) := -635575777;
2103                 templateIdSet(1166887647) := 1166887647;
2104                 templateIdSet(-23601230) := -23601230;
2105                 templateIdSet(-1365202497) := -1365202497;
2106                 templateIdSet(1714967517) := 1714967517;
2107                 templateIdSet(99972710) := 99972710;
2108                 templateIdSet(-1722035741) := -1722035741;
2109                 templateIdSet(-1746165408) := -1746165408;
2110                 templateIdSet(329225748) := 329225748;
2111                 templateIdSet(1301924307) := 1301924307;
2112                 templateIdSet(-846740906) := -846740906;
2113                 templateIdSet(471067493) := 471067493;
2114                 templateIdSet(-1483553925) := -1483553925;
2115                 templateIdSet(-1938284398) := -1938284398;
2116                 templateIdSet(1466927109) := 1466927109;
2117                 templateIdSet(509800328) := 509800328;
2118                 templateIdSet(-444480356) := -444480356;
2119                 templateIdSet(-1400069359) := -1400069359;
2120                 templateIdSet(-589619825) := -589619825;
2121                 templateIdSet(-1781106174) := -1781106174;
2122                 templateIdSet(1848987926) := 1848987926;
2123                 templateIdSet(657995419) := 657995419;
2124                 templateIdSet(1931602976) := 1931602976;
2125                 templateIdSet(-679440489) := -679440489;
2126                 templateIdSet(2059421636) := 2059421636;
2127                 templateIdSet(-737833670) := -737833670;
2128                 templateIdSet(-893992793) := -893992793;
2129                 templateIdSet(-1107035087) := -1107035087;
2130                 templateIdSet(1695831206) := 1695831206;
2131                 templateIdSet(-1266575809) := -1266575809;
2132                 templateIdSet(1872117416) := 1872117416;
2133                 templateIdSet(647715109) := 647715109;
2134                 templateIdSet(-579309007) := -579309007;
2135                 templateIdSet(-1804266052) := -1804266052;
2136                 templateIdSet(527556965) := 527556965;
2137                 templateIdSet(-999929358) := -999929358;
2138                 templateIdSet(2005513882) := 2005513882;
2139                 templateIdSet(-1398923763) := -1398923763;
2140                 templateIdSet(-443319936) := -443319936;
2141                 templateIdSet(510677652) := 510677652;
2142                 templateIdSet(1045341716) := 1045341716;
2143                 templateIdSet(-447148413) := -447148413;
2144                 templateIdSet(-1403754226) := -1403754226;
2145                 templateIdSet(1471627802) := 1471627802;
2146                 templateIdSet(2049606520) := 2049606520;
2147                 templateIdSet(-1589826577) := -1589826577;
2148                 templateIdSet(-399487902) := -399487902;
2149                 templateIdSet(332621686) := 332621686;
2150                 templateIdSet(-106672157) := -106672157;
2151                 templateIdSet(582215540) := 582215540;
2152                 templateIdSet(1807646969) := 1807646969;
2153                 templateIdSet(-231292762) := -231292762;
2154                 templateIdSet(690055217) := 690055217;
2155                 templateIdSet(1613500348) := 1613500348;
2156                 templateIdSet(-1680923480) := -1680923480;
2157                 templateIdSet(-132280259) := -132280259;
2158                 templateIdSet(587872426) := 587872426;
2159                 templateIdSet(1778868007) := 1778868007;
2160                 templateIdSet(-1847299021) := -1847299021;
2161                 templateIdSet(-220731710) := -220731710;
2162                 templateIdSet(700468821) := 700468821;
2163                 templateIdSet(1624058328) := 1624058328;
2164                 templateIdSet(-1634928232) := -1634928232;
2165                 templateIdSet(1167806735) := 1167806735;
2166                 templateIdSet(211170946) := 211170946;
2167                 templateIdSet(-143319658) := -143319658;
2168                 templateIdSet(949453622) := 949453622;
2169                 templateIdSet(-478139487) := -478139487;
2170                 templateIdSet(-1433580500) := -1433580500;
2171                 templateIdSet(1366189880) := 1366189880;
2172                 templateIdSet(1240046010) := 1240046010;
2173                 templateIdSet(-1828835027) := -1828835027;
2174                 templateIdSet(-604809568) := -604809568;
2175                 templateIdSet(537951668) := 537951668;
2176                 templateIdSet(310195605) := 310195605;
2177                 templateIdSet(672875303) := 672875303;
2178                 templateIdSet(-217257040) := -217257040;
2179                 templateIdSet(-1174303683) := -1174303683;
2180                 templateIdSet(-2011612965) := -2011612965;
2181                 templateIdSet(1393463372) := 1393463372;
2182                 templateIdSet(436467649) := 436467649;
2183                 templateIdSet(-505357099) := -505357099;
2184                 templateIdSet(-1460815016) := -1460815016;
2185                 templateIdSet(-97283480) := -97283480;
2186                 templateIdSet(556022527) := 556022527;
2187                 templateIdSet(1415748921) := 1415748921;
2188                 templateIdSet(-1888143954) := -1888143954;
2189                 templateIdSet(-1676060831) := -1676060831;
2190                 templateIdSet(1192165366) := 1192165366;
2191                 templateIdSet(235116667) := 235116667;
2192                 templateIdSet(-169823377) := -169823377;
2193                 templateIdSet(-1125264158) := -1125264158;
2194                 templateIdSet(-328757929) := -328757929;
2195                 templateIdSet(930096576) := 930096576;
2196                 templateIdSet(2122138189) := 2122138189;
2197                 templateIdSet(-2053215911) := -2053215911;
2198                 templateIdSet(-862777644) := -862777644;
2199                 templateIdSet(430317917) := 430317917;
2200                 templateIdSet(-1028552246) := -1028552246;
2201                 templateIdSet(-1950552505) := -1950552505;
2202                 templateIdSet(1885324627) := 1885324627;
2203                 templateIdSet(961716958) := 961716958;
2204                 templateIdSet(-1677860148) := -1677860148;
2205                 templateIdSet(1089096283) := 1089096283;
2206                 templateIdSet(166145494) := 166145494;
2207                 templateIdSet(-234617150) := -234617150;
2208                 templateIdSet(-1157013169) := -1157013169;
2209                 templateIdSet(1184142638) := 1184142638;
2210                 templateIdSet(-1652343367) := -1652343367;
2211                 templateIdSet(-728868300) := -728868300;
2212                 templateIdSet(795701536) := 795701536;
2213                 templateIdSet(1717573293) := 1717573293;
2214                 templateIdSet(-1765458857) := -1765458857;
2215                 templateIdSet(1305646272) := 1305646272;
2216                 templateIdSet(81785677) := 81785677;
2217                 templateIdSet(-12789671) := -12789671;
2218                 templateIdSet(-1238253612) := -1238253612;
2219                 templateIdSet(-1657672270) := -1657672270;
2220                 templateIdSet(1176913189) := 1176913189;
2221                 templateIdSet(254485160) := 254485160;
2222                 templateIdSet(-188216900) := -188216900;
2223                 templateIdSet(-1111134671) := -1111134671;
2224                 templateIdSet(157634799) := 157634799;
2225                 templateIdSet(-1983000237) := -1983000237;
2226                 templateIdSet(1390049732) := 1390049732;
2227                 templateIdSet(467082825) := 467082825;
2228                 templateIdSet(-764217224) := -764217224;
2229                 templateIdSet(-1686134795) := -1686134795;
2230                 templateIdSet(95475824) := 95475824;
2231                 templateIdSet(90200724) := 90200724;
2232                 templateIdSet(-562564605) := -562564605;
2233                 templateIdSet(-1753574002) := -1753574002;
2234                 templateIdSet(-559451929) := -559451929;
2235                 templateIdSet(-1750460566) := -1750460566;
2236                 templateIdSet(1506389102) := 1506389102;
2237                 templateIdSet(-2099378951) := -2099378951;
2238                 templateIdSet(-875338892) := -875338892;
2239                 templateIdSet(53231194) := 53231194;
2240                 templateIdSet(-667183411) := -667183411;
2241                 templateIdSet(-1858670272) := -1858670272;
2242                 templateIdSet(-1166687602) := -1166687602;
2243                 templateIdSet(1633839641) := 1633839641;
2244                 templateIdSet(678366612) := 678366612;
2245                 templateIdSet(-1206446259) := -1206446259;
2246                 templateIdSet(1660993498) := 1660993498;
2247                 templateIdSet(705550423) := 705550423;
2248                 templateIdSet(-2037168026) := -2037168026;
2249                 templateIdSet(1568989425) := 1568989425;
2250                 templateIdSet(344557436) := 344557436;
2251                 templateIdSet(810684832) := 810684832;
2252                 templateIdSet(-347752137) := -347752137;
2253                 templateIdSet(-1572282694) := -1572282694;
2254                 templateIdSet(1934373193) := 1934373193;
2255                 templateIdSet(-1470391842) := -1470391842;
2256                 templateIdSet(-514392493) := -514392493;
2257                 templateIdSet(1856972813) := 1856972813;
2258                 templateIdSet(-1246199654) := -1246199654;
2259                 templateIdSet(-55187689) := -55187689;
2260                 templateIdSet(324224015) := 324224015;
2261                 templateIdSet(-935007080) := -935007080;
2262                 templateIdSet(-2125886699) := -2125886699;
2263                 templateIdSet(-1564805563) := -1564805563;
2264                 templateIdSet(2041405138) := 2041405138;
2265                 templateIdSet(815806815) := 815806815;
2266                 templateIdSet(-1636411245) := -1636411245;
2267                 templateIdSet(1164046340) := 1164046340;
2268                 templateIdSet(208443273) := 208443273;
2269                 templateIdSet(-979596476) := -979596476;
2270                 templateIdSet(512435155) := 512435155;
2271                 templateIdSet(1468417118) := 1468417118;
2272                 templateIdSet(-596190638) := -596190638;
2273                 templateIdSet(123826885) := 123826885;
2274                 templateIdSet(1315706184) := 1315706184;
2275                 templateIdSet(-1062853951) := -1062853951;
2276                 templateIdSet(464620118) := 464620118;
2277                 templateIdSet(1388113371) := 1388113371;
2278                 templateIdSet(2035451832) := 2035451832;
2279                 templateIdSet(-1572524241) := -1572524241;
2280                 templateIdSet(-347584350) := -347584350;
2281                 templateIdSet(-601857572) := -601857572;
2282                 templateIdSet(121096523) := 121096523;
2283                 templateIdSet(1312468678) := 1312468678;
2284                 templateIdSet(681976607) := 681976607;
2285                 templateIdSet(-206468216) := -206468216;
2286                 templateIdSet(-1162023931) := -1162023931;
2287                 templateIdSet(-1465630540) := -1465630540;
2288                 templateIdSet(1941170211) := 1941170211;
2289                 templateIdSet(985567150) := 985567150;
2290                 templateIdSet(-1647095649) := -1647095649;
2291                 templateIdSet(1187313672) := 1187313672;
2292                 templateIdSet(264871813) := 264871813;
2293                 templateIdSet(235278722) := 235278722;
2294                 templateIdSet(-720258795) := -720258795;
2295                 templateIdSet(-1675829608) := -1675829608;
2296                 templateIdSet(-1950783554) := -1950783554;
2297                 templateIdSet(1353633577) := 1353633577;
2298                 templateIdSet(430155940) := 430155940;
2299                 templateIdSet(-636296737) := -636296737;
2300                 templateIdSet(17123656) := 17123656;
2301                 templateIdSet(1208495813) := 1208495813;
2302                 templateIdSet(409740963) := 409740963;
2303                 templateIdSet(-1015312844) := -1015312844;
2304                 templateIdSet(-1971918407) := -1971918407;
2305                 templateIdSet(-1085939198) := -1085939198;
2306                 templateIdSet(1683114645) := 1683114645;
2307                 templateIdSet(761212184) := 761212184;
2308                 templateIdSet(794688942) := 794688942;
2309                 templateIdSet(-2053523137) := -2053523137;
2310                 templateIdSet(-1092500879) := -1092500879;
2311                 templateIdSet(-1730770782) := -1730770782;
2312                 templateIdSet(208928229) := 208928229;
2313                 templateIdSet(807772545) := 807772545;
2314                 templateIdSet(-596014267) := -596014267;
2315                 templateIdSet(-1106535119) := -1106535119;
2316                 templateIdSet(-1599002060) := -1599002060;
2317                 templateIdSet(-1680302670) := -1680302670;
2318                 templateIdSet(144304422) := 144304422;
2319                 templateIdSet(1089638525) := 1089638525;
2320                 templateIdSet(1491099597) := 1491099597;
2321                 templateIdSet(1896411640) := 1896411640;
2322                 templateIdSet(656430760) := 656430760;
2323                 templateIdSet(-637806373) := -637806373;
2324                 templateIdSet(1450479489) := 1450479489;
2325                 templateIdSet(-2028859065) := -2028859065;
2326                 templateIdSet(1338425771) := 1338425771;
2327                 templateIdSet(-508865592) := -508865592;
2328                 templateIdSet(186405659) := 186405659;
2329                 templateIdSet(1367605438) := 1367605438;
2330                 templateIdSet(766575814) := 766575814;
2331                 templateIdSet(-1695066256) := -1695066256;
2332                 templateIdSet(-1026091453) := -1026091453;
2333                 templateIdSet(-2032640577) := -2032640577;
2334                 templateIdSet(1362576287) := 1362576287;
2335                 templateIdSet(430277184) := 430277184;
2336                 templateIdSet(148075865) := 148075865;
2337                 templateIdSet(-1319720093) := -1319720093;
2338                 templateIdSet(-14537666) := -14537666;
2339                 templateIdSet(-1597210008) := -1597210008;
2340                 templateIdSet(389089358) := 389089358;
2341                 templateIdSet(143113263) := 143113263;
2342                 templateIdSet(-1981094972) := -1981094972;
2343                 templateIdSet(787604538) := 787604538;
2344                 templateIdSet(233382897) := 233382897;
2345                 templateIdSet(-820961364) := -820961364;
2346                 templateIdSet(-1929517492) := -1929517492;
2347                 templateIdSet(1825046689) := 1825046689;
2348                 templateIdSet(-497561499) := -497561499;
2349                 templateIdSet(-370688623) := -370688623;
2350                 templateIdSet(1252325702) := 1252325702;
2351                 templateIdSet(1219727576) := 1219727576;
2352                 templateIdSet(-261254912) := -261254912;
2353                 templateIdSet(-826946743) := -826946743;
2354                 templateIdSet(-307530442) := -307530442;
2355                 templateIdSet(-126968979) := -126968979;
2356                 templateIdSet(1352512078) := 1352512078;
2357                 templateIdSet(38436739) := 38436739;
2358                 templateIdSet(-648161516) := -648161516;
2359                 templateIdSet(-1873760103) := -1873760103;
2360                 templateIdSet(1806932877) := 1806932877;
2361                 templateIdSet(-2043897502) := -2043897502;
2362                 templateIdSet(1672986063) := 1672986063;
2363                 templateIdSet(-201478902) := -201478902;
2364                 templateIdSet(-320858653) := -320858653;
2365                 templateIdSet(-428819171) := -428819171;
2366                 templateIdSet(649015964) := 649015964;
2367                 templateIdSet(-1588852672) := -1588852672;
2368                 templateIdSet(1589268411) := 1589268411;
2369                 templateIdSet(-2063383877) := -2063383877;
2370                 templateIdSet(-184506838) := -184506838;
2371                 templateIdSet(205254138) := 205254138;
2372                 templateIdSet(1936734520) := 1936734520;
2373                 templateIdSet(1577598037) := 1577598037;
2374                 templateIdSet(83272939) := 83272939;
2375                 templateIdSet(-383871740) := -383871740;
2376                 templateIdSet(-1338608150) := -1338608150;
2377                 templateIdSet(-132717072) := -132717072;
2378                 templateIdSet(375006515) := 375006515;
2379                 templateIdSet(-144833342) := -144833342;        -- manufacturing schematic
2380                 templateIdSet(162889564) := 162889564;          -- weapon crate
2381                 templateIdSet(1120303977) := 1120303977;        -- armor crate
2382                 templateIdSet(-200781577) := -200781577;        -- food crate
2383                 templateIdSet(-1966544754) := -1966544754;      -- chemical crate
2384                 templateIdSet(-754298423) := -754298423;        -- electronics crate
2385                 templateIdSet(-1207917085) := -1207917085;      -- clothing crate
2386                 templateIdSet(1717727484) := 1717727484;        -- nyax necklace
2387                 templateIdSet(-1674079888) := -1674079888;
2388                 templateIdSet(-171018882) := -171018882;
2389                 templateIdSet(1193294311) := 1193294311;
2390                 templateIdSet(237854314) := 237854314;
2391                 templateIdSet(-470906696) := -470906696;
2392                 templateIdSet(344340565) := 344340565;
2393                 
2394                 templateNameText(2099054288)  := 'armor_bounty_hunter_crafted_belt';
2395                 templateNameText(-852325331)  := 'armor_bounty_hunter_crafted_bicep_l';
2396                 templateNameText(-1108883010) := 'armor_bounty_hunter_crafted_bicep_r';
2397                 templateNameText(315293450)   := 'armor_bounty_hunter_crafted_boots';
2398                 templateNameText(-151793970)  := 'armor_bounty_hunter_crafted_bracer_l';
2399                 templateNameText(-2044294307) := 'armor_bounty_hunter_crafted_bracer_r';
2400                 templateNameText(1649659380)  := 'armor_bounty_hunter_crafted_chest_plate';
2401                 templateNameText(140529204)   := 'armor_bounty_hunter_crafted_gloves';
2402                 templateNameText(-1096765636) := 'armor_bounty_hunter_crafted_helmet';
2403                 templateNameText(2044138449)  := 'armor_bounty_hunter_crafted_leggings';
2404                 templateNameText(-983864428)  := 'armor_layer_kinetic';
2405                 templateNameTable(-983864428) := 'craft_clothing_ingredients_n';
2406                 templateNameText(1594162622)  := 'armor_recon_segment';
2407                 templateNameTable(1594162622) := 'craft_armor_ingredients_n';
2408                 templateNameText(-1438161694) := 'armor_battle_segment';
2409                 templateNameTable(-1438161694):= 'craft_armor_ingredients_n';
2410                 templateNameText(2042493214)  := 'armor_assault_segment';
2411                 templateNameTable(2042493214) := 'craft_armor_ingredients_n';
2412                 templateNameText(-2117547605) := 'weapon_mine_explosive';
2413                 templateNameTable(-2117547605):= 'powerup_n';   
2414                 templateNameText(548609244)   := 'weapon_melee_balancing_weights';
2415                 templateNameTable(548609244)  := 'powerup_n';
2416                 templateNameText(-1004627683) := 'weapon_melee_inertial_fluctuator';
2417                 templateNameTable(-1004627683):= 'powerup_n';
2418                 templateNameText(352903310)   := 'weapon_ranged_barrel';
2419                 templateNameTable(352903310)  := 'powerup_n';
2420                 templateNameText(130303407)   := 'weapon_ranged_grip';
2421                 templateNameTable(130303407)  := 'powerup_n';
2422                 templateNameText(1006954225)  := 'weapon_ranged_muzzle';
2423                 templateNameTable(1006954225) := 'powerup_n';
2424                 templateNameText(200431483)   := 'weapon_ranged_scope';
2425                 templateNameTable(200431483)  := 'powerup_n';
2426                 templateNameText(1219521873)  := 'weapon_ranged_stock';
2427                 templateNameTable(1219521873) := 'powerup_n';
2428                 templateNameText(-551790316)  := 'weapon_melee_surface_serration';
2429                 templateNameTable(-551790316) := 'powerup_n';
2430                 templateNameText(-1042074732) := 'weapon_melee_tactical_grip';
2431                 templateNameTable(-1042074732):= 'powerup_n';
2432                 templateNameText(-356900087)  := 'instant_stimpack_a';
2433                 templateNameTable(-356900087) := 'medicine_name';
2434                 templateNameText(833457054)   := 'instant_stimpack_b';
2435                 templateNameTable(833457054)  := 'medicine_name';
2436                 templateNameText(2023812115)  := 'instant_stimpack_c';
2437                 templateNameTable(2023812115) := 'medicine_name';
2438                 templateNameText(-2092710137) := 'instant_stimpack_d';
2439                 templateNameTable(-2092710137):= 'medicine_name';
2440                 templateNameText(-1674079888) := 'stimpack_pet_a';
2441                 templateNameTable(-1674079888):= 'medicine_name';
2442                 templateNameText(1193294311)  := 'stimpack_pet_b';
2443                 templateNameTable(1193294311) := 'medicine_name';
2444                 templateNameText(237854314)   := 'stimpack_pet_c';
2445                 templateNameTable(237854314)  := 'medicine_name';
2446                 templateNameText(-171018882)  := 'stimpack_pet_d';
2447                 templateNameTable(-171018882) := 'medicine_name';
2448                 templateNameText(-1631144444) := 'rifle_bowcaster_heavy';
2449                 templateNameText(-746051337)  := 'carbine_e11_mark2';
2450                 templateNameText(1893534473)  := 'enhancer_bactajab';
2451                 templateNameTable(1893534473) := 'medicine_name';
2452                 templateNameText(189249679)   := 'enhancer_bactaspray';
2453                 templateNameTable(189249679)  := 'medicine_name';
2454                 templateNameText(-1945173818) := 'enhancer_bactatoss';
2455                 templateNameTable(-1945173818):= 'medicine_name';
2456                 templateNameText(-21620221)   := 'enhancer_deuteriumtoss';
2457                 templateNameTable(-21620221)  := 'medicine_name';
2458                 templateNameText(1004186547)  := 'enhancer_disinfect';
2459                 templateNameTable(1004186547) := 'medicine_name';
2460                 templateNameText(232945406)   := 'enhancer_endorphineinjection';
2461                 templateNameTable(232945406)  := 'medicine_name';
2462                 templateNameText(-2018470158) := 'enhancer_neurotoxin';
2463                 templateNameTable(-2018470158):= 'medicine_name';
2464                 templateNameText(2094584686)  := 'enhancer_nutrientinjection';
2465                 templateNameTable(2094584686) := 'medicine_name';
2466                 templateNameText(-1847366477) := 'enhancer_stabilizer';
2467                 templateNameTable(-1847366477):= 'medicine_name';
2468                 templateNameText(-410958245)  := 'enhancer_thyroidrupture';
2469                 templateNameTable(-410958245) := 'medicine_name';
2470                 templateNameText(-454097742)  := 'enhancer_traumatize';
2471                 templateNameTable(-454097742) := 'medicine_name';
2472                 
2473                 return TRUE;
2474         exception
2475                 when others then
2476                         err_num := SQLCODE;
2477                         dbms_output.put_line('Error in InitializeData - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2478                         db_error_logger.dblogerror(err_num, 'Error in InitializeData');
2479                         return FALSE;
2480         end;
2482         procedure AddObjVar (objvar_name varchar2, objvar_type number, objvar_value varchar2)
2483         is
2484                 n number;
2485                 tempObjVar objVarType;
2486                 oldName varchar2(500);
2487         begin
2488                 if slot_map.exists(objvar_name) then
2489                         ModifyObjVar(objvar_name, objvar_name, objvar_type, objvar_value);
2490                 else
2491                         if free_slots.count > 0 and length(objvar_name) <= 50 then
2492                                 n := free_slots(free_slots.first);
2493                                 Obj_ObjVars(n).objvar_name := objvar_name;
2494                                 Obj_ObjVars(n).objvar_type := objvar_type;
2495                                 Obj_ObjVars(n).objvar_value := objvar_value;
2496                                 free_slots.delete(n);
2497                                 isObjModified := TRUE;
2498                         else
2499                                 if deleted_objvars.count > 0 then
2500                                         oldName := deleted_objvars(deleted_objvars.last);
2501                                         deleted_objvars.trim(1);
2502                                         OV_ObjVars(oldName).objvar_name := objvar_name;
2503                                         OV_ObjVars(oldName).objvar_type := objvar_type;
2504                                         OV_ObjVars(oldName).objvar_value := objvar_value;
2505                                         updated_objvars.extend(1);
2506                                         updated_objvars(updated_objvars.last) := oldName;
2507                                 else
2508                                         tempObjVar.object_id := object_id;
2509                                         tempObjVar.objvar_name := objvar_name;
2510                                         tempObjVar.objvar_type := objvar_type;
2511                                         tempObjVar.objvar_value := objvar_value;
2512                                         tempObjVar.objvar_name_id := objvarNameIdMap(objvar_name);
2513                                         OV_ObjVars(objvar_name) := tempObjVar;
2514                                         added_objvars.extend(1);
2515                                         added_objvars(added_objvars.last) := objvar_name;
2516                                 end if;
2517                         end if;
2518                 end if;
2519         exception
2520                 when others then
2521                         err_num := SQLCODE;
2522                         dbms_output.put_line('Error in AddObjVar - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2523                         db_error_logger.dblogerror(err_num, 'Error in AddObjVar');
2524         end;
2526         procedure DeleteObjVar (objVarName in varchar2)
2527         is
2528                 n number;
2529                 v varchar2(500);
2530         begin
2531                 if slot_map.exists(objVarName) then
2532                         if slot_map(objVarName) < 21 then
2533                                 n := slot_map(objVarName);
2534                                 if Obj_ObjVars(n).objvar_name = objVarName then
2535                                         Obj_ObjVars(n).objvar_name := NULL;
2536                                         Obj_ObjVars(n).objvar_type := NULL;
2537                                         Obj_ObjVars(n).objvar_value := NULL;
2538                                         free_slots(n) := n;
2539                                         isObjModified := TRUE;
2540                                 end if;
2541                         else
2542                                 if OV_ObjVars(objVarName).objvar_name  = objVarName then
2543                                         OV_ObjVars(objVarName).old_objvar_name_id := OV_ObjVars(objVarName).objvar_name_id;
2544                                         OV_ObjVars(objVarName).objvar_name := NULL;
2545                                         OV_ObjVars(objVarName).objvar_type := NULL;
2546                                         OV_ObjVars(objVarName).objvar_value := NULL;
2547                                         deleted_objvars.extend(1);
2548                                         deleted_objvars(deleted_objvars.last) := objVarName;
2549                                 end if;
2550                         end if;
2551                 elsif instr(objVarName,'*') > 0 then
2552                         n := instr(objVarName,'*') -1;
2553                         v := slot_map.first;
2554                         while v is not null loop
2555                                 if substr(v,1,n) = substr(objVarName,1,n) then
2556                                         DeleteObjVar(v);
2557                                 end if;
2558                                 v := slot_map.next(v);
2559                         end loop;
2560                 end if;
2561         exception
2562                 when others then
2563                         err_num := SQLCODE;
2564                         dbms_output.put_line('Error in DeleteObjVar - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2565                         db_error_logger.dblogerror(err_num, 'Error in DeleteObjVar');
2566         end;
2568         procedure ModifyObjVar (oldObjVarName varchar2, objvar_name varchar2, objvar_type number, objvar_value varchar2)
2569         is
2570                 n number;
2571         begin
2572                 if slot_map.exists(oldObjVarName) then
2573                         if slot_map(oldObjVarName) < 21 then
2574                                 n := slot_map(oldObjVarName);
2575                                 Obj_ObjVars(n).objvar_name := objvar_name;
2576                                 Obj_ObjVars(n).objvar_type := objvar_type;
2577                                 Obj_ObjVars(n).objvar_value := objvar_value;
2578                                 isObjModified := TRUE;
2579                         else
2580                                 OV_ObjVars(oldObjVarName).old_objvar_name_id := OV_ObjVars(oldObjVarName).objvar_name_id;
2581                                 OV_ObjVars(oldObjVarName).objvar_name := objvar_name;
2582                                 OV_ObjVars(oldObjVarName).objvar_type := objvar_type;
2583                                 OV_ObjVars(oldObjVarName).objvar_value := objvar_value;
2584                                 updated_objvars.extend(1);
2585                                 updated_objvars(updated_objvars.last) := oldObjVarName;
2586                         end if;
2587                 end if;
2588         exception
2589                 when others then
2590                         err_num := SQLCODE;
2591                         dbms_output.put_line('Error in ModifyObjVar - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2592                         db_error_logger.dblogerror(err_num, 'Error in ModifyObjVar');
2593         end;
2595         procedure ModifyObjVar (oldObjVarName varchar2, objvar_name varchar2, objvar_type number, rangeTable rangeTableType)
2596         is
2597                 n number;
2598         begin
2599                 if slot_map.exists(oldObjVarName) then
2600                         if slot_map(oldObjVarName) < 21 then
2601                                 n := slot_map(oldObjVarName);
2602                                 Obj_ObjVars(n).objvar_name := objvar_name;
2603                                 Obj_ObjVars(n).objvar_type := objvar_type;
2604                                 Obj_ObjVars(n).objvar_value := ConvertValue (to_number(Obj_ObjVars(n).objvar_value), rangeTable);
2605                                 isObjModified := TRUE;
2606                         else
2607                                 if OV_ObjVars(oldObjVarName).old_objvar_name_id = 0 then
2608                                         OV_ObjVars(oldObjVarName).old_objvar_name_id := OV_ObjVars(oldObjVarName).objvar_name_id;
2609                                 end if;
2610                                 OV_ObjVars(oldObjVarName).objvar_name := objvar_name;
2611                                 OV_ObjVars(oldObjVarName).objvar_type := objvar_type;
2612                                 OV_ObjVars(oldObjVarName).objvar_value := ConvertValue (to_number(OV_ObjVars(oldObjVarName).objvar_value), rangeTable);
2613                                 updated_objvars.extend(1);
2614                                 updated_objvars(updated_objvars.last) := oldObjVarName;
2615                         end if;
2616                 end if;
2617         exception
2618                 when others then
2619                         err_num := SQLCODE;
2620                         dbms_output.put_line('Error in ModifyObjVar - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2621                         db_error_logger.dblogerror(err_num, 'Error in ModifyObjVar');
2622         end;
2624         procedure RenameObjVar (oldObjVarName varchar2, objvar_name varchar2)
2625         is
2626                 n number;
2627         begin
2628                 if slot_map.exists(oldObjVarName) then
2629                         if slot_map(oldObjVarName) < 21 then
2630                                 n := slot_map(oldObjVarName);
2631                                 Obj_ObjVars(n).objvar_name := objvar_name;
2632                                 isObjModified := TRUE;
2633                         else
2634                                 OV_ObjVars(oldObjVarName).old_objvar_name_id := OV_ObjVars(oldObjVarName).objvar_name_id;
2635                                 OV_ObjVars(oldObjVarName).objvar_name := objvar_name;
2636                                 updated_objvars.extend(1);
2637                                 updated_objvars(updated_objvars.last) := oldObjVarName;
2638                         end if;
2639                 end if;
2640         exception
2641                 when others then
2642                         err_num := SQLCODE;
2643                         dbms_output.put_line('Error in ModifyObjVar - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2644                         db_error_logger.dblogerror(err_num, 'Error in ModifyObjVar');
2645         end;
2647         function GetObjVarValue (objvar_name varchar2) return varchar2
2648         is
2649         begin
2650                 if slot_map.exists(objvar_name) then
2651                         if slot_map(objvar_name) < 21 then
2652                                 return Obj_ObjVars(slot_map(objvar_name)).objvar_value;
2653                         else
2654                                 return OV_ObjVars(objvar_name).objvar_value;
2655                         end if;
2656                 else
2657                         return null;
2658                 end if;
2659         end;
2661         procedure AddScript (newScript varchar2)
2662         is
2663         begin
2664                 script_list := trim(script_list) ||  newScript || ':';
2665                 isObjModified := TRUE;
2666         end;
2668         procedure RemoveScript (oldScript varchar2)
2669         is
2670         begin
2671                 script_list := replace(script_list, oldScript || ':');
2672                 isObjModified := TRUE;
2673         end;
2675         procedure SetNewTemplateId (newTemplateId number)
2676         is
2677         begin
2678                 new_template_id := newTemplateId;
2679                 SetTemplateText (newTemplateId);
2680         end;
2681         
2682         procedure SetTemplateText (newTemplateId number)
2683         is
2684         begin           
2685                 if templateNameText.exists(newTemplateId) then
2686                         object_name := null;
2687                         name_text  := templateNameText(newTemplateId);
2688                         if templateNameTable.exists(newTemplateId) then
2689                                 name_table := templateNameTable(newTemplateId);
2690                         end if;
2691                 end if;
2692         end;
2693         
2694         procedure InvalidateSchematic
2695         is
2696         begin
2697                 AddObjVar('ImAnInvalidSchematic',0,1);
2698                 isObjModified := TRUE;
2699         end;
2700         
2701         procedure AddAttrib (attrib_name varchar2, attrib_value float)
2702         is
2703                 oldName varchar2(500);
2704                 tempAttrib manfAttributeRowType;
2705         begin
2706                 if manf_attributes.exists(attrib_name) then
2707                         ModifyAttrib(attrib_name, attrib_name, attrib_value);
2708                 else
2709                         if deleted_attribs.count >0 then
2710                                 oldName := deleted_attribs(deleted_attribs.last);
2711                                 deleted_attribs.trim(1);
2712                                 manf_attributes(oldName).attribute := attrib_name;
2713                                 manf_attributes(oldName).value := attrib_value;
2714                                 updated_attribs.extend(1);
2715                                 updated_attribs(updated_attribs.last) := oldName;
2716                         else
2717                                 tempAttrib.object_id := object_id;
2718                                 tempAttrib.attribute := attrib_name;
2719                                 tempAttrib.value := attrib_value;
2720                                 manf_attributes(attrib_name) := tempAttrib;
2721                                 added_attribs.extend(1);
2722                                 added_attribs(added_attribs.last) := attrib_name;
2723                         end if;
2724                 end if;
2725         exception
2726                 when others then
2727                         err_num := SQLCODE;
2728                         dbms_output.put_line('Error in AddAttrib - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2729                         db_error_logger.dblogerror(err_num, 'Error in AddAttrib');
2730         end;
2732         procedure DeleteAttrib (attrib_name in varchar2)
2733         is
2734                 n number;
2735                 v varchar2(500);
2736         begin
2737                 if manf_attributes.exists(attrib_name) then
2738                         if manf_attributes(attrib_name).attribute  = attrib_name then
2739                                 manf_attributes(attrib_name).attribute := NULL;
2740                                 manf_attributes(attrib_name).value := NULL;
2741                                 deleted_attribs.extend(1);
2742                                 deleted_attribs(deleted_attribs.last) := attrib_name;
2743                         end if;
2744                 elsif instr(attrib_name,'*') > 0 then
2745                         n := instr(attrib_name,'*') -1;
2746                         v := manf_attributes.first;
2747                         while v is not null loop
2748                                 if substr(v,1,n) = substr(attrib_name,1,n) then
2749                                         DeleteAttrib(v);
2750                                 end if;
2751                                 v := manf_attributes.next(v);
2752                         end loop;
2753                 end if;
2754         exception
2755                 when others then
2756                         err_num := SQLCODE;
2757                         dbms_output.put_line('Error in DeleteAttrib - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2758                         db_error_logger.dblogerror(err_num, 'Error in DeleteAttrib');
2759         end;
2761         procedure ModifyAttrib (old_attrib_name varchar2, attrib_name varchar2, attrib_value float)
2762         is
2763                 n number;
2764         begin
2765                 if manf_attributes.exists(attrib_name) then
2766                         manf_attributes(old_attrib_name).attribute := attrib_name;
2767                         manf_attributes(old_attrib_name).value := attrib_value;
2768                         updated_attribs.extend(1);
2769                         updated_attribs(updated_attribs.last) := old_attrib_name;
2770                 end if;
2771         exception
2772                 when others then
2773                         err_num := SQLCODE;
2774                         dbms_output.put_line('Error in ModifyAttribs - time = ' || to_char(sysdate, 'MM/DD/YY HH24:MI:SS'));
2775                         db_error_logger.dblogerror(err_num, 'Error in ModifyAttribs');
2776         end;
2777         
2778         procedure DeleteOldArmorObjvars
2779         is
2780         begin
2781                 DeleteObjVar('armor.rating');
2782                 DeleteObjVar('armor.vulnerability');
2783                 DeleteObjVar('armor.encumbrance');
2784                 DeleteObjVar('armor.special*');
2785                 DeleteObjVar('crafting_components.armor*');
2786                 RemoveScript('item.armor.armor');
2787         end;
2788         
2789         procedure SetGenProtection(rangeTable rangeTableType)
2790         is
2791         begin
2792                 if isFactory= TRUE then
2793                         ModifyObjVar('crafting_attributes.crafting:armor_effectiveness','crafting_attributes.crafting:general_protection',2,rangeTable);
2794                 else
2795                         ModifyObjVar('armor.effectiveness','armor.general_protection',2,rangeTable);
2796                 end if;
2797         end;
2798         
2799         procedure SetArmorCondLevelCat(condition varchar2, lev varchar2, category varchar2)
2800         is
2801         begin
2802                 if isFactory= TRUE then
2803                         AddObjVar('crafting_attributes.crafting:condition',2,condition);
2804                         AddObjVar('armorLevel',0,lev);
2805                         AddObjVar('armorCategory',0,category);
2806                 else
2807                         AddObjVar('armor.condition',2,condition);
2808                         AddObjVar('armor.armorLevel',0,lev);
2809                         AddObjVar('armor.armorCategory',0,category);
2810                 end if;
2811         end;
2812         
2813         procedure SetArmorLevel(lev varchar)
2814         is
2815         begin
2816                 if isFactory= TRUE then
2817                         AddObjVar('armorLevel',0,lev);
2818                 else
2819                         AddObjVar('armor.armorLevel',0,lev);
2820                 end if;
2821         end;
2822         
2823         procedure SetArmorCategory(category varchar2)
2824         is 
2825         begin
2826                 if isFactory= TRUE then
2827                         AddObjVar('armorCategory',0,category);
2828                 else
2829                         AddObjVar('armor.armorCategory',0,category);
2830                 end if;
2831         end;
2833         procedure SetGpAndCond(gp_name varchar2, gp_val varchar2, cond_name varchar2, cond_val varchar2)
2834         is 
2835         begin
2836                 AddObjVar(gp_name,2,gp_val);
2837                 AddObjVar(cond_name,2,cond_val);
2838         end;
2839         
2840         procedure DeleteCraftingComponents
2841         is
2842         begin
2843                 DeleteObjVar('crafting_components.*');
2844                 DeleteObjVar('item_attrib_keys');
2845                 DeleteObjVar('item_attrib_values');
2846         end;
2848         procedure CopySchematicAttributes
2849         is
2850                 n number;
2851                 v varchar2(500);
2852         begin
2853                 if (manf_attributes.count = 0) then
2854                         v := slot_map.first;
2855                         while v is not null loop
2856                                 if substr(v,1,29) = 'crafting_attributes.crafting:' then
2857                                         if slot_map(v) < 21 then
2858                                                 n := Obj_ObjVars(slot_map(v)).objvar_value;
2859                                         else
2860                                                 n := OV_ObjVars(v).objvar_value;
2861                                         end if;
2862                                         AddAttrib(substr(v,21), n);
2863                                 end if;
2864                                 v := slot_map.next(v);
2865                         end loop;
2866                 end if;
2867                 DeleteObjVar('crafting_attributes.crafting:*');
2868         end;
2870         procedure HandleFoodSchematic
2871         is
2872         begin
2873                 CopySchematicAttributes;
2874                 ConvertAttribValue('flavor', rangeTableType(rangeType(0,200,0.0,200.0)));
2875                 ConvertAttribValue('nutrition', rangeTableType(rangeType(0,200,0.0,200.0)));
2876                 DeleteObjVar('item_attrib_keys');
2877                 DeleteObjVar('item_attrib_values');
2878         end;
2879         
2880         procedure HandleFoodCrate
2881         is
2882         begin
2883                 ModifyObjVar('crafting_attributes.crafting:flavor','crafting_attributes.crafting:flavor',2,rangeTableType(rangeType(0,200,0.0,200.0)));
2884                 ModifyObjVar('crafting_attributes.crafting:nutrition','crafting_attributes.crafting:nutrition',2,rangeTableType(rangeType(0,200,0.0,200.0)));
2885         end;
2887         procedure ConvertToStimpack(stim_template number,healing_power number, combat_level number)
2888         is
2889         begin
2890                 if isSchematic = TRUE then
2891                         CopySchematicAttributes;
2892                         new_schematic_id := stim_template;
2893                         SetTemplateText(SchematicMap(stim_template));
2894                         ModifyAttrib('power','power',healing_power);
2895                         DeleteObjVar('item_attrib_keys');
2896                         DeleteObjVar('item_attrib_values');
2897                         script_list := 'systems.crafting.chemistry.crafted_items.crafting_medpack_stimpack_chemistry:';
2898                         isObjModified := TRUE;
2899                 elsif isFactory = TRUE then     
2900                         SetTemplateText(SchematicMap(stim_template));
2901                         ModifyObjVar('draftSchematic','draftSchematic',0,stim_template);
2902                         ModifyObjVar('crafting_attributes.crafting:power','crafting_attributes.crafting:power',2,healing_power);
2903                         script_list := 'systems.crafting.chemistry.crafted_items.crafting_medpack_stimpack_chemistry:';
2904                         isObjModified := TRUE;
2905                 else
2906                         SetNewTemplateId (SchematicMap(stim_template));
2907                         DeleteObjVar('healing.*');
2908                         DeleteObjVar('consumable.*');
2909                         AddObjVar('healing.power',0,healing_power);
2910                         AddObjVar('healing.combat_level_required',0,combat_level);
2911                         RemoveScript('item.comestible.medicine');
2912                         AddScript('item.medicine.stimpack');
2913                 end if;
2914         end;
2915         
2916         procedure ConvertToPetStimpack(stim_template number,healing_power number)
2917         is
2918         begin
2919                 if isSchematic = TRUE then
2920                         CopySchematicAttributes;
2921                         new_schematic_id := stim_template;
2922                         SetTemplateText(SchematicMap(stim_template));
2923                         ModifyAttrib('power','power',healing_power);
2924                         DeleteObjVar('item_attrib_keys');
2925                         DeleteObjVar('item_attrib_values');
2926                         script_list := 'systems.crafting.bio_engineer.instant_stimpack.crafting_stimpack_pet:';
2927                         isObjModified := TRUE;
2928                 elsif isFactory = TRUE then     
2929                         SetTemplateText(SchematicMap(stim_template));
2930                         ModifyObjVar('draftSchematic','draftSchematic',0,stim_template);
2931                         ModifyObjVar('crafting_attributes.crafting:power','crafting_attributes.crafting:power',2,healing_power);
2932                         script_list := 'systems.crafting.bio_engineer.instant_stimpack.crafting_stimpack_pet:';
2933                         isObjModified := TRUE;
2934                 else
2935                         SetNewTemplateId (SchematicMap(stim_template));
2936                         DeleteObjVar('healing.*');
2937                         DeleteObjVar('consumable.*');
2938                         AddObjVar('healing.power',0,healing_power);
2939                         RemoveScript('item.comestible.pet_med');
2940                         AddScript('item.comestible.pet_med');
2941                 end if;
2942         end;
2943         
2944         procedure ConvertToEnhancer(enh_template number, enh_name varchar2, enh_power number)
2945         is
2946         begin
2947                 if isSchematic = TRUE then
2948                         CopySchematicAttributes;
2949                         new_schematic_id := enh_template;
2950                         SetTemplateText(SchematicMap(enh_template));
2951                         ModifyAttrib('power','power',enh_power);
2952                         DeleteObjVar('item_attrib_keys');
2953                         DeleteObjVar('item_attrib_values');
2954                         script_list := 'systems.crafting.chemistry.crafting_enhancers:';
2955                         isObjModified := TRUE;
2956                 elsif isFactory = TRUE then     
2957                         SetTemplateText(SchematicMap(enh_template));
2958                         ModifyObjVar('draftSchematic','draftSchematic',0,enh_template);
2959                         ModifyObjVar('crafting_attributes.crafting:power','crafting_attributes.crafting:power',2,enh_power);
2960                         script_list := 'systems.crafting.chemistry.crafting_enhancers:';
2961                         isObjModified := TRUE;
2962                 else
2963                         SetNewTemplateId (SchematicMap(enh_template));
2964                         DeleteObjVar('healing.*');
2965                         DeleteObjVar('consumable.*');
2966                         AddObjVar('commandName',4,enh_name);
2967                         AddObjVar('healing.enhancement',2,enh_power);
2968                         RemoveScript('item.comestible.medicine');
2969                         AddScript('item.medicine.enhancer');
2970                 end if;
2971         end;
2972         
2973         procedure ConvertSpice(spice_name varchar2)
2974         is
2975         begin
2976                 if isSchematic = TRUE then
2977                         DeleteObjVar('item_attrib_keys');
2978                         DeleteObjVar('item_attrib_values');
2979                 elsif isFactory = FALSE then
2980                         AddObjVar('spice.name',4,spice_name);
2981                         DeleteObjVar('dur');
2982                         DeleteObjVar('health');
2983                         DeleteObjVar('str');
2984                         DeleteObjVar('con');
2985                         DeleteObjVar('action');
2986                         DeleteObjVar('quick');
2987                         DeleteObjVar('stam');
2988                         DeleteObjVar('mind');
2989                         DeleteObjVar('focus');
2990                         DeleteObjVar('will');
2991                         RemoveScript('item.comestible.spice');
2992                         AddScript('item.spice');
2993                 end if;
2994         end;
2995         
2997         procedure HandleWeaponDots
2998         is
2999                 a varchar2(500);
3000                 b varchar2(10);
3001                 dmgDelta number;
3002         begin
3003                 a := dot_list.first;
3004                 while a is not null loop
3005                         if (dot_list(a).exists('type') and dot_list(a).exists('attribute') and dot_list(a).exists('strength')) then
3006                                 dmgDelta := ((weapon_attribs.min_damage +weapon_attribs.max_damage) / 2) *
3007                                         ((to_number(nvl(dot_list(a)('strength').objvar_value,0)) / 1000) *
3008                                         (DotsMatrix(dot_list(a)('type').objvar_value, 
3009                                                 to_number(nvl(dot_list(a)('attribute').objvar_value,-1)) ) / 20));
3010                                 weapon_attribs.min_damage := weapon_attribs.min_damage + dmgDelta;      
3011                                 weapon_attribs.max_damage := weapon_attribs.max_damage + dmgDelta;      
3012                                 
3013                                 b := dot_list(a).first;
3014                                 while b is not null loop
3015                                         DeleteObjVar(dot_list(a)(b).objvar_name);
3016                                         b := dot_list(a).next(b);
3017                                 end loop;
3018                         end if; 
3019                         a := dot_list.next(a);
3020                 end loop;
3021                 -- also remove powerups
3022                 DeleteObjVar('powerup.*');
3023                 RemoveScript('powerup.weapon');
3024         end;
3026         procedure SetWeaponBaseStats(attack number, acc number, minrange number, maxrange number, damagetype number)
3027         is
3028         begin
3029                 SetAttackCost(attack);
3030                 SetAccuracy(acc);
3031                 SetMinRange(minrange);
3032                 SetMaxRange(maxrange);
3033                 SetDamageType(damagetype);
3034         end;
3036         procedure SetMinDamage (min_damage number) 
3037         is
3038         begin
3039                 if isSchematic = TRUE then
3040                         AddAttrib('crafting:minDamage', min_damage);
3041                         DeleteObjVar('crafting_attributes.crafting:minDamage');
3042                 elsif isFactory = TRUE then     
3043                         AddObjVar('crafting_attributes.crafting:minDamage',2,min_damage);
3044                 elsif isWeaponObj = TRUE then
3045                         weapon_attribs.min_damage := min_damage;
3046                 else
3047                         AddObjVar('crafting_components.minDamage',2,min_damage);                        
3048                 end if;
3049         end;
3050         
3051         procedure SetMaxDamage (max_damage number)
3052         is
3053         begin
3054                 if isSchematic = TRUE then
3055                         AddAttrib('crafting:maxDamage', max_damage);
3056                         DeleteObjVar('crafting_attributes.crafting:maxDamage');
3057                 elsif isFactory = TRUE then     
3058                         AddObjVar('crafting_attributes.crafting:maxDamage',2,max_damage);
3059                 elsif isWeaponObj = TRUE then
3060                         weapon_attribs.max_damage := max_damage;
3061                 else
3062                         AddObjVar('crafting_components.maxDamage',2,max_damage);                        
3063                 end if;
3064         end;
3065         
3066         procedure SetAttackSpeed (attack_speed number)
3067         is
3068         begin
3069                 if isSchematic = TRUE then
3070                         AddAttrib('crafting:attackSpeed', attack_speed);
3071                         DeleteObjVar('crafting_attributes.crafting:attackSpeed');
3072                 elsif isFactory = TRUE then     
3073                         AddObjVar('crafting_attributes.crafting:attackSpeed',2,attack_speed);
3074                 elsif isWeaponObj = TRUE then
3075                         weapon_attribs.attack_speed := attack_speed;
3076                 else
3077                         AddObjVar('crafting_components.attackSpeed',2,attack_speed);                    
3078                 end if;
3079         end;
3080         
3081         procedure SetWoundChance (wound_chance number)
3082         is
3083         begin
3084                 if isSchematic = TRUE then
3085                         AddAttrib('crafting:woundChance', wound_chance);
3086                         DeleteObjVar('crafting_attributes.crafting:woundChance');
3087                 elsif isFactory = TRUE then     
3088                         AddObjVar('crafting_attributes.crafting:woundChance',2,wound_chance);
3089                 elsif isWeaponObj = TRUE then
3090                         weapon_attribs.wound_chance := wound_chance;
3091                 else
3092                         AddObjVar('crafting_components.woundChance',2,wound_chance);                    
3093                 end if;
3094         end;
3095         
3096         procedure SetAccuracy (accuracy number)
3097         is
3098         begin
3099                 if isSchematic = TRUE then
3100                         DeleteAttrib('crafting:zeroRangeMod');
3101                         DeleteAttrib('crafting:minRangeMod');
3102                         DeleteAttrib('crafting:midRangeMod');
3103                         DeleteAttrib('crafting:maxRangeMod');
3104                         AddAttrib('crafting:accuracy', accuracy);
3105                         DeleteObjVar('crafting_attributes.crafting:minRangeMod');
3106                         DeleteObjVar('crafting_attributes.crafting:zeroRangeMod');
3107                         DeleteObjVar('crafting_attributes.crafting:midRangeMod');
3108                         DeleteObjVar('crafting_attributes.crafting:maxRangeMod');
3109                 elsif isFactory = TRUE then     
3110                         AddObjVar('crafting_attributes.crafting:accuracy',2,accuracy);
3111                         DeleteObjVar('crafting_attributes.crafting:zeroRangeMod');
3112                         DeleteObjVar('crafting_attributes.crafting:minRangeMod');
3113                         DeleteObjVar('crafting_attributes.crafting:midRangeMod');
3114                         DeleteObjVar('crafting_attributes.crafting:maxRangeMod');
3115                 elsif isWeaponObj = TRUE then
3116                         weapon_attribs.accuracy := accuracy;
3117                 else
3118                         AddObjVar('crafting_components.accuracy',2,accuracy);                   
3119                 end if;
3120         end;
3121         
3122         procedure SetAttackCost (attack_cost number)
3123         is
3124         begin
3125                 if isSchematic = TRUE then
3126                         AddAttrib('crafting:attackCost', attack_cost);
3127                         DeleteAttrib('crafting:attackHealthCost');
3128                         DeleteAttrib('crafting:attackActionCost');
3129                         DeleteAttrib('crafting:attackMindCost');
3130                         DeleteObjVar('crafting_attributes.crafting:attackHealthCost');
3131                         DeleteObjVar('crafting_attributes.crafting:attackActionCost');
3132                         DeleteObjVar('crafting_attributes.crafting:attackMindCost');
3133                 elsif isFactory = TRUE then     
3134                         AddObjVar('crafting_attributes.crafting:attackCost',2,attack_cost);
3135                         DeleteObjVar('crafting_attributes.crafting:attackHealthCost');
3136                         DeleteObjVar('crafting_attributes.crafting:attackActionCost');
3137                         DeleteObjVar('crafting_attributes.crafting:attackMindCost');
3138                 elsif isWeaponObj = TRUE then
3139                         weapon_attribs.attack_cost := attack_cost;
3140                 else
3141                         AddObjVar('crafting_components.attackCost',2,attack_cost);                      
3142                 end if;
3143         end;
3144         
3145         procedure SetMinRange (min_range number)
3146         is
3147         begin
3148                 if isSchematic = TRUE then
3149                         AddAttrib('crafting:minRange', min_range);
3150                         DeleteObjVar('crafting_attributes.crafting:minRange');
3151                         DeleteObjVar('crafting_attributes.crafting:midRange');
3152                 elsif isFactory = TRUE then     
3153                         AddObjVar('crafting_attributes.crafting:minRange',2,min_range);
3154                         DeleteObjVar('crafting_attributes.crafting:midRange');
3155                 elsif isWeaponObj = TRUE then
3156                         weapon_attribs.min_range := min_range;
3157                 else
3158                         AddObjVar('crafting_components.minRange',2,min_range);                  
3159                 end if;
3160         end;
3161         
3162         procedure SetMaxRange (max_range number)
3163         is
3164         begin
3165                 if isSchematic = TRUE then
3166                         AddAttrib('crafting:maxRange', max_range);
3167                         DeleteObjVar('crafting_attributes.crafting:maxRange');
3168                 elsif isFactory = TRUE then     
3169                         AddObjVar('crafting_attributes.crafting:maxRange',2,max_range);
3170                 elsif isWeaponObj = TRUE then
3171                         weapon_attribs.max_range := max_range;
3172                 else
3173                         AddObjVar('crafting_components.maxRange',2,max_range);                  
3174                 end if;
3175         end;
3177         procedure SetDamageType (dmg_type number)       
3178         is
3179         begin
3180                 if isSchematic = TRUE then
3181                         AddAttrib('crafting:damageType', dmg_type);
3182                         DeleteObjVar('crafting_attributes.crafting:damageType');
3183                 elsif isFactory = TRUE then     
3184                         AddObjVar('crafting_attributes.crafting:damageType',2,dmg_type);
3185                 elsif isWeaponObj = TRUE then
3186                         weapon_attribs.damage_type := dmg_type;
3187                 else
3188                         AddObjVar('crafting_components.damageType',2,dmg_type);                 
3189                 end if;
3190         end;
3192         procedure SetElementalType (ele_type number)    
3193         is
3194         begin
3195                 if isSchematic = TRUE then
3196                         AddAttrib('crafting:elementalType', ele_type);
3197                         DeleteObjVar('crafting_attributes.crafting:elementalType');
3198                 elsif isFactory = TRUE then     
3199                         AddObjVar('crafting_attributes.crafting:elementalType',2,ele_type);
3200                 elsif isWeaponObj = TRUE then
3201                         weapon_attribs.elemental_type := ele_type;
3202                 else
3203                         AddObjVar('crafting_components.elementalType',2,ele_type);                      
3204                 end if;
3205         end;
3207         procedure SetElementalValue (ele_value number)  
3208         is
3209         begin
3210                 if isSchematic = TRUE then
3211                         AddAttrib('crafting:elementalValue', ele_value);
3212                         DeleteObjVar('crafting_attributes.crafting:elementalValue');
3213                 elsif isFactory = TRUE then     
3214                         AddObjVar('crafting_attributes.crafting:elementalValue',2,ele_value);
3215                 elsif isWeaponObj = TRUE then
3216                         weapon_attribs.elemental_value := ele_value;
3217                 else
3218                         AddObjVar('crafting_components.elementalValue',2,ele_value);                    
3219                 end if;
3220         end;
3222         procedure ConvertAttribValue(attribute varchar2, rangeTable rangeTableType)
3223         is
3224                 n number;
3225         begin
3226                 if manf_attributes.exists('crafting:' || attribute) then
3227                         ModifyAttrib('crafting:' || attribute,'crafting:' || attribute,ConvertValue(manf_attributes('crafting:' || attribute).value, rangeTable));
3228                 elsif slot_map.exists('crafting_attributes.crafting:' || attribute) then
3229                         if slot_map('crafting_attributes.crafting:' || attribute) < 21 then
3230                                 n := Obj_ObjVars(slot_map('crafting_attributes.crafting:' || attribute)).objvar_value;
3231                         else
3232                                 n := OV_ObjVars('crafting_attributes.crafting:' || attribute).objvar_value;
3233                         end if;
3234                         AddAttrib('crafting:' || attribute, ConvertValue(n, rangeTable));
3235                 end if;
3236         end;
3238         procedure ConvertMinDamage (rangeTable rangeTableType) 
3239         is
3240         begin
3241                 if isSchematic = TRUE then
3242                         ConvertAttribValue('minDamage', rangeTable);
3243                 elsif isFactory = TRUE then     
3244                         ModifyObjVar('crafting_attributes.crafting:minDamage','crafting_attributes.crafting:minDamage',2,rangeTable);
3245                 else
3246                         weapon_attribs.min_damage := ConvertValue(weapon_attribs.min_damage, rangeTable);
3247                 end if;
3248         end;
3249         
3250         procedure ConvertMaxDamage (rangeTable rangeTableType)
3251         is
3252         begin
3253                 if isSchematic = TRUE then
3254                         ConvertAttribValue('maxDamage', rangeTable);
3255                 elsif isFactory = TRUE then     
3256                         ModifyObjVar('crafting_attributes.crafting:maxDamage','crafting_attributes.crafting:maxDamage',2,rangeTable);
3257                 else
3258                         weapon_attribs.max_damage := ConvertValue(weapon_attribs.max_damage, rangeTable);
3259                 end if;
3260         end;
3261         
3262         procedure ConvertAttackSpeed (rangeTable rangeTableType)
3263         is
3264         begin
3265                 if isSchematic = TRUE then
3266                         ConvertAttribValue('attackSpeed', rangeTable);                  
3267                 elsif isFactory = TRUE then     
3268                         ModifyObjVar('crafting_attributes.crafting:attackSpeed','crafting_attributes.crafting:attackSpeed',2,rangeTable);
3269                 else
3270                         weapon_attribs.attack_speed := ConvertValue(weapon_attribs.attack_speed*10, rangeTable)/100;
3271                 end if;
3272         end;
3273         
3274         procedure ConvertWoundChance (rangeTable rangeTableType)
3275         is
3276         begin
3277                 if isSchematic = TRUE then
3278                         ConvertAttribValue('woundChance', rangeTable);
3279                 elsif isFactory = TRUE then     
3280                         ModifyObjVar('crafting_attributes.crafting:woundChance','crafting_attributes.crafting:woundChance',2,rangeTable);
3281                 else
3282                         weapon_attribs.wound_chance := ConvertValue(weapon_attribs.wound_chance, rangeTable);
3283                 end if;
3284         end;
3285         
3286         procedure ConvertRangedPowerup
3287         is
3288                 schematic_id varchar2(50);
3289                 oldval number;
3290                 bonus number;
3291                 penalty number;
3292                 bonusObjVar varchar2(50);
3293                 penaltyObjVar varchar2(50);
3294         begin
3295                 if slot_map.exists('powerup.max_dam') then
3296                         schematic_id := 996671491; -- ranged_barrel             
3297                         oldval := to_number(GetObjVarValue('powerup.max_dam'));
3298                         if oldval > 0.33 then oldval := 0.33; end if;
3299                         bonus := oldval * 0.9;
3300                         penalty := bonus * 0.67;
3301                         bonusObjVar := 'powerup.damage';
3302                         penaltyObjVar := 'powerup.speed';
3303                 elsif slot_map.exists('powerup.min_dam') then
3304                         schematic_id := 996671491; -- ranged_barrel             
3305                         oldval := to_number(GetObjVarValue('powerup.min_dam'));
3306                         if oldval > 0.33 then oldval := 0.33; end if;
3307                         bonus := oldval * 0.9;
3308                         penalty := bonus * 0.67;
3309                         bonusObjVar := 'powerup.damage';
3310                         penaltyObjVar := 'powerup.speed';
3311                 elsif slot_map.exists('powerup.speed') then
3312                         schematic_id := -671068023; -- ranged_grip
3313                         oldval := to_number(GetObjVarValue('powerup.speed'));
3314                         if oldval > 0.33 then oldval := 0.33; end if;
3315                         bonus := oldval * -0.9;
3316                         penalty := trunc(-134 * bonus);
3317                         bonusObjVar := 'powerup.speed';
3318                         penaltyObjVar := 'powerup.accuracy';
3319                 elsif slot_map.exists('powerup.wound_chance') then
3320                         schematic_id := -1092259441; --ranged_muzzle
3321                         oldval := to_number(GetObjVarValue('powerup.wound'));
3322                         if oldval > 0.33 then oldval := 0.33; end if;
3323                         bonus := oldval * 0.9;
3324                         penalty := bonus * 0.67;
3325                         bonusObjVar := 'powerup.wound';
3326                         penaltyObjVar := 'powerup.actionCost';
3327                 elsif slot_map.exists('powerup.zero_mod') or slot_map.exists('powerup.mid_mod')  or slot_map.exists('powerup.max_mod') then
3328                         schematic_id := 917984840; -- ranged_scope
3329                         oldval := 0.20;
3330                         bonus := 18;
3331                         penalty := 0.09;
3332                         bonusObjVar := 'powerup.accuracy';
3333                         penaltyObjVar := 'powerup.speed';
3334                 else
3335                         schematic_id := 2108030646; -- ranged_stock                     
3336                         oldval := to_number(nvl(GetObjVarValue('powerup.health_cost'),'0'));
3337                         if oldval = 0 then
3338                                 oldval :=  to_number(nvl(GetObjVarValue('powerup.action_cost'),'0'));
3339                                 if oldval = 0 then
3340                                         oldval :=  to_number(nvl(GetObjVarValue('powerup.mind_cost'),'0'));
3341                                 end if;
3342                         end if;
3343                         if oldval = 0 then 
3344                                 oldval := 0.10;
3345                         elsif oldval > 0.33 then 
3346                                 oldval := 0.33; 
3347                         end if;
3348                         bonus := oldval * -0.9;
3349                         penalty := trunc(-67 * bonus);
3350                         bonusObjVar := 'powerup.actionCost';
3351                         penaltyObjVar := 'powerup.accuracy';
3352                 end if; 
3353                 if isSchematic = TRUE then
3354                         CopySchematicAttributes;
3355                         new_schematic_id := schematic_id;
3356                         SetTemplateText(SchematicMap(schematic_id));
3357                         DeleteObjVar('powerup.*');
3358                         DeleteObjVar('item_attrib_keys');
3359                         DeleteObjVar('item_attrib_values');
3360                         AddAttrib('crafting:effect',  oldval * 300);
3361                         AddAttrib('crafting:efficiency', 33);
3362                         script_list := 'systems.crafting.item.specific_item.crafting_powerup_item:';
3363                         isObjModified := TRUE;
3364                 elsif isFactory = TRUE then     
3365                         SetTemplateText(SchematicMap(schematic_id));
3366                         DeleteObjVar('powerup.*');
3367                         ModifyObjVar('draftSchematic','draftSchematic',0,schematic_id);
3368                         AddObjVar('crafting_attributes.crafting:effect',2,oldval * 300);
3369                         AddObjVar('crafting_attributes.crafting:efficiency',2,33);
3370                         script_list := 'systems.crafting.item.specific_item.crafting_powerup_item:';
3371                         isObjModified := TRUE;
3372                 else
3373                         SetNewTemplateId(SchematicMap(schematic_id));
3374                         DeleteObjVar('powerup.*');
3375                         AddObjVar('powerup.effect', 2, oldval * 300);
3376                         AddObjVar('powerup.efficiency', 2, 33);
3377                         AddObjVar('powerup.usesLeft', 0, 100);
3378                         AddObjVar(bonusObjVar, 2, bonus);
3379                         AddObjVar(penaltyObjVar, 2, penalty);
3380                 end if;
3381         end;
3383         procedure ConvertMeleePowerup
3384         is
3385                 schematic_id varchar2(50);
3386                 oldval number;
3387                 bonus number;
3388                 penalty number;
3389                 bonusObjVar varchar2(50);
3390                 penaltyObjVar varchar2(50);
3391         begin
3392                 if slot_map.exists('powerup.max_dam') then
3393                         schematic_id := 1380627363; -- inertial_fluctuator              
3394                         oldval := to_number(GetObjVarValue('powerup.max_dam'));
3395                         if oldval > 0.33 then oldval := 0.33; end if;
3396                         bonus := oldval * 0.9;
3397                         penalty := bonus * 0.67;
3398                         bonusObjVar := 'powerup.damage';
3399                         penaltyObjVar := 'powerup.speed';
3400                 elsif slot_map.exists('powerup.min_dam') then
3401                         schematic_id := 1380627363; -- inertial_fluctuator
3402                         oldval := to_number(GetObjVarValue('powerup.min_dam'));
3403                         if oldval > 0.33 then oldval := 0.33; end if;
3404                         bonus := oldval * 0.9;
3405                         penalty := bonus * 0.67;
3406                         bonusObjVar := 'powerup.damage';
3407                         penaltyObjVar := 'powerup.speed';
3408                 elsif slot_map.exists('powerup.speed') then
3409                         schematic_id := 695657910; -- tactical_grip_modifier
3410                         oldval := to_number(GetObjVarValue('powerup.speed'));
3411                         if oldval > 0.33 then oldval := 0.33; end if;
3412                         bonus := oldval * -0.9;
3413                         penalty := trunc(-134 * bonus);
3414                         bonusObjVar := 'powerup.speed';
3415                         penaltyObjVar := 'powerup.accuracy';
3416                 elsif slot_map.exists('powerup.wound_chance') then
3417                         schematic_id := -862055522; --surface_serration_kit
3418                         oldval := to_number(GetObjVarValue('powerup.wound'));
3419                         if oldval > 0.33 then oldval := 0.33; end if;
3420                         bonus := oldval * 0.9;
3421                         penalty := bonus * 0.67;
3422                         bonusObjVar := 'powerup.wound';
3423                         penaltyObjVar := 'powerup.actionCost';
3424                 elsif slot_map.exists('powerup.zero_mod') or slot_map.exists('powerup.mid_mod')  or slot_map.exists('powerup.max_mod') then
3425                         schematic_id := 1867435580; -- balancing_weights
3426                         oldval := 0.20;
3427                         bonus := 18;
3428                         penalty := 0.09;
3429                         bonusObjVar := 'powerup.accuracy';
3430                         penaltyObjVar := 'powerup.speed';
3431                 else
3432                         schematic_id := -1838768682; -- hilt_reinforcement_kit                  
3433                         oldval := to_number(nvl(GetObjVarValue('powerup.health_cost'),'0'));
3434                         if oldval = 0 then
3435                                 oldval :=  to_number(nvl(GetObjVarValue('powerup.action_cost'),'0'));
3436                                 if oldval = 0 then
3437                                         oldval :=  to_number(nvl(GetObjVarValue('powerup.mind_cost'),'0'));
3438                                 end if;
3439                         end if;
3440                         if oldval = 0 then 
3441                                 oldval := 0.10;
3442                         elsif oldval > 0.33 then 
3443                                 oldval := 0.33; 
3444                         end if;
3445                         bonus := oldval * -0.9;
3446                         penalty := trunc(-67 * bonus);
3447                         bonusObjVar := 'powerup.actionCost';
3448                         penaltyObjVar := 'powerup.accuracy';
3449                 end if; 
3450                 if isSchematic = TRUE then
3451                         CopySchematicAttributes;
3452                         new_schematic_id := schematic_id;
3453                         SetTemplateText(SchematicMap(schematic_id));
3454                         DeleteObjVar('powerup.*');
3455                         DeleteObjVar('item_attrib_keys');
3456                         DeleteObjVar('item_attrib_values');
3457                         AddAttrib('crafting:effect',  oldval * 300);
3458                         AddAttrib('crafting:efficiency', 33);
3459                         script_list := 'systems.crafting.item.specific_item.crafting_powerup_item:';
3460                         isObjModified := TRUE;
3461                 elsif isFactory = TRUE then     
3462                         SetTemplateText(SchematicMap(schematic_id));
3463                         ModifyObjVar('draftSchematic','draftSchematic',0,schematic_id);
3464                         AddObjVar('crafting_attributes.crafting:effect',2,oldval * 300);
3465                         AddObjVar('crafting_attributes.crafting:efficiency',2,33);
3466                         script_list := 'systems.crafting.item.specific_item.crafting_powerup_item:';
3467                         isObjModified := TRUE;
3468                 else
3469                         SetNewTemplateId(SchematicMap(schematic_id));
3470                         DeleteObjVar('powerup.*');
3471                         AddObjVar('powerup.effect', 2, oldval * 300);
3472                         AddObjVar('powerup.efficiency', 2, 33);
3473                         AddObjVar('powerup.usesLeft', 0, 100);
3474                         AddObjVar(bonusObjVar, 2, bonus);
3475                         AddObjVar(penaltyObjVar, 2, penalty);
3476                 end if;
3477         end;
3479         procedure ConvertMinePowerup
3480         is
3481                 oldval number;
3482         begin
3483                 if slot_map.exists('powerup.max_dam') then
3484                         oldval := to_number(GetObjVarValue('powerup.max_dam'));
3485                 elsif slot_map.exists('powerup.min_dam') then
3486                         oldval := to_number(GetObjVarValue('powerup.min_dam'));
3487                 else
3488                         oldval := 0.10;
3489                 end if; 
3490                 if oldval > 0.33 then oldval := 0.33; end if;
3491                 if isSchematic = TRUE then
3492                         CopySchematicAttributes;
3493                         new_schematic_id := -1704666295;
3494                         SetTemplateText(-2117547605);
3495                         DeleteObjVar('powerup.*');
3496                         DeleteObjVar('item_attrib_keys');
3497                         DeleteObjVar('item_attrib_values');
3498                         AddAttrib('crafting:effect',  oldval * 300);
3499                         AddAttrib('crafting:efficiency', 33);
3500                         script_list := 'systems.crafting.item.specific_item.crafting_powerup_item:';
3501                         isObjModified := TRUE;
3502                 elsif isFactory = TRUE then     
3503                         SetTemplateText(-2117547605);
3504                         ModifyObjVar('draftSchematic','draftSchematic',0,-1704666295);
3505                         AddObjVar('crafting_attributes.crafting:effect',2,oldval * 300);
3506                         AddObjVar('crafting_attributes.crafting:efficiency',2,33);
3507                         script_list := 'systems.crafting.item.specific_item.crafting_powerup_item:';
3508                         isObjModified := TRUE;
3509                 else
3510                         SetNewTemplateId(-2117547605);
3511                         DeleteObjVar('powerup.*');
3512                         AddObjVar('powerup.effect', 2, oldval * 300);
3513                         AddObjVar('powerup.efficiency', 2, 33);
3514                         AddObjVar('powerup.usesLeft', 0, 100);
3515                         AddObjVar('powerup.damage', 2, oldval * 0.9);
3516                 end if;
3517         end;
3519         function ConvertValue (oldvalue number, rangeTable rangeTableType)
3520                 return number
3521         is
3522                 retval number;
3523                 i number;
3524         begin
3525                 retval := rangeTable(rangeTable.first)(3);  -- default to min value
3526                 if oldvalue >= rangeTable(rangeTable.last)(2) then
3527                         retval := rangeTable(rangeTable.last)(4);
3528                 else
3529                         i := rangeTable.first;
3530                         while i is not null loop
3531                                 if oldvalue >= rangeTable(i)(1) and oldvalue < rangeTable(i)(2) then
3532                                         retval := (( (oldvalue - rangeTable(i)(1)) * 
3533                                                                  ((rangeTable(i)(4)-rangeTable(i)(3))/(rangeTable(i)(2)-rangeTable(i)(1))) )
3534                                                                 + rangeTable(i)(3) );
3535                                         exit;
3536                                 end if;
3537                                 i := rangeTable.next(i);
3538                         end loop;
3539                 end if;
3541                 return retval;
3542         end;
3544         procedure CheckObjVarForDot (objvar objVarType)
3545         is
3546                 dotName varchar2(500);
3547         begin
3548                 if substr(objvar.objvar_name,1,4) = 'dot.' and (instr(objvar.objvar_name,'.',-1) > 4) then
3549                         dotName := substr(objvar.objvar_name,5,instr(objvar.objvar_name,'.',-1)-5);
3550                         dot_list(dotName)(substr(objvar.objvar_name,instr(objvar.objvar_name,'.',1,2)+1,10)) := objvar;
3551                 end if;
3552         end;
3553         
3554         function DotsMatrix(dot_type varchar2, dot_attrib number)
3555                 return number
3556         is
3557                 retval number := 0;
3558         begin
3559                 if dots_matrix.exists(dot_type) and dots_matrix(dot_type).exists(dot_attrib) then
3560                         retval := dots_matrix(dot_type)(dot_attrib);
3561                 end if;
3562                 return retval;
3563         end;
3565         function SchematicMap(schematic_id number)
3566                 return number
3567         is
3568                 retval number := 0;
3569         begin
3570                 if schematic_map.exists(schematic_id) then
3571                         retval := schematic_map(schematic_id);
3572                 end if;
3573                 return retval;
3574         end;
3575 end;