【Discovery】How a normal PB2 load your map files.

【Discovery】How a normal PB2 load your map files.

Postby yi en » 9 June 2020, 18:23

Credit to maoge for the thread. I am just arranging what he says and post it onto guides.
    Step 1: Read if there's keywords "<q", thus transform the code into <xml> format, and initializing the file.
    Spoiler: Show More
    Code: Select all

    if 
    (MovieClip(root).mapdata.slice(0, 3) == "<q.")
    {
    MovieClip(root).mapdata = this.un_qpack(MovieClip(root).mapdata);
    }
    this.firstframe = true;
    xml = new XML("<r>" + MovieClip(root).mapdata + "</r>");
    this.boxestotal = 0;
    this.doorstotal = 0;
    this.regionstotal = 0;
    this.lampstotal = 0;
    this.gunstotal = 0;
    this.pushstotal = 0;
    this.bgstotal = 0;
    this.mShape = new Sprite();


    Step 2: Further initializing the file, preparing the map structure.
    Spoiler: Show More
    Code: Select all

    trace
    ("L-map 2");
    var _loc_2:* = 0;
    var _loc_3:* = xml.children();
    while (_loc_3 in _loc_2)
    {

    bookInfo = _loc_3[_loc_2];
    = bookInfo.name();
    = new Array();
    var _loc_4:* = 0;
    var _loc_5:* = bookInfo.attributes();
    while (_loc_5 in _loc_4)
    {

    bookInfo2 = _loc_5[_loc_4];
    b["#" + bookInfo2.name()] = bookInfo2;
    }


    Step 3: Drawing the wall (box)
    Spoiler: Show More
    Code: Select all

    if 
    (== "box")
    {
    this.boxx[this.boxestotal] = new Number(b["#x"]);
    this.boxy[this.boxestotal] = new Number(b["#y"]);
    this.boxw[this.boxestotal] = new Number(b["#w"]);
    this.boxh[this.boxestotal] = new Number(b["#h"]);
    this.boxmat[this.boxestotal] = new int(b["#m"]);
    var _loc_4:* = this;
    var _loc_5:* = this.boxestotal + 1;
    _loc_4.boxestotal = _loc_5;
    }

    # this code repeats until it can't find any walls.


    Step 4: Drawing the backgrounds
    Spoiler: Show More
    Code: Select all

    if 
    (== "bg")
    {
    if (b["#m"] == "0")
    {
    this.mShape.graphics.beginBitmapFill(new panel_tile(0, 0));
    }
    if (b["#m"] == "1")
    {
    this.mShape.graphics.beginBitmapFill(new ground_tile(0, 0));
    }
    if (b["#m"] == "2")
    {
    this.mShape.graphics.beginBitmapFill(new panel2_tile(0, 0));
    }
    if (b["#m"] == "3")
    {
    this.mShape.graphics.beginBitmapFill(new white(0, 0));
    }
    if (b["#m"] == "4")
    {
    this.mShape.graphics.beginBitmapFill(new slider_tile(0, 0));
    }
    if (b["#m"] == "5")
    {
    this.mShape.graphics.beginBitmapFill(new panel3_tile(0, 0));
    }
    if (b["#m"] == "6")
    {
    this.mShape.graphics.beginBitmapFill(new red(0, 0));
    }
    if (b["#m"] == "7")
    {
    this.mShape.graphics.beginBitmapFill(new green(0, 0));
    }
    if (b["#m"] == "8")
    {
    this.mShape.graphics.beginBitmapFill(new blue(0, 0));
    }
    this.mShape.graphics.moveTo(Number(b["#x"]), Number(b["#y"]));
    this.mShape.graphics.lineTo(Number(b["#x"]) + Number(b["#w"]), Number(b["#y"]));
    this.mShape.graphics.lineTo(Number(b["#x"]) + Number(b["#w"]), Number(b["#y"]) + Number(b["#h"]));
    this.mShape.graphics.lineTo(Number(b["#x"]), Number(b["#y"]) + Number(b["#h"]));
    this.mShape.graphics.endFill();
    if (!this.HQ)
    {
    this.mShape.graphics.beginBitmapFill(new lite_shadow(0, 0));
    this.mShape.graphics.moveTo(Number(b["#x"]), Number(b["#y"]));
    this.mShape.graphics.lineTo(Number(b["#x"]) + Number(b["#w"]), Number(b["#y"]));
    this.mShape.graphics.lineTo(Number(b["#x"]) + Number(b["#w"]), Number(b["#y"]) + Number(b["#h"]));
    this.mShape.graphics.lineTo(Number(b["#x"]), Number(b["#y"]) + Number(b["#h"]));
    this.mShape.graphics.endFill();
    }
    this.bgx[this.bgstotal] = new Number(b["#x"]);
    this.bgy[this.bgstotal] = new Number(b["#y"]);
    this.bgw[this.bgstotal] = new Number(b["#w"]);
    this.bgh[this.bgstotal] = new Number(b["#h"]);
    var _loc_4:* = this;
    var _loc_5:* = this.bgstotal + 1;
    _loc_4.bgstotal = _loc_5;
    }

    # this code repeats until it can't find any backgrounds.


    Step 5: Making pushers
    Spoiler: Show More
    Code: Select all

    if 
    (== "pushf")
    {
    this.pushx[this.pushstotal] = new Number(b["#x"]);
    this.pushy[this.pushstotal] = new Number(b["#y"]);
    this.pushw[this.pushstotal] = new Number(b["#w"]) + this.pushx[this.pushstotal];
    this.pushh[this.pushstotal] = new Number(b["#h"]) + this.pushy[this.pushstotal];
    this.pushtox[this.pushstotal] = new Number(b["#tox"]);
    this.pushtoy[this.pushstotal] = new Number(b["#toy"]);
    this.pushstab[this.pushstotal] = new Number(b["#stab"]);
    this.pushdamage[this.pushstotal] = new Number(b["#damage"]);
    var _loc_4:* = this;
    var _loc_5:* = this.pushstotal + 1;
    _loc_4.pushstotal = _loc_5;
    }

    # this code repeats until it can't find any pushers.


    Step 6: Create water field
    Spoiler: Show More
    Code: Select all

    if 
    (== "water")
    {
    this.wax[this.watertotal] = new Number(b["#x"]);
    this.way[this.watertotal] = new Number(b["#y"]);
    this.waw[this.watertotal] = new Number(b["#w"]);
    this.wah[this.watertotal] = new Number(b["#h"]);
    this.wadamage[this.watertotal] = new Number(b["#damage"]);
    var _loc_4:* = this;
    var _loc_5:* = this.watertotal + 1;
    _loc_4.watertotal = _loc_5;
    }

    # this code repeats until it can't find any waters.


    Step 7: Create the door
    Spoiler: Show More
    Code: Select all

    if 
    (== "door")
    {
    this.mc = this.graphics_3d.addChildAt(new door(), this.graphics_3d.numChildren);
    this.NoMouse(this.mc);
    this.mc.visible = false;
    if (b["#vis"] == "true")
    {
    this.mc.vis = true;
    }
    else
    {
    this.mc.vis = false;
    }
    var _loc_4:* = new Number(b["#x"]);
    this.mc.= new Number(b["#x"]);
    this.mc.s_x = _loc_4;
    var _loc_4:* = new Number(b["#y"]);
    this.mc.= new Number(b["#y"]);
    this.mc.s_y = _loc_4;
    this.mc.scaleX = new Number(b["#w"]) / 100;
    this.mc.scaleY = new Number(b["#h"]) / 100;
    this.doors[this.doorstotal] = this.mc;
    this.mc.= new Number(b["#w"]);
    this.mc.= new Number(b["#h"]);
    this.mc.tox = new Number(0);
    this.mc.toy = new Number(0);
    this.mc.moving = new Boolean();
    if (b["#moving"] == "true")
    {
    this.mc.moving = true;
    }
    else
    {
    this.mc.moving = false;
    }
    this.mc.s_moving = this.mc.moving;
    var _loc_4:* = new Number(b["#tarx"]);
    this.mc.tarx = new Number(b["#tarx"]);
    this.mc.s_tarx = _loc_4;
    var _loc_4:* = new Number(b["#tary"]);
    this.mc.tary = new Number(b["#tary"]);
    this.mc.s_tary = _loc_4;
    this.mc.use_target = new int(-1);
    this.mc.use_on = new int(0);
    var _loc_4:* = new Number(b["#maxspeed"]);
    this.mc.maxspeed = new Number(b["#maxspeed"]);
    this.mc.s_maxspeed = _loc_4;
    var _loc_4:* = this;
    var _loc_5:* = this.doorstotal + 1;
    _loc_4.doorstotal = _loc_5;
    }

    # this code repeats until it can't find any doors.


    Step 8: Create regions
    Spoiler: Show More
    Code: Select all

    if 
    (== "region")
    {
    this.regions[this.regionstotal] = new Object();
    this.regions[this.regionstotal].= new Number(b["#x"]);
    this.regions[this.regionstotal].= new Number(b["#y"]);
    this.regions[this.regionstotal].= new Number(b["#w"]);
    this.regions[this.regionstotal].= new Number(b["#h"]);
    this.regions[this.regionstotal].use_target = new Number(b["#use_target"]);
    this.regions[this.regionstotal].use_on = new Number(b["#use_on"]);
    if (this.regions[this.regionstotal].use_on == 1)
    {
    this.mc = this.game.addChildAt(new switchh(), 0);
    this.NoMouse(this.mc);
    this.mc.= this.regions[this.regionstotal].+ this.regions[this.regionstotal]./ 2;
    this.mc.= this.regions[this.regionstotal].+ this.regions[this.regionstotal]./ 2;
    this.mc.gotoAndStop(1);
    this.regions[this.regionstotal].mc = this.mc;
    }
    var _loc_4:* = this;
    var _loc_5:* = this.regionstotal + 1;
    _loc_4.regionstotal = _loc_5;
    }

    # this code repeats until it can't find any regions.


    Step 9: Adding triggers
    Spoiler: Show More
    Code: Select all

    if 
    (== "trigger")
    {
    this.triggers[this.triggerstotal] = new Object();
    this.triggers[this.triggerstotal].enabledd = new Boolean();
    if (b["#enabled"] == "true")
    {
    this.triggers[this.triggerstotal].enabledd = true;
    }
    else
    {
    this.triggers[this.triggerstotal].enabledd = false;
    }
    this.triggers[this.triggerstotal].s_enabledd = this.triggers[this.triggerstotal].enabledd;
    var _loc_4:* = new int(b["#maxcalls"]);
    this.triggers[this.triggerstotal].maxcalls = new int(b["#maxcalls"]);
    this.triggers[this.triggerstotal].s_maxcalls = _loc_4;
    this.triggers[this.triggerstotal].actions_total = new int(0);
    this.triggers[this.triggerstotal].actions_targetA = new Array();
    this.triggers[this.triggerstotal].actions_targetB = new Array();
    this.triggers[this.triggerstotal].actions_type = new Array();
    this.triggers[this.triggerstotal].forcehyperjump = new Boolean(false);
    this.= 1;
    while (this.<= 10)
    {

    if (b["#actions_" + this.+ "_type"] != -1)
    {
    this.add_action_to_trigger(this.triggerstotal, b["#actions_" + this.+ "_targetA"], b["#actions_" + this.+ "_targetB"], b["#actions_" + this.+ "_type"]);
    }
    var _loc_4:* = this;
    var _loc_5:* = this.+ 1;
    _loc_4.= _loc_5;
    }
    var _loc_4:* = this;
    var _loc_5:* = this.triggerstotal + 1;
    _loc_4.triggerstotal = _loc_5;
    }

    # this code repeats until it can't find any triggers.


    Step 10: Adding timers
    Spoiler: Show More
    Code: Select all

    if 
    (== "timer")
    {
    this.timers[this.timerstotal] = new Object();
    this.timers[this.timerstotal].enabledd = new Boolean();
    if (b["#enabled"] == "true")
    {
    this.timers[this.timerstotal].enabledd = true;
    }
    else
    {
    this.timers[this.timerstotal].enabledd = false;
    }
    this.timers[this.timerstotal].s_enabledd = this.timers[this.timerstotal].enabledd;
    var _loc_4:* = new int(b["#maxcalls"]);
    this.timers[this.timerstotal].maxcalls = new int(b["#maxcalls"]);
    this.timers[this.timerstotal].s_maxcalls = _loc_4;
    this.timers[this.timerstotal].actions_target = new int(b["#target"]);
    var _loc_4:* = new int(b["#delay"]);
    this.timers[this.timerstotal].ddelay = new int(b["#delay"]);
    this.timers[this.timerstotal].s_ddelay = _loc_4;
    this.timers[this.timerstotal].ticknew = new int(0);
    var _loc_4:* = this;
    var _loc_5:* = this.timerstotal + 1;

    # this code repeats until it can't find any timers.


    Step 11: Adding barrels
    Spoiler: Show More
    Code: Select all

    if 
    (!this.MP_mode)
    {
    if (== "barrel")
    {
    if (b["#model"] == "bar_orange")
    {
    this.mc = this.game.addChildAt(new bar_orange(), this.game.numChildren);
    }
    if (b["#model"] == "bar_blue")
    {
    this.mc = this.game.addChildAt(new bar_blue(), this.game.numChildren);
    }
    if (b["#model"] == "bar_red")
    {
    this.mc = this.game.addChildAt(new bar_red(), this.game.numChildren);
    }
    this.NoMouse(this.mc);
    this.mc.mdl = b["#model"];
    this.mc.= new Number(b["#x"]);
    this.mc.= new Number(b["#y"]);
    this.mc.tox = new Number(b["#tox"]);
    this.mc.toy = new Number(b["#toy"]);
    this.create_barrel(this.mc);
    if (b["#model"] == "bar_blue")
    {
    this.mc.dist = this.mc.dist * 1.5;
    }
    if (b["#model"] == "bar_red")
    {
    this.mc.dist = this.mc.dist * 2;
    }
    }
    }

    # this code repeats until it can't find any barrels.


    Step 12: Adding vehicles
    Spoiler: Show More
    Code: Select all
    # if (!this.MP_mode)
    {
    if (== "vehicle")
    {
    n;
    if (b["#model"] == "veh_jeep")
    {
    this.mc = this.game.addChildAt(new veh_jeep(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_walker")
    {
    this.mc = this.game.addChildAt(new veh_walker(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_capsule")
    {
    this.mc = this.game.addChildAt(new veh_capsule(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_crate")
    {
    this.mc = this.game.addChildAt(new veh_crate(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_drone")
    {
    this.mc = this.game.addChildAt(new veh_drone(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_rope")
    {
    this.mc = this.game.addChildAt(new veh_rope(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_hh")
    {
    this.mc = this.game.addChildAt(new veh_hh(), this.game.numChildren);
    n;
    }
    if (b["#model"] == "veh_corvette")
    {
    this.mc = this.game.addChildAt(new veh_corvette(), this.game.numChildren);
    n;
    }
    this.NoMouse(this.mc);
    this.mc.= new Number(b["#x"]);
    this.mc.= new Number(b["#y"]);
    this.mc.tox = new Number(b["#tox"]);
    this.mc.toy = new Number(b["#toy"]);
    this.create_vehicle(this.mc, n, new Number(b["#side"]));
    this.mc.hea = this.mc.hea * (new Number(b["#hpp"]) / 100);
    this.mc.hmax = this.mc.hmax * (new Number(b["#hpp"]) / 100);
    if (!this.ARCADE_GAME_MODE)
    {
    this.mc.hea = this.mc.hea * 0.25;
    this.mc.hmax = this.mc.hmax * 0.25;
    }
    }
    }
    }

    # this code repeats until it can't find any vehicles.


    Step 13: Add decors
    Spoiler: Show More
    Code: Select all

    if 
    (== "decor")
    {
    this.mc = this.game.addChildAt(new decor(), this.game.numChildren);
    this.NoMouse(this.mc);
    this.mc.= new Number(b["#x"]);
    this.mc.= new Number(b["#y"]);
    this.mc.gotoAndStop(b["#model"]);
    this.decors[this.decorstotal] = this.mc;
    var _loc_4:* = this;
    var _loc_5:* = this.decorstotal + 1;
    _loc_4.decorstotal = _loc_5;
    }

    # this code repeats until it can't find any decors.


    Step 14: Adding players and enemies

    Step 15: Adding engine marks and apply it.

Step 14 and 15 Maoge haven't get rid of the code source yet, need some time to decompile the files and observe again.
User avatar
yi en
Civil Security Ghost [400]
 
Posts: 432
Joined: 20 August 2013, 09:10
Location: My gif is now animated yes!

Return to Guides & Tutorials

Who is online

Users browsing this forum: No registered users