Author Topic: Script Editor Guide  (Read 4597 times)

maeyan

  • Loves Hellgate
  • Administrator
  • Eldest
  • *****
  • Posts: 1997
  • Karma: 31
Script Editor Guide
« on: Aug 06, 2010; 09:48 AM »
How to write Reanimator scripts.

Reanimator scripts are XML documents, therefor comply with XML specification. There nesting is only 4 levels deep and designed to modify entire row collections with just a few lines of code.

Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<modification>
<file id="GAME_GLOBALS">
<!--REDUCE LUCK TUGBOAT-->
<entity id="55">
<attribute id="intValue">10000</attribute>
</entity>
</file>
</modification>
Above: Simple modification example 1.

Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>This first line declares the document is in XML format. This line is required for every script. Just copy and paste it as is.

Code: [Select]
<modification>The modification node is the root node for all modifications. It will always be the next line in your modification.

Code: [Select]
<file id="GAME_GLOBALS">The modification node can contain any number of <file> nodes. You must set the ID to the id of the table you want to modify. You can get the ID of the tables from the 'LOADED EXCEL LIST' in Reanimator or from the EXCELTABLES table. The ID is case sensative.

Code: [Select]
<!--REDUCE LUCK TUGBOAT-->This line is just a comment. You can put them anywhere in your mod as long as you use the write syntax. Its a good idea to comment as you go because you will be referencing a lot of things by numbers. Add a comment whereever there is just a number so you can quickly realise what everything means.

Code: [Select]
<entity id="55">Entity is another word for row. The id is the primary key of the row which you can retrieve from Reanimator. In this case we want to modify the LUCK TUGBOAT which is row 55 in the GAME_GLOBALS table. If you wanted to add a new item, simply use an index that doesnt already exist in the table. For example, the ITEMS table has 1894 rows. If you set the ID to any number greater than 1984, that row will be automatically appended.

Code: [Select]
<attribute id="intValue">10000</attribute>Attribute is another word for Column. The ID is the name of the column which you can also retrieve from Reanimator. 10000 is the value we want to set to the given cell (row 55, column intValue)

Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<modification>
<file id="INVENTORY">
<!--INCREASE INVENTORY HEIGHT-->
<entity id="10">
<attribute id="height">24</attribute>
</entity>
<!--INCREASE STASH HEIGHT-->
<entity id="26">
<attribute id="height">100</attribute>
</entity>
<!--REDUCE BUYBACK SPACE-->
<!--Notes: Performance tweak.-->
<entity id="47">
<attribute id="height">10</attribute>
</entity>
<!--CUBE FIX-->
<!--Notes: Cube doesn't work as intended without.-->
<entity id="55">
<attribute id="playerPutRestricted">0</attribute>
<attribute id="playerTakeRestricted">0</attribute>
</entity>
</file>
</modification>
Above: A larger simple example.

Advanced.

Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<modification>
<file id="ITEMS">
<!--FOR ALL ITEMS-->
<!--UNLOCK SUBSCRIBER & MULTIPLAYER ITEMS, REMOVE NO TRADE-->
<!--Notes: There are no cases when you will want to alter these values.-->
<entity id="*">
<attribute id="bitmask02" bit="SubscriberOnly">false</attribute>
<attribute id="bitmask05" bit="NoTrade">false</attribute>
<attribute id="bitmask07" bit="MultiplayerOnly">false</attribute>
</entity>
<!--SKILL RETRAINER-->
<!--ATTRIBUTE RETRAINER-->
<entity id="15,265">
<attribute id="Quality">5</attribute>
<attribute id="bitmask05" bit="NoDrop">true</attribute>
<attribute id="fixedLevel">26,55,0</attribute>
</entity>
<!--MANTRAWRAITH, ZOMBOT AND COKOMOKO-->
<entity id="178-183">
<attribute id="bitmask05" bit="NoDropExceptForDuplicates">true</attribute>
</entity>
<!--WARTS PEG LEG-->
<!--Notes: Warts leg equipable by all factions.-->
<entity id="735">
<attribute id="containerUnitType1">1</attribute>
</entity>
<!--NEW REVIVAL ITEMS-->
<!--SWORD OF MAEYAN-->
<!--Notes: This is a nice high level sword, unique level 55 based on YongKwang sword. -->
<entity id="1905">
<attribute id="name">sword of maeyan</attribute>
<attribute id="fixedLevel">26,55,0</attribute>
</entity>
</file>
</modification>
Above: a more advanced example.

Code: [Select]
<!--FOR ALL ITEMS-->
<!--UNLOCK SUBSCRIBER & MULTIPLAYER ITEMS, REMOVE NO TRADE-->
<!--Notes: There are no cases when you will want to alter these values.-->
<entity id="*">
<attribute id="bitmask02" bit="SubscriberOnly">false</attribute>
<attribute id="bitmask05" bit="NoTrade">false</attribute>
<attribute id="bitmask07" bit="MultiplayerOnly">false</attribute>
</entity>

WILD CARDS
Notice in this section the entity is uses the wildcard (the * character). This means every row in table will have their bitmask02, bitmask05 and bitmask07 columns modified.

BIT MASKS
When changing bitmasks, specify which bit you want to change by getting its name from Reanimator and specifying it in the bit attribute. Set the text to the desired operation, which will either be turning the bit on (true) or turning the bit off (false). The above code goes through every item in the ITEMS table and turns off all of the SubscriberOnly and MultiplayerOnly bits so that all items can be used inside singleplayer.

Code: [Select]
<!--SKILL RETRAINER-->
<!--ATTRIBUTE RETRAINER-->
<entity id="15,265">
<attribute id="Quality">5</attribute>
<attribute id="bitmask05" bit="NoDrop">true</attribute>
<attribute id="fixedLevel">26,55,0</attribute>
</entity>
      
RANGE LISTS
If you want to change a number of items in the same way, you can specify multiple specific rows by seperating the ids with a comma. This can be done for any number of rows, for example id="1,54,242,53,2,5". The above example changes the Skill Retrainer (15) and the Attribute Retrainer (265) to unique items, that cannot be dropped and have a fixed level of 55.

INT PTRS
Some attributes require a special syntax. These columns/attributes are know as IntPtrs or IntOffsets. Please see the IntPtr document for more information on modifying IntPtrs.

Code: [Select]
<!--MANTRAWRAITH, ZOMBOT AND COKOMOKO-->
<entity id="178-183">
<attribute id="bitmask05" bit="NoDropExceptForDuplicates">true</attribute>
</entity>

VALUE RANGES
If you want to modify a range of rows that are next to each other, using the - character in the ID can specify a range from x to y. For example the above modifies the bitmask05 for items 178,179,180,181,182,182. id="178-183" is the same as id="178,179,180,181,182,182" but is the short hand method.

Code: [Select]
<file id="ITEM_LEVELS">
<entity id="*">
<attribute id="AugmentCostRare" param="/">2</attribute>
<attribute id="AugmentCostLegendary" param="/">2</attribute>
</entity>
</file>

PARAMS
There are 4 types of params used. Params are used when you want to modify a range of entities in a logical way. This mean the entity id will either use a wildcard (*), a value list (1,22,53,41) or a range (20-25). The above example uses the divide param (/) which divides the existing value by the given demoninator, in this case 2. So basically, this code modifies every row in the ITEM_LEVELS table and divides the AugmentCostRare and AugmentCostLegendary values in half.

Another param is the multiply operator (*). If you were to replace the divide param above with the multiply param, every AugmentCostRare and AugmentCostLegendary would instead be multiplied by 2.

The other 2 params are + and -. These increase or reduce the values of a range by a given step.

Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<modification>
<file id="ITEM_LEVELS">
<entity id="1-100">
<attribute id="AugmentCostRare" param="+5">100</attribute>
</entity>
</file>
</modification>

The above example means that the first value in the range is assigned the starting value(100). Every following row will be +5 more than the last row. So if first row is assigned 100, the next row is 105, the next 110, 115, 120, 125 etc etc. Use the subtract operator to reduce values.

Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<modification>
<file id="FONTCOLORS">
<!--DOUBLE EDGED-->
<entity id="157">
<attribute id="Color">double edged</attribute>
<attribute id="blue">255</attribute>
<attribute id="green">255</attribute>
<attribute id="red">255</attribute>
<attribute id="alpha">255</attribute>
<attribute id="fontColor">-1</attribute>
</entity>
<!--MUTANT-->
<entity id="158">
<attribute id="Color">mythic</attribute>
<attribute id="blue">255</attribute>
<attribute id="green">255</attribute>
<attribute id="red">255</attribute>
<attribute id="alpha">255</attribute>
<attribute id="fontColor">-1</attribute>
</entity>
</file>
</modification>

Adding new items
THe above example adds to new items to the FONTCOLORS table. Notice the syntax is exactly the same if you were to replace an existing row, its all about specifying the id. If you add a row number that doesn't already exist, Reanimator knows that a new row must be added. FONTCOLORS has 156 rows already, so the above script would add the news colors double edged (157) and mythic (158) in the next avaiable row. Note that any new row id doesnt have to be exactly the new available row. If you were to change the double edged id to 160, 3 blank rows will be automatically appended inbetween. Notice that this has been done a lot in the ITEMS table as a method of reserving space for other items you may want to add in the future.
Don't dream what to be; be what you always dreamed.

Wildman

  • Founder
  • Eldest
  • ****
  • Posts: 1037
  • Karma: 9
  • Mental Case
Re: Script Editor Guide
« Reply #1 on: Aug 06, 2010; 10:05 AM »
Oh yeah, time to take a break from Python, and play with reanimator  [smilie=tease.gif]
All is cloaked in darkness and the darkness is my home. I shun the light but still I fight, until the dark is safe once again.

guidovl

  • Founder
  • Nameless
  • *
  • Posts: 70
  • Karma: 1
Re: Script Editor Guide
« Reply #2 on: Jan 01, 2011; 01:46 PM »
hi, i made a couple of scripts with the script editor , used the same syntax as maeyan,
however i dont seem to find a way to apply them with the script editor from within reanimator, however im hesisant to use the 1.5b1 launcher to apply the scripts because of the chestdrop bug.

Malachor

  • Developer
  • Eldest
  • ****
  • Posts: 1984
  • Karma: 25
Re: Script Editor Guide
« Reply #3 on: Jan 01, 2011; 03:34 PM »
The format used in this topic is different to what is used in 1.5b1, so following this will not work if you use the 1.5b1 launcher.
From memory, you had to "check" the script, and "apply checked scripts", then you'd need to save the file that was modified, and get the game using that file.

guidovl

  • Founder
  • Nameless
  • *
  • Posts: 70
  • Karma: 1
Re: Script Editor Guide
« Reply #4 on: Jan 01, 2011; 11:01 PM »
okay, i saved the script in reanimator.
restarted reanimator, went back to script editor but it can't find any of the scripts i made in reanimator, there is no button for checking scripts either, and apply current script does nothing except for something quickly flashing on the screen, no changes appear to be made to items either, when i do a save then of item file, nothing changed.

i am a bit stumped myself, wanting to bulk change alot itemproperty's . this is the code of my file :
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<modification>
   <file id="ITEMS">
      <!--Notes: There are no cases when you will want to alter these values.-->
      <entity id="1874-1894">
         <attribute id="bitmask05" bit="CanNotBeAugmented">false</attribute>
         <attribute id="bitmask05" bit="CanNotBeDeModded">false</attribute>
      </entity>
      <!--Notes: There are no cases when you will want to alter these values.-->
      <entity id="2120-2191">
         <attribute id="bitmask05" bit="canNotBeAugmented">false</attribute>
         <attribute id="bitmask05" bit="canNotBeDeModded">false</attribute>
      </entity>
      <!--SKILL RETRAINER-->
      <!--ATTRIBUTE RETRAINER-->
      <entity id="15,265">
         <attribute id="bitmask05" bit="NoDrop">false</attribute>
      </entity>
   </file>
</modification>