Skip to content

Instantly share code, notes, and snippets.

@Nnubes256
Last active June 10, 2016 15:00
Show Gist options
  • Save Nnubes256/09c07bb3ff3ab294d1c983a0b09c08a3 to your computer and use it in GitHub Desktop.
Save Nnubes256/09c07bb3ff3ab294d1c983a0b09c08a3 to your computer and use it in GitHub Desktop.
Dorito mods
// For 0.3.5
dorito.Events.GameLoaded.add(function() {
var override = dorito_api.Injectors.override;
var before = dorito_api.InjectTypes.before;
var filter = dorito_api.InjectTypes.filter;
var dispatch_before = dorito_api.InjectTypes.dispatch_before;
window.__GLOBAL__ = {};
window.Gh = {};
window.sc.Wy = {};
window.ig.uC = true;
// HACK
window.console.ZP = console.log.bind(window.console);
override(window.console, "ZP", before(function() {
console.group.call(window.console);
}));
window.sc.Wy.pUa = function() {
console.log("(sc.Wy.pUa) DEBUG START!");
};
window.sc.Wy.cMa = function() {
console.log("(sc.Wy.cMa) MAP CHECK!");
};
window.sc.Wy.pTa = function(args) {
//console.log("sc.Wy.pTa ACHIEVEMENTS CALLED WITH ", args);
};
//
// DEBUG CONTROLS
//
window.sc.af["keys-jump"] = {
type: "CONTROLS",
f: {
key1: ig.ma.eda,
key2: g
},
Dc: sc.Rb.mf,
LE: true,
Nx: h,
oe: "debug"
};
window.sc.af["keys-time"] = {
type: "CONTROLS",
f: {
key1: ig.ma.Rfa,
key2: g
},
Dc: sc.Rb.mf,
LE: true
};
window.sc.af["keys-rumble"] = {
type: "CONTROLS",
f: {
key1: ig.ma.jfa,
key2: g
},
Dc: sc.Rb.mf,
LE: true
};
window.sc.af["keys-debug"] = {
type: "CONTROLS",
f: {
key1: ig.ma.nga,
key2: g
},
Dc: sc.Rb.mf,
LE: true
};
window.sc.af["keys-debug2"] = {
type: "CONTROLS",
f: {
key1: ig.ma.oga,
key2: g
},
Dc: sc.Rb.mf,
LE: true
};
window.sc.af["keys-addBuff"] = {
type: "CONTROLS",
f: {
key1: ig.ma.hga,
key2: g
},
Dc: sc.Rb.mf,
LE: true
};
window.sc.af["keys-levelUp"] = {
type: "CONTROLS",
f: {
key1: ig.ma.Oca,
key2: g
},
Dc: sc.Rb.mf,
LE: true
};
(function addStuff() {
if(window.globalGui) {
if(!(window.globalGui instanceof window.dat.GUI)) {
return setTimeout(addStuff, 100);
}
var gui = window.globalGui;
var debugStuff = gui.addFolder('Debug Routines');
var debugFunctions = {
langEdit: function() {
ig.qf.Rra();
}
};
debugStuff.add(debugFunctions, "langEdit");
}
})();
//
// DEBUG FIXES
//
// Null entities
dorito_api.Injectors.override(ig.Jva.prototype, "PNa", filter(
function(a, b) {
if(!b) {
console.warn(
"Found null property list while parsing entities, fixing"
);
return [a, {}];
} else return arguments;
}
));
// Crashing SET_CAMERA_TARGET calls
var camEvent = new signals.Signal();
override(ig.cd.RG.prototype, "start", dispatch_before(camEvent));
override(ig.cd.RG.prototype, "WX", dispatch_before(camEvent));
camEvent.add(function(ev) {
if(!ev.self.O) {
console.warn(
"SET_CAMERA_TARGET was probably called with null args!"
);
ev.cancelled = true;
}
});
// Replacing of old character sets
override($, "ajax", filter(function(params) {
if(params.url === "data/characters/CargoCrew1.json") {
params.url = "data/characters/cargo-crew/female-short.json";
}
return [params];
}));
});
// For 0.3.5
dorito.Events.GameLoaded.add(function() {
var filter = dorito_api.InjectTypes.filter;
console.log("piratelea loaded");
// Oh my god I hate this module system. Yes we have to override on the
// prototype.
dorito_api.Injectors.override(ig.ca.SHOW_MSG.prototype, "start", filter(
function() {
console.log("SHOW_MSG called");
this.message.value = this.message.value.replace(/Hi/g, "Ahoy");
return arguments;
}
));
});
(function (global, api) {
// PLACE BAKED VARIABLE NAMES HERE:
var SPAWN_ENTITY = "Ke";
var PLAYER_OBJ_LOCATION = "ta";
var SPAWN_PLAYER_ENTITY = "Rqa";
var MAIN_MENU = "zCa";
var MAIN_ENTITY = "vb";
var POSITION_PROP = "G4";
var ANIM_PROP = "Sf";
var THAT_CRASHING_ANIM_METHOD = "xza";
var override = api.Injectors.override;
var after = api.InjectTypes.after;
var before = api.InjectTypes.before;
global.mainPlayerEntity = {};
global.mainPlayerAnimation = {};
global.mainPlayerPositon = {};
var myContext = null;
global.dorito.Events.GameLoaded.add(function() {
override(
sc[MAIN_MENU].prototype,
"start",
before(function() {
// Make sure we always have the lastest entity list on the global scope
window.entities = this.entities;
})
);
override(
sc[MAIN_MENU].prototype,
SPAWN_PLAYER_ENTITY,
after(function() {
// Make sure the game doesn't lose track of the main player by keeping track of it by ourselves.
// Also, we'll need to keep a copy of the main menu context to access SPAWN_ENTITY cleanly.
mainPlayerEntity = this[MAIN_ENTITY];
mainPlayerPositon = mainPlayerEntity[POSITION_PROP];
mainPlayerAnimation = mainPlayerEntity[ANIM_PROP];
myContext = this;
})
);
override(
ig[PLAYER_OBJ_LOCATION].Player.prototype,
THAT_CRASHING_ANIM_METHOD,
before(function(args) {
// As the game fucks up with animations when creating the player entity this way(leaving a null reference),
// we'll simply use the one the main player has.
// The cool thing happening with this is that as all player entities spawned will be using the same animation
// object, all players will happen to look syncronized.
// And somehow the game doesn't fuck up. Now that's robust code.
if(!(this[ANIM_PROP])) {
console.log("Warn: no anim!");
this[ANIM_PROP] = mainPlayerEntity[ANIM_PROP];
}
})
);
});
global.clonePlayer = function() {
if(!myContext) return -1;
var newEntity = myContext[SPAWN_ENTITY](
ig[PLAYER_OBJ_LOCATION].Player,
global.mainPlayerPositon.x,
global.mainPlayerPositon.y,
global.mainPlayerPositon.z
);
newEntity[ANIM_PROP] = mainPlayerEntity[ANIM_PROP];
};
global.clonePlayerAtPos = function(x, y, z) {
if(!myContext) return -1;
var newEntity = myContext[SPAWN_ENTITY](
ig[PLAYER_OBJ_LOCATION].Player,
x,
y,
z
);
newEntity[ANIM_PROP] = mainPlayerEntity[ANIM_PROP];
};
global.makeCloneLine = function(num, yOffset) {
if(!yOffset) yOffset = 0;
for (var i = 0; i < num; i++) {
global.clonePlayerAtPos(
global.mainPlayerPositon.x + (16 * (i + 1)),
global.mainPlayerPositon.y + yOffset,
global.mainPlayerPositon.z
);
}
};
})(window, dorito_api);
// For 0.3.5
console.log("Test2");
var loggingHistory = [];
function crossLogger() {
loggingHistory = loggingHistory || [];
loggingHistory.push(arguments);
if (window.console){
window.console.log( Array.prototype.slice.call(arguments) );
}
}
try {
dorito.Events.DoritoInitialized.add(function() {
console.log("Test2 says HI!");
var level = prompt("Load a level?");
if(level !== null) {
window.LOAD_LEVEL_ON_GAME_START = level;
window.MARKER_ON_GAME_START = "start";
} else window.LOAD_LEVEL_ON_GAME_START = null;
window.to.log = crossLogger.bind(this);
window.to.debug = crossLogger.bind(this);
window.to.info = crossLogger.bind(this);
window.to.warn = crossLogger.bind(this);
});
} catch(e) {
console.log("ERROR LOADING " + e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment