H
H
Holy Saint2021-10-19 15:35:26
Notepad++
Holy Saint, 2021-10-19 15:35:26

Find/Replace (in an XML file) the value of one attribute if another attribute has a specific value?

There are about a hundred files, 8k attribute lines each, containing lines like this:

XML

<npc id="25001" name="Greyclaw Kutus" title="Raid Boss">
    <set name="aggroRange" value="0"/>
    <set name="ai_type" value="Fighter"/>
    <set name="baseAtkRange" value="40"/>
    <set name="baseCON" value="57"/>
    <set name="baseCritRate" value="40"/>
    <set name="baseDEX" value="73"/>
    <set name="baseHpMax" value="40330.26"/>
    <set name="baseHpRate" value="1"/>
    <set name="baseHpReg" value="17.535"/>
    <set name="baseINT" value="76"/>
    <set name="baseMAtk" value="3"/>
    <set name="baseMAtkSpd" value="3819"/>
    <set name="baseMDef" value="174"/>
    <set name="baseMEN" value="80"/>
    <set name="baseMpMax" value="231.96"/>
    <set name="baseMpReg" value="1.5"/>
    <set name="basePAtk" value="84"/>
    <set name="basePAtkSpd" value="253"/>
    <set name="basePDef" value="321"/>
    <set name="baseRunSpd" value="275"/>
    <set name="baseSTR" value="60"/>
    <set name="baseShldDef" value="382"/>
    <set name="baseShldRate" value="20"/>
    <set name="baseWIT" value="70"/>
    <set name="baseWalkSpd" value="81"/>
    <set name="collision_height" value="43.5"/>
    <set name="collision_radius" value="21.0"/>
    <set name="level" value="23"/>
    <set name="rewardExp" value="714843"/>
    <set name="rewardRp" value="284"/>
    <set name="rewardSp" value="67170"/>
    <set name="shots" value="NONE"/>
    <set name="texture" value=""/>
    <set name="type" value="RaidBoss"/>
    <equip>
      <rhand item_id="67"/>
      <!--Orcish Sword-->
      <lhand item_id="633"/>
      <!--Zubei's Shield-->
    </equip>
    <minions>
      <minion npc_id="25002" count="3"/>
      <!--Guard of Kutus-->
      <minion npc_id="25003" count="1"/>
      <!--Pawn of Kutus-->
    </minions>
    <skills>
      <skill id="4045" level="1"/>
      <!--Resist Full Magic Attack-->
      <skill id="4197" level="2"/>
      <!--Hold-->
      <skill id="4408" level="1"/>
      <!--HP Increase (1x)-->
      <skill id="4409" level="1"/>
      <!--MP Increase (1x)-->
      <skill id="4410" level="11"/>
      <!--Average P. Atk.-->
      <skill id="4411" level="11"/>
      <!--Average M. Atk.-->
      <skill id="4412" level="11"/>
      <!--Average P. Def.-->
      <skill id="4413" level="11"/>
      <!--Average M. Def.-->
      <skill id="4414" level="2"/>
      <!--Standard Type-->
      <skill id="4415" level="3"/>
      <!--One-handed Sword-->
      <skill id="4416" level="6"/>
      <!--Humanoids-->
      <skill id="4494" level="1"/>
      <!--Raid Boss-->
      <skill id="4790" level="1"/>
      <!--Raid Boss - Level 23-->
    </skills>
    <attributes>
      <defence attribute="fire" value="0"/>
      <defence attribute="water" value="0"/>
      <defence attribute="wind" value="0"/>
      <defence attribute="earth" value="0"/>
      <defence attribute="holy" value="0"/>
      <defence attribute="unholy" value="0"/>
    </attributes>
    <rewardlist type="RATED_GROUPED">
      <group chance="85.3096">
        <reward item_id="377" min="1" max="1" chance="31.1115"/>
        <reward item_id="1937" min="24" max="72" chance="23.1922"/>
        <reward item_id="1935" min="53" max="157" chance="6.8944"/>
        <reward item_id="348" min="1" max="1" chance="19.4855"/>
        <reward item_id="69" min="1" max="1" chance="4.8291"/>
        <reward item_id="128" min="1" max="1" chance="4.8291"/>
        <reward item_id="126" min="1" max="1" chance="4.8291"/>
        <reward item_id="125" min="1" max="1" chance="4.8291"/>
      </group>
      <group chance="79.6613">
        <reward item_id="2021" min="3" max="9" chance="35.0419"/>
        <reward item_id="6575" min="1" max="1" chance="3.9974"/>
        <reward item_id="956" min="12" max="36" chance="24.9839"/>
        <reward item_id="6576" min="1" max="1" chance="35.9768"/>
      </group>
    </rewardlist>
  </npc>


It is necessary through search / replace to replace the data in the attribute
XML 2

<rewardlist type="RATED_GROUPED">
      <group chance="85.3096">
        <reward item_id="377" min="1" max="1" chance="31.1115"/>
        <reward item_id="1937" min="24" max="72" chance="23.1922"/>
        <reward item_id="1935" min="53" max="157" chance="6.8944"/>
        <reward item_id="348" min="1" max="1" chance="19.4855"/>
        <reward item_id="69" min="1" max="1" chance="4.8291"/>
        <reward item_id="128" min="1" max="1" chance="4.8291"/>
        <reward item_id="126" min="1" max="1" chance="4.8291"/>
        <reward item_id="125" min="1" max="1" chance="4.8291"/>
      </group>
      <group chance="79.6613">
        <reward item_id="2021" min="3" max="9" chance="35.0419"/>
        <reward item_id="6575" min="1" max="1" chance="3.9974"/>
        <reward item_id="956" min="12" max="36" chance="24.9839"/>
        <reward item_id="6576" min="1" max="1" chance="35.9768"/>
      </group>
    </rewardlist>
on your
Example
<rewardlist type="RATED_GROUPED">
      <group chance="100.0">
        <reward item_id="2021" min="3" max="9" chance="20.0"/>
        <reward item_id="6575" min="1" max="1" chance="20.0"/>
        <reward item_id="956" min="12" max="36" chance="20.0"/>
        <reward item_id="6576" min="1" max="1" chance="20.0"/>
        <reward item_id="6576" min="1" max="1" chance="20.0"/>
      </group>
    </rewardlist>
but only if title="Raid Boss"?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question