Cleaning up the code


There were a few points on the party-swap scene I wanted to address. Spelling corrections aside, I wanted to make sure that selecting an open party slot displayed Unites, and selecting a character, whither it’s on an active party slot, or moving through the party list, displayed their stats.

Things weren’t 100% updating properly, where it was displaying Unites after selecting a character to join the active party, or displaying character stats that wasn’t selected. The fixes and testing to this system have been pretty much limited to my “Alpha Island”/debug room, but, in this regard, I feel I’ve settled this issue. Perhaps further testing in-game will reveal additional bugs, but, we’ll see when one gets that far!

The next item to tackle was the encounter cancel cost. Initially, my idea was to have the cost be a flat number equal to the average level across all the monsters the player could feasibly face. This was the technique used in my Ace games, Heaven’s Gate and Trail of the Interloper. As of the time of this writing, those games only exist on RMN, and the best way to obtain either of these games would be through RMN’s archive.org’s collection.

That aside, I wasn’t comfortable with that idea any more. If Wild Arms 3’s encounter cancel cost depends on what encounter is imminent, maybe I should try to see how I would go about doing that as well. The method I was using the get the average level across all troops was pretty clunky. While I no longer have that method available, I can show you what method I am using now.

// Calculates average enemy level for ECN cost.
Game_Map.prototype.ecnCost = function() {
	// If the troopID is undefined/nonexistant, get one!
	if (!this.troopId) {
		this.troopId = $gamePlayer.makeEncounterTroopId();
	};	
	let troop = $dataTroops[this.troopId];
	let total = 0;
	// Get the total enemy level of this troop.
	for (let i=0; i<troop.members.length; i++) {
		let enemy = new Game_Enemy(troop.members[i].enemyId, 0, 0);
		total += enemy.level;
	};
	// Take the average level among the creatures in this troop, then add 1 so there would be
	// a bare minimum cost of 1 after subtraction.
	total = Math.round(1.0 * total / troop.members.length) + 1;
	// Pass troop ID to game variable #1, and use that for the encounter event-command.
	$gameVariables.setValue(1, this.troopId);
	return total;
};

The tests on Alpha Island, and what legit in-game tests I’ve run so far, this method seems to work.

A part of me thinks it might be neat for the demo release to give access to the full arrangement of party members after the event with Natalie in Lothril, and/or setting up all the shops in the demo to have Grandmaster-level items/equipment. This would be DEMOnstrating (pun 108% intended) at least the full range of possible Unites in the game that players can fool around with. I highly doubt anyone would earn money fast enough to buy Master-level runes, much less the Grandmaster ones, but, there’s still much of the demo that I haven’t mapped out yet. Quite literally in some cases!

Comments

Log in with itch.io to leave a comment.

Hehe! Puns!

Woo! Devlog! Code!

Could avoid "enemy" variable by using a map for a "get level" code, then sum the array?

https://www.w3schools.com/jsref/jsref_map.asp