Skip to content

Example: Monster list (monsters.xml)

Chris edited this page May 10, 2016 · 5 revisions

Options

The parser implementation (pandaac\Exporter\Parsers\Monsters in this case) accepts an array of options as its first parameter. By default they are as shown below, but you may pass either of them to change it.

Syntax
new pandaac\Exporter\Parsers\Monsters([
  'recursion' => false,
])
Defaults
  • recursion true
    • If recursion is enabled, it will fetch detailed information for each individual monster
Recursion options

Please refer to the options of the pandaac\Exporter\Parsers\Monster object.

Example

use pandaac\Exporter\Exporter;
use pandaac\Exporter\Parsers\Monsters;

try {

  $monsters = new Exporter(
    './data/monster/monsters.xml',
    new Monsters
  );

  $response = $monsters->export();

} catch (Exception $e) {
  // Log errors...
}

The export() method returns a Illuminate\Support\Collection object, please refer to its documentation. If you would prefer a JSON or an array response however, you may do as follows...

$response = $monsters->export()->toJson();
$response = $monsters->export()->toArray();

Example output with recursion disabled (JSON)

[
  {
    "name": "Amazon",
    "file": "Amazons/amazon.xml",
    "path": "~/data/monster/Amazons/amazon.xml"
  },
  {
    "name": "Valkyrie",
    "file": "Amazons/valkyrie.xml",
    "path": "~/data/monster/Amazons/valkyrie.xml"
  },
  {
    "name": "Carrion Worm",
    "file": "Annelids/carrion worm.xml",
    "path": "~/data/monster/Annelids/carrion worm.xml"
  },

  ...
]

Example output with recursion enabled (JSON)

[
  {
    "name": "Amazon",
    "nameDescription": "a amazon",
    "race": "blood",
    "experience": 60,
    "speed": 180,
    "manacost": 390,
    "health": {
      "now": 110,
      "max": 110
    },
    "look": {
      "type": 137,
      "head": 113,
      "body": 120,
      "legs": 114,
      "feet": 132,
      "corpse": 20323
    },
    "targetchange": {
      "interval": 4000,
      "chance": 10
    },
    "flags": {
      "summonable": 1,
      "attackable": 1,
      "hostile": 1,
      "illusionable": 1,
      "convinceable": 1,
      "canpushitems": 1,
      "targetdistance": 4,
      "staticattack": 90,
      "runonhealth": 10
    },
    "attacks": [
      {
        "name": "melee",
        "interval": 2000,
        "max": -45,
        "attributes": [
          
        ]
      },
      {
        "name": "physical",
        "interval": 2000,
        "max": -40,
        "chance": 15,
        "range": 7,
        "attributes": {
          "shootEffect": "throwingknife"
        }
      }
    ],
    "defenses": {
      "armor": 10,
      "defense": 10,
      "defenses": [
        
      ]
    },
    "elements": {
      "physical": -5,
      "death": -5
    },
    "immunities": [
      
    ],
    "voices": {
      "interval": 5000,
      "chance": 10,
      "sentences": [
        "Yeeee ha!",
        "Your head shall be mine!",
        "Your head will be mine!"
      ]
    },
    "summons": [
      
    ],
    "loot": [
      {
        "id": 2148,
        "countmax": 20,
        "chance": 40000,
        "comment": "gold coin"
      },
      {
        "id": 2229,
        "countmax": 2,
        "chance": 80000,
        "comment": "skull"
      },
      {
        "id": 2379,
        "chance": 80000,
        "comment": "dagger"
      },
      {
        "id": 12400,
        "chance": 5000,
        "comment": "Protective Charm"
      },
      {
        "id": 2691,
        "chance": 30333,
        "comment": "brown bread"
      },
      {
        "id": 2385,
        "chance": 23000,
        "comment": "sabre"
      },
      {
        "id": 12399,
        "chance": 10000,
        "comment": "Girlish Hair Decoration"
      },
      {
        "id": 2050,
        "chance": 1005,
        "comment": "torch"
      },
      {
        "id": 2125,
        "chance": 287,
        "comment": "crystal necklace"
      },
      {
        "id": 2147,
        "chance": 161,
        "comment": "small ruby"
      }
    ],
    "paths": {
      "name": "Amazon",
      "file": "Amazons/amazon.xml",
      "path": "~/data/monster/Amazons/amazon.xml"
    }
  },
  {
    "name": "Valkyrie",
    "nameDescription": "a valkyrie",
    "race": "blood",
    "experience": 85,
    "speed": 190,
    "manacost": 450,
    "health": {
      "now": 190,
      "max": 190
    },
    "look": {
      "type": 139,
      "head": 113,
      "body": 57,
      "legs": 95,
      "feet": 113,
      "corpse": 20523
    },
    "targetchange": {
      "interval": 4000,
      "chance": 10
    },
    "flags": {
      "summonable": 1,
      "attackable": 1,
      "hostile": 1,
      "illusionable": 1,
      "convinceable": 1,
      "canpushitems": 1,
      "targetdistance": 1,
      "staticattack": 90,
      "runonhealth": 20
    },
    "attacks": [
      {
        "name": "melee",
        "interval": 2000,
        "max": -70,
        "attributes": [
          
        ]
      },
      {
        "name": "physical",
        "interval": 2000,
        "max": -50,
        "chance": 15,
        "range": 7,
        "attributes": {
          "shootEffect": "spear"
        }
      }
    ],
    "defenses": {
      "armor": 20,
      "defense": 20,
      "defenses": [
        
      ]
    },
    "elements": {
      "ice": 10,
      "fire": 10,
      "holy": 5,
      "death": -5,
      "physical": -5
    },
    "immunities": [
      
    ],
    "voices": {
      "interval": 5000,
      "chance": 10,
      "sentences": [
        "Another head for me!",
        "Head off!",
        "Your head will be mine!",
        "Stand still!",
        "One more head for me!"
      ]
    },
    "summons": [
      
    ],
    "loot": [
      {
        "id": 2148,
        "countmax": 12,
        "chance": 30000,
        "comment": "gold coin"
      },
      {
        "id": 2666,
        "chance": 30100,
        "comment": "meat"
      },
      {
        "id": 2674,
        "countmax": 2,
        "chance": 6800,
        "comment": "apple"
      },
      {
        "id": 2229,
        "chance": 760,
        "comment": "skull"
      },
      {
        "id": 2464,
        "chance": 10000,
        "comment": "chain armor"
      },
      {
        "id": 2389,
        "countmax": 3,
        "chance": 55000,
        "comment": "spear"
      },
      {
        "id": 3965,
        "chance": 5155,
        "comment": "hunting spear"
      },
      {
        "id": 2463,
        "chance": 719,
        "comment": "plate armor"
      },
      {
        "id": 2387,
        "chance": 492,
        "comment": "double axe"
      },
      {
        "id": 2200,
        "chance": 1086,
        "comment": "protection amulet"
      },
      {
        "id": 7618,
        "chance": 591,
        "comment": "health potion"
      },
      {
        "id": 2145,
        "chance": 200,
        "comment": "small diamond"
      },
      {
        "id": 12399,
        "chance": 5800,
        "comment": "Girlish Hair Decoration"
      },
      {
        "id": 12400,
        "chance": 3400,
        "comment": "Protective Charm"
      }
    ],
    "paths": {
      "name": "Valkyrie",
      "file": "Amazons/valkyrie.xml",
      "path": "~/data/monster/Amazons/valkyrie.xml"
    }
  },
  {
    "name": "Carrion Worm",
    "nameDescription": "a carrion worm",
    "race": "blood",
    "experience": 70,
    "speed": 160,
    "manacost": 380,
    "health": {
      "now": 145,
      "max": 145
    },
    "look": {
      "type": 192,
      "corpse": 6069
    },
    "targetchange": {
      "interval": 4000
    },
    "flags": {
      "attackable": 1,
      "hostile": 1,
      "convinceable": 1,
      "canpushitems": 1,
      "targetdistance": 1,
      "staticattack": 80
    },
    "attacks": [
      {
        "name": "melee",
        "interval": 2000,
        "max": -45,
        "attributes": [
          
        ]
      }
    ],
    "defenses": {
      "armor": 15,
      "defense": 15,
      "defenses": [
        
      ]
    },
    "elements": {
      "earth": 20,
      "energy": 5,
      "fire": -5,
      "ice": -5
    },
    "immunities": [
      
    ],
    "voices": [
      
    ],
    "summons": [
      
    ],
    "loot": [
      {
        "id": 2148,
        "countmax": 45,
        "chance": 50000,
        "comment": "gold coin"
      },
      {
        "id": 2666,
        "countmax": 2,
        "chance": 9460,
        "comment": "meat"
      },
      {
        "id": 3976,
        "countmax": 2,
        "chance": 2100,
        "comment": "worm"
      },
      {
        "id": 11192,
        "chance": 10000,
        "comment": "Carrion Worm Fang"
      },
      {
        "id": 13757,
        "chance": 210,
        "comment": "Coal"
      }
    ],
    "paths": {
      "name": "Carrion Worm",
      "file": "Annelids/carrion worm.xml",
      "path": "~/data/monster/Annelids/carrion worm.xml"
    }
  },

  ...
]

Please note that the comments provided in the loot array are merely guidelines and may be faulty.

Clone this wiki locally