So I've made a few more alterations as time allows and I wanted to post a quick one. One issue I knew would result from the way I handled the camera in my prior posts was having intended targets off screen and the like. Especially an issue if you were trying to select said target. This post will cover my personal fix to that and is based off the other modifications I've shown already. The only prior required modification is the one I made to Galv's Camera Control to add followers into the plugin's ability to focus the camera on something. All variable and switch numbers can be whatever as long as they all are used accordingly in that project. Now off to the races...
Inside chrono engine you'll need to find the "refresh Position" function. This is where the magic happens. I've commented relevant parts of the code that I added. the part where I store two variables name cameraX and Y are not needed. It's a method I'm going to approach at a later date as its going to require me digging in to ultra mode 7 as well and understanding it how it does things. I assume I simply need to store just the Map coordinates there instead of the returned "screen" but I digress.
Anyway, add the relevant portions or just overwrite the function with mine, the changes are self contained so it won't change its original functionality. Then we need to make one more small change to the way I handled the followers addition to galv's cam plugin.
I made a slight alteration to how I was already handling the actor index here so if you used my prior mod on this you'll need this as well. All we do here is check if switch 118 is on. if it is we are going to get our index from the variable that was loaded with it in the refresh Position function.
So let me explain a bit more for context. In my setup, 117 calls a common event that governs camera behavior when an enemy is a target. 118 is for the actors and tied to it's own common event.
Here, variable 55 is being used for the actor index.
Well that about covers this. Here's a video showing it off for those curious on how it looks and not wanting to have to go through the trouble of setting it up just to see it. I also show off having maps that ignore pitch commands from mode 7. The first map accepts the pitch commands while the second doesn't. This is just simple conditional statements inside common events so unless someone needs explicit help setting something up I doubt it's worth posting in this. Anyways, have a good day everyone!
JavaScript:
//==============================
// * refresh Position
//==============================
ToolCursor.prototype.refreshPosition = function() {
this._active = $gameTemp._autoTarget.enabled;
$gameTemp._autoTarget.refresh = false;
if (this.battlers().length === 0) {
this.executeCancel();
return;
}
$gameTemp._autoTarget.index = this._index;
for (var i = 0; i < this.battlers().length; i++) {
if (this._index === i) {
var target = this.battlers()[i];
if (target) {
this._target = target;
$gameTemp._autoTarget.target = target;
this._nx = target.screenX();
this._ny = target.screenY();
this.refreshName(target);
// Kalian: ultra mode seven didn't like this method and I assume its because it expects
// map coords? I'll look into it later. Leaving this here as a reminder.
var cameraX = Graphics.width / 2 - this._nx;
var cameraY = Graphics.height / 2 - this._ny;
$gameVariables.setValue(51, cameraX);
$gameVariables.setValue(52, cameraY);
// Kalian: Workaround to prior issue, just grabbing the cursor's target's
//event Id
if (target.eventId) {
var eventId = target.eventId();
$gameVariables.setValue(53, eventId);
console.log("Event ID stored in game variable 53: " + eventId);
}
// Kalian: Checking if the target is an actor and handling it as such
if (target.battler() && target.battler().actorId) {
var actorId = target.battler().actorId();
var actorIndex = $gameParty.battleMembers().indexOf(target.battler());
$gameVariables.setValue(54, actorId);
$gameVariables.setValue(55, actorIndex);
console.log("Actor ID stored in game variable 54: " + actorId);
console.log("Actor Index stored in game variable 55: " + actorIndex);
// Kalian: turn on switch 118 if it is an actor.
// this calls a common event that handles camera focus etc.
$gameSwitches.setValue(118, true);
}
if ($gameTemp._chronoCom.user) {
this.refreshDirection(target);
}
}
}
}
if (this._hpGauge && this._target) {
this._hpLayout.x = this._hpLayout.org[0] - (this._hpLayout.width / 2);
this._hpLayout.y = this._hpLayout.org[1];
this._hpGauge.x = this._hpGauge.org[0] - (this._hpGaugeImg.width / 2);
this._hpGauge.y = this._hpGauge.org[1];
this.refreshHpGauge();
}
$gameSwitches.setValue(117, true); //Kalian: calls switch 117 common event
//to process cursor cam on enemy target
};
Inside chrono engine you'll need to find the "refresh Position" function. This is where the magic happens. I've commented relevant parts of the code that I added. the part where I store two variables name cameraX and Y are not needed. It's a method I'm going to approach at a later date as its going to require me digging in to ultra mode 7 as well and understanding it how it does things. I assume I simply need to store just the Map coordinates there instead of the returned "screen" but I digress.
Anyway, add the relevant portions or just overwrite the function with mine, the changes are self contained so it won't change its original functionality. Then we need to make one more small change to the way I handled the followers addition to galv's cam plugin.
JavaScript:
Galv.pCmd.CAM = function(arguments) {
var key = arguments[0].toLowerCase();
var speed = 800;
switch (key) {
case "player":
var target = $gamePlayer;
if (arguments[1]) speed = Galv.CC.getValue(arguments[1]);
break;
case "event":
var eId = Galv.CC.getValue(arguments[1]);
var target = $gameMap.event(eId);
if (arguments[2]) speed = Galv.CC.getValue(arguments[2]);
break;
case "follower":
var followerIndex = $gameSwitches.value(118) ? $gameVariables.value(55) : $gameVariables.value(42);
var follower = $gamePlayer.followers().follower(followerIndex - 1);
var target = follower ? follower : $gamePlayer;
if (arguments[1]) speed = Galv.CC.getValue(arguments[1]);
break;
case "disable":
$gameMap.camTarget = $gamePlayer;
$gameMap.camNorm = true;
$gameMap.savedCamTarget = null;
return;
default:
var px = Galv.CC.getValue(arguments[0]);
var py = Galv.CC.getValue(arguments[1]);
if (arguments[2]) speed = Galv.CC.getValue(arguments[2]);
var target = {
x: px,
y: py,
_realX: px,
_realY: py,
screenX: Game_CharacterBase.prototype.screenX,
screenY: function() {
var th = $gameMap.tileHeight();
return Math.round(this.scrolledY() * th + th);
},
scrolledX: Game_CharacterBase.prototype.scrolledX,
scrolledY: Game_CharacterBase.prototype.scrolledY
};
};
I made a slight alteration to how I was already handling the actor index here so if you used my prior mod on this you'll need this as well. All we do here is check if switch 118 is on. if it is we are going to get our index from the variable that was loaded with it in the refresh Position function.
So let me explain a bit more for context. In my setup, 117 calls a common event that governs camera behavior when an enemy is a target. 118 is for the actors and tied to it's own common event.
Here, variable 55 is being used for the actor index.
Well that about covers this. Here's a video showing it off for those curious on how it looks and not wanting to have to go through the trouble of setting it up just to see it. I also show off having maps that ignore pitch commands from mode 7. The first map accepts the pitch commands while the second doesn't. This is just simple conditional statements inside common events so unless someone needs explicit help setting something up I doubt it's worth posting in this. Anyways, have a good day everyone!