Frame 1
stop();
Instance of Symbol 5 MovieClip in Frame 1
onClipEvent (load) {
var nSpeed = 50;
var nCurrLoad = 0;
var nRealLoad = 0;
}
onClipEvent (enterFrame) {
nRealLoad = (this._parent.getBytesLoaded() / this._parent.getBytesTotal()) * 100;
if (nRealLoad > (nCurrLoad + nSpeed)) {
nCurrLoad = nCurrLoad + nSpeed;
} else {
nCurrLoad = nRealLoad;
}
txtPourcentage.text = Math.floor(nCurrLoad) + "%";
if ((nCurrLoad == 100) && (this._parent.getBytesTotal() > 100)) {
new Main(_root);
}
}
Symbol 482 MovieClip [__Packages.library.State] Frame 0
class library.State
{
var mcRef, sState;
function State (_mcRef) {
mcRef = _mcRef;
}
function setState(_sState) {
sState = _sState;
mcRef.gotoAndStop(sState);
loadState(sState);
}
function setMc(_mcRef) {
mcRef = _mcRef;
setState(sState);
}
function pause() {
mcRef.mcState.stop();
}
function resume() {
mcRef.mcState.play();
}
function enterFrame() {
this["do" + sState]();
}
function loadState(_sState) {
this["start" + sState]();
}
function isStateComplete() {
if (mcRef.mcState._currentframe == mcRef.mcState._totalframes) {
this["end" + sState]();
}
return(mcRef.mcState._currentframe == mcRef.mcState._totalframes);
}
function get Mc() {
return(mcRef);
}
function get getState() {
return(sState);
}
}
Symbol 483 MovieClip [__Packages.Main] Frame 0
class Main extends library.State
{
static var Instance;
var mcRef, enterFrame, bLoading, nCounter, setState, oPopupOnlineCodeSkirmish, oPopupHowToPlay, oMainMenu, oBattlefield, oStatistics, oTeamSelect, oSharedObject;
function Main (_mcRef) {
super();
mcRef = _mcRef;
mcRef.onEnterFrame = library.Delegate.create(this, enterFrame);
Instance = this;
bLoading = false;
nCounter = 0;
data.Statistics.init();
load();
setState(sSTATE_TITLE);
}
function startTitle() {
mcRef.txtVersion.text = "Version " + nVERSION;
oPopupOnlineCodeSkirmish = new PopupOnlineCodeSkirmish(mcRef.mcPopupOnlineSkirmish, library.Delegate.create(this, skirmish, false, false, true), library.Delegate.create(this, skirmish, false, true, false));
oPopupHowToPlay = new PopupHowToPlay(mcRef.mcPopupHowToPlay);
oMainMenu = new mainmenu.MainMenuCreator(mcRef.mcMenu, "btnMainMenu");
oMainMenu.addOption(mainmenu.MainMenuCreator.sMAIN, "How to play", library.Delegate.create(oPopupHowToPlay, oPopupHowToPlay.startTransition));
oMainMenu.addOption(mainmenu.MainMenuCreator.sMAIN, "Skirmish", null);
oMainMenu.addOption("Skirmish", "Single Player", library.Delegate.create(this, skirmish, false, false, false));
oMainMenu.addOption("Skirmish", "Local Multiplayer", library.Delegate.create(this, skirmish, true, false, false));
oMainMenu.addOption("Skirmish", "Online Multiplayer", library.Delegate.create(oPopupOnlineCodeSkirmish, oPopupOnlineCodeSkirmish.startTransition));
oMainMenu.addOption(mainmenu.MainMenuCreator.sMAIN, "Objectives", null);
oMainMenu.addOption("Objectives", "Statistics", library.Delegate.create(this, setState, sSTATE_STATISTICS));
oMainMenu.displayOptions("");
}
function doTitle() {
oMainMenu.enterFrame();
oPopupOnlineCodeSkirmish.enterFrame();
oPopupHowToPlay.enterFrame();
}
function doTeamSelect() {
}
function startBattlefield() {
}
function doBattlefield() {
oBattlefield.enterFrame();
}
function endBattlefield() {
oBattlefield = undefined;
delete oBattlefield;
}
function startStatistics() {
oStatistics = new StatisticsScreen(mcRef);
}
function doStatistics() {
oStatistics.enterFrame();
}
function onlineSkirmish() {
}
function story(_bContinue) {
}
function mission() {
}
function tutorial() {
}
function objectives() {
}
function options() {
}
function skirmish(_bLocalMultiplayer, _bOnlineCodeMultiplayerHost, _bOnlineCodeMultiplayerJoin) {
setState(sSTATE_TEAMSELECT);
oTeamSelect = new TeamSelect(mcRef, _bLocalMultiplayer, _bOnlineCodeMultiplayerHost, _bOnlineCodeMultiplayerJoin);
}
function aiskirmish() {
setState(sSTATE_TEAMSELECT);
oTeamSelect = new TeamSelect(mcRef, false, false, false);
oTeamSelect.setAISkirmish();
}
function initBattlefield(_bFromTeamSelect) {
setState(sSTATE_BATTLEFIELD);
oBattlefield = new Battlefield(mcRef.mcGame);
if (_bFromTeamSelect) {
oBattlefield.load(oTeamSelect.__get__players(), oTeamSelect.__get__field());
}
}
function load() {
oSharedObject = SharedObject.getLocal("FieldBangers");
if ((oSharedObject.data.sStats != null) && (oSharedObject.data.sStats != "")) {
data.Statistics.load(oSharedObject.data.sStats);
}
}
function saveStats() {
oSharedObject.data.sStats = data.Statistics.save();
oSharedObject.flush();
}
function save(_nPosition, _sData) {
}
static var nVERSION = "0.084";
static var bTEST_MONSTER = false;
static var sSTATE_TITLE = "Title";
static var sSTATE_TEAMSELECT = "TeamSelect";
static var sSTATE_BATTLEFIELD = "Battlefield";
static var sSTATE_STATISTICS = "Statistics";
}
Symbol 484 MovieClip [__Packages.library.Popup] Frame 0
class library.Popup extends library.State
{
var setState, fMidFunction, isStateComplete, fOutFunction, sState, __get__midFunction, __get__outFunction;
function Popup (_mcRef) {
super(_mcRef);
setState(sSTATE_HIDDEN);
}
function loadState(_sState) {
super.loadState(_sState);
switch (_sState) {
case sSTATE_HIDDEN :
break;
case sSTATE_IN :
break;
case sSTATE_IDLE :
if (fMidFunction) {
fMidFunction();
fMidFunction = undefined;
}
break;
case sSTATE_OUT :
}
}
function doIn() {
if (isStateComplete()) {
setState(sSTATE_IDLE);
}
}
function doOut() {
if (isStateComplete()) {
setState(sSTATE_HIDDEN);
if (fOutFunction) {
fOutFunction();
fOutFunction = undefined;
}
}
}
function startTransition() {
if (sState == sSTATE_HIDDEN) {
setState(sSTATE_IN);
}
}
function set midFunction(_fMidFunction) {
fMidFunction = _fMidFunction;
//return(__get__midFunction());
}
function set outFunction(_fOutFunction) {
fOutFunction = _fOutFunction;
//return(__get__outFunction());
}
static var sSTATE_HIDDEN = "Hidden";
static var sSTATE_IN = "In";
static var sSTATE_IDLE = "Idle";
static var sSTATE_OUT = "Out";
}
Symbol 485 MovieClip [__Packages.PopupOnlineCodeSkirmish] Frame 0
class PopupOnlineCodeSkirmish extends library.Popup
{
var fJoin, fHost, btnJoin, mcRef, btnHost;
function PopupOnlineCodeSkirmish (_mcRef, _fJoin, _fHost) {
super(_mcRef);
fJoin = _fJoin;
fHost = _fHost;
}
function startIn() {
btnJoin = new library.MCButton(mcRef.mcState.mcState.btnJoin);
btnHost = new library.MCButton(mcRef.mcState.mcState.btnHost);
}
function startIdle() {
btnJoin = new library.MCButton(mcRef.mcState.btnJoin, fJoin);
btnHost = new library.MCButton(mcRef.mcState.btnHost, fHost);
}
function doIdle() {
btnJoin.enterFrame();
btnHost.enterFrame();
}
function startOut() {
btnJoin = new library.MCButton(mcRef.mcState.mcState.btnJoin);
btnHost = new library.MCButton(mcRef.mcState.mcState.btnHost);
}
}
Symbol 486 MovieClip [__Packages.library.MCButton] Frame 0
class library.MCButton extends library.State
{
var setState, mcRef;
function MCButton (_mcRef, _fFunction) {
super(_mcRef);
setState("Idle");
mcRef.onRollOver = library.Delegate.create(this, setState, "Over");
mcRef.onRollOut = library.Delegate.create(this, setState, "Idle");
mcRef.onPress = library.Delegate.create(this, setState, "Down");
mcRef.onMouseUp = library.Delegate.create(this, setState, "Idle");
mcRef.onRelease = _fFunction;
}
}
Symbol 487 MovieClip [__Packages.library.Delegate] Frame 0
class library.Delegate extends Object
{
var func;
function Delegate (f) {
super();
func = f;
}
static function create(obj, func) {
var _local2 = function () {
var _local3 = arguments.callee.target;
var _local4 = arguments.callee.func;
var _local2 = arguments.callee.arg;
_local2 = _local2.concat(arguments);
return(_local4.apply(_local3, _local2));
};
_local2.target = obj;
_local2.func = func;
_local2.arg = arguments.slice(2);
return(_local2);
}
function createDelegate(obj) {
return(create(obj, func));
}
}
Symbol 488 MovieClip [__Packages.PopupHowToPlay] Frame 0
class PopupHowToPlay extends library.Popup
{
var btnBack, mcRef, btnNext, btnClose, nCurrentPage, setState;
function PopupHowToPlay (_mcRef) {
super(_mcRef);
}
function startIn() {
btnBack = new library.MCButton(mcRef.mcState.mcState.btnBack);
btnNext = new library.MCButton(mcRef.mcState.mcState.btnNext);
btnClose = new library.MCButton(mcRef.mcState.mcState.btnClose);
nCurrentPage = 1;
changePage(mcRef.mcState.mcState);
}
function startIdle() {
btnBack = new library.MCButton(mcRef.mcState.btnBack, library.Delegate.create(this, prevPage));
btnNext = new library.MCButton(mcRef.mcState.btnNext, library.Delegate.create(this, nextPage));
btnClose = new library.MCButton(mcRef.mcState.btnClose, library.Delegate.create(this, setState, library.Popup.sSTATE_OUT));
changePage(mcRef.mcState);
}
function doIdle() {
btnBack.enterFrame();
btnNext.enterFrame();
btnClose.enterFrame();
}
function startOut() {
btnBack = new library.MCButton(mcRef.mcState.mcState.btnBack);
btnNext = new library.MCButton(mcRef.mcState.mcState.btnNext);
btnClose = new library.MCButton(mcRef.mcState.mcState.btnClose);
changePage(mcRef.mcState.mcState);
}
function changePage(_mcRef) {
_mcRef.gotoAndStop(nCurrentPage);
_mcRef.txtPage.text = (nCurrentPage + " / ") + _mcRef._totalframes;
btnBack.__get__Mc()._visible = true;
btnNext.__get__Mc()._visible = true;
if (nCurrentPage == 1) {
btnBack.__get__Mc()._visible = false;
} else if (nCurrentPage == _mcRef._totalframes) {
btnNext.__get__Mc()._visible = false;
}
}
function prevPage() {
nCurrentPage--;
changePage(mcRef.mcState);
}
function nextPage() {
nCurrentPage++;
changePage(mcRef.mcState);
}
}
Symbol 489 MovieClip [__Packages.TeamSelect] Frame 0
class TeamSelect
{
var mcRef, bLocalMultiplayer, bOnlineCodeMultiplayerHost, bOnlineCodeMultiplayerJoin, bAISkirmish, btnPreviousField, btnNextField, btnStart, btnCancel, aPlayers, nCurrentPlayer, btnAddCharacter, btnRemoveCharacter, aCharacters, aDisplayChar, nField, nTeamMaxValue, nSelectedCharacter;
function TeamSelect (_mcRef, _bLocalMultiplayer, _bOnlineCodeMultiplayerHost, _bOnlineCodeMultiplayerJoin) {
mcRef = _mcRef;
bLocalMultiplayer = _bLocalMultiplayer;
bOnlineCodeMultiplayerHost = _bOnlineCodeMultiplayerHost;
bOnlineCodeMultiplayerJoin = _bOnlineCodeMultiplayerJoin;
bAISkirmish = false;
init();
}
function enterFrame() {
btnPreviousField.enterFrame();
btnNextField.enterFrame();
btnStart.enterFrame();
btnCancel.enterFrame();
}
function setCurrentPlayer() {
}
function init() {
if (bOnlineCodeMultiplayerJoin) {
aPlayers = new Array(new battlefield.BattlefieldPlayer(false, true), new battlefield.BattlefieldPlayer(false, false));
setCurrentPlayer(1);
nCurrentPlayer = 1;
mcRef.txtPlayer.text = "Player 2";
} else {
aPlayers = new Array(new battlefield.BattlefieldPlayer(false, false), new battlefield.BattlefieldPlayer(!bLocalMultiplayer, bOnlineCodeMultiplayerHost));
nCurrentPlayer = 0;
}
btnAddCharacter = new library.MCButton(mcRef.btnAddCharacter, library.Delegate.create(this, addCharacter));
btnAddCharacter.__get__Mc()._visible = false;
btnRemoveCharacter = new library.MCButton(mcRef.btnRemoveCharacter, library.Delegate.create(this, removeCharacter));
btnRemoveCharacter.__get__Mc()._visible = false;
btnPreviousField = new library.MCButton(mcRef.btnPreviousField, library.Delegate.create(this, previousField));
btnNextField = new library.MCButton(mcRef.btnNextField, library.Delegate.create(this, nextField));
if (!bLocalMultiplayer) {
btnStart = new library.MCButton(mcRef.btnStart, library.Delegate.create(Main.Instance, Main.Instance.initBattlefield, true));
} else {
btnStart = new library.MCButton(mcRef.btnStart, library.Delegate.create(this, nextPlayer));
}
btnCancel = new library.MCButton(mcRef.btnCancel, library.Delegate.create(Main.Instance, Main.Instance.setState, Main.sSTATE_TITLE));
aCharacters = new Array();
aDisplayChar = new Array();
var _local3;
var _local2;
_local2 = 0;
while (_local2 < data.DataCharacter.aLIST_CHARACTERS.length) {
_local3 = mcRef.mcCharList.attachMovie(data.DataCharacter.sLINKAGE_SPRITE + data.DataCharacter.aLIST_CHARACTERS[_local2], "mcChar" + mcRef.mcCharList.getNextHighestDepth(), mcRef.mcCharList.getNextHighestDepth());
_local3._x = -((_local3._width + nCHARACTER_SPACING) * Math.floor(_local2 / nCHARS_PER_COLUMN));
_local3._y = (_local3._height + nCHARACTER_SPACING) * (_local2 % nCHARS_PER_COLUMN);
aCharacters.push(new battlefield.Character(_local3));
aCharacters[_local2].load(data.DataCharacter.getCharacter(data.DataCharacter.aLIST_CHARACTERS[_local2]));
_local2++;
}
nField = 0;
updateField();
updateCharacters();
selectCharacter(-1);
_local2 = 0;
while (_local2 < aPlayers.length) {
mcRef["txtTeamValue" + (_local2 + 1)].text = nTeamMaxValue;
aDisplayChar.push(new teamselect.TeamDisplay(mcRef["mcCharContainer" + (_local2 + 1)], library.Delegate.create(this, selectTeamDisplay)));
_local2++;
}
mcRef.txtPlayer.text = "Player 1";
}
function nextPlayer() {
btnStart = new library.MCButton(mcRef.btnStart, library.Delegate.create(Main.Instance, Main.Instance.initBattlefield, true));
nCurrentPlayer++;
mcRef.txtPlayer.text = "Player 2";
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].setState(battlefield.Character.sSTATE_IDLE);
_local2++;
}
updateCharacters();
selectCharacter(-1);
}
function previousField() {
nField = ((nField + data.DataFields.aFIELD.length) - 1) % data.DataFields.aFIELD.length;
updateField();
}
function nextField() {
nField = (nField + 1) % data.DataFields.aFIELD.length;
updateField();
}
function updateField() {
mcRef.mcFieldList.gotoAndStop(data.DataFields.aFIELD[nField]);
var _local2 = data.DataFields.getField(data.DataFields.aFIELD[nField]);
nTeamMaxValue = _local2.nDefaultTeamValue;
mcRef.txtTeamValue.text = nTeamMaxValue;
}
function selectTeamDisplay() {
var _local3 = aDisplayChar[nCurrentPlayer].selected;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if (aCharacters[_local2].linkage == _local3) {
selectCharacter(_local2);
}
_local2++;
}
}
function selectCharacter(_nSelectedCharacter) {
if (_nSelectedCharacter >= 0) {
nSelectedCharacter = _nSelectedCharacter;
var _local2 = data.DataCharacter.getCharacter(aCharacters[nSelectedCharacter].linkage);
mcRef.mcProfile.gotoAndStop(aCharacters[nSelectedCharacter].linkage);
mcRef.txtName.text = _local2.sName;
mcRef.txtSubName.text = _local2.sSubName;
mcRef.txtCountry.text = _local2.sCountry;
mcRef.txtAttack.text = _local2.nAttack;
mcRef.mcAttackBar.gotoAndStop(_local2.nAttack * 2);
if (_local2.nAttack == 0) {
mcRef.mcAttackBar.gotoAndStop(mcRef.mcAttackBar._totalframes);
}
mcRef.txtAttackRange.text = _local2.nAttackRange;
mcRef.mcAttackBar.gotoAndStop(_local2.nAttack * 2);
if (_local2.nAttack == 0) {
mcRef.mcAttackBar.gotoAndStop(mcRef.mcAttackBar._totalframes);
}
mcRef.txtDefense.text = _local2.nDefense;
mcRef.mcDefenseBar.gotoAndStop(_local2.nDefense * 2);
if (_local2.nDefense == 0) {
mcRef.mcDefenseBar.gotoAndStop(mcRef.mcDefenseBar._totalframes);
}
mcRef.txtHealth.text = _local2.nHealth;
mcRef.mcHealthBar.gotoAndStop(_local2.nHealth * 2);
if (_local2.nHealth == 0) {
mcRef.mcHealthBar.gotoAndStop(mcRef.mcHealthBar._totalframes);
}
mcRef.txtMovement.text = _local2.nMovement;
mcRef.mcMovementBar.gotoAndStop(Math.floor(_local2.nMovement * 2));
if (_local2.nMovement == 0) {
mcRef.mcMovementBar.gotoAndStop(mcRef.mcMovementBar._totalframes);
}
mcRef.txtRessource.text = _local2.nRessource;
mcRef.mcRessourceBar.gotoAndStop(Math.floor(_local2.nRessource) * 2);
if (_local2.nRessource == 0) {
mcRef.mcRessourceBar.gotoAndStop(mcRef.mcRessourceBar._totalframes);
}
mcRef.txtInitiative.text = _local2.nInitiative;
mcRef.txtInitiative.text = mcRef.txtInitiative.text.split(".").join("/");
mcRef.mcInitiativeBar.gotoAndStop(_local2.nInitiative * 2);
if (_local2.nInitiative == 0) {
mcRef.mcInitiativeBar.gotoAndStop(mcRef.mcInitiativeBar._totalframes);
}
mcRef.txtValue.text = _local2.nValue;
mcRef.mcValueBar.gotoAndStop(_local2.nValue * 2);
if (_local2.nValue == 0) {
mcRef.mcValueBar.gotoAndStop(mcRef.mcAttackBar._totalframes);
}
if (_local2.aSkills.length > 0) {
setSkill(_local2.aSkills[0]);
} else {
setSkill(data.DataCharacter.sSKILL_NONE);
}
} else {
mcRef.txtName.text = "";
mcRef.txtSubName.text = "";
mcRef.txtCountry.text = "";
mcRef.txtAttack.text = "";
mcRef.mcAttackBar.gotoAndStop(mcRef.mcAttackBar._totalframes);
mcRef.txtAttackRange.text = "";
mcRef.mcAttackBar.gotoAndStop(mcRef.mcAttackBar._totalframes);
mcRef.txtDefense.text = "";
mcRef.mcDefenseBar.gotoAndStop(mcRef.mcDefenseBar._totalframes);
mcRef.txtHealth.text = "";
mcRef.mcHealthBar.gotoAndStop(mcRef.mcHealthBar._totalframes);
mcRef.txtMovement.text = "";
mcRef.mcMovementBar.gotoAndStop(mcRef.mcMovementBar._totalframes);
mcRef.txtRessource.text = "";
mcRef.mcRessourceBar.gotoAndStop(mcRef.mcRessourceBar._totalframes);
mcRef.txtInitiative.text = "";
mcRef.mcInitiativeBar.gotoAndStop(mcRef.mcInitiativeBar._totalframes);
mcRef.txtValue.text = "";
mcRef.mcValueBar.gotoAndStop(mcRef.mcAttackBar._totalframes);
setSkill(data.DataCharacter.sSKILL_NONE);
mcRef.mcProfile.gotoAndStop(data.DataCharacter.sSKILL_NONE);
}
}
function setSkill(_sSkill) {
if (_sSkill == data.DataCharacter.sSKILL_NONE) {
mcRef.mcSkill._visible = false;
} else {
mcRef.mcSkill._visible = true;
var _local2 = data.DataCharacter.getSkill(_sSkill);
mcRef.mcSkill.txtName.text = _local2.sName;
mcRef.mcSkill.txtCost.text = _local2.nCost;
mcRef.mcSkill.txtDescription.text = _local2.sDesc;
mcRef.mcSkill.mcImage.gotoAndStop(_local2.sLinkage);
}
}
function addCharacter() {
var _local2 = data.DataCharacter.getCharacter(aCharacters[nSelectedCharacter].linkage);
if (_local2.nValue <= (nTeamMaxValue - aDisplayChar[nCurrentPlayer].teamValue)) {
aDisplayChar[nCurrentPlayer].addCharacter(_local2);
aCharacters[nSelectedCharacter].setState(battlefield.Character.sSTATE_SELECTED);
mcRef["txtTeamValue" + (nCurrentPlayer + 1)].text = nTeamMaxValue - aDisplayChar[nCurrentPlayer].teamValue;
updateCharacters();
}
}
function removeCharacter() {
var _local2 = data.DataCharacter.getCharacter(aCharacters[nSelectedCharacter].linkage);
aDisplayChar[nCurrentPlayer].removeCharacter(_local2);
aCharacters[nSelectedCharacter].setState(battlefield.Character.sSTATE_IDLE);
mcRef["txtTeamValue" + (nCurrentPlayer + 1)].text = nTeamMaxValue - aDisplayChar[nCurrentPlayer].teamValue;
updateCharacters();
}
function updateCharacters() {
var _local6 = 0.33;
var _local7 = 0.5;
var _local5 = 0.16;
var _local4 = new flash.filters.ColorMatrixFilter([_local6, _local7, _local5, 0, 0, _local6, _local7, _local5, 0, 0, _local6, _local7, _local5, 0, 0, 0, 0, 0, 1, 0]);
var _local3;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if ((aCharacters[_local2].value > (nTeamMaxValue - aDisplayChar[nCurrentPlayer].teamValue)) && (!aDisplayChar[nCurrentPlayer].isCharacter(aCharacters[_local2].linkage))) {
aCharacters[_local2].Mc.filters = new Array(_local4);
if (aDisplayChar[nCurrentPlayer].isCharacter(aCharacters[_local2].linkage)) {
_local3 = library.Delegate.create(this, removeCharacter);
} else {
_local3 = null;
}
} else {
aCharacters[_local2].Mc.filters = new Array();
if (!aDisplayChar[nCurrentPlayer].isCharacter(aCharacters[_local2].linkage)) {
_local3 = library.Delegate.create(this, addCharacter);
} else {
_local3 = library.Delegate.create(this, removeCharacter);
}
}
aCharacters[_local2].setMouseClick(_local3, library.Delegate.create(this, selectCharacter, _local2), library.Delegate.create(this, selectCharacter, -1));
_local2++;
}
}
function setRandom() {
var _local3 = new Array();
var _local6;
var _local5 = 0;
var _local4;
var _local2;
_local2 = 0;
while (_local2 < data.DataCharacter.aLIST_CHARACTERS.length) {
_local3.push(data.DataCharacter.getCharacter(data.DataCharacter.aLIST_CHARACTERS[_local2]));
_local2++;
}
do {
_local2 = 0;
while (_local2 < _local3.length) {
if (_local3[_local2].nValue > (nTeamMaxValue - _local5)) {
_local3.splice(_local2, 1);
_local2--;
}
_local2++;
}
if (_local3.length > 0) {
_local4 = Math.floor(Math.random() * _local3.length);
_local5 = _local5 + _local3[_local4].nValue;
aDisplayChar[nCurrentPlayer].addCharacter(_local3[_local4]);
_local3.splice(_local4, 1);
}
} while (_local3.length > 0);
}
function setAISkirmish() {
bAISkirmish = true;
}
function get field() {
return(data.DataFields.aFIELD[nField]);
}
function get players() {
var _local2;
var _local3;
_local2 = 0;
while (_local2 < aPlayers.length) {
if (aPlayers[_local2].isOnline) {
aPlayers[_local2].addCharactersAI(nTeamMaxValue);
} else {
if ((aDisplayChar[_local2].teamValue == 0) && (!aPlayers[_local2].isOnline)) {
nCurrentPlayer = _local2;
setRandom();
}
_local3 = 0;
while (_local3 < aDisplayChar[_local2].characters.length) {
aPlayers[_local2].addCharacter(aDisplayChar[_local2].characters[_local3]);
_local3++;
}
}
_local2++;
}
return(aPlayers);
}
static var nCHARS_PER_COLUMN = 2;
static var nCHARACTER_SPACING = 15;
static var nDEFAULT_TEAM_MAX_VALUE = 100;
}
Symbol 490 MovieClip [__Packages.battlefield.BattlefieldPlayer] Frame 0
class battlefield.BattlefieldPlayer
{
var oAI, bOnlineCodePlayer, aCharacters, nRessource, nMaxRessource, nActiveChar;
function BattlefieldPlayer (_bAI, _bOnlineCodePlayer) {
oAI = new battlefield.battlefieldplayer.AI(_bAI, true);
bOnlineCodePlayer = _bOnlineCodePlayer;
aCharacters = new Array();
}
function enterFrame() {
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].enterFrame();
_local2++;
}
if (oAI.__get__isAI()) {
oAI.enterFrame();
}
}
function mouseOverCharacter() {
var _local4 = null;
var _local3;
_local3 = 0;
while (_local3 < aCharacters.length) {
if (aCharacters[_local3].Mc.hitTest(_root._xmouse, _root._ymouse)) {
_local4 = aCharacters[_local3].charObj;
_local4.nChar = _local3;
_local4.mc = aCharacters[_local3].Mc;
break;
}
_local3++;
}
return(_local4);
}
function addCharacter(_oChar) {
var _local3 = false;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
_local3 = _local3 || (aCharacters[_local2].sChar == _oChar.sChar);
_local2++;
}
if (!_local3) {
var _local5 = new battlefield.Character();
_local5.load(_oChar);
aCharacters.push(_local5);
}
return(_local3);
}
function addCharacterOnline(_nPlayer, _oBattlefield, _aCharacterOrder, _oChar, _nX, _nY) {
var _local4 = addCharacter(_oChar);
if (!_local4) {
aCharacters[aCharacters.length - 1].setMc(_oBattlefield.addCharacter(_nPlayer, aCharacters.length - 1, aCharacters[aCharacters.length - 1]));
aCharacters[aCharacters.length - 1].Mc._xscale = ((_nPlayer * 200) - 100) * -1;
aCharacters[aCharacters.length - 1].setBase(_nPlayer);
_aCharacterOrder.reverse();
updateCharacterOrder(aCharacters.length - 1, _aCharacterOrder, _nPlayer);
aCharacters[aCharacters.length - 1].setPos(_nX, _nY);
_aCharacterOrder.reverse();
}
return(_aCharacterOrder);
}
function addCharactersAI(_nTeamMaxValue) {
var _local3 = oAI.createTeam(_nTeamMaxValue);
var _local2;
_local2 = 0;
while (_local2 < _local3.length) {
addCharacter(_local3[_local2]);
_local2++;
}
}
function removeCharacter(_oChar) {
var _local4 = false;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if (aCharacters[_local2].sChar == _oChar.sChar) {
aCharacters.splice(_local2, 1);
_local2--;
}
_local2++;
}
}
function loadBattlefield(_nPlayer, _oBattlefield, _aCharacterOrder, _mcField, _mcCharacters, _mcDraw, _mcDrawUpper) {
var _local2;
var _local10;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].setMc(_oBattlefield.addCharacter(_nPlayer, _local2, aCharacters[_local2]));
aCharacters[_local2].Mc._xscale = ((_nPlayer * 200) - 100) * -1;
aCharacters[_local2].setBase(_nPlayer);
aCharacters[_local2].setDrawZones(_mcField, _mcCharacters, _mcDraw, _mcDrawUpper);
_aCharacterOrder = updateCharacterOrder(_local2, _aCharacterOrder, _nPlayer);
_local2++;
}
nRessource = Battlefield.nSTART_RESSOURCE;
nMaxRessource = Battlefield.nMAX_RESSOURCE;
return(_aCharacterOrder);
}
function changeRessource(_nRessource) {
nRessource = nRessource + _nRessource;
nRessource = Math.max(0, Math.min(nRessource, nMaxRessource));
}
function setAITurn() {
oAI.setTurn();
}
function nextAIAction(_oField, _aEnemyChar, _oBattlefield, _nPlayer, _nChar, _nMovement, _fEndTurn) {
var _local2 = oAI.getNextAction(aCharacters[_nChar], _oBattlefield, _oField, aCharacters, _aEnemyChar, _nMovement, nRessource, library.Delegate.create(this, nextAIAction, _oField, _aEnemyChar, _oBattlefield, _nPlayer, _nChar, _nMovement, _fEndTurn));
switch (_local2.nAction) {
case battlefield.battlefieldplayer.AI.nACTION_ATTACK :
_nPlayer = (_nPlayer + 1) % 2;
if (_local2.bUseSkill) {
_oBattlefield.useSkill();
}
_oBattlefield.attackChar(_local2.sTargetChar);
break;
case battlefield.battlefieldplayer.AI.nACTION_MOVEMENT :
if (_local2.bUseSkill) {
_oBattlefield.useSkill();
} else {
var _local9 = library.MyMath.lineSize(aCharacters[_nChar].Mc._x, aCharacters[_nChar].Mc._y, _local2.aMoves[0].x, _local2.aMoves[0].y) / data.DataFields.nTILE_SIZE;
_nMovement = _nMovement - _local9;
if (_nMovement < 1) {
_nMovement = 0;
}
}
moveCharacter(_nChar, _local2.aMoves, library.Delegate.create(this, nextAIAction, _oField, _aEnemyChar, _oBattlefield, _nPlayer, _nChar, _nMovement, _fEndTurn), false);
break;
case battlefield.battlefieldplayer.AI.nACTION_SKILL :
break;
case battlefield.battlefieldplayer.AI.nACTION_WAIT :
break;
case battlefield.battlefieldplayer.AI.nACTION_END_TURN :
_fEndTurn();
}
}
function updateCharacterOrder(_nCpt, _aCharacterOrder, _nPlayer) {
var _local2;
var _local3;
var _local6;
var _local5 = new Array();
if (aCharacters[_nCpt].initiative == Math.floor(aCharacters[_nCpt].initiative)) {
_local5.push(new Object({nPlayer:_nPlayer, nChar:_nCpt, mc:aCharacters[_nCpt].Mc, nRessources:aCharacters[_nCpt].charObj.nRessources, sChar:aCharacters[_nCpt].linkage, nInitiative:aCharacters[_nCpt].initiative, nMovement:aCharacters[_nCpt].movement, nAttackRange:aCharacters[_nCpt].attackrange}));
} else {
_local5.push(new Object({nPlayer:_nPlayer, nChar:_nCpt, mc:aCharacters[_nCpt].Mc, nRessources:aCharacters[_nCpt].charObj.nRessources, sChar:aCharacters[_nCpt].linkage, nInitiative:Math.floor(aCharacters[_nCpt].initiative), nMovement:aCharacters[_nCpt].movement, nAttackRange:aCharacters[_nCpt].attackrange}));
_local5.push(new Object({nPlayer:_nPlayer, nChar:_nCpt, mc:aCharacters[_nCpt].Mc, nRessources:aCharacters[_nCpt].charObj.nRessources, sChar:aCharacters[_nCpt].linkage, nInitiative:(aCharacters[_nCpt].initiative * 10) % 10, nMovement:aCharacters[_nCpt].movement, nAttackRange:aCharacters[_nCpt].attackrange}));
}
_local3 = 0;
while (_local3 < _local5.length) {
_local6 = false;
_local2 = 0;
while (_local2 < _aCharacterOrder.length) {
if (_local5[_local3].nInitiative < _aCharacterOrder[_local2].nInitiative) {
_aCharacterOrder.splice(_local2, 0, _local5[_local3]);
_local6 = true;
break;
}
if (_local5[_local3].nInitiative == _aCharacterOrder[_local2].nInitiative) {
if (_local5[_local3].nMovement < _aCharacterOrder[_local2].nMovement) {
_aCharacterOrder.splice(_local2, 0, _local5[_local3]);
_local6 = true;
break;
}
if (_local5[_local3].nMovement == _aCharacterOrder[_local2].nMovement) {
if (_local5[_local3].nPlayer < _aCharacterOrder[_local2].nPlayer) {
_aCharacterOrder.splice(_local2, 0, _local5[_local3]);
_local6 = true;
break;
}
}
}
_local2++;
}
if (!_local6) {
_aCharacterOrder.push(_local5[_local3]);
}
_local3++;
}
return(_aCharacterOrder);
}
function setPlaceCharacters(_fEndPlace, _fHudButton) {
if (!oAI.__get__isAI()) {
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].setPlace(library.Delegate.create(this, setActiveChar, _local2), _fEndPlace);
_local2++;
}
} else {
_fHudButton();
}
}
function getCharacterObj(_nChar) {
return(aCharacters[_nChar].charObj);
}
function getActiveCharacter() {
return(aCharacters[nActiveChar]);
}
function getCharacters() {
return(aCharacters);
}
function getAliveCharacters() {
var _local3 = new Array();
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if (aCharacters[_local2].health > 0) {
_local3.push(aCharacters[_local2]);
}
_local2++;
}
return(_local3);
}
function setAttackable(_oPoint, _nAttackRange, _fAttack) {
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].setAttackable(_oPoint, _nAttackRange, _fAttack);
_local2++;
}
}
function attackChar(_oCharObj, _sTarget, _nAttack, _bIgnoreDefense, _nType) {
var _local4 = null;
var _local3;
_local3 = 0;
while (_local3 < aCharacters.length) {
if (_sTarget == aCharacters[_local3].linkage) {
if (_nType == nTYPE_ATTACK) {
_local4 = aCharacters[_local3].attack(_oCharObj, _nAttack, _bIgnoreDefense);
} else {
_local4 = aCharacters[_local3].heal(_oCharObj, _nAttack);
}
_local4.char = _local3;
break;
}
if (aCharacters[_local3].Mc.hitTest(_root._xmouse, _root._ymouse) && ((_sTarget == null) || (_sTarget == ""))) {
if (_nType == nTYPE_ATTACK) {
_local4 = aCharacters[_local3].attack(_oCharObj, _nAttack, _bIgnoreDefense);
} else {
_local4 = aCharacters[_local3].heal(_oCharObj, _nAttack);
}
_local4.char = _local3;
break;
}
_local3++;
}
return(_local4);
}
function getCharPos(_nCharacter) {
return(new flash.geom.Point(aCharacters[_nCharacter].Mc._x, aCharacters[_nCharacter].Mc._y));
}
function removeAllCharacterZones() {
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].Mc.onRollOver = undefined;
delete aCharacters[_local2].Mc.onRollOver;
aCharacters[_local2].Mc.onRollOut = undefined;
delete aCharacters[_local2].Mc.onRollOut;
_local2++;
}
}
function moveCharacter(_nCharacter, _aMove, _fEndMove, _bFlyTo) {
return(aCharacters[_nCharacter].setMove(_aMove, _fEndMove, _bFlyTo));
}
function resetMouseCharacters() {
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
aCharacters[_local2].unsetPress();
_local2++;
}
}
function setVictory(_bVictory) {
var _local3 = data.Statistics.nSTAT_VICTORIES;
if (!_bVictory) {
_local3 = data.Statistics.nSTAT_DEFEATS;
}
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
data.Statistics.addStat(aCharacters[_local2].linkage, _local3, 1);
_local2++;
}
}
function setActiveChar(_nActiveChar) {
nActiveChar = _nActiveChar;
}
function get characters() {
return(aCharacters);
}
function get teamValue() {
var _local3 = 0;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
_local3 = _local3 + aCharacters[_local2].value;
_local2++;
}
return(_local3);
}
function get isAI() {
return(oAI.__get__isAI());
}
function get isOnline() {
return(bOnlineCodePlayer);
}
function get onlineCodePosition() {
var _local4;
var _local3 = "";
var _local2;
var _local5;
_local2 = 0;
while (_local2 < aCharacters.length) {
_local3 = _local3 + ((((((data.DataCharacter.sONLINE_CHARACTER + data.DataCharacter.posFromLinkage(aCharacters[_local2].linkage)) + ":") + aCharacters[_local2].Mc._x) + ":") + aCharacters[_local2].Mc._y) + ";");
_local2++;
}
_local3 = _local3 + data.DataCharacter.sONLINE_END_CHARACTER;
return(_local3);
}
function get ressource() {
return(nRessource);
}
var nFIELD_X_SIZE = 800;
var nFIELD_Y_SIZE = 707;
static var nTYPE_ATTACK = 0;
static var nTYPE_HEAL = 1;
}
Symbol 491 MovieClip [__Packages.battlefield.battlefieldplayer.AI] Frame 0
class battlefield.battlefieldplayer.AI
{
var bAI, bWait, bHasWaited, aPreferences, nWait, fEndWait, bMovement, bAttack;
function AI (_bAI, _bWait) {
bAI = _bAI;
bWait = _bWait;
bHasWaited = bWait;
aPreferences = aAI_CLOSEST;
}
function enterFrame() {
if ((bWait && (!bHasWaited)) && (nWait <= getTimer())) {
fEndWait();
}
}
function createTeam(_nTeamMaxValue) {
var _local8;
var _local7;
switch (getDecision(aCHOICES_TEAM)) {
case nCHOICE_TEAM_RANDOM :
_local7 = createRandomTeam(_nTeamMaxValue, data.DataCharacter.aLIST_CHARACTERS);
break;
case nCHOICE_TEAM_FULLEST_OF_FIVE :
var _local3 = new Array();
var _local2;
_local2 = 0;
while (_local2 < 5) {
_local3.push(createRandomTeam(_nTeamMaxValue, data.DataCharacter.aLIST_CHARACTERS));
_local2++;
}
var _local4 = 0;
var _local5 = 0;
do {
_local4 = 0;
_local5 = 0;
_local2 = 0;
while (_local2 < _local3[0].length) {
_local4 = _local4 + _local3[0].nValue;
_local2++;
}
_local2 = 0;
while (_local2 < _local3[1].length) {
_local5 = _local5 + _local3[1].nValue;
_local2++;
}
if (_local4 > _local5) {
_local3.splice(1, 1);
} else {
_local3.splice(0, 1);
}
} while (_local3.length > 1);
_local7 = _local3[0];
break;
case nCHOICE_TEAM_TIER_LIST :
_local7 = createRandomTeam(_nTeamMaxValue, data.DataCharacter.aLIST_CHARACTERS);
}
return(_local7);
}
function createRandomTeam(_nTeamMaxValue, _aListCharacters) {
var _local2 = new Array();
var _local6 = new Array();
var _local8;
var _local4 = 0;
var _local3;
var _local1;
_local1 = 0;
while (_local1 < data.DataCharacter.aLIST_CHARACTERS.length) {
_local2.push(data.DataCharacter.getCharacter(_aListCharacters[_local1]));
_local1++;
}
do {
_local3 = Math.floor(Math.random() * _local2.length);
_local4 = _local4 + _local2[_local3].nValue;
_local6.push(_local2[_local3]);
_local2.splice(_local3, 1);
_local1 = 0;
while (_local1 < _local2.length) {
if (_local2[_local1].nValue > (_nTeamMaxValue - _local4)) {
_local2.splice(_local1, 1);
_local1--;
}
_local1++;
}
} while (_local2.length > 0);
return(_local6);
}
function setTurn() {
bMovement = true;
bAttack = true;
}
function getNextAction(_oChar, _oBattlefield, _oField, _aPlayerChar, _aEnemyChar, _nMovement, _nRessource, _fEndWait) {
var _local9 = null;
if (bWait) {
if (getTimer() >= nWait) {
bHasWaited = !bHasWaited;
if (!bHasWaited) {
_local9 = getWait();
fEndWait = _fEndWait;
} else {
_oBattlefield.endWait();
}
}
}
if (bHasWaited) {
var _local6;
var _local2;
var _local4;
var _local5 = new Object();
var _local12;
var _local10;
_local12 = 0;
while (_local12 < aPreferences.length) {
switch (aPreferences[_local12]) {
case nCHOICE_MOVE_CLOSEST :
if (_nMovement > 0) {
_local2 = _oField.findClosestChar(_oChar.__get__Mc(), _aEnemyChar);
_local5 = moveTowardTarget(_oChar, _nMovement, _aEnemyChar[_local2].Mc, _oBattlefield, false);
if (_local5 != null) {
_local6 = _oField.getMovement(_oChar.__get__Mc(), _local5);
_local9 = getMovement(_local6, false);
bMovement = false;
}
}
break;
case nCHOICE_ATTACK_CLOSEST :
if (bAttack) {
_local2 = _oField.findClosestChar(_oChar.__get__Mc(), _aEnemyChar);
if (targetWithinRange(_oChar, _aEnemyChar[_local2].Mc, _oBattlefield)) {
_local9 = getAttack(_aEnemyChar[_local2].linkage, false);
bAttack = false;
}
}
break;
case nCHOICE_SKILL_HEAL_FULL_USE :
_local4 = data.DataCharacter.getSkill(data.DataCharacter.sSKILL_HEAL);
if (hasSkill(_oChar, _local4, _nRessource)) {
_local10 = targetsMinHealth(_aPlayerChar, _local4.nValue, 0);
if (_local10.length > 0) {
_local2 = _oField.findClosestChar(_oChar.__get__Mc(), _local10);
if (targetWithinRange(_oChar, _local10[_local2].Mc, _oBattlefield)) {
_local9 = getAttack(_aEnemyChar[_local2].linkage, true);
bAttack = false;
}
}
}
break;
case nCHOICE_MOVE_HEAL_FULL_USE :
_local4 = data.DataCharacter.getSkill(data.DataCharacter.sSKILL_HEAL);
if (hasSkill(_oChar, _local4, _nRessource)) {
if (_nMovement > 0) {
_local10 = targetsMinHealth(_aPlayerChar, _local4.nValue, 0);
_local2 = _oField.findClosestChar(_oChar.__get__Mc(), _local10);
_local5 = moveTowardTarget(_oChar, _nMovement, _local10[_local2].Mc, _oBattlefield, false);
if (_local5 != null) {
_local6 = _oField.getMovement(_oChar.__get__Mc(), _local5);
_local9 = getMovement(_local6, false);
bMovement = false;
}
}
}
break;
case nCHOICE_SKILL_PROJECTILE_TO_KILL :
_local4 = data.DataCharacter.getSkill(data.DataCharacter.sSKILL_PROJECTILE);
if (hasSkill(_oChar, _local4, _nRessource)) {
_local10 = targetsMinHealth(_aEnemyChar, 0, _local4.nValue);
_local2 = 0;
while ((_local2 < _local10.length) && (targetWithinRange(_oChar, _local10[_local2].Mc, _oBattlefield))) {
_local2++;
}
if (_local2 < _local10.length) {
_local9 = getAttack(_aEnemyChar[_local2].linkage, true);
}
}
break;
case nCHOICE_SKILL_TELEPORT_TO_KILL :
_local4 = data.DataCharacter.getSkill(data.DataCharacter.sSKILL_TELEPORT);
if (!hasSkill(_oChar, _local4, _nRessource)) {
break;
}
_local10 = targetsMinHealth(_aEnemyChar, 0, _local4.nValue);
_local2 = 0;
while ((_local2 < _local10.length) && (targetWithinRange(_oChar, _local10[_local2].Mc, _oBattlefield))) {
_local2++;
}
if (_local2 >= _local10.length) {
break;
}
_local5 = teleportTowardTarget(_oChar, _local10[_local2].Mc, _oBattlefield);
if (_local5.bCollide) {
break;
}
_local6 = new Array();
_local6.push(new Object());
_local6[0].x = _local5.x;
_local6[0].y = _local5.y;
_local9 = getMovement(_local6, true);
bMovement = false;
}
if (_local9 != null) {
break;
}
_local12++;
}
if (_local9 == null) {
_local9 = new Object();
_local9.nAction = nACTION_END_TURN;
}
}
return(_local9);
}
function moveTowardTarget(_oChar, _nMovement, _mcEnemy, _oBattlefield, _bFlying) {
var _local7 = new Object();
var _local2 = new Object({x:_oChar.__get__Mc()._x, y:_oChar.__get__Mc()._y});
var _local5 = library.MyMath.angleDirection(_oChar.__get__Mc()._x, _oChar.__get__Mc()._y, _mcEnemy._x, _mcEnemy._y);
var _local3 = 5;
var _local8 = library.MyMath.lineSize(_oChar.__get__Mc()._x, _oChar.__get__Mc()._y, _mcEnemy._x, _mcEnemy._y);
var _local9;
if (!targetWithinRange(_oChar, _mcEnemy, _oBattlefield)) {
do {
_local2 = new Object({x:_oChar.__get__Mc()._x, y:_oChar.__get__Mc()._y});
if (_local8 >= ((_nMovement + _oChar.__get__attackrange()) * data.DataFields.nTILE_SIZE)) {
_local2 = library.MyMath.DistanceAngle(_local2, _nMovement * data.DataFields.nTILE_SIZE, _local5 % 360);
} else {
_local9 = Math.min(_local8 - ((_oChar.__get__attackrange() * data.DataFields.nTILE_SIZE) - 10), _nMovement * data.DataFields.nTILE_SIZE);
_local2 = library.MyMath.DistanceAngle(_local2, _local9, _local5 % 360);
}
_local2.x = Math.round(_local2.x);
_local2.y = Math.round(_local2.y);
_local5 = _local5 - _local3;
_local3 = Math.abs(_local3) + (5 * ((-_local3) / _local3));
_local7 = _oBattlefield.tryCollideMovement(_oChar.__get__Mc(), _local2, _bFlying);
} while (_local7.bCollide && (Math.abs(_local3) < 100));
if (_local7.bCollide) {
_local2 = null;
}
} else {
_local2 = null;
}
return(_local2);
}
function teleportTowardTarget(_oChar, _mcEnemy, _oBattlefield) {
var _local1;
var _local5 = library.MyMath.angleDirection(_mcEnemy._x, _mcEnemy._y, _oChar.__get__Mc()._x, _oChar.__get__Mc()._y);
var _local2 = new Object();
var _local3;
var _local6 = (_oChar.__get__attackrange() * data.DataFields.nTILE_SIZE) + data.DataFields.nTILE_SIZE;
_local2.x = _mcEnemy._x;
_local2.y = _mcEnemy._y;
do {
_local2 = library.MyMath.DistanceAngle(_local2, _local6, (_local5 + _local1) % 360);
_local1 = (Math.abs(_local1) + 5) * ((-_local1) / _local1);
_local3 = _oBattlefield.tryCollideMovement(_oChar.__get__Mc(), _local2, true);
} while (_local3.bCollide && (Math.abs(_local1) < 360));
return(_local3);
}
function targetsMinHealth(_aChar, _nMissingHP, _nHPRemaining) {
var _local5 = new Array();
var _local1;
_local1 = 0;
while (_local1 < _aChar.length) {
if (((_aChar[_local1].health <= _nHPRemaining) && (_nMissingHP > 0)) || (((_aChar[_local1].maxhealth - _aChar[_local1].health) >= _nMissingHP) && (_nHPRemaining > 0))) {
_local5.push.push(_aChar[_local1]);
}
_local1++;
}
return(_local5);
}
function targetWithinRange(_oChar, _mcEnemy, _oBattlefield) {
var _local2 = library.MyMath.lineSize(_oChar.__get__Mc()._x, _oChar.__get__Mc()._y, _mcEnemy._x, _mcEnemy._y);
return(_local2 <= ((_oChar.__get__attackrange() * data.DataFields.nTILE_SIZE) + data.DataFields.nTILE_SIZE));
}
function hasSkill(_oChar, _oSkill, _nRessource) {
var _local2 = _oChar.charObj.aSkills;
var _local4 = false;
var _local1;
_local1 = 0;
while (_local1 < _local2.length) {
if (_local2[_local1] == _oSkill.sLinkage) {
_local4 = _nRessource >= _oSkill.nCost;
break;
}
_local1++;
}
return(_local4);
}
function getMovement(_aMovement, _bUseSkill) {
var _local1 = new Object();
_local1.nAction = nACTION_MOVEMENT;
_local1.aMoves = _aMovement;
_local1.bUseSkill = _bUseSkill;
return(_local1);
}
function getAttack(_sChar, _bUseSkill) {
var _local1 = new Object();
_local1.nAction = nACTION_ATTACK;
_local1.sTargetChar = _sChar;
_local1.bUseSkill = _bUseSkill;
return(_local1);
}
function getSkill() {
var _local1 = new Object();
_local1.nAction = nACTION_SKILL;
return(_local1);
}
function getWait() {
var _local2 = new Object();
_local2.nAction = nACTION_WAIT;
_local2.nWait = (getTimer() + (Math.random() * (nWAIT_MAX - nWAIT_MIN))) + nWAIT_MIN;
nWait = _local2.nWait;
return(_local2);
}
function getDecision(_aChoices) {
return(_aChoices[Math.floor(Math.random() * _aChoices.length)]);
}
function get isAI() {
return(bAI);
}
static var nWAIT_MIN = 100;
static var nWAIT_MAX = 300;
static var aCHOICES_TEAM = new Array(nCHOICE_TEAM_RANDOM, nCHOICE_TEAM_FULLEST_OF_FIVE, nCHOICE_TEAM_TIER_LIST);
static var nCHOICE_TEAM_RANDOM = 0;
static var nCHOICE_TEAM_FULLEST_OF_FIVE = 1;
static var nCHOICE_TEAM_TIER_LIST = 2;
static var aCHOICES_MOVE = new Array(nCHOICE_MOVE_CLOSEST, nCHOICE_MOVE_THREAT, nCHOICE_MOVE_RANDOM);
static var nCHOICE_MOVE_CLOSEST = 10;
static var nCHOICE_MOVE_THREAT = 11;
static var nCHOICE_MOVE_RANDOM = 12;
static var nCHOICE_MOVE_LOWEST_HP = 13;
static var nCHOICE_MOVE_HEAL_FULL_USE = 14;
static var aCHOICES_ATTACK = new Array(nCHOICE_ATTACK_LOW_HP, nCHOICE_ATTACK_THREAT, nCHOICE_ATTACK_RANDOM, nCHOICE_ATTACK_CLOSEST, nCHOICE_MOVE_HEAL_FULL_USE);
static var nCHOICE_ATTACK_LOW_HP = 20;
static var nCHOICE_ATTACK_THREAT = 21;
static var nCHOICE_ATTACK_RANDOM = 22;
static var nCHOICE_ATTACK_CLOSEST = 23;
static var nCHOICE_SKILL_TELEPORT_TO_KILL = 30;
static var nCHOICE_SKILL_PROJECTILE_TO_KILL = 31;
static var nCHOICE_SKILL_HEAL_FULL_USE = 32;
static var nACTION_ATTACK = 0;
static var nACTION_MOVEMENT = 1;
static var nACTION_END_TURN = 2;
static var nACTION_SKILL = 3;
static var nACTION_WAIT = 4;
static var aAI_CLOSEST = new Array(nCHOICE_SKILL_HEAL_FULL_USE, nCHOICE_MOVE_HEAL_FULL_USE, nCHOICE_ATTACK_CLOSEST, nCHOICE_SKILL_TELEPORT_TO_KILL, nCHOICE_SKILL_PROJECTILE_TO_KILL, nCHOICE_MOVE_CLOSEST);
}
Symbol 492 MovieClip [__Packages.data.DataCharacter] Frame 0
class data.DataCharacter
{
function DataCharacter () {
}
static function posFromLinkage(_sLinkage) {
var _local1;
_local1 = 0;
while (_local1 < aLIST_CHARACTERS.length) {
if (aLIST_CHARACTERS[_local1] == _sLinkage) {
break;
}
_local1++;
}
return(_local1);
}
static function getSkill(_sSkill) {
var _local1 = new Object();
switch (_sSkill) {
case sSKILL_NONE :
_local1 = createSkillStats("None", 0, 0, _sSkill, nSKILL_TYPE_NONE, nSKILL_RANGE_FIELD, nSKILL_EFFECT_NONE);
_local1.sDesc = "";
break;
case sSKILL_TELEPORT :
_local1 = createSkillStats("Flight", 4, 0, _sSkill, nSKILL_TYPE_ACTIVE_FIELD, nSKILL_RANGE_FIELD, nSKILL_EFFECT_FLIGHT);
_local1.sDesc = "Move to any location on the field";
break;
case sSKILL_PROJECTILE :
_local1 = createSkillStats("Cum shot", 3, 0, _sSkill, nSKILL_TYPE_ACTIVE_ENEMY, nSKILL_RANGE_FIELD, nSKILL_EFFECT_DAMAGE);
_local1.sDesc = "Attack any banger on the field";
break;
case sSKILL_HEAL :
_local1 = createSkillStats("Recover", 7, 3, _sSkill, nSKILL_TYPE_ACTIVE_FRIEND, nSKILL_RANGE_ATTACK, nSKILL_EFFECT_HEAL);
_local1.sDesc = "Return 3 health to any other banger in your team";
break;
case sSKILL_MESSY :
_local1 = createSkillStats("Messy", 0, 1, _sSkill, nSKILL_TYPE_PASSIVE_DEATH, nSKILL_RANGE_FIXED, nSKILL_EFFECT_DAMAGE);
_local1.sDesc = "Deal damage around you when you die";
break;
case sSKILL_ECSTASY :
_local1 = createSkillStats("Fuzzy", 0, 5, _sSkill, nSKILL_TYPE_PASSIVE_DEATH, nSKILL_RANGE_NONE, nSKILL_EFFECT_HEAT);
_local1.sDesc = "Get 5 heat when you die";
break;
case sSKILL_DARK_SELF :
_local1 = createSkillStats("Shadow Self", 6, 2, _sSkill, nSKILL_TYPE_NONE, nSKILL_RANGE_CLOSE, nSKILL_EFFECT_CLONE);
_local1.sDesc = "Give half your life to a clone";
break;
case sSKILL_REVENGE :
_local1 = createSkillStats("Revenge", 0, 1, _sSkill, nSKILL_TYPE_PASSIVE_DEATH, nSKILL_RANGE_OPPONENT, nSKILL_EFFECT_DAMAGE);
_local1.sDesc = "Deal 1 damage on death.";
}
return(_local1);
}
static function createSkillStats(_sName, _nCost, _nValue, _sLinkage, _nType, _nTypeRange, _nEffect) {
var _local1 = new Object();
_local1.sName = _sName;
_local1.nCost = _nCost;
_local1.sLinkage = _sLinkage;
_local1.nType = _nType;
_local1.nTypeRange = _nTypeRange;
_local1.nValue = _nValue;
_local1.nEffect = _nEffect;
return(_local1);
}
static function getCharacter(_sChar) {
var _local1 = new Object();
switch (_sChar) {
case sCHAR_COITUS :
_local1 = createChar("Coitus", sCHAR_COITUS, "the goblin", "USA", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 1, 0.8, 0, 4, 4.2, 7, 10);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_NONE));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_ASH :
_local1 = createChar("Ash", sCHAR_ASH, "the werebear", "Canada", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 4, 0.8, 1, 6, 5.7, 5, 23);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_NONE));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_TYGRN :
_local1 = createChar("Tygrn", sCHAR_TYGRN, "the fuckromancer", "Russia", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 3, 0.8, 0, 4, 5.2, 5, 35);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_HEAL));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_KUNGFU :
_local1 = createChar("Kourin", sCHAR_KUNGFU, "the wolf", "Japan", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 2, 0.8, 1, 4, 5.1, 9.2, 32);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_NONE));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_GAU :
_local1 = createChar("Lamarr", sCHAR_GAU, "the elf", "New Zealand", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 2, 0.8, 1, 5, 3, 4, 30);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_PROJECTILE));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_BAHAMUT :
_local1 = createChar("Bahamut", sCHAR_BAHAMUT, "the dragon", "Lusty Labyrinth", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 3, 0.8, 2, 5, 6.6, 5, 42);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_TELEPORT));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_EWOK :
_local1 = createChar("Tackoo", sCHAR_EWOK, "the ursine", "Japan", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 1, 0.8, 1, 5, 2.9, 6, 18);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_ECSTASY));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case sCHAR_BERSERKER :
_local1 = createChar("Caesar", sCHAR_BERSERKER, "the orc", "Argentina", sATTACK_VANILLA_FUCK);
_local1 = createCharStats(_local1, 5, 0.8, 0, 4, 4.4, 4, 29);
_local1 = createCharSkills(_local1, 1, new Array(sSKILL_NONE));
_local1.aAttackFrame = new Array(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2);
_local1.aAttackDepth = new Array(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
return(_local1);
}
static function createChar(_sName, _sChar, _sSubName, _sCountry, _sAttackType) {
var _local1 = new Object();
_local1.sName = _sName;
_local1.sChar = _sChar;
_local1.sSubName = _sSubName;
_local1.sCountry = _sCountry;
_local1.sAttackType = _sAttackType;
return(_local1);
}
static function createCharStats(_oChar, _nAttack, _nAttackRange, _nDefense, _nHealth, _nMovement, _nInitiative, _nValue) {
_oChar.nAttack = _nAttack;
_oChar.nAttackRange = _nAttackRange;
_oChar.nDefense = _nDefense;
_oChar.nHealth = _nHealth;
_oChar.nMovement = _nMovement;
_oChar.nInitiative = _nInitiative;
_oChar.nValue = _nValue;
return(_oChar);
}
static function createCharSkills(_oChar, _nRessources, _aSkills) {
_oChar.nRessources = _nRessources;
_oChar.aSkills = _aSkills;
return(_oChar);
}
static function getItem(_sItem) {
var _local1 = new Object();
switch (_sItem) {
case sITEM_SMALL_HEALTH :
_local1 = createItemStats("Small potion", 2, 2, _sItem, nSKILL_TYPE_ACTIVE_SELF, nSKILL_RANGE_NONE, nSKILL_EFFECT_HEAL);
_local1.sDesc = "Gain back 2 health";
break;
case sITEM_LARGE_HEALTH :
_local1 = createItemStats("Large potion", 3, 4, _sItem, nSKILL_TYPE_ACTIVE_SELF, nSKILL_RANGE_NONE, nSKILL_EFFECT_HEAL);
_local1.sDesc = "Gain back 4 health";
break;
case sITEM_MOVEMENT :
_local1 = createItemStats("Adrenaline", 3, 0, _sItem, nSKILL_TYPE_ACTIVE_SELF, nSKILL_RANGE_NONE, nSKILL_EFFECT_MOVE);
_local1.sDesc = "Gain back move twice the distance this turn";
break;
case sITEM_ATTACK :
_local1 = createItemStats("Blue pill", 3, 2, _sItem, nSKILL_TYPE_ACTIVE_SELF, nSKILL_RANGE_NONE, nSKILL_EFFECT_HEAL);
_local1.sDesc = "Attack +2 for this turn";
break;
case sITEM_RANDOM_TELEPORT :
_local1 = createItemStats("Time fracture", 2, 0, _sItem, nSKILL_TYPE_ACTIVE_SELF, nSKILL_RANGE_FIELD, nSKILL_EFFECT_RANDOM_FLIGHT);
_local1.sDesc = "Move to a random location on the field";
break;
case sITEM_REVIVE :
_local1 = createItemStats("Morning wood", 8, 2, _sItem, nSKILL_TYPE_ACTIVE_DEAD_FRIEND, nSKILL_RANGE_ATTACK, nSKILL_EFFECT_REVIVE);
_local1.sDesc = "Raise a fallen companion";
break;
case sITEM_SMALL_HEAT :
_local1 = createItemStats("Porn magazine", 1, 3, _sItem, nSKILL_TYPE_NONE, nSKILL_RANGE_NONE, nSKILL_EFFECT_HEAT);
_local1.sDesc = "Gain 3 heat";
break;
case sITEM_LARGE_HEAT :
_local1 = createItemStats("Porn video", 2, 5, _sItem, nSKILL_TYPE_NONE, nSKILL_RANGE_NONE, nSKILL_EFFECT_HEAT);
_local1.sDesc = "Gain 5 heat";
}
return(_local1);
}
static function createItemStats(_sName, _nCost, _nValue, _sLinkage, _nType, _nTypeRange, _nEffect) {
var _local1 = new Object();
_local1.sName = _sName;
_local1.nCost = _nCost;
_local1.sLinkage = _sLinkage;
_local1.nType = _nType;
_local1.nTypeRange = _nTypeRange;
_local1.nValue = _nValue;
_local1.nEffect = _nEffect;
return(_local1);
}
static var sONLINE_CHARACTER = "c";
static var sONLINE_MOVEMENT = "m";
static var sONLINE_ATTACK = "a";
static var sONLINE_SKILL = "s";
static var sONLINE_END_TURN = "e";
static var sONLINE_END_CHARACTER = "x";
static var sLINKAGE_SPRITE = "mcSprite_";
static var sLINKAGE_BATTLE = "mcSprite_";
static var aCOLOR_PLAYERS = new Array("Red", "Blue");
static var aCOLOR_CODE_PLAYERS = new Array(16711680, 255);
static var sCHAR_COITUS = "Coitus";
static var sCHAR_ASH = "Ash";
static var sCHAR_TYGRN = "Tygrn";
static var sCHAR_KUNGFU = "KungFu";
static var sCHAR_GAU = "Gau";
static var sCHAR_BAHAMUT = "Bahamut";
static var sCHAR_EWOK = "Ewok";
static var sCHAR_BERSERKER = "Berserker";
static var sCHAR_SOWK = "Sowk";
static var sATTACK_VANILLA_FUCK = "VanillaFuck";
static var sSKILL_NONE = "None";
static var sSKILL_TELEPORT = "Teleport";
static var sSKILL_PROJECTILE = "Projectile";
static var sSKILL_HEAL = "Heal";
static var sSKILL_MESSY = "Messy";
static var sSKILL_RESILIANT = "Resiliant";
static var sSKILL_SACRIFICE = "Sacrifice";
static var sSKILL_CHARM = "Charm";
static var sSKILL_RAISE = "Raise";
static var sSKILL_ECSTASY = "Ecstasy";
static var sSKILL_DARK_SELF = "DarkSelf";
static var sSKILL_REVENGE = "Revenge";
static var sITEM_SMALL_HEALTH = "SmallHealth";
static var sITEM_LARGE_HEALTH = "LargeHealth";
static var sITEM_MOVEMENT = "Movement";
static var sITEM_ATTACK = "Attack";
static var sITEM_RANDOM_TELEPORT = "RandomTeleport";
static var sITEM_REVIVE = "Revive";
static var sITEM_SMALL_HEAT = "SmallHeat";
static var sITEM_LARGE_HEAT = "LargeHeat";
static var nSKILL_TYPE_NONE = 0;
static var nSKILL_TYPE_PASSIVE_DEATH = 10;
static var nSKILL_TYPE_ACTIVE_FIELD = 20;
static var nSKILL_TYPE_ACTIVE_ENEMY = 21;
static var nSKILL_TYPE_ACTIVE_FRIEND = 22;
static var nSKILL_TYPE_ACTIVE_SELF = 23;
static var nSKILL_TYPE_ACTIVE_DEAD_FRIEND = 24;
static var nSKILL_EFFECT_NONE = 0;
static var nSKILL_EFFECT_DAMAGE = 1;
static var nSKILL_EFFECT_HEAL = 2;
static var nSKILL_EFFECT_MOVE = 3;
static var nSKILL_EFFECT_FLIGHT = 4;
static var nSKILL_EFFECT_HEAT = 5;
static var nSKILL_EFFECT_RANDOM_FLIGHT = 6;
static var nSKILL_EFFECT_REVIVE = 7;
static var nSKILL_EFFECT_CLONE = 8;
static var nSKILL_RANGE_FIELD = 0;
static var nSKILL_RANGE_ATTACK = 1;
static var nSKILL_RANGE_FIXED = 2;
static var nSKILL_RANGE_NONE = 3;
static var nSKILL_RANGE_OPPONENT = 4;
static var nSKILL_RANGE_CLOSE = 5;
static var aLIST_CHARACTERS = new Array(sCHAR_COITUS, sCHAR_ASH, sCHAR_TYGRN, sCHAR_KUNGFU, sCHAR_GAU, sCHAR_BAHAMUT, sCHAR_EWOK, sCHAR_BERSERKER);
static var aLIST_ITEMS = new Array(sCHAR_COITUS, sCHAR_ASH, sCHAR_TYGRN, sCHAR_KUNGFU, sCHAR_GAU, sCHAR_BAHAMUT, sCHAR_EWOK, sCHAR_BERSERKER);
}
Symbol 493 MovieClip [__Packages.battlefield.Character] Frame 0
class battlefield.Character extends library.State
{
var setState, nMoveSpeedX, mcRef, nMoveSpeedY, nTargetX, nTargetY, aTarget, fEndFunction, isStateComplete, oBase, oChar, sName, sChar, sSubName, sCountry, nAttack, nAttackRange, nDefense, nHealth, nMaxHealth, nMovement, nInitiative, nValue;
function Character (_mcRef) {
super(_mcRef);
setState(sSTATE_IDLE);
}
function doMove() {
mcRef._x = mcRef._x + nMoveSpeedX;
mcRef._y = mcRef._y + nMoveSpeedY;
if (((((mcRef._x > nTargetX) && (nMoveSpeedX > 0)) || ((mcRef._x < nTargetX) && (nMoveSpeedX < 0))) || ((mcRef._y > nTargetY) && (nMoveSpeedY > 0))) || ((mcRef._y < nTargetY) && (nMoveSpeedY < 0))) {
setPos(nTargetX, nTargetY);
aTarget.shift();
if (aTarget.length == 0) {
fEndFunction();
setState(sSTATE_IDLE);
}
} else {
setPos(mcRef._x, mcRef._y);
}
}
function doFlyingIn() {
if (isStateComplete()) {
setPos(nTargetX, nTargetY);
setState(sSTATE_FLYING_OUT);
}
}
function doFlyingOut() {
if (isStateComplete()) {
fEndFunction();
setState(sSTATE_IDLE);
}
}
function setPos(_nX, _nY) {
mcRef._x = _nX;
mcRef._y = _nY;
oBase.setCharPos(mcRef._x, mcRef._y);
}
function load(_oChar) {
oChar = _oChar;
sName = _oChar.sName;
sChar = _oChar.sChar;
sSubName = _oChar.sSubName;
sCountry = _oChar.sCountry;
nAttack = _oChar.nAttack;
nAttackRange = _oChar.nAttackRange;
nDefense = _oChar.nDefense;
nHealth = _oChar.nHealth;
nMaxHealth = _oChar.nHealth;
nMovement = _oChar.nMovement;
nInitiative = _oChar.nInitiative;
nValue = _oChar.nValue;
}
function setMouseClick(_fClick, _fRollOver, _fRollOut) {
mcRef.onPress = _fClick;
mcRef.onRollOver = _fRollOver;
mcRef.onRollOut = _fRollOut;
}
function setPlace(_fSetActive, _fEndPlace) {
mcRef.onPress = library.Delegate.create(this, startPlace, _fSetActive);
mcRef.onRelease = library.Delegate.create(this, endPlace, mcRef._x, mcRef._y, _fSetActive, _fEndPlace);
mcRef.onReleaseOutside = library.Delegate.create(this, endPlace, mcRef._x, mcRef._y, _fSetActive, _fEndPlace);
}
function startPlace(_fSetActive) {
_fSetActive();
mcRef.startDrag(false);
}
function endPlace(_nX, _nY, _fSetActive, _fEndPlace) {
mcRef.stopDrag();
var _local2 = _fEndPlace();
if (_local2) {
setPos(_nX, _nY);
} else {
oBase.setCharPos(mcRef._x, mcRef._y);
}
setPlace(_fSetActive, _fEndPlace);
}
function setMove(_aTarget, _fEndMove, _bFlyTo) {
var _local2 = true;
if (_local2) {
aTarget = _aTarget;
move(aTarget[0].x, aTarget[0].y);
if (_bFlyTo) {
setState(sSTATE_FLYING_IN);
} else {
setState(sSTATE_MOVE);
}
fEndFunction = _fEndMove;
}
return(_local2);
}
function move(_nX, _nY) {
nTargetX = _nX;
nTargetY = _nY;
var _local3 = Math.abs(_nX - mcRef._x) / (Math.abs(_nX - mcRef._x) + Math.abs(_nY - mcRef._Y));
nMoveSpeedX = (nMOVE_SPEED * _local3) * ((_nX - mcRef._x) / Math.abs(_nX - mcRef._x));
nMoveSpeedY = (nMOVE_SPEED * (1 - _local3)) * ((_nY - mcRef._Y) / Math.abs(_nY - mcRef._y));
}
function attack(_oCharObj, _nAttack, _bIgnoreDefense) {
var _local2 = new Object();
var _local3 = Math.max(1, _oCharObj.nAttack - nDefense);
nHealth = nHealth - _local3;
if (nHealth <= 0) {
setState(sSTATE_DEAD);
}
_local2.sChar = sChar;
_local2.damage = _local3;
_local2.health = nHealth;
data.Statistics.addStat(_oCharObj.sChar, data.Statistics.nSTAT_DAMAGE_DEALT, _local3);
data.Statistics.addStat(sChar, data.Statistics.nSTAT_DAMAGE_RECEIVED, _local3);
if (nHealth == 0) {
data.Statistics.addStat(sChar, data.Statistics.nSTAT_DEATH, 1);
data.Statistics.addStat(_oCharObj.sChar, data.Statistics.nSTAT_KILL, 1);
}
oBase.setHealth(nHealth);
return(_local2);
}
function heal(_oCharObj, _nHeal) {
var _local2 = new Object();
var _local3 = Math.min(_nHeal, nMaxHealth - nHealth);
nHealth = nHealth + _local3;
_local2.sChar = sChar;
_local2.damage = _local3;
_local2.health = nHealth;
oBase.setHealth(nHealth);
return(_local2);
}
function cleanDead(_oPoint, _nAttackRange, _fAttack) {
if (nHealth > 0) {
}
}
function setBase(_nPlayer) {
var _local2 = mcRef._parent._parent.mcCharacterBase.attachMovie(battlefield.character.CharacterBase.sLINKAGE, battlefield.character.CharacterBase.sLINKAGE + mcRef._parent._parent.mcCharacterBase.getNextHighestDepth(), mcRef._parent._parent.mcCharacterBase.getNextHighestDepth());
oBase = new battlefield.character.CharacterBase(_local2, _nPlayer);
oBase.setCharPos(mcRef._x, mcRef._y);
oBase.setHealth(nHealth);
}
function unsetPress() {
mcRef.onPress = undefined;
delete mcRef.onPress;
mcRef.onRelease = undefined;
delete mcRef.onRelease;
mcRef.onReleaseOutside = undefined;
delete mcRef.onReleaseOutside;
var _local3 = new flash.geom.ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
var _local2 = new flash.geom.Transform(mcRef);
_local2.colorTransform = _local3;
}
function get charObj() {
return(oChar);
}
function get attackrange() {
return(nAttackRange);
}
function get health() {
return(nHealth);
}
function get maxhealth() {
return(nMaxHealth);
}
function get linkage() {
return(sChar);
}
function get movement() {
return(nMovement);
}
function get initiative() {
return(nInitiative);
}
function get value() {
return(nValue);
}
static var nMOVE_SPEED = 17;
static var sSTATE_IDLE = "Idle";
static var sSTATE_MOVE = "Move";
static var sSTATE_DEAD = "Dead";
static var sSTATE_FLYING_IN = "FlyingIn";
static var sSTATE_FLYING_OUT = "FlyingOut";
static var sSTATE_SELECTED = "Selected";
}
Symbol 494 MovieClip [__Packages.battlefield.character.CharacterBase] Frame 0
class battlefield.character.CharacterBase
{
var mcRef;
function CharacterBase (_mcRef, _nPlayer) {
mcRef = _mcRef;
mcRef.gotoAndStop(data.DataCharacter.aCOLOR_PLAYERS[_nPlayer]);
}
function setHealth(_nHealth) {
if (_nHealth > 0) {
mcRef.mcHealth.gotoAndStop(_nHealth);
} else {
mcRef.removeMovieClip();
}
}
function setCharPos(_nX, _nY) {
mcRef._x = _nX;
mcRef._y = _nY + nOFFSET_Y;
}
static var nOFFSET_Y = 25;
static var sLINKAGE = "mcBase";
}
Symbol 495 MovieClip [__Packages.data.Statistics] Frame 0
class data.Statistics
{
static var aCHAR_STATISTICS;
function Statistics () {
}
static function init() {
aCHAR_STATISTICS = new Array();
var _local1;
var _local2;
_local2 = 0;
while (_local2 < data.DataCharacter.aLIST_CHARACTERS.length) {
_local1 = new Object();
_local1.sChar = data.DataCharacter.aLIST_CHARACTERS[_local2];
_local1.nKills = 0;
_local1.nDeaths = 0;
_local1.nDamageDealt = 0;
_local1.nDamageReceived = 0;
_local1.nVictories = 0;
_local1.nDefeats = 0;
aCHAR_STATISTICS.push(_local1);
_local2++;
}
}
static function load(_sStats) {
var _local4 = _sStats.split("&");
var _local2;
var _local3;
var _local1;
_local3 = 0;
while (_local3 < _local4.length) {
_local2 = _local4[_local3].split(";");
_local1 = 0;
while (_local1 < aCHAR_STATISTICS.length) {
if (aCHAR_STATISTICS[_local1].sChar == _local2[0]) {
aCHAR_STATISTICS[_local1].nKills = Number(_local2[1]);
aCHAR_STATISTICS[_local1].nDeaths = Number(_local2[2]);
aCHAR_STATISTICS[_local1].nDamageDealt = Number(_local2[3]);
aCHAR_STATISTICS[_local1].nDamageReceived = Number(_local2[4]);
aCHAR_STATISTICS[_local1].nVictories = Number(_local2[5]);
aCHAR_STATISTICS[_local1].nDefeats = Number(_local2[6]);
break;
}
_local1++;
}
_local3++;
}
}
static function save() {
var _local2 = "";
var _local1;
_local1 = 0;
while (_local1 < aCHAR_STATISTICS.length) {
_local2 = _local2 + (aCHAR_STATISTICS[_local1].sChar + ";");
_local2 = _local2 + (aCHAR_STATISTICS[_local1].nKills + ";");
_local2 = _local2 + (aCHAR_STATISTICS[_local1].nDeaths + ";");
_local2 = _local2 + (aCHAR_STATISTICS[_local1].nDamageDealt + ";");
_local2 = _local2 + (aCHAR_STATISTICS[_local1].nDamageReceived + ";");
_local2 = _local2 + (aCHAR_STATISTICS[_local1].nVictories + ";");
_local2 = _local2 + (aCHAR_STATISTICS[_local1].nDefeats + "&");
_local1++;
}
return(_local2);
}
static function addStat(_sChar, _nStat, _nValue) {
var _local1;
_local1 = 0;
while (_local1 < aCHAR_STATISTICS.length) {
if (aCHAR_STATISTICS[_local1].sChar == _sChar) {
switch (_nStat) {
case nSTAT_KILL :
aCHAR_STATISTICS[_local1].nKills = aCHAR_STATISTICS[_local1].nKills + Number(_nValue);
break;
case nSTAT_DEATH :
aCHAR_STATISTICS[_local1].nDeaths = aCHAR_STATISTICS[_local1].nDeaths + Number(_nValue);
break;
case nSTAT_DAMAGE_DEALT :
aCHAR_STATISTICS[_local1].nDamageDealt = aCHAR_STATISTICS[_local1].nDamageDealt + Number(_nValue);
break;
case nSTAT_DAMAGE_RECEIVED :
aCHAR_STATISTICS[_local1].nDamageReceived = aCHAR_STATISTICS[_local1].nDamageReceived + Number(_nValue);
break;
case nSTAT_VICTORIES :
aCHAR_STATISTICS[_local1].nVictories = aCHAR_STATISTICS[_local1].nVictories + Number(_nValue);
break;
case nSTAT_DEFEATS :
aCHAR_STATISTICS[_local1].nDefeats = aCHAR_STATISTICS[_local1].nDefeats + Number(_nValue);
}
break;
}
_local1++;
}
Main.Instance.saveStats();
}
static function getChar(_sChar) {
var _local2;
var _local1;
_local1 = 0;
while (_local1 < aCHAR_STATISTICS.length) {
if (aCHAR_STATISTICS[_local1].sChar == _sChar) {
_local2 = aCHAR_STATISTICS[_local1];
break;
}
_local1++;
}
return(_local2);
}
static var nSTAT_KILL = 0;
static var nSTAT_DEATH = 1;
static var nSTAT_DAMAGE_DEALT = 2;
static var nSTAT_DAMAGE_RECEIVED = 3;
static var nSTAT_VICTORIES = 4;
static var nSTAT_DEFEATS = 5;
}
Symbol 496 MovieClip [__Packages.Battlefield] Frame 0
class Battlefield extends library.State
{
var aPlayers, oField, mcRef, oHud, oBattleAnimaiton, oEndBattlefieldEffect, oPopupPlayerCode, oPopupMessage, aCharacterOrder, aEffects, bLock, sCharAttack, oOnlineManagement, setState, nCurrentTurn, sState, bUseSkill, nMovementRange, bAttack, bMovement;
function Battlefield (_mcRef) {
super(_mcRef);
}
function load(_aPlayers, _sField) {
aPlayers = _aPlayers;
oField = new battlefield.Field(mcRef, _sField);
oHud = new battlefield.Hud(mcRef.mcHud, mcRef.mcField, oField.__get__view(), _sField, library.Delegate.create(this, hudButton));
oHud.__set__clickMinimap(library.Delegate.create(oField, oField.clickMinimap, oHud));
oField.setViewingArea();
oBattleAnimaiton = new BattleAnimation(mcRef.mcBattleAnimation, BattleAnimation.nDEFAULT_ANIMATION_DURATION, library.Delegate.create(this, unlock));
oEndBattlefieldEffect = new battlefield.EndBattlefieldEffect(mcRef.mcEndBattlefield, library.Delegate.create(this, endBattlefieldEffect));
oPopupPlayerCode = new battlefield.PopupPlayerCode(mcRef.mcPopupPlayerCode, library.Delegate.create(this, validatePlayerCode));
oPopupMessage = new battlefield.PopupMessage(mcRef.mcPopupMessage, library.Delegate.create(this, unlock), library.Delegate.create(this, lock));
init();
}
function init() {
var _local3 = false;
aCharacterOrder = new Array();
aEffects = new Array();
bLock = false;
sCharAttack = "";
var _local2;
_local2 = 0;
while (_local2 < aPlayers.length) {
aCharacterOrder = aPlayers[_local2].loadBattlefield(_local2, this, aCharacterOrder, mcRef.mcField.mcField, mcRef.mcCharacter, mcRef.mcDraw, mcRef.mcDrawUpper);
_local3 = _local3 || (aPlayers[_local2].isOnline);
oHud.updateRessource(_local2, aPlayers[_local2].ressource, nMAX_RESSOURCE);
_local2++;
}
oOnlineManagement = new battlefield.OnlineManagement(_local3);
aCharacterOrder.reverse();
setState(sSTATE_PLACE_CHARACTERS);
}
function enterFrame() {
super.enterFrame();
oOnlineManagement.enterFrame();
oHud.enterFrame(aCharacterOrder);
oBattleAnimaiton.enterFrame();
oEndBattlefieldEffect.enterFrame();
oPopupPlayerCode.enterFrame();
oPopupMessage.enterFrame();
oField.enterFrame();
var _local3;
_local3 = 0;
while (_local3 < aPlayers.length) {
aPlayers[_local3].enterFrame();
_local3++;
}
_local3 = 0;
while (_local3 < aEffects.length) {
if (aEffects[_local3].enterFrame()) {
aEffects.splice(_local3, 1);
_local3--;
}
_local3++;
}
}
function startPlaceChar() {
if (aPlayers[0].isOnline) {
nCurrentTurn = 1;
} else {
nCurrentTurn = 0;
}
setPlaceCharacter();
}
function startPlayChar() {
nCurrentTurn = 0;
oField.startPlayChar();
setPlayCharacter();
}
function addCharacter(_nPlayer, _nChar, _oCharacter) {
oHud.addCharacter(_nPlayer, _nChar, _oCharacter.__get__charObj());
return(oField.addCharacter(_nPlayer, _oCharacter.__get__linkage()));
}
function tryCollideMovement(_mcRef, _oTarget, _bFlying) {
return(oField.tryCollideMovement(_mcRef, _oTarget, _bFlying));
}
function mouseMove() {
switch (sState) {
case sSTATE_PLACE_CHARACTERS :
break;
case sSTATE_PLAY_CHARACTER :
oHud.removeMouseOver();
oField.mouseOutChar();
var _local2;
var _local3;
_local3 = 0;
for(;;){
if (_local3 >= aPlayers.length) {
break;
}
_local2 = aPlayers[_local3].mouseOverCharacter();
if ((_local2 != null) && (_local2.mc != aCharacterOrder[nCurrentTurn].mc)) {
oHud.setMouseOver(_local3, _local2.nChar);
oField.drawCharacterZones(_local2.nAttackRange, _local2.nMovement, true, true, _local2.mc, false);
break;
}
_local3++;
};
}
}
function useSkill() {
oField.clearAttackable(aCharacterOrder);
var _local2 = 0;
var _local4 = 0;
var _local3 = data.DataCharacter.getSkill(aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).aSkills[0]);
aCharacterOrder[nCurrentTurn].mc.onPress = library.Delegate.create(this, useSkill);
if (Math.floor(_local3.nType / 10) == Math.floor(data.DataCharacter.nSKILL_TYPE_ACTIVE_FIELD / 10)) {
if (aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].ressource >= _local3.nCost) {
bUseSkill = !bUseSkill;
if (bUseSkill) {
switch (_local3.nTypeRange) {
case data.DataCharacter.nSKILL_RANGE_ATTACK :
_local2 = (nMovementRange + aCharacterOrder[nCurrentTurn].nAttackRange) * data.DataFields.nTILE_SIZE;
break;
case data.DataCharacter.nSKILL_RANGE_FIELD :
_local2 = 100000 /* 0x0186A0 */;
}
oField.setSkillable(aCharacterOrder, nCurrentTurn, _local3, _local2 + _local4, library.Delegate.create(this, attackChar, ""));
}
} else {
oPopupMessage.displayText("Not enough heat meter.", 3);
}
}
oHud.selectSkill(bUseSkill);
oField.setUseSkill(aCharacterOrder, nCurrentTurn, bUseSkill);
if (!bUseSkill) {
oField.drawCharacterZones(aCharacterOrder[nCurrentTurn].nAttackRange, nMovementRange, bAttack, nMovementRange > 0, aCharacterOrder[nCurrentTurn].mc, true);
if (bAttack) {
oField.setAttackable(aCharacterOrder, nCurrentTurn, nMovementRange, library.Delegate.create(this, attackChar, ""));
}
} else {
oField.drawSkillsZones(_local4, _local2, aCharacterOrder[nCurrentTurn].mc);
}
}
function attackChar(_sChar) {
var _local11 = false;
var _local12 = true;
var _local10 = sCOLOR_RED;
var _local4 = data.DataCharacter.getSkill(aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).aSkills[0]);
var _local3 = (aCharacterOrder[nCurrentTurn].nPlayer + 1) % 2;
var _local6 = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar);
var _local5 = aPlayers[_local3].mouseOverCharacter();
var _local13 = _local6.nAttackRange + 0.4;
var _local2 = new Object();
_local2.nResult = battlefield.Field.nATTACK_CANT;
if (bUseSkill) {
if ((_local5 == null) && (_local4.nType == data.DataCharacter.nSKILL_TYPE_ACTIVE_FRIEND)) {
_local5 = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].mouseOverCharacter();
}
_local12 = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].ressource >= _local4.nCost;
if (!(_local4.nTypeRange === data.DataCharacter.nSKILL_RANGE_FIELD)) {
} else {
_local13 = 100000 /* 0x0186A0 */;
_local2.nResult = battlefield.Field.nATTACK_DONT_MOVE;
_local11 = true;
}
}
if (_local12 && (!_local11)) {
_local2 = oField.moveToAttack(aCharacterOrder[nCurrentTurn].mc, _local5.mc, _local13, nMovementRange);
}
if (_local2.nResult == battlefield.Field.nATTACK_DONT_MOVE) {
var _local7 = _local6.nAttack;
if (bUseSkill) {
switch (_local4.nEffect) {
case data.DataCharacter.nSKILL_EFFECT_DAMAGE :
if (_local4.nValue > 0) {
_local7 = _local4.nValue;
}
_local2 = aPlayers[_local3].attackChar(_local6, _sChar, _local7, false, battlefield.BattlefieldPlayer.nTYPE_ATTACK);
break;
case data.DataCharacter.nSKILL_EFFECT_HEAL :
_local7 = _local4.nValue;
_local2 = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].attackChar(_local6, _sChar, _local7, false, battlefield.BattlefieldPlayer.nTYPE_HEAL);
_local10 = sCOLOR_BLUE;
}
} else {
_local2 = aPlayers[_local3].attackChar(_local6, _sChar, _local7, false, battlefield.BattlefieldPlayer.nTYPE_ATTACK);
}
if (_local2 != null) {
oHud.updateHealth(_local3, _local2);
if (oOnlineManagement.__get__isOnline() && (!aPlayers[aCharacterOrder[_nCpt].nPlayer].isOnline)) {
if (bUseSkill) {
oOnlineManagement.addCommand(data.DataCharacter.sONLINE_SKILL, _local2.sChar);
} else {
oOnlineManagement.addCommand(data.DataCharacter.sONLINE_ATTACK, _local2.sChar);
}
}
if (_local2.health <= 0) {
var _local8 = data.DataCharacter.getSkill(_local5.aSkills[0]);
if (_local8.nType == data.DataCharacter.nSKILL_TYPE_PASSIVE_DEATH) {
switch (_local8.nEffect) {
case data.DataCharacter.nSKILL_EFFECT_HEAT :
aPlayers[_local3].changeRessource(_local8.nValue);
oHud.updateRessource(_local3, aPlayers[_local3].ressource, nMAX_RESSOURCE);
break;
case data.DataCharacter.nSKILL_EFFECT_DAMAGE :
}
}
var _nCpt;
_nCpt = 0;
while (_nCpt < aCharacterOrder.length) {
if ((aCharacterOrder[_nCpt].nPlayer == _local3) && (aCharacterOrder[_nCpt].nChar == _local2.char)) {
aCharacterOrder.splice(_nCpt, 1);
if (_nCpt < nCurrentTurn) {
nCurrentTurn--;
}
_nCpt--;
}
_nCpt++;
}
}
lock();
if (bUseSkill) {
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].changeRessource(-_local4.nCost);
oHud.updateRessource(aCharacterOrder[nCurrentTurn].nPlayer, aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].ressource, nMAX_RESSOURCE);
} else {
bAttack = false;
}
var _local9 = new Object();
_local9.x = _local5.mc._x;
_local9.y = _local5.mc._y;
oBattleAnimaiton.__set__endAnimation(library.Delegate.create(this, displayFadeOutText, _local2.damage, _local10, _local9, library.Delegate.create(this, unlock)));
oBattleAnimaiton.setAttack(_local6, _local2);
sCharAttack = "";
}
} else if (_local2.nResult == battlefield.Field.nATTACK_MOVE) {
sCharAttack = _local5.sChar;
moveOnField(_local2);
} else {
sCharAttack = "";
}
}
function clickField() {
if (!bLock) {
switch (sState) {
case sSTATE_PLACE_CHARACTERS :
break;
case sSTATE_PLAY_CHARACTER :
var _local5 = data.DataCharacter.getSkill(aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).aSkills[0]);
if (!((bMovement && (!bUseSkill)) || (bUseSkill && (_local5.nType == data.DataCharacter.nSKILL_TYPE_ACTIVE_FIELD)))) {
break;
}
var _local3 = true;
var _local2;
_local2 = 0;
while (_local2 < aPlayers.length) {
_local3 = _local3 && (aPlayers[_local2].mouseOverCharacter() == null);
_local2++;
}
if (!_local3) {
break;
}
var _local4 = new Object();
_local4.x = mcRef.mcCharacter._xmouse;
_local4.y = mcRef.mcCharacter._ymouse;
if (bUseSkill) {
switch (_local5.nEffect) {
case data.DataCharacter.nSKILL_EFFECT_MOVE :
case data.DataCharacter.nSKILL_EFFECT_FLIGHT :
moveOnField(_local4);
}
} else {
moveOnField(_local4);
}
}
}
}
function moveOnField(_oPoint) {
var _local3 = false;
var _local6 = false;
var _local2 = data.DataCharacter.getSkill(aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).aSkills[0]);
if (bUseSkill) {
_local6 = (_local2.nEffect == data.DataCharacter.nSKILL_EFFECT_FLIGHT) || (_local2.nEffect == data.DataCharacter.nSKILL_EFFECT_RANDOM_FLIGHT);
}
var _local8 = oField.tryCollideMovement(aCharacterOrder[nCurrentTurn].mc, _oPoint, _local6);
if (!_local8.bCollide) {
var _local7 = true;
var _local9 = oField.getMovement(aCharacterOrder[nCurrentTurn].mc, _oPoint);
if (!battlefield.Field.bTILE_BASED) {
var _local4 = nMovementRange * data.DataFields.nTILE_SIZE;
var _local10 = library.MyMath.lineSize(aCharacterOrder[nCurrentTurn].mc._x, aCharacterOrder[nCurrentTurn].mc._y, _local9[0].x, _local9[0].y);
if (bUseSkill) {
if (_local2.nType == data.DataCharacter.nSKILL_TYPE_ACTIVE_FIELD) {
_local3 = true;
switch (_local2.nTypeRange) {
case data.DataCharacter.nSKILL_RANGE_FIELD :
_local4 = 100000 /* 0x0186A0 */;
break;
case data.DataCharacter.nSKILL_RANGE_ATTACK :
_local4 = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).nMovement * data.DataFields.nTILE_SIZE;
break;
case data.DataCharacter.nSKILL_RANGE_FIXED :
_local4 = _local2.nValue * data.DataFields.nTILE_SIZE;
}
}
}
if (_local10 <= _local4) {
if (!_local3) {
nMovementRange = nMovementRange - (Math.floor((_local10 / data.DataFields.nTILE_SIZE) * 10) / 10);
if (nMovementRange < 1) {
nMovementRange = 0;
bMovement = false;
}
}
_local7 = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].moveCharacter(aCharacterOrder[nCurrentTurn].nChar, _local9, library.Delegate.create(this, unlock), _local6);
} else {
_local7 = false;
}
}
if (_local7) {
lock();
bMovement = bMovement && (_local3 || (bSINGLE_RANGE));
if (_local3) {
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].changeRessource(-_local2.nCost);
oHud.updateRessource(aCharacterOrder[nCurrentTurn].nPlayer, aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].ressource, nMAX_RESSOURCE);
}
if (oOnlineManagement.__get__isOnline()) {
if (_local3) {
oOnlineManagement.addCommand(data.DataCharacter.sONLINE_SKILL, (_oPoint.x + ":") + _oPoint.y);
} else {
oOnlineManagement.addCommand(data.DataCharacter.sONLINE_MOVEMENT, (_oPoint.x + ":") + _oPoint.y);
}
}
}
} else {
oField.displayCollision(aCharacterOrder[nCurrentTurn].sChar, _local8.x, _local8.y);
}
}
function hudButton() {
switch (sState) {
case sSTATE_PLACE_CHARACTERS :
nextTurn();
break;
case sSTATE_PLAY_CHARACTER :
if (bLock) {
break;
}
lock();
if (oOnlineManagement.__get__isOnline()) {
oOnlineManagement.addCommand(data.DataCharacter.sONLINE_END_TURN, "");
}
updateRessourceEndTurn();
if (!aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].isOnline) {
nextTurn();
} else {
oPopupPlayerCode.startTransition(oOnlineManagement.__get__selfOnlineCode(), true);
}
}
}
function updateRessourceEndTurn() {
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].changeRessource(aCharacterOrder[nCurrentTurn].nRessources);
oHud.updateRessource(aCharacterOrder[nCurrentTurn].nPlayer, aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].ressource, nMAX_RESSOURCE);
}
function setPlaceCharacter() {
aPlayers[nCurrentTurn].setPlaceCharacters(library.Delegate.create(oField, oField.placeCharacter, nCurrentTurn, aPlayers[nCurrentTurn]), library.Delegate.create(this, hudButton));
}
function setPlayCharacter() {
mcRef.onMouseMove = library.Delegate.create(this, mouseMove);
oHud.nextTurn(aCharacterOrder[nCurrentTurn].nPlayer, aCharacterOrder[nCurrentTurn].nChar, nCurrentTurn, aCharacterOrder);
if ((!oOnlineManagement.__get__isOnline()) || (!aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].isOnline)) {
bAttack = true;
bMovement = true;
nMovementRange = aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).nMovement;
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].setAITurn();
unlock();
} else if (!oOnlineManagement.__get__otherCodeRemaining()) {
oPopupPlayerCode.startTransition(oOnlineManagement.__get__selfOnlineCode(), true);
}
}
function startWait() {
}
function endWait() {
}
function nextTurn() {
nCurrentTurn++;
switch (sState) {
case sSTATE_PLACE_CHARACTERS :
aPlayers[nCurrentTurn - 1].resetMouseCharacters();
if (oOnlineManagement.__get__isOnline()) {
oOnlineManagement.addCommand(aPlayers[nCurrentTurn - 1].onlineCodePosition, "");
oPopupPlayerCode.startTransition(oOnlineManagement.__get__selfOnlineCode(), false);
} else if (nCurrentTurn >= aPlayers.length) {
setState(sSTATE_PLAY_CHARACTER);
} else {
setPlaceCharacter();
}
break;
case sSTATE_PLAY_CHARACTER :
var _local2;
var _local3 = false;
_local2 = 0;
while (_local2 < aPlayers.length) {
aPlayers[_local2].resetMouseCharacters();
_local2++;
}
_local3 = oOnlineManagement.__get__isOnline() && (aPlayers[aCharacterOrder[nCurrentTurn - 1].nPlayer].isOnline);
if (nCurrentTurn >= aCharacterOrder.length) {
nCurrentTurn = 0;
}
setPlayCharacter();
}
}
function lock() {
bLock = true;
oField.clearDrawZones();
oField.setUseSkill(aCharacterOrder, nCurrentTurn, false);
oHud.lock();
oField.clearAttackable(aCharacterOrder);
}
function unlock() {
if (playerDeath()) {
if (oOnlineManagement.__get__isOnline() && (aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].isOnline)) {
oOnlineManagement.setWait(library.Delegate.create(this, readNextOnlineCode));
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].drawCharacterZones(aCharacterOrder[nCurrentTurn].nChar, mcRef.mcDrawUpper, false, false, true);
} else if (sCharAttack != "") {
attackChar(sCharAttack);
} else {
bLock = false;
bUseSkill = false;
oHud.selectSkill(false);
if (!aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].isAI) {
if (bAttack) {
oField.setAttackable(aCharacterOrder, nCurrentTurn, nMovementRange, library.Delegate.create(this, attackChar, ""));
}
oField.drawCharacterZones(aCharacterOrder[nCurrentTurn].nAttackRange, nMovementRange, bAttack, nMovementRange > 0, aCharacterOrder[nCurrentTurn].mc, true);
aCharacterOrder[nCurrentTurn].mc.onPress = library.Delegate.create(this, useSkill);
oField.setClickField(library.Delegate.create(this, clickField));
oHud.unlock();
} else {
var _local2 = aPlayers[(aCharacterOrder[nCurrentTurn].nPlayer + 1) % 2].getAliveCharacters();
oHud.lock();
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].nextAIAction(oField, _local2, this, aCharacterOrder[nCurrentTurn].nPlayer, aCharacterOrder[nCurrentTurn].nChar, nMovementRange, library.Delegate.create(this, hudButton));
}
}
} else {
if (aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].isAI || (aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].isOnline)) {
oEndBattlefieldEffect.setLose();
} else {
oEndBattlefieldEffect.setWin();
}
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].setVictory(true);
aPlayers[(aCharacterOrder[nCurrentTurn].nPlayer + 1) % 2].setVictory(false);
oHud.lock();
}
}
function validatePlayerCode() {
var _local2 = oOnlineManagement.validatePlayerCode(oPopupPlayerCode.__get__playerCode());
if (_local2) {
oPopupPlayerCode.__set__outFunction(library.Delegate.create(this, readNextOnlineCode));
}
return(_local2);
}
function readNextOnlineCode() {
var _local2 = oOnlineManagement.getNextCommand();
bUseSkill = false;
switch (_local2.sCmd) {
case data.DataCharacter.sONLINE_ATTACK :
if (sState == sSTATE_PLAY_CHARACTER) {
attackChar(_local2.aCode[0]);
}
break;
case data.DataCharacter.sONLINE_MOVEMENT :
if (sState == sSTATE_PLAY_CHARACTER) {
var _local6 = new Array();
var _local5 = new Object();
_local5.x = _local2.aCode[0];
_local5.y = _local2.aCode[1];
_local6.push(_local5);
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].moveCharacter(aCharacterOrder[nCurrentTurn].nChar, _local6, library.Delegate.create(oOnlineManagement, oOnlineManagement.setWait, library.Delegate.create(this, readNextOnlineCode)), false);
}
break;
case data.DataCharacter.sONLINE_END_TURN :
if (sState == sSTATE_PLAY_CHARACTER) {
updateRessourceEndTurn();
if (oOnlineManagement.__get__otherCodeRemaining()) {
nCurrentTurn++;
if (nCurrentTurn >= aCharacterOrder.length) {
nCurrentTurn = 0;
}
oHud.setSelected(aCharacterOrder[nCurrentTurn].nPlayer, aCharacterOrder[nCurrentTurn].nChar);
oOnlineManagement.setWait(library.Delegate.create(this, readNextOnlineCode));
readNextOnlineCode();
} else {
oOnlineManagement.resetSelf();
nextTurn();
}
}
break;
case data.DataCharacter.sONLINE_CHARACTER :
if (sState == sSTATE_PLACE_CHARACTERS) {
var _local4 = 0;
if (aPlayers[1].isOnline) {
_local4 = 1;
}
aCharacterOrder = aPlayers[_local4].addCharacterOnline(_local4, this, aCharacterOrder, data.DataCharacter.getCharacter(data.DataCharacter.aLIST_CHARACTERS[_local2.aCode[0]]), _local2.aCode[1], _local2.aCode[2]);
if (oOnlineManagement.__get__otherCodeRemaining()) {
readNextOnlineCode();
} else {
setState(sSTATE_PLAY_CHARACTER);
}
} else if (oOnlineManagement.__get__otherCodeRemaining()) {
oOnlineManagement.setWait(library.Delegate.create(this, readNextOnlineCode));
} else {
oPopupPlayerCode.startTransition(oOnlineManagement.__get__selfOnlineCode(), false);
}
break;
case data.DataCharacter.sONLINE_END_CHARACTER :
setState(sSTATE_PLAY_CHARACTER);
if (oOnlineManagement.__get__otherCodeRemaining()) {
oOnlineManagement.setWait(library.Delegate.create(this, readNextOnlineCode));
}
break;
case data.DataCharacter.sONLINE_SKILL :
if (sState != sSTATE_PLAY_CHARACTER) {
break;
}
bUseSkill = true;
var _local3 = data.DataCharacter.getSkill(aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].getCharacterObj(aCharacterOrder[nCurrentTurn].nChar).aSkills[0]);
switch (_local3.nEffect) {
case data.DataCharacter.nSKILL_EFFECT_DAMAGE :
case data.DataCharacter.nSKILL_EFFECT_HEAL :
attackChar(_local2.aCode[0]);
break;
case data.DataCharacter.nSKILL_EFFECT_MOVE :
case data.DataCharacter.nSKILL_EFFECT_FLIGHT :
case data.DataCharacter.nSKILL_EFFECT_RANDOM_FLIGHT :
var _local6 = new Array();
var _local5 = new Object();
var _local7 = (_local3.nEffect == data.DataCharacter.nSKILL_EFFECT_FLIGHT) || (_local3.nEffect == data.DataCharacter.nSKILL_EFFECT_RANDOM_FLIGHT);
_local5.x = _local2.aCode[0];
_local5.y = _local2.aCode[1];
_local6.push(_local5);
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].moveCharacter(aCharacterOrder[nCurrentTurn].nChar, _local6, library.Delegate.create(oOnlineManagement, oOnlineManagement.setWait, library.Delegate.create(this, readNextOnlineCode)), _local7);
break;
case data.DataCharacter.nSKILL_EFFECT_HEAT :
aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].changeRessource(_local3.nValue);
oHud.updateRessource(aCharacterOrder[nCurrentTurn].nPlayer, aPlayers[aCharacterOrder[nCurrentTurn].nPlayer].ressource, nMAX_RESSOURCE);
break;
case data.DataCharacter.nSKILL_EFFECT_REVIVE :
break;
case data.DataCharacter.nSKILL_EFFECT_CLONE :
}
}
}
function playerDeath() {
var _local3 = false;
var _local2;
_local2 = 0;
while (_local2 < aCharacterOrder.length) {
if (aCharacterOrder[_local2].nPlayer != aCharacterOrder[nCurrentTurn].nPlayer) {
_local3 = true;
break;
}
_local2++;
}
return(_local3);
}
function displayFadeOutText(_sText, _sState, _oPoint, _fNext) {
var _local3 = mcRef.mcCharacter.getNextHighestDepth();
var _local2 = mcRef.mcCharacter.attachMovie(sLINKAGE_FADEOUT_TEXT, sLINKAGE_FADEOUT_TEXT + _local3, _local3);
_local2.gotoAndStop(_sState);
switch (_sState) {
case sCOLOR_RED :
_local2.mcState.mcState.txtText.textColor = 16711680 /* 0xFF0000 */;
break;
case sCOLOR_BLUE :
_local2.mcState.mcState.txtText.textColor = 255;
break;
case sCOLOR_WHITE :
_local2.mcState.mcState.txtText.textColor = 16777215 /* 0xFFFFFF */;
}
_local2.mcState.mcState.txtText.text = _sText;
_local2._x = _oPoint.x;
_local2._y = _oPoint.y;
aEffects.push(new library.Effect(_local2, true));
if (_fNext != null) {
_fNext();
}
}
function endBattlefieldEffect() {
Main.Instance.setState(Main.sSTATE_TITLE);
}
static var sLINKAGE_FADEOUT_TEXT = "mcEffect_FadeOutText";
static var sCOLOR_RED = "Red";
static var sCOLOR_BLUE = "Blue";
static var sCOLOR_WHITE = "White";
static var nSTART_RESSOURCE = 5;
static var nMAX_RESSOURCE = 20;
static var bSINGLE_RANGE = true;
var sSTATE_PLACE_CHARACTERS = "PlaceChar";
var sSTATE_PLAY_CHARACTER = "PlayChar";
var sSTATE_END_GAME = "EndGame";
}
Symbol 497 MovieClip [__Packages.battlefield.Hud] Frame 0
class battlefield.Hud
{
var mcRef, aCharacter, oHudCharacter, oMinimap, btnComplete, __get__clickMinimap;
function Hud (_mcRef, _mcField, _rectView, _sField, _fComplete) {
mcRef = _mcRef;
aCharacter = new Array();
aCharacter[0] = new Array();
aCharacter[1] = new Array();
oHudCharacter = new battlefield.hud.HudCharacter(mcRef.mcCharacter);
oMinimap = new battlefield.hud.Minimap(mcRef.mcMinimap, _rectView, _mcField, _sField);
btnComplete = new library.MCButton(mcRef.btnComplete, _fComplete);
}
function enterFrame(_aCharacterOrder) {
btnComplete.enterFrame();
oMinimap.enterFrame(_aCharacterOrder);
}
function addCharacter(_nPlayer, _nChar, _oChar) {
oHudCharacter.addChar(_nPlayer, _nChar, _oChar);
}
function setSelected(_nPlayer, _nChar) {
oHudCharacter.setChar(true, _nPlayer, _nChar);
}
function setMouseOver(_nPlayer, _nChar) {
oHudCharacter.setChar(false, _nPlayer, _nChar);
}
function removeMouseOver() {
oHudCharacter.resetChar();
}
function nextTurn(_nPlayer, _nChar, _nStartPos, _aCharacterOrder) {
oHudCharacter.setChar(true, _nPlayer, _nChar);
displayTurnOrder(_nStartPos, _aCharacterOrder);
}
function updateHealth(_nPlayer, _oResult) {
oHudCharacter.updateChar(_nPlayer, _oResult.char, _oResult.health);
}
function updateRessource(_nPlayer, _nRessource, _nRessourceMax) {
mcRef["mcLustGauge" + (_nPlayer + 1)].gotoAndStop(_nRessource + 1);
mcRef["mcLustGauge" + (_nPlayer + 1)].txtRessource.text = (_nRessource + " / ") + _nRessourceMax;
}
function displayTurnOrder(_nStartPos, _aCharacterOrder) {
var _local7;
for (_local7 in mcRef.mcOrder) {
mcRef.mcOrder[_local7].removeMovieClip();
}
var _local2;
var _local6;
var _local5 = 0;
var _local3 = (_nStartPos + 1) % _aCharacterOrder.length;
do {
_local2 = mcRef.mcOrder.attachMovie(sLINKAGE_CHARBACK, sLINKAGE_CHARBACK + mcRef.mcOrder.getNextHighestDepth(), mcRef.mcOrder.getNextHighestDepth());
_local2._x = (_local2._width + nSPACING) * _local5;
_local2.gotoAndStop(data.DataCharacter.aCOLOR_PLAYERS[_aCharacterOrder[_local3].nPlayer]);
_local6 = _local2.attachMovie(data.DataCharacter.sLINKAGE_SPRITE + _aCharacterOrder[_local3].sChar, data.DataCharacter.sLINKAGE_SPRITE, _local2.getNextHighestDepth());
_local6._x = 25;
_local6._y = 25;
_local6.gotoAndStop(1);
_local6.mcState.gotoAndStop(1);
_local3++;
if (_local3 >= _aCharacterOrder.length) {
_local3 = 0;
}
_local5++;
if ((_local5 >= nMAX_REMAINING) && ((_local5 + 1) < _aCharacterOrder.length)) {
_local2 = mcRef.mcOrder.attachMovie(sLINKAGE_CHARBACK, sLINKAGE_CHARBACK + mcRef.mcOrder.getNextHighestDepth(), mcRef.mcOrder.getNextHighestDepth());
_local2._x = (_local2._width + nSPACING) * _local5;
_local2.gotoAndStop(nSTATE_OTHER);
_local2.txtText.text = (_aCharacterOrder.length - nMAX_REMAINING) - 1;
break;
}
} while (_local3 != _nStartPos);
oHudCharacter.setChar(true, _aCharacterOrder[_nStartPos].nPlayer, _aCharacterOrder[_nStartPos].nChar);
}
function selectSkill(_bSelect) {
oHudCharacter.selectSkill(_bSelect);
}
function lock() {
btnComplete.__get__Mc()._visible = false;
}
function unlock() {
btnComplete.__get__Mc()._visible = true;
}
function get minimapMoveTo() {
return(oMinimap.__get__moveTo());
}
function set clickMinimap(_fMinimapClick) {
oMinimap.__set__clickMinimap(_fMinimapClick);
//return(__get__clickMinimap());
}
static var sLINKAGE_CHARBACK = "mcHud_CharBack";
var nSPACING = 7;
var nMAX_REMAINING = 8;
static var nSTATE_OTHER = "Other";
}
Symbol 498 MovieClip [__Packages.battlefield.hud.HudCharacter] Frame 0
class battlefield.hud.HudCharacter
{
var mcRef, aCharacters, nPlayer, nChar;
function HudCharacter (_mcRef) {
mcRef = _mcRef;
mcRef.mcRingColor.gotoAndStop(sDEFAULT_COLOR);
mcRef.mcChar.gotoAndStop(sDEFAULT_IMAGE);
mcRef.mcSkill.gotoAndStop(sDEFAULT_IMAGE);
mcRef.mcSkillSelected._visible = false;
aCharacters = new Array();
}
function addChar(_nPlayer, _nChar, _oCharObj) {
var _local2 = new Object();
_local2.nCpt = aCharacters.length;
_local2.nPlayer = _nPlayer;
_local2.nChar = _nChar;
_local2.oChar = _oCharObj;
_local2.bSelected = false;
aCharacters.push(_local2);
}
function updateChar(_nPlayer, _nChar, _nHealth) {
var _local2 = getCharacter(_nPlayer, _nChar);
_local2.nHealth = _nHealth;
}
function setChar(_bCurrent, _nPlayer, _nChar) {
if (_bCurrent) {
nPlayer = _nPlayer;
nChar = _nChar;
}
var _local2 = getCharacter(_nPlayer, _nChar);
mcRef.txtAttack.text = _local2.nAttack;
mcRef.txtDefense.text = _local2.nDefense;
mcRef.txtName.text = _local2.sName;
mcRef.mcRingColor.gotoAndStop(data.DataCharacter.aCOLOR_PLAYERS[_nPlayer]);
mcRef.mcHealth.txtHealth.text = _local2.nHealth;
mcRef.mcChar.gotoAndStop(_local2.sChar);
mcRef.mcSkill.gotoAndStop(_local2.aSkills[0]);
mcRef.mcSkillSelected._visible = false;
}
function selectSkill(_bSelect) {
var _local2 = getCharacter(nPlayer, nChar);
mcRef.mcSkillSelected._visible = _bSelect;
_local2.bSelected = _bSelect;
}
function resetChar() {
var _local2 = getCharacter(nPlayer, nChar);
mcRef.txtAttack.text = _local2.nAttack;
mcRef.txtDefense.text = _local2.nDefense;
mcRef.txtName.text = _local2.sName;
mcRef.mcRingColor.gotoAndStop(data.DataCharacter.aCOLOR_PLAYERS[nPlayer]);
mcRef.mcHealth.txtHealth.text = _local2.nHealth;
mcRef.mcChar.gotoAndStop(_local2.sChar);
mcRef.mcSkill.gotoAndStop(_local2.aSkills[0]);
mcRef.mcSkillSelected._visible = _local2.bSelected;
_local2.nCpt;
}
function getCharacter(_nPlayer, _nChar) {
var _local3;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if ((aCharacters[_local2].nPlayer == _nPlayer) && (aCharacters[_local2].nChar == _nChar)) {
_local3 = aCharacters[_local2].oChar;
}
_local2++;
}
return(_local3);
}
static var sDEFAULT_COLOR = "Grey";
static var sDEFAULT_IMAGE = "None";
}
Symbol 499 MovieClip [__Packages.battlefield.hud.Minimap] Frame 0
class battlefield.hud.Minimap
{
var mcRef, mcDraw, mcField, oField, nWidth, nHeight, nFieldZeroX, nFieldZeroY, rectView, nRatio, nZeroX, nZeroY, nMoveToX, nMoveToY, fClickMap, __get__clickMinimap;
function Minimap (_mcRef, _rectView, _mcField, _sField) {
mcRef = _mcRef;
mcDraw = mcRef.createEmptyMovieClip("mcDraw", mcRef.getNextHighestDepth());
mcField = _mcField;
oField = data.DataFields.getField(_sField);
nWidth = mcField.mcField.mcViewingArea._width;
nHeight = mcField.mcField.mcViewingArea._height;
nFieldZeroX = mcField.mcField.mcViewingArea._x;
nFieldZeroY = mcField.mcField.mcViewingArea._y;
rectView = _rectView;
nRatio = Math.min((mcRef._width - (nSPACING_X * 2)) / nWidth, (mcRef._height - (nSPACING_Y * 2)) / nHeight);
nZeroX = (mcRef._width / 2) - ((nWidth * nRatio) / 2);
nZeroY = (mcRef._height / 2) - ((nHeight * nRatio) / 2);
mcRef.onPress = library.Delegate.create(this, clickMap);
}
function enterFrame(_aCharacterOrder) {
drawMap(_aCharacterOrder);
}
function drawMap(_aCharacters) {
mcDraw.clear();
mcDraw.lineStyle(0, 16777215, 0);
mcDraw.beginFill(oField.nFieldColor, 100);
mcDraw.moveTo(nZeroX, nZeroY);
mcDraw.lineTo(nZeroX, nZeroY + (nHeight * nRatio));
mcDraw.lineTo(nZeroX + (nWidth * nRatio), nZeroY + (nHeight * nRatio));
mcDraw.lineTo(nZeroX + (nWidth * nRatio), nZeroY);
mcDraw.lineTo(nZeroX, nZeroY);
mcDraw.endFill();
var _local5;
var _local2;
_local2 = 0;
while (_local2 < _aCharacters.length) {
_local5 = data.DataCharacter.aCOLOR_CODE_PLAYERS[_aCharacters[_local2].nPlayer];
drawCharSquare(_aCharacters[_local2].mc._x, _aCharacters[_local2].mc._y, _local5);
_local2++;
}
var _local4;
for (_local4 in mcField.mcField) {
if (_local4.substring(0, 13) != "mcStartPlayer") {
drawObstacleSquare(mcField.mcField[_local4]);
}
}
drawPosition();
}
function drawCharSquare(_nX, _nY, _nColor) {
mcDraw.lineStyle(0, 16777215, 0);
mcDraw.beginFill(_nColor, 100);
_nX = _nX - nFieldZeroX;
_nY = _nY - nFieldZeroY;
mcDraw.moveTo(nZeroX + ((_nX - (data.DataFields.nTILE_SIZE / 2)) * nRatio), nZeroY + ((_nY - (data.DataFields.nTILE_SIZE / 2)) * nRatio));
mcDraw.lineTo(nZeroX + ((_nX - (data.DataFields.nTILE_SIZE / 2)) * nRatio), nZeroY + ((_nY + (data.DataFields.nTILE_SIZE / 2)) * nRatio));
mcDraw.lineTo(nZeroX + ((_nX + (data.DataFields.nTILE_SIZE / 2)) * nRatio), nZeroY + ((_nY + (data.DataFields.nTILE_SIZE / 2)) * nRatio));
mcDraw.lineTo(nZeroX + ((_nX + (data.DataFields.nTILE_SIZE / 2)) * nRatio), nZeroY + ((_nY - (data.DataFields.nTILE_SIZE / 2)) * nRatio));
mcDraw.lineTo(nZeroX + ((_nX - (data.DataFields.nTILE_SIZE / 2)) * nRatio), nZeroY + ((_nY - (data.DataFields.nTILE_SIZE / 2)) * nRatio));
mcDraw.endFill();
}
function drawObstacleSquare(_mcObstacle) {
var _local4 = oField.nObstacleColor;
mcDraw.lineStyle(0, _local4, 0);
mcDraw.beginFill(_local4, 100);
var _local9 = _mcObstacle._x - nFieldZeroX;
var _local8 = _mcObstacle._y - nFieldZeroY;
var _local3 = nZeroX + (Math.max(nFieldZeroX, _local9) * nRatio);
var _local6 = nZeroX + ((_local9 + _mcObstacle._width) * nRatio);
var _local2 = nZeroY + (Math.max(nFieldZeroY, _local8) * nRatio);
var _local7 = nZeroY + ((_local8 + _mcObstacle._height) * nRatio);
mcDraw.moveTo(Math.max(nZeroX, _local3), Math.max(_local2, nZeroY));
mcDraw.lineTo(Math.max(nZeroX, _local3), Math.max(nZeroY, Math.min(_local7, nZeroY + (nHeight * nRatio))));
mcDraw.lineTo(Math.max(nZeroX, Math.min(_local6, nZeroX + (nWidth * nRatio))), Math.max(nZeroY, Math.min(_local7, nZeroY + (nHeight * nRatio))));
mcDraw.lineTo(Math.max(nZeroX, Math.min(_local6, nZeroX + (nWidth * nRatio))), Math.max(_local2, nZeroY));
mcDraw.lineTo(Math.max(nZeroX, _local3), Math.max(_local2, nZeroY));
mcDraw.endFill();
}
function drawPosition() {
var _local4 = Math.abs(mcField._x + nFieldZeroX) / Math.max(nWidth - rectView.width, 1);
var _local5 = Math.abs(mcField._y + nFieldZeroY) / Math.max(nHeight - rectView.height, 1);
var _local3 = nZeroX + ((_local4 * (nWidth - rectView.width)) * nRatio);
var _local2 = nZeroY + ((_local5 * (nHeight - rectView.height)) * nRatio);
mcDraw.lineStyle(2, 65535, 100);
mcDraw.moveTo(_local3, _local2);
mcDraw.lineTo(_local3, _local2 + Math.min(nHeight * nRatio, rectView.height * nRatio));
mcDraw.lineTo(_local3 + Math.min(nWidth * nRatio, rectView.width * nRatio), _local2 + Math.min(nHeight * nRatio, rectView.height * nRatio));
mcDraw.lineTo(_local3 + Math.min(nWidth * nRatio, rectView.width * nRatio), _local2);
mcDraw.lineTo(_local3, _local2);
}
function clickMap() {
var _local5 = (rectView.width * nRatio) / 2;
var _local2 = (rectView.height * nRatio) / 2;
var _local4 = Math.max(0, (nWidth * nRatio) - (_local5 * 2));
var _local3 = Math.max(0, (nHeight * nRatio) - (_local2 * 2));
nMoveToX = Math.max(Math.min(Math.max((mcRef._xmouse - nZeroX) - _local5, 0), _local4) / _local4, 0) - nFieldZeroX;
nMoveToY = Math.max(Math.min(Math.max((mcRef._ymouse - nZeroY) - _local2, 0), _local3) / _local3, 0) - nFieldZeroY;
fClickMap();
}
function get moveTo() {
var _local2 = new Object();
_local2.x = nMoveToX;
_local2.y = nMoveToY;
return(_local2);
}
function set clickMinimap(_fClickMap) {
fClickMap = _fClickMap;
//return(__get__clickMinimap());
}
var nSPACING_X = 5;
var nSPACING_Y = 5;
}
Symbol 500 MovieClip [__Packages.data.DataFields] Frame 0
class data.DataFields
{
function DataFields () {
}
static function getField(_sField) {
var _local1 = new Object();
switch (_sField) {
case sTEST_FIELD :
_local1.nDefaultTeamValue = 100;
_local1.nFieldColor = 65280;
_local1.nObstacleColor = 21760;
break;
case sCENTER_BLOCK :
_local1.nDefaultTeamValue = 100;
_local1.nFieldColor = 65280;
_local1.nObstacleColor = 21760;
break;
case sCENTER_START :
_local1.nDefaultTeamValue = 100;
_local1.nFieldColor = 65280;
_local1.nObstacleColor = 21760;
}
return(_local1);
}
static var nTILE_SIZE = 50;
static var sTEST_FIELD = "mcField_Test";
static var sCENTER_BLOCK = "mcField_CenterBlock";
static var sCENTER_START = "mcField_CenterStart";
static var aFIELD = new Array(sTEST_FIELD, sCENTER_BLOCK, sCENTER_START);
}
Symbol 501 MovieClip [__Packages.BattleAnimation] Frame 0
class BattleAnimation extends library.State
{
var nDuration, fEndAnimation, setState, nCurrentFrame, mcRef, isStateComplete, nEndTimer, oAttChar, oDefChar;
function BattleAnimation (_mcRef, _nDuration, _fEndAnimation) {
super(_mcRef);
nDuration = _nDuration;
fEndAnimation = _fEndAnimation;
setState(sSTATE_HIDDEN);
}
function startIn() {
nCurrentFrame = 0;
setChars(mcRef.mcState);
}
function doIn() {
if (isStateComplete()) {
setState(sSTATE_IDLE);
}
}
function startIdle() {
setChars(mcRef.mcState);
}
function doIdle() {
updateChars(mcRef.mcState);
if (nEndTimer <= getTimer()) {
setState(sSTATE_OUT);
}
}
function startOut() {
setChars(mcRef.mcState);
}
function doOut() {
if (isStateComplete()) {
setState(sSTATE_HIDDEN);
fEndAnimation();
}
}
function setAttack(_oCharAtt, _oCharDef) {
oAttChar = _oCharAtt;
oDefChar = _oCharDef;
setState(sSTATE_IN);
}
function setChars(_mcRef) {
_mcRef.gotoAndStop(oAttChar.sAttackType);
_mcRef.mcCharAttackUpper._visible = false;
_mcRef.mcCharAttackUpper.gotoAndStop(oAttChar.sChar);
_mcRef.mcCharAttackUpper.mcState.gotoAndStop("Attack");
_mcRef.mcCharDefenseUpper._visible = false;
_mcRef.mcCharDefenseUpper.gotoAndStop(oDefChar.sChar);
_mcRef.mcCharDefenseUpper.mcState.gotoAndStop("Defend" + oAttChar.sAttackType);
_mcRef.mcCharAttackMiddle.gotoAndStop(oAttChar.sChar);
_mcRef.mcCharAttackMiddle.mcState.gotoAndStop("Attack");
_mcRef.mcCharDefenseMiddle.gotoAndStop(oDefChar.sChar);
_mcRef.mcCharDefenseMiddle.mcState.gotoAndStop("Defend" + oAttChar.sAttackType);
nEndTimer = getTimer() + nDuration;
updateChars(_mcRef);
}
function updateChars(_mcRef) {
_mcRef.mcCharAttackMiddle.mcState.mcState.gotoAndStop(oAttChar.aAttackFrame[nCurrentFrame]);
_mcRef.mcCharDefenseMiddle.mcState.mcState.gotoAndStop(oAttChar.aAttackFrame[nCurrentFrame]);
if (((_mcRef.mcCharAttackMiddle.Mc.getDepth() > _mcRef.mcCharDefenseMiddle.Mc.getDepth()) && (oAttChar.aAttackDepth[nCurrentFrame] == 0)) || ((_mcRef.mcCharAttackMiddle.Mc.getDepth() < _mcRef.mcCharDefenseMiddle.Mc.getDepth()) && (oAttChar.aAttackDepth[nCurrentFrame] == 1))) {
_mcRef.mcCharAttackMiddle.Mc.swapDepths(_mcRef.mcCharDefenseMiddle.Mc);
}
nCurrentFrame++;
if (nCurrentFrame >= oAttChar.aAttackDepth.length) {
nCurrentFrame = 0;
}
}
function get endAnimation() {
return(fEndAnimation);
}
function set endAnimation(_fEndAnimation) {
fEndAnimation = _fEndAnimation;
//return(endAnimation);
}
function setDepths() {
oAttChar.aAttackDepth;
}
static var nDEFAULT_ANIMATION_DURATION = 1700;
static var sSTATE_IN = "In";
static var sSTATE_IDLE = "Idle";
static var sSTATE_OUT = "Out";
static var sSTATE_HIDDEN = "Hidden";
}
Symbol 502 MovieClip [__Packages.battlefield.EndBattlefieldEffect] Frame 0
class battlefield.EndBattlefieldEffect extends library.State
{
var setState, fEndEffect, isStateComplete;
function EndBattlefieldEffect (_mcRef, _fEndEffect) {
super(_mcRef);
setState(sSTATE_HIDDEN);
fEndEffect = _fEndEffect;
}
function doWin() {
if (isStateComplete()) {
fEndEffect();
setState(sSTATE_HIDDEN);
}
}
function doLose() {
if (isStateComplete()) {
fEndEffect();
setState(sSTATE_HIDDEN);
}
}
function setWin() {
setState(sSTATE_WIN);
}
function setLose() {
setState(sSTATE_LOSE);
}
static var sSTATE_WIN = "Win";
static var sSTATE_LOSE = "Lose";
static var sSTATE_HIDDEN = "Hidden";
}
Symbol 503 MovieClip [__Packages.battlefield.PopupPlayerCode] Frame 0
class battlefield.PopupPlayerCode extends library.Popup
{
var fValid, sDisplayPlayerCode, setState, btnCancel, mcRef, bCanCancel, btnSubmit, sEnterPlayerCode, fOutFunction;
function PopupPlayerCode (_mcRef, _fValid) {
super(_mcRef);
fValid = _fValid;
}
function setDisplay(_sDisplayPlayerCode) {
sDisplayPlayerCode = _sDisplayPlayerCode;
setState(library.Popup.sSTATE_IN);
}
function startIn() {
trace("start popup player code");
btnCancel = new library.MCButton(mcRef.mcState.mcState.btnCancel);
btnCancel.__get__Mc()._visible = bCanCancel;
btnSubmit = new library.MCButton(mcRef.mcState.mcState.btnSubmit);
mcRef.mcState.mcState.txtPlayerCode.text = sDisplayPlayerCode;
}
function startIdle() {
btnCancel = new library.MCButton(mcRef.mcState.btnCancel, library.Delegate.create(this, cancel));
btnCancel.__get__Mc()._visible = bCanCancel;
btnSubmit = new library.MCButton(mcRef.mcState.btnSubmit, library.Delegate.create(this, submit));
mcRef.mcState.txtPlayerCode.text = sDisplayPlayerCode;
}
function doIdle() {
btnCancel.enterFrame();
btnSubmit.enterFrame();
}
function startOut() {
btnCancel = new library.MCButton(mcRef.mcState.mcState.btnCancel);
btnCancel.__get__Mc()._visible = bCanCancel;
btnSubmit = new library.MCButton(mcRef.mcState.mcState.btnSubmit);
mcRef.mcState.mcState.txtPlayerCode.text = sDisplayPlayerCode;
mcRef.mcState.mcState.txtEnterPlayerCode.text = sEnterPlayerCode;
}
function cancel() {
fOutFunction = undefined;
setState(library.Popup.sSTATE_OUT);
}
function submit() {
sEnterPlayerCode = mcRef.mcState.txtEnterPlayerCode.text;
if (fValid()) {
setState(library.Popup.sSTATE_OUT);
}
}
function startTransition(_sDisplayPlayerCode, _bCanCancel) {
sDisplayPlayerCode = _sDisplayPlayerCode;
bCanCancel = _bCanCancel;
super.startTransition();
}
function get playerCode() {
return(sEnterPlayerCode);
}
}
Symbol 504 MovieClip [__Packages.battlefield.PopupMessage] Frame 0
class battlefield.PopupMessage extends library.Popup
{
var fUnlock, fLock, mcRef, nSize, sText, btnSubmit, setState;
function PopupMessage (_mcRef, _fUnlock, _fLock) {
super(_mcRef);
fUnlock = _fUnlock;
fLock = _fLock;
}
function startIn() {
mcRef.mcState.mcState.gotoAndStop(nSize);
mcRef.mcState.mcState.txtText.text = sText;
}
function startIdle() {
mcRef.mcState.gotoAndStop(nSize);
mcRef.mcState.txtText.text = sText;
btnSubmit = new library.MCButton(mcRef.mcState.btnSubmit, library.Delegate.create(this, setState, library.Popup.sSTATE_OUT));
}
function startOut() {
mcRef.mcState.mcState.gotoAndStop(nSize);
mcRef.mcState.mcState.txtText.text = sText;
}
function endOut() {
fUnlock();
}
function displayText(_sText, _nSize) {
fLock();
sText = _sText;
nSize = _nSize;
setState(library.Popup.sSTATE_IN);
}
}
Symbol 505 MovieClip [__Packages.battlefield.OnlineManagement] Frame 0
class battlefield.OnlineManagement
{
var bOnline, sSelfOnlineCode, sOtherOnlineCode, bWait, nEndWait, fEndWait;
function OnlineManagement (_bOnline) {
bOnline = _bOnline;
sSelfOnlineCode = "";
sOtherOnlineCode = "";
bWait = false;
nEndWait = 0;
}
function enterFrame() {
if (bWait) {
if (nEndWait <= getTimer()) {
bWait = false;
fEndWait();
}
}
}
function setWait(_fEndWait) {
bWait = true;
nEndWait = (getTimer() + (Math.random() * (nWAIT_MAX - nWAIT_MIN))) + nWAIT_MIN;
fEndWait = _fEndWait;
}
function resetSelf() {
sSelfOnlineCode = "";
}
function addCommand(_sCommand, _sDetail) {
sSelfOnlineCode = sSelfOnlineCode + ((_sCommand + _sDetail) + ";");
}
function loadOtherCode(_sOtherOnlineCode) {
sOtherOnlineCode = _sOtherOnlineCode;
}
function getNextCommand() {
var _local4 = sOtherOnlineCode.split(";")[0];
var _local2 = _local4.split(":");
if (sOtherOnlineCode.indexOf(";") != -1) {
sOtherOnlineCode = sOtherOnlineCode.substring(sOtherOnlineCode.indexOf(";") + 1);
} else {
sOtherOnlineCode = "";
}
var _local3 = new Object();
_local3.sCmd = _local2[0].charAt(0);
_local2[0] = _local2[0].substring(1);
_local3.aCode = _local2;
return(_local3);
}
function validatePlayerCode(_sOtherOnlineCode) {
var _local3 = false;
if (_sOtherOnlineCode.indexOf("*") != _sOtherOnlineCode.lastIndexOf("*")) {
_sOtherOnlineCode = _sOtherOnlineCode.substring(_sOtherOnlineCode.indexOf("*") + 1, _sOtherOnlineCode.lastIndexOf("*") - 1);
if (_sOtherOnlineCode.split("*")[0] == Main.nVERSION) {
sOtherOnlineCode = _sOtherOnlineCode.split("*")[1];
_local3 = true;
}
}
return(_local3);
}
function get isOnline() {
return(bOnline);
}
function get otherCodeRemaining() {
trace("otherCodeRemaining: " + sOtherOnlineCode);
return(sOtherOnlineCode != "");
}
function get selfOnlineCode() {
return(((("*" + Main.nVERSION) + "*") + sSelfOnlineCode) + "*");
}
var nWAIT_MIN = 200;
var nWAIT_MAX = 400;
}
Symbol 506 MovieClip [__Packages.battlefield.Field] Frame 0
class battlefield.Field
{
var mcRef, mcCharacter, mcBase, aTiles, aEffects, mcTile, oCollision, nViewingAreaTop, nViewingAreaBottom, nViewingAreaLeft, nViewingAreaRight, rectTop, rectBottom, rectLeft, rectRight, rectView, fClickField;
function Field (_mcRef, _sField) {
mcRef = _mcRef.mcField;
mcCharacter = _mcRef.mcCharacter;
mcBase = _mcRef.mcCharacterBase;
aTiles = new Array();
aEffects = new Array();
mcRef.attachMovie(_sField, "mcField", mcRef.mcField.getNextHighestDepth());
if (bTILE_BASED) {
mcTile = mcRef.createEmptyMovieClip("mcTile", mcRef.getNextHighestDepth());
generateTiles();
} else {
oCollision = new battlefield.character.CollisionDetection(mcRef.mcField, mcCharacter, _mcRef.mcDraw, _mcRef.mcDrawUpper);
}
setScroll();
}
function enterFrame() {
scroll();
var _local2;
_local2 = 0;
while (_local2 < aEffects.length) {
if (aEffects[_local2].enterFrame()) {
aEffects.splice(_local2, 1);
_local2--;
}
_local2++;
}
}
function setViewingArea() {
nViewingAreaTop = mcRef.mcField.mcViewingArea._y;
nViewingAreaBottom = mcRef.mcField.mcViewingArea._y + mcRef.mcField.mcViewingArea._height;
nViewingAreaLeft = mcRef.mcField.mcViewingArea._x;
nViewingAreaRight = mcRef.mcField.mcViewingArea._x + mcRef.mcField.mcViewingArea._width;
mcRef.mcField.mcViewingArea.swapDepths(mcRef.mcField.getNextHighestDepth());
mcRef.mcField.mcViewingArea.removeMovieClip();
}
function setScroll() {
rectTop = new flash.geom.Rectangle(mcRef._parent.mcScroll.mcTop._x, mcRef._parent.mcScroll.mcTop._y, mcRef._parent.mcScroll.mcTop._width, mcRef._parent.mcScroll.mcTop._height);
rectBottom = new flash.geom.Rectangle(mcRef._parent.mcScroll.mcBottom._x, mcRef._parent.mcScroll.mcBottom._y, mcRef._parent.mcScroll.mcBottom._width, mcRef._parent.mcScroll.mcBottom._height);
rectLeft = new flash.geom.Rectangle(mcRef._parent.mcScroll.mcLeft._x, mcRef._parent.mcScroll.mcLeft._y, mcRef._parent.mcScroll.mcLeft._width, mcRef._parent.mcScroll.mcLeft._height);
rectRight = new flash.geom.Rectangle(mcRef._parent.mcScroll.mcRight._x, mcRef._parent.mcScroll.mcRight._y, mcRef._parent.mcScroll.mcRight._width, mcRef._parent.mcScroll.mcRight._height);
rectView = new flash.geom.Rectangle(mcRef._parent.mcScroll.mcView._x, mcRef._parent.mcScroll.mcView._y, mcRef._parent.mcScroll.mcView._width, mcRef._parent.mcScroll.mcView._height);
mcRef._parent.mcScroll.swapDepths(mcRef.getNextHighestDepth());
mcRef._parent.mcScroll.removeMovieClip();
}
function scroll() {
if ((((_root._xmouse >= rectTop.left) && (_root._xmouse <= rectTop.right)) && (_root._ymouse >= rectTop.top)) && (_root._ymouse <= rectTop.bottom)) {
mcRef._y = Math.min(mcRef._y + nSPEED_Y, -nViewingAreaTop);
} else if ((((_root._xmouse >= rectBottom.left) && (_root._xmouse <= rectBottom.right)) && (_root._ymouse >= rectBottom.top)) && (_root._ymouse <= rectBottom.bottom)) {
mcRef._y = Math.max(mcRef._y - nSPEED_Y, Math.min(-nViewingAreaTop, (rectView.height - rectView.y) - nViewingAreaBottom));
}
if ((((_root._xmouse >= rectLeft.left) && (_root._xmouse <= rectLeft.right)) && (_root._ymouse >= rectLeft.top)) && (_root._ymouse <= rectLeft.bottom)) {
mcRef._x = Math.min(mcRef._x + nSPEED_X, -nViewingAreaLeft);
} else if ((((_root._xmouse >= rectRight.left) && (_root._xmouse <= rectRight.right)) && (_root._ymouse >= rectRight.top)) && (_root._ymouse <= rectRight.bottom)) {
mcRef._x = Math.max(mcRef._x - nSPEED_X, Math.min(-nViewingAreaLeft, (rectView.width - rectView.x) - nViewingAreaRight));
}
mcCharacter._x = mcRef._x;
mcCharacter._y = mcRef._y;
mcBase._x = mcRef._x;
mcBase._y = mcRef._y;
oCollision.moveTo(mcRef._x, mcRef._y);
}
function startPlayChar() {
mcRef.mcField.mcStartPlayer1.swapDepths(mcRef.mcField.getNextHighestDepth());
mcRef.mcField.mcStartPlayer1.removeMovieClip();
mcRef.mcField.mcStartPlayer2.swapDepths(mcRef.mcField.getNextHighestDepth());
mcRef.mcField.mcStartPlayer2.removeMovieClip();
if (bTILE_BASED) {
var _local2 = 0;
_local2 = 0;
while (_local2 < aTiles.length) {
aTiles[_local2].setState(battlefield.field.FieldTile.sSTATE_NONE);
_local2++;
}
}
}
function setClickField(_fClickField) {
fClickField = _fClickField;
if (bTILE_BASED) {
} else {
mcRef.onPress = library.Delegate.create(this, clickField);
}
}
function clearDrawZones() {
oCollision.clearZone(battlefield.character.CollisionDetection.nZONE);
oCollision.clearZone(battlefield.character.CollisionDetection.nZONE_UPPER);
}
function drawCharacterZones(_nAttackRange, _nMovement, _bAttack, _bMovement, _mcRef, _bCurrentChar) {
var _local2 = battlefield.character.CollisionDetection.nZONE_UPPER;
if (!_bCurrentChar) {
_local2 = battlefield.character.CollisionDetection.nZONE;
}
oCollision.setStats(_nAttackRange, _nMovement);
oCollision.drawZone(_bAttack, _bMovement, _local2, _mcRef);
}
function drawSkillsZones(_nRange, _nMovement, _mcRef) {
var _local2 = battlefield.character.CollisionDetection.nZONE_UPPER;
oCollision.setStats(_nRange, _nMovement);
oCollision.drawZone(_nRange > 0, _nMovement > 0, _local2, _mcRef);
}
function mouseOutChar() {
oCollision.clearZone(battlefield.character.CollisionDetection.nZONE);
}
function clickField() {
var _local3 = true;
if (bTILE_BASED) {
var _local2;
_local2 = 0;
while (_local2 < aTiles.length) {
if (aTiles[_local2].isMouseOver) {
}
_local2++;
}
} else {
_local3 = true;
}
if (_local3) {
fClickField();
}
}
function clickMinimap(_oHud) {
var _local2 = _oHud.__get__minimapMoveTo();
mcRef._y = ((rectView.height - rectView.y) - mcRef._height) * _local2.y;
mcRef._x = ((rectView.width - rectView.x) - mcRef._width) * _local2.x;
scroll();
}
function lightField(_bMain, _mcRef, _nAttack, _nMovement) {
var _local2 = battlefield.character.CollisionDetection.nZONE;
if (_bMain) {
_local2 = battlefield.character.CollisionDetection.nZONE_UPPER;
}
if (bTILE_BASED) {
} else {
oCollision.setStats(_nAttack, _nMovement);
oCollision.drawZone(_nAttack > 0, _nMovement > 0, _local2, _mcRef);
}
}
function charModeNodes() {
var _local1 = new Array();
return(_local1);
}
function addCharacter(_nPlayer, _sLinkage) {
var _local2 = mcCharacter.attachMovie(data.DataCharacter.sLINKAGE_SPRITE + _sLinkage, "mcChar" + mcCharacter.getNextHighestDepth(), mcCharacter.getNextHighestDepth());
if (bTILE_BASED) {
var _local4;
do {
_local4 = Math.floor(Math.random() * aTiles.length);
_local2._x = aTiles[_local4].Mc._x;
_local2._y = aTiles[_local4].Mc._y;
} while ((!aTiles[_local4].isStart(_nPlayer)) || (tryCollide(_local2)));
} else {
var _local3 = mcRef.mcField["mcStartPlayer" + (_nPlayer + 1)];
do {
_local2._x = (_local3._x + (_local2._width / 2)) + Math.floor(Math.random() * (_local3._width - _local2._width));
_local2._y = (_local3._y + (_local2._height / 2)) + Math.floor(Math.random() * (_local3._height - _local2._height));
} while (tryCollide(_local2));
}
return(_local2);
}
function placeCharacter(_nPlayer, _oPlayer) {
var _local4 = true;
var _local7 = _oPlayer.getActiveCharacter();
var _local2 = _local7.__get__Mc();
if (bTILE_BASED) {
var _local5 = new Object();
_local5.x = _local2._x;
_local5.y = _local2._y;
_local2._parent.localToGlobal(_local5);
var _local6 = getTileCollide(_local5.x, _local5.y);
if (_local6 >= 0) {
_local4 = (!aTiles[_local6].isStart(_nPlayer)) || (tryCollide(_local2));
if (!_local4) {
_local2._x = aTiles[_local6].Mc._x;
_local2._y = aTiles[_local6].Mc._y;
}
} else {
_local4 = true;
}
} else {
var _local3 = mcRef.mcField["mcStartPlayer" + (_nPlayer + 1)];
if ((((_local2._x < (_local3._x + (_local2._width / 2))) || (_local2._x > ((_local3._x + _local3._width) - (_local2._width / 2)))) || (_local2._y < (_local3._y - (_local2._height / 2)))) || (_local2._y > ((_local3._y + _local3._height) - (_local2._height / 2)))) {
_local4 = true;
trace("**1");
} else {
_local4 = oCollision.getCollisionClipOnField(_local2);
}
}
return(_local4);
}
function getMovement(_mcRef, _oPoint) {
var _local2 = new Array();
if (bTILE_BASED) {
var _local4 = getTileCollide(_mcRef._x, _mcRef._y);
var _local5 = getTileCollide(_oPoint.x, _oPoint.y);
} else {
_local2.push({x:_oPoint.x, y:_oPoint.y});
}
return(_local2);
}
function clearAttackable(_aCharacterOrder) {
var _local4;
var _local3;
var _local1;
_local1 = 0;
while (_local1 < _aCharacterOrder.length) {
if (bTILE_BASED) {
} else {
_aCharacterOrder[_local1].mc.onPress = undefined;
delete _aCharacterOrder[_local1].mc.onPress;
_local4 = new flash.geom.ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
_local3 = new flash.geom.Transform(_aCharacterOrder[_local1].mc);
_local3.colorTransform = _local4;
}
_local1++;
}
}
function setUseSkill(_aCharacterOrder, _nCurrentTurn, _bActive) {
var _local1;
if (_bActive) {
_local1 = new flash.geom.ColorTransform(0.5, 0.5, 1, 1, 0, 0, 75, 0);
} else {
_local1 = new flash.geom.ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
}
var _local2 = new flash.geom.Transform(_aCharacterOrder[_nCurrentTurn].mc);
_local2.colorTransform = _local1;
}
function setSkillable(_aCharacterOrder, _nCurrentTurn, _oSkill, _nRange, _fSkill) {
var _local4 = false;
var _local6;
var _local5;
var _local2;
_local2 = 0;
while (_local2 < _aCharacterOrder.length) {
switch (_oSkill.nType) {
case data.DataCharacter.nSKILL_TYPE_ACTIVE_ENEMY :
_local4 = _aCharacterOrder[_local2].nPlayer != _aCharacterOrder[_nCurrentTurn].nPlayer;
break;
case data.DataCharacter.nSKILL_TYPE_ACTIVE_FRIEND :
_local4 = (_aCharacterOrder[_local2].nPlayer == _aCharacterOrder[_nCurrentTurn].nPlayer) && (_local2 != _nCurrentTurn);
break;
default :
_local4 = false;
}
if (_local4) {
if (bTILE_BASED) {
} else if ((library.MyMath.lineSize(_aCharacterOrder[_local2].mc._x, _aCharacterOrder[_local2].mc._y, _aCharacterOrder[_nCurrentTurn].mc._x, _aCharacterOrder[_nCurrentTurn].mc._y) - (data.DataFields.nTILE_SIZE / 2)) <= _nRange) {
_aCharacterOrder[_local2].mc.onPress = _fSkill;
_local6 = new flash.geom.ColorTransform(0.5, 1, 0.5, 1, 0, 75, 0, 0);
_local5 = new flash.geom.Transform(_aCharacterOrder[_local2].mc);
_local5.colorTransform = _local6;
}
}
_local2++;
}
}
function setAttackable(_aCharacterOrder, _nCurrentTurn, _nMovement, _fAttack) {
var _local5;
var _local4;
var _local2;
_local2 = 0;
while (_local2 < _aCharacterOrder.length) {
if (_aCharacterOrder[_local2].nPlayer != _aCharacterOrder[_nCurrentTurn].nPlayer) {
if (bTILE_BASED) {
} else if ((library.MyMath.lineSize(_aCharacterOrder[_local2].mc._x, _aCharacterOrder[_local2].mc._y, _aCharacterOrder[_nCurrentTurn].mc._x, _aCharacterOrder[_nCurrentTurn].mc._y) - (data.DataFields.nTILE_SIZE / 2)) <= ((_aCharacterOrder[_nCurrentTurn].nAttackRange + _nMovement) * data.DataFields.nTILE_SIZE)) {
_aCharacterOrder[_local2].mc.onPress = _fAttack;
_local5 = new flash.geom.ColorTransform(1, 0.5, 0.5, 1, 75, 0, 0, 0);
_local4 = new flash.geom.Transform(_aCharacterOrder[_local2].mc);
_local4.colorTransform = _local5;
}
}
_local2++;
}
}
function moveToAttack(_mcSelf, _mcTarget, _nAttackRange, _nMovement) {
var _local2 = new Object();
_local2.nResult = nATTACK_CANT;
var _local6 = library.MyMath.lineSize(_mcSelf._x, _mcSelf._y, _mcTarget._x, _mcTarget._y);
var _local4;
_nAttackRange = _nAttackRange * data.DataFields.nTILE_SIZE;
_nAttackRange = _nAttackRange + (data.DataFields.nTILE_SIZE / 2);
_nMovement = _nMovement * data.DataFields.nTILE_SIZE;
if (_local6 <= _nAttackRange) {
_local2.nResult = nATTACK_DONT_MOVE;
} else if (_local6 <= (_nAttackRange + _nMovement)) {
_local4 = moveToFromAttackTarget(_mcSelf, _mcTarget, _nAttackRange - 10, _nMovement);
_local2 = tryCollideMovement(_mcSelf, _local4, false);
if (!_local2.bCollide) {
_local2.nResult = nATTACK_MOVE;
_local2.x = _local4.x;
_local2.y = _local4.y;
}
}
return(_local2);
}
function moveToFromAttackTarget(_mcSelf, _mcTarget, _nAttackRange, _nMovement) {
var _local5 = library.MyMath.lineSize(_mcSelf._x, _mcSelf._y, _mcTarget._x, _mcTarget._y);
var _local7;
var _local3 = (_local5 - _nAttackRange) / _local5;
var _local2 = new Object();
_local2.x = _mcSelf._x + ((_mcTarget._x - _mcSelf._x) * _local3);
_local2.y = _mcSelf._y + ((_mcTarget._y - _mcSelf._y) * _local3);
return(_local2);
}
function tryCollide(_mcRef) {
return(oCollision.getCollisionClipOnField(_mcRef));
}
function tryCollideMovement(_mcRef, _oTarget, _bFlying) {
var _local2 = new Object();
_local2.bCollide = true;
if (bTILE_BASED) {
} else {
_local2 = oCollision.tryCollideMovement(_mcRef, _oTarget, _bFlying);
}
return(_local2);
}
function findClosestChar(_mcChar, _aEnemyChar) {
var _local6 = 0;
if (bTILE_BASED) {
} else {
var _local1;
var _local4 = library.MyMath.lineSize(_mcChar._x, _mcChar._y, _aEnemyChar[0].Mc._x, _aEnemyChar[0].Mc._y);
var _local3;
_local1 = 1;
while (_local1 < _aEnemyChar.length) {
_local3 = library.MyMath.lineSize(_mcChar._x, _mcChar._y, _aEnemyChar[_local1].Mc._x, _aEnemyChar[_local1].Mc._y);
if (_local3 < _local4) {
_local6 = _local1;
_local3 = _local4;
}
_local1++;
}
}
return(_local6);
}
function getTileCollide(_nX, _nY) {
var _local3 = -1;
var _local2;
_local2 = 0;
while (_local2 < aTiles.length) {
if (aTiles[_local2].Mc.hitTest(_nX, _nY)) {
_local3 = _local2;
break;
}
_local2++;
}
return(_local3);
}
function displayCollision(_sChar, _nX, _nY) {
var _local3 = mcRef._parent.mcDrawUpper.getNextHighestDepth();
var _local2 = mcRef._parent.mcDrawUpper.attachMovie(sLINKAGE_BLOCKED, sLINKAGE_BLOCKED + _local3, _local3);
_local2.mcState.attachMovie(data.DataCharacter.sLINKAGE_SPRITE + _sChar, "mcChar", _local2.mcState.getNextHighestDepth());
_local2._x = _nX;
_local2._y = _nY;
_local2.lineStyle(1, 16711680, 100);
_local2.moveTo(-25, -25);
_local2.lineTo(25, -25);
_local2.lineTo(25, 25);
_local2.lineTo(-25, 25);
_local2.lineTo(-25, -25);
var _local5 = new flash.geom.ColorTransform(1, 0.5, 0.5, 1, 75, 0, 0, 0);
var _local4 = new flash.geom.Transform(_local2);
_local4.colorTransform = _local5;
aEffects.push(new library.Effect(_local2, false));
}
function generateTiles() {
var _local5 = 0;
var _local6 = 0;
var _local8 = 0;
var _local2 = 0;
var _local3 = 0;
var _local4 = 0;
var _local7 = _mcTile._height;
var _mcTile;
if (bHEX_TILES) {
_mcTile = mcTile.attachMovie(sLINKAGE_HEX, "mcTile" + mcTile.getNextHighestDepth(), mcTile.getNextHighestDepth());
_local7 = (_mcTile._height * 3) / 4;
} else {
_mcTile = mcTile.attachMovie(sLINKAGE_SQUARE, "mcTile" + mcTile.getNextHighestDepth(), mcTile.getNextHighestDepth());
_local7 = _mcTile._height;
}
_mcTile.removeMovieClip();
do {
if (bHEX_TILES) {
_mcTile = mcTile.attachMovie(sLINKAGE_HEX, "mcTile" + mcTile.getNextHighestDepth(), mcTile.getNextHighestDepth());
} else {
_mcTile = mcTile.attachMovie(sLINKAGE_SQUARE, "mcTile" + mcTile.getNextHighestDepth(), mcTile.getNextHighestDepth());
}
_mcTile._x = ((_local3 * _mcTile._width) + nEDGE_X) + (_mcTile._width / 2);
if (bHEX_TILES && ((_local4 % 2) == 1)) {
_mcTile._x = _mcTile._x + (_mcTile._width / 2);
}
_local3++;
_mcTile._y = ((_local4 * _local7) + nEDGE_Y) + (_mcTile._height / 2);
if ((_mcTile._x + _mcTile._width) >= ((mcRef._width - (nEDGE_X * 2)) - (_mcTile._width / 2))) {
if (_local4 % 0) {
_local5 = _local3;
} else {
_local6 = _local3;
}
_local4++;
_local3 = 0;
}
aTiles.push(new battlefield.field.FieldTile(_mcTile, _local2));
if (mcRef.mcField.mcStartPlayer1.hitTest(_mcTile._x, _mcTile._y)) {
aTiles[_local2].setStart(1);
} else if (mcRef.mcField.mcStartPlayer2.hitTest(_mcTile._x, _mcTile._y)) {
aTiles[_local2].setStart(2);
}
_local2++;
} while ((_local3 != 0) || ((_mcTile._y + _local7) < ((mcRef._height - _mcTile._height) - (nEDGE_Y * 2))));
_local8 = _local4;
_local3 = 0;
_local4 = 0;
_local2 = 0;
while (_local2 < aTiles.length) {
if (_local3 > 0) {
aTiles[_local2].addAdjacentTile(_local2 - 1);
}
if ((_local4 % 2) == 0) {
if ((_local3 + 1) < _local5) {
aTiles[_local2].addAdjacentTile(_local2 + 1);
}
} else if ((_local3 + 1) < _local6) {
aTiles[_local2].addAdjacentTile(_local2 + 1);
}
if (_local4 > 0) {
if ((_local4 % 2) == 0) {
if (_local3 > 0) {
aTiles[_local2].addAdjacentTile(_local2 - _local5);
}
} else {
aTiles[_local2].addAdjacentTile(_local2 - _local5);
}
}
if ((_local4 + 1) < _local8) {
if ((_local4 % 2) == 0) {
if (_local3 > 0) {
aTiles[_local2].addAdjacentTile(_local2 + _local5);
}
} else {
aTiles[_local2].addAdjacentTile(_local2 + _local5);
}
}
_local3++;
if ((_local4 % 2) == 0) {
if (_local3 >= _local5) {
_local3 = 0;
_local4++;
}
} else if (_local3 >= _local6) {
_local3 = 0;
_local4++;
}
_local2++;
}
mcRef.mcField.mcStartPlayer1._visible = false;
mcRef.mcField.mcStartPlayer2._visible = false;
}
function get view() {
return(rectView);
}
static var sLINKAGE_BLOCKED = "mcSprite_FadeOut";
static var nATTACK_MOVE = 0;
static var nATTACK_DONT_MOVE = 1;
static var nATTACK_CANT = 2;
static var nSPEED_X = 20;
static var nSPEED_Y = 20;
var nEDGE_X = 10;
var nEDGE_Y = 10;
static var bTILE_BASED = false;
var bHEX_TILES = true;
var sLINKAGE_HEX = "HexTile";
var sLINKAGE_SQUARE = "SquareTile";
}
Symbol 507 MovieClip [__Packages.battlefield.character.CollisionDetection] Frame 0
class battlefield.character.CollisionDetection
{
var mcField, mcCharacters, mcDraw, mcDrawUpper, nAttackRange, nMovement;
function CollisionDetection (_mcField, _mcCharacters, _mcDraw, _mcDrawUpper) {
mcField = _mcField;
mcCharacters = _mcCharacters;
mcDraw = _mcDraw;
mcDrawUpper = _mcDrawUpper;
}
function setStats(_nAttackRange, _nMovement) {
nAttackRange = _nAttackRange * data.DataFields.nTILE_SIZE;
nMovement = _nMovement * data.DataFields.nTILE_SIZE;
}
function clearZone(_nZone) {
var _local2 = mcDrawUpper;
if (_nZone == nZONE) {
_local2 = mcDraw;
}
_local2.clear();
var _local3;
for (_local3 in _local2) {
_local2[_local3].removeMovieClip();
}
}
function moveTo(_nX, _nY) {
mcDraw._x = _nX;
mcDraw._y = _nY;
mcDrawUpper._x = _nX;
mcDrawUpper._y = _nY;
}
function drawZone(_bAttack, _bMovement, _nZone, _mcRef) {
clearZone(_nZone);
if (nAttackRange > nMovement) {
if (_bAttack) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_ATTACK, _nZone, _bMovement);
}
if (_bMovement) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_MOVEMENT, _nZone, false);
}
} else if (nAttackRange < nMovement) {
if (_bMovement) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_MOVEMENT, _nZone, false);
}
if (_bAttack) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_ATTACK, _nZone, _bMovement);
}
} else {
if (_bMovement) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_MOVEMENT, _nZone, false);
}
if (_bAttack) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_ATTACK, _nZone, _bMovement);
}
}
if (_bMovement && (_bAttack)) {
drawCircle(_mcRef._x, _mcRef._y, nACTION_RANGE, _nZone, false);
}
}
function tryCollideMovement(_mcRef, _oTarget, _bFlying) {
var _local4 = new Object();
_local4.bCollide = false;
var _local8 = _mcRef._width / 2;
var _local7 = _mcRef._height / 2;
var _local6 = library.MyMath.angleDirection(_mcRef._x, _mcRef._y, _oTarget.x, _oTarget.y);
var _local3 = getDistanceCollisionPoint(_mcRef._x, _mcRef._y, library.MyMath.lineSize(_mcRef._x, _mcRef._y, _oTarget.x, _oTarget.y), _local6, !_bFlying);
if ((!_local4.bCollide) && (!_bFlying)) {
if (_local6 <= 90) {
_local3 = tryCollideEdge(_mcRef, _oTarget, -_local8, -_local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, _local8, -_local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, _local8, _local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
}
}
} else if (_local6 <= 180) {
_local3 = tryCollideEdge(_mcRef, _oTarget, _local8, -_local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, _local8, _local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, -_local8, _local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
}
}
} else if (_local6 <= 270) {
_local3 = tryCollideEdge(_mcRef, _oTarget, -_local8, _local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, _local8, _local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, -_local8, -_local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
}
}
} else {
_local3 = tryCollideEdge(_mcRef, _oTarget, -_local8, -_local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, -_local8, _local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
if (!_local4.bCollide) {
_local3 = tryCollideEdge(_mcRef, _oTarget, _local8, -_local7, _local6);
_local4 = confirmCollideEdge(_oTarget, _local3);
}
}
}
}
return(_local4);
}
function tryCollideEdge(_mcRef, _oTarget, _nWidthMod, _nHeightMod, _nAngle) {
var _local2 = getDistanceCollisionPoint(_mcRef._x + _nWidthMod, _mcRef._y + _nHeightMod, library.MyMath.lineSize(_mcRef._x + _nWidthMod, _mcRef._y + _nHeightMod, _oTarget.x + _nWidthMod, _oTarget.y + _nHeightMod), _nAngle, true);
_local2.x = _local2.x - _nWidthMod;
_local2.y = _local2.y - _nHeightMod;
return(_local2);
}
function confirmCollideEdge(_oTarget, _oPoint) {
var _local1 = new Object();
_local1.bCollide = !((Math.abs(_oTarget.x - _oPoint.x) < 1) && (Math.abs(_oTarget.y - _oPoint.y) < 1));
_local1.x = _oPoint.x;
_local1.y = _oPoint.y;
return(_local1);
}
function drawCircle(_nX, _nY, _nAction, _nZone, _bIgnore) {
var _local2 = mcDrawUpper;
if (_nZone == nZONE) {
_local2 = mcDraw;
}
scatterCircle(_local2, _nAction, _nX, _nY, _bIgnore);
}
function scatterCircle(_mcDrawZone, _nAction, _nX, _nY, _bIgnore) {
var _local8;
var _local6;
var _local14 = nTHICKNESS_BORDER;
var _local11;
var _local15 = 100;
var _local12;
var _local16 = 20;
var _local19;
var _local13 = bDETECT_COLLISION;
switch (_nAction) {
case nACTION_ATTACK :
_local6 = sLINKAGE_ATTACK;
_local8 = nAttackRange;
_local11 = nCOLOR_ATTACK_BORDER;
_local12 = nCOLOR_ATTACK_FILL;
_local13 = false;
break;
case nACTION_MOVEMENT :
_local6 = sLINKAGE_MOVEMENT;
_local8 = nMovement;
_local11 = nCOLOR_MOVE_BORDER;
_local12 = nCOLOR_MOVE_FILL;
break;
case nACTION_RANGE :
_local6 = sLINKAGE_ATTACK;
_local8 = nAttackRange + nMovement;
_local11 = nCOLOR_ATTACK_BORDER;
_local12 = nCOLOR_ATTACK_FILL;
_local13 = false;
}
if (!_bIgnore) {
var _local2;
var _local5;
var _local7;
var _local3 = new Array();
_local2 = 0;
while (_local2 < nCIRCLE_SIDES) {
_local7 = getDistanceCollisionPoint(_nX, _nY, _local8, ((360 / nCIRCLE_SIDES) * (_local2 + 1)) % 360, false);
_local3.push(_local7);
_local2++;
}
if (bDISPLAY_DRAW) {
_mcDrawZone.moveTo(_local3[_local3.length - 1].x, _local3[_local3.length - 1].y);
_mcDrawZone.lineStyle(_local14, _local11, _local15);
_mcDrawZone.beginFill(_local12, _local16);
}
_local2 = 0;
while (_local2 < _local3.length) {
if (bDISPLAY_DRAW) {
_mcDrawZone.lineTo(_local3[_local2].x, _local3[_local2].y);
} else {
_local5 = _mcDrawZone.attachMovie(_local6, _local6 + _mcDrawZone.getNextHighestDepth(), _mcDrawZone.getNextHighestDepth());
_local5._x = _local3[_local2].x;
_local5._y = _local3[_local2].y;
}
_local2++;
}
if (bDISPLAY_DRAW) {
_mcDrawZone.endFill();
}
}
}
function getDistanceCollisionPoint(_nX1, _nY1, _nRadius, _nAngle, _bCollision) {
var _local3 = ((_nAngle / 360) * Math.PI) * 2;
var _local7 = Math.sin(_local3);
var _local8 = Math.cos(_local3);
var _local2 = new flash.geom.Point(_nX1 + (_local7 * _nRadius), _nY1 + ((-_local8) * _nRadius));
var _local4;
if (_bCollision) {
var _local9 = getCollisionPoints(_nX1, _nY1, _local2.x, _local2.y);
_local4 = tryCollide(_nX1, _nY1, _local2.x, _local2.y, _local9);
} else {
_local4 = _local2;
}
return(_local4);
}
function getCollisionPoints(_nX1, _nY1, _nX2, _nY2) {
var _local3;
var _local8 = new Array();
var _local2;
var _local11;
var _local9 = _nX1;
var _local10 = _nY1;
if (_nX1 > _nX2) {
_local11 = _nX1;
_nX1 = _nX2;
_nX2 = _local11;
}
if (_nY1 > _nY2) {
_local11 = _nY1;
_nY1 = _nY2;
_nY2 = _local11;
}
for (_local2 in mcField) {
if (library.MyMath.collisionSquareToSquare(_nX1, _nX2, _nY1, _nY2, mcField[_local2]._x, mcField[_local2]._x + mcField[_local2]._width, mcField[_local2]._y, mcField[_local2]._y + mcField[_local2]._height)) {
_local3 = new Object();
_local3.left = mcField[_local2]._x;
_local3.right = mcField[_local2]._x + mcField[_local2]._width;
_local3.top = mcField[_local2]._y;
_local3.bottom = mcField[_local2]._y + mcField[_local2]._height;
_local8.push(_local3);
}
}
for (_local2 in mcCharacters) {
if ((Math.abs(_local9 - mcCharacters[_local2]._x) > ((data.DataFields.nTILE_SIZE / 2) + 1)) || (Math.abs(_local10 - mcCharacters[_local2]._y) > ((data.DataFields.nTILE_SIZE / 2) + 1))) {
if (library.MyMath.collisionSquareToSquare(_nX1, _nX2, _nY1, _nY2, mcCharacters[_local2]._x - (mcCharacters[_local2]._width / 2), mcCharacters[_local2]._x + (mcCharacters[_local2]._width / 2), mcCharacters[_local2]._y - (mcCharacters[_local2]._height / 2), mcCharacters[_local2]._y + (mcCharacters[_local2]._height / 2))) {
_local3 = new Object();
_local3.left = mcCharacters[_local2]._x - (mcCharacters[_local2]._width / 2);
_local3.right = mcCharacters[_local2]._x + (mcCharacters[_local2]._width / 2);
_local3.top = mcCharacters[_local2]._y - (mcCharacters[_local2]._height / 2);
_local3.bottom = mcCharacters[_local2]._y + (mcCharacters[_local2]._height / 2);
_local8.push(_local3);
}
}
}
return(_local8);
}
function tryCollide(_nX1, _nY1, _nX2, _nY2, _aCollisionPoints) {
var _local9 = false;
var _local1;
var _local8 = library.MyMath.lineSize(_nX1, _nY1, _nX2, _nY2);
var _local3 = new Object();
_local1 = 0;
while (_local1 < _aCollisionPoints.length) {
_local3.collide = false;
if (_nY1 < _aCollisionPoints[_local1].top) {
_local3 = library.MyMath.collisionLineToLine(_nX1, _nY1, _nX2, _nY2, _aCollisionPoints[_local1].left, _aCollisionPoints[_local1].top, _aCollisionPoints[_local1].right, _aCollisionPoints[_local1].top);
} else if (_nY1 > _aCollisionPoints[_local1].bottom) {
_local3 = library.MyMath.collisionLineToLine(_nX1, _nY1, _nX2, _nY2, _aCollisionPoints[_local1].left, _aCollisionPoints[_local1].bottom, _aCollisionPoints[_local1].right, _aCollisionPoints[_local1].bottom);
}
if (!_local3.collide) {
if (_nX1 < _aCollisionPoints[_local1].left) {
_local3 = library.MyMath.collisionLineToLine(_nX1, _nY1, _nX2, _nY2, _aCollisionPoints[_local1].left, _aCollisionPoints[_local1].top, _aCollisionPoints[_local1].left, _aCollisionPoints[_local1].bottom);
} else if (_nX1 > _aCollisionPoints[_local1].right) {
_local3 = library.MyMath.collisionLineToLine(_nX1, _nY1, _nX2, _nY2, _aCollisionPoints[_local1].right, _aCollisionPoints[_local1].top, _aCollisionPoints[_local1].right, _aCollisionPoints[_local1].bottom);
}
}
if (_local3.collide) {
if ((_local8 > library.MyMath.lineSize(_nX1, _nY1, _local3.x, _local3.y)) && (2 <= library.MyMath.lineSize(_nX2, _nY2, _local3.x, _local3.y))) {
_nX2 = _local3.x;
_nY2 = _local3.y;
_local8 = library.MyMath.lineSize(_nX1, _nY1, _nX2, _nY2);
_local9 = true;
}
}
_local1++;
}
_local3.x = _nX2;
_local3.y = _nY2;
_local3.collide = _local9;
return(_local3);
}
function getCollisionClipOnField(_mcRef) {
var _local4 = false;
var _local2;
for (_local2 in mcField) {
if ((mcField[_local2].hitTest(_mcRef) && (_mcRef != mcField[_local2])) && (_local2.substring(0, 13) != "mcStartPlayer")) {
_local4 = true;
break;
}
}
if (!_local4) {
for (_local2 in mcCharacters) {
if ((mcCharacters[_local2].hitTest(_mcRef) && (_mcRef != mcCharacters[_local2])) && (mcCharacters[_local2]._currentframe == 1)) {
_local4 = true;
break;
}
}
}
return(_local4);
}
function getCollisionPointOnField(_nX, _nY, _mcIgnore) {
var _local1 = false;
return(_local1);
}
static var bDISPLAY_DRAW = true;
static var bDETECT_COLLISION = false;
static var sLINKAGE_MOVEMENT = "mcDropMovement";
static var sLINKAGE_ATTACK = "mcDropAttack";
static var sLINKAGE_RANGE = "mcDropRange";
static var nZONE = 0;
static var nZONE_UPPER = 1;
static var nACTION_ATTACK = 0;
static var nACTION_MOVEMENT = 1;
static var nACTION_RANGE = 2;
static var nCIRCLE_SIDES = 90;
static var nTHICKNESS_BORDER = 3;
static var nEQUAL_MODIFIER = 2;
static var nCOLOR_ATTACK_FILL = 16711680;
static var nCOLOR_ATTACK_BORDER = 7798784;
static var nCOLOR_MOVE_FILL = 255;
static var nCOLOR_MOVE_BORDER = 119;
static var nCOLOR_RANGE_FILL = 65280;
static var nCOLOR_RANGE_BORDER = 30464;
}
Symbol 508 MovieClip [__Packages.library.MyMath] Frame 0
class library.MyMath
{
function MyMath () {
}
static function Distance(_oPoint1, _oPoint2) {
return(Math.sqrt(Math.pow(_oPoint1.x - _oPoint2.x, 2) + Math.pow(_oPoint1.y - _oPoint2.y, 2)));
}
static function DistanceAngle(_oOrigin, _nDistance, _nAngle) {
_nAngle = ((_nAngle / 360) * Math.PI) * 2;
var _local1 = Math.sin(_nAngle);
var _local2 = Math.cos(_nAngle);
_oOrigin.x = _oOrigin.x + (_nDistance * (_local1 / (Math.abs(_local1) + Math.abs(_local2))));
_oOrigin.y = _oOrigin.y + (_nDistance * (-(_local2 / (Math.abs(_local1) + Math.abs(_local2)))));
return(_oOrigin);
}
static function angleDirection(x1, y1, x2, y2) {
var _local7 = Math.abs(x2 - x1);
var _local6 = lineSize(x1, y1, x2, y2);
var _local1 = Math.asin(_local7 / _local6) * 57.2957795130823;
if ((x2 >= x1) && (y2 >= y1)) {
_local1 = 90 + (90 - _local1);
} else if ((x2 <= x1) && (y2 >= y1)) {
_local1 = _local1 + 180;
} else if ((x2 <= x1) && (y2 <= y1)) {
_local1 = 270 + (90 - _local1);
}
return(_local1);
}
static function lineSize(x1, y1, x2, y2) {
var _local2 = Math.abs(x2 - x1);
var _local1 = Math.abs(y2 - y1);
return(Math.sqrt(Math.pow(_local2, 2) + Math.pow(_local1, 2)));
}
static function circumcenter(l_nX1, l_nY1, l_nX2, l_nY2, l_nX3, l_nY3) {
var _local4 = l_nX2 - l_nX1;
var _local3 = l_nY2 - l_nY1;
var _local6 = l_nX3 - l_nX1;
var _local12 = l_nY3 - l_nY1;
var _local11 = (_local4 * (l_nX1 + l_nX2)) + (_local3 * (l_nY1 + l_nY2));
var _local10 = (_local6 * (l_nX1 + l_nX3)) + (_local12 * (l_nY1 + l_nY3));
var _local5 = 2 * ((_local4 * (l_nY3 + l_nY2)) - (_local3 * (l_nX3 + l_nX2)));
if (_local5 == 0) {
return(0);
}
var _local19 = ((_local12 * _local11) - (_local3 * _local10)) / _local5;
var _local18 = ((_local4 * _local10) - (_local6 * _local11)) / _local5;
var _local20 = (l_nX3 + l_nX1) / 2;
var _local21 = (l_nY3 + l_nY1) / 2;
var _local9 = Math.abs(_local19 - l_nX1);
var _local17 = Math.abs(_local18 - l_nY1);
var _local14 = Math.sqrt(Math.pow(_local9, 2) + Math.pow(_local17, 2));
var _local16 = Math.asin(_local9 / _local14) * 57.2957795130823;
return(_local16 * 2);
}
static function between(small, large, compare, include) {
var _local1 = false;
if (((!isNaN(small)) && (!isNaN(large))) && (!isNaN(compare))) {
if ((include === true) || (include === undefined)) {
if ((small <= compare) && (large >= compare)) {
_local1 = true;
}
} else if ((small < compare) && (large > compare)) {
_local1 = true;
}
}
return(_local1);
}
static function angleBetween(small, large, compare, include) {
var _local1 = false;
if (small < large) {
if ((small <= compare) && (large >= compare)) {
_local1 = true;
}
} else if ((small <= compare) || (large >= compare)) {
_local1 = true;
}
if (include === false) {
if ((small == compare) || (large == compare)) {
_local1 = false;
}
}
return(_local1);
}
static function angleRange(angle1, angle2) {
var _local1 = Math.abs(angle2 - angle1);
return(Math.min(360 - _local1, _local1));
}
static function positionCompare(l_o1, l_o2) {
var _local1 = false;
if ((l_o1 != undefined) && (l_o2 != undefined)) {
_local1 = (l_o2.x2 == l_o1.x1) && (l_o2.y2 == l_o1.y1);
}
return(_local1);
}
static function randomPoint(l_nMin, l_nMax, l_nInterval) {
l_nMax = (l_nMax - l_nMin) * (1 / l_nInterval);
var _local1 = Math.floor(Math.random() * l_nMax);
return((_local1 * l_nInterval) + l_nMin);
}
static function convertNumber(_nValue, _nTotal) {
var _local1 = "";
var _local3 = 36;
var _local2 = 0;
var _local4 = 0;
do {
if (_nValue <= 0) {
break;
}
_local2 = (_nValue % _local3) / (_local3 / 36);
if (_local2 <= 9) {
_local1 = String(_local2) + _local1;
} else {
_local1 = String.fromCharCode(65 + (_local2 - 10)) + _local1;
}
_nValue = _nValue - (_local2 * (_local3 / 36));
_local3 = _local3 * 36;
_local4++;
} while (_local4 <= 5);
while (_local4 > 5) {
}
while (_local1.length < _nTotal) {
_local1 = String("0") + _local1;
}
return(_local1);
}
static function convertAlphaNum(_sValue) {
var _local4 = 0;
var _local1 = 0;
var _local2;
while (_sValue.length > _local1) {
_local2 = _sValue.substr((_sValue.length - 1) - _local1, 1);
if (isNaN(_local2)) {
_local4 = _local4 + (Number(_local2.charCodeAt(0) - 55) * Math.max(1, Math.pow(36, _local1)));
} else {
_local4 = _local4 + (Number(_local2) * Math.max(1, Math.pow(36, _local1)));
}
_local1++;
}
return(_local4);
}
static function drawCircle(_mcRef, _nX, _nY, _nRadius, _nSides, _nBorderThickness, _nBorderColor, _nBorderAlpha, _nFillColor, _nFillAlpha) {
_mcRef.moveTo(_nX, _nY - _nRadius);
_mcRef.lineStyle(_nBorderThickness, _nBorderColor, _nBorderAlpha);
_mcRef.beginFill(_nFillColor, _nFillAlpha);
var _local6;
var _local4;
var _local3;
var _local5;
var _local1;
_local1 = 0;
while (_local1 < _nSides) {
_local6 = ((360 / _nSides) * (_local1 + 1)) % 360;
_local4 = ((_local6 / 360) * Math.PI) * 2;
_local3 = Math.sin(_local4);
_local5 = Math.cos(_local4);
_mcRef.curveTo(_nX + (_local3 * _nRadius), _nY + ((-_local5) * _nRadius), _nX + (_local3 * _nRadius), _nY + ((-_local5) * _nRadius));
_local1++;
}
_mcRef.endFill();
}
static function scatterCircle(_mcRef, _sLinkage, _nX, _nY, _nRadius, _nSides) {
var _local7;
var _local2;
var _local5;
var _local6;
var _local1;
var _local3;
_local1 = 0;
while (_local1 < _nSides) {
_local7 = ((360 / _nSides) * (_local1 + 1)) % 360;
_local2 = ((_local7 / 360) * Math.PI) * 2;
_local5 = Math.sin(_local2);
_local6 = Math.cos(_local2);
_local3 = _mcRef.attachMovie(_sLinkage, _sLinkage + _mcRef.getNextHighestDepth(), _mcRef.getNextHighestDepth());
_local3._x = _nX + (_local5 * _nRadius);
_local3._y = _nY + ((-_local6) * _nRadius);
_local1++;
}
}
static function collisionLineToLine(x1, y1, x2, y2, x3, y3, x4, y4) {
var _local1 = new Object();
_local1.collide = true;
var _local5 = x2 - x1;
var _local4 = y2 - y1;
var _local8 = x4 - x3;
var _local7 = y4 - y3;
var _local3 = (_local5 * _local7) - (_local4 * _local8);
if (_local3 == 0) {
_local1.collide = false;
}
var _local10 = x3 - x1;
var _local9 = y3 - y1;
var _local2 = ((_local10 * _local7) - (_local9 * _local8)) / _local3;
if ((_local2 < 0) || (_local2 > 1)) {
_local1.collide = false;
}
var _local6 = ((_local10 * _local4) - (_local9 * _local5)) / _local3;
if ((_local6 < 0) || (_local6 > 1)) {
_local1.collide = false;
}
if (_local1.collide) {
_local1.x = x1 + (_local2 * _local5);
_local1.y = y1 + (_local2 * _local4);
}
return(_local1);
}
static function collisionSquareToSquare(_nX1, _nX2, _nY1, _nY2, _nLeft, _nRight, _nTop, _nBottom) {
return((((between(_nX1, _nX2, _nLeft, true) && (between(_nX1, _nX2, _nRight, true))) || (between(_nLeft, _nRight, _nX1, true))) || (between(_nLeft, _nRight, _nX2, true))) && (((between(_nY1, _nY2, _nTop, true) && (between(_nY1, _nY2, _nBottom, true))) || (between(_nTop, _nBottom, _nY1, true))) || (between(_nTop, _nBottom, _nY2, true))));
}
}
Symbol 509 MovieClip [__Packages.battlefield.field.FieldTile] Frame 0
class battlefield.field.FieldTile extends library.State
{
var nPosition, aAdjacentTiles, bStart1, bStart2, bObstacle, mcRef;
function FieldTile (_mcRef, _nPosition) {
super(_mcRef);
nPosition = _nPosition;
aAdjacentTiles = new Array();
setState(sSTATE_NONE);
}
function isStart(_nPlayer) {
var _local2 = bStart1;
if (_nPlayer == 1) {
_local2 = bStart2;
}
return(_local2);
}
function setObstacle() {
bObstacle = true;
setState(sSTATE_OBSTACLE);
}
function setStart(_nPlayer) {
if (_nPlayer == 1) {
bStart1 = true;
} else {
bStart2 = true;
}
setState(sSTATE_START);
}
function setState(_sState) {
if (!bObstacle) {
super.setState(_sState);
}
}
function resetDisplay() {
if (!bObstacle) {
super.setState(sSTATE_NONE);
}
}
function addAdjacentTile(_nPosition) {
trace("addAdjacentTile: " + _nPosition);
aAdjacentTiles.push(_nPosition);
}
function isAdjacent(_nPosition) {
}
function adjacentTiles() {
return(aAdjacentTiles);
}
function get isMouseOver() {
return(mcRef.hitTest(_root._xmouse, _root._ymouse));
}
static var sSTATE_ATTACK = "Attack";
static var sSTATE_MOVEMENT = "Movement";
static var sSTATE_REACH = "Reach";
static var sSTATE_START = "Start";
static var sSTATE_OBSTACLE = "Obstacle";
static var sSTATE_NONE = "None";
}
Symbol 510 MovieClip [__Packages.library.Effect] Frame 0
class library.Effect
{
var mcRef, bState;
function Effect (_mcRef, _bState) {
mcRef = _mcRef;
bState = _bState;
}
function enterFrame() {
var _local2 = false;
if (bState) {
if (mcRef.mcState._currentframe == mcRef.mcState._totalframes) {
mcRef.removeMovieClip();
_local2 = true;
}
} else if (mcRef._currentframe == mcRef._totalframes) {
mcRef.removeMovieClip();
_local2 = true;
}
return(_local2);
}
}
Symbol 511 MovieClip [__Packages.teamselect.TeamDisplay] Frame 0
class teamselect.TeamDisplay
{
var mcRef, fOnPress, aCharacters;
function TeamDisplay (_mcRef, _fOnPress) {
mcRef = _mcRef;
fOnPress = _fOnPress;
aCharacters = new Array();
}
function addCharacter(_oCharData) {
aCharacters.push(_oCharData);
displayCharacters();
}
function removeCharacter(_oCharData) {
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if (aCharacters[_local2].sChar == _oCharData.sChar) {
aCharacters.splice(_local2, 1);
break;
}
_local2++;
}
displayCharacters();
}
function isCharacter(_sLinkage) {
var _local3 = false;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
if (aCharacters[_local2].sChar == _sLinkage) {
_local3 = true;
break;
}
_local2++;
}
return(_local3);
}
function displayCharacters() {
}
function get teamValue() {
var _local3 = 0;
var _local2;
_local2 = 0;
while (_local2 < aCharacters.length) {
_local3 = _local3 + aCharacters[_local2].nValue;
_local2++;
}
return(_local3);
}
function get characters() {
return(aCharacters);
}
function get selected() {
var _local4;
var _local3;
_local3 = 0;
while (_local3 < aCharacters.length) {
if (aCharacters[_local3].Mc.hitTest(_root._xmouse, _root._ymouse)) {
_local4 = aCharacters[_local3].sChar;
break;
}
_local3++;
}
return(_local4);
}
var nSPACING = 10;
var nMAX_CHARS = 8;
}
Symbol 512 MovieClip [__Packages.StatisticsScreen] Frame 0
class StatisticsScreen
{
var mcRef, btnBack, btnReset;
function StatisticsScreen (_mcRef) {
mcRef = _mcRef;
btnBack = new library.MCButton(mcRef.btnBack, library.Delegate.create(Main.Instance, Main.Instance.setState, Main.sSTATE_TITLE));
btnReset = new library.MCButton(mcRef.btnReset, library.Delegate.create(this, reset));
init();
}
function enterFrame() {
btnBack.enterFrame();
btnReset.enterFrame();
}
function init() {
var _local2;
var _local4;
var _local5;
var _local3;
_local4 = 0;
while (_local4 < data.DataCharacter.aLIST_CHARACTERS.length) {
_local2 = data.Statistics.getChar(data.DataCharacter.aLIST_CHARACTERS[_local4]);
_local3 = mcRef.mcCharacters.attachMovie(sLINKAGE_CHARACTER, sLINKAGE_CHARACTER + mcRef.mcCharacters.getNextHighestDepth(), mcRef.mcCharacters.getNextHighestDepth());
_local3._y = (_local3._height + nSPACING) * _local4;
_local5 = _local3.mcCharacter.attachMovie(data.DataCharacter.sLINKAGE_SPRITE + _local2.sChar, _local2.sChar, _local3.mcCharacter.getNextHighestDepth());
_local5.gotoAndStop(1);
_local3.txtName.text = data.DataCharacter.getCharacter(_local2.sChar).sName;
_local3.txtKill.text = _local2.nKills;
_local3.txtDeath.text = _local2.nDeaths;
_local3.txtKDRatio.text = Math.round((_local2.nKills * 100) / Math.max(1, _local2.nDeaths)) / 100;
_local3.txtDamageDealt.text = _local2.nDamageDealt;
_local3.txtDamageReceived.text = _local2.nDamageReceived;
_local3.txtVictory.text = _local2.nVictories;
_local3.txtDefeat.text = _local2.nDefeats;
_local3.txtVDRatio.text = Math.round((_local2.nVictories / Math.max(1, _local2.nVictories + _local2.nDefeats)) * 100) + "%";
_local4++;
}
}
function reset() {
data.Statistics.init();
var _local2;
for (_local2 in mcRef.mcCharacters) {
mcRef.mcCharacters[_local2].removeMovieClip();
}
init();
}
static var sLINKAGE_CHARACTER = "mcStatistics_Character";
static var nSPACING = 20;
}
Symbol 513 MovieClip [__Packages.mainmenu.MainMenuCreator] Frame 0
class mainmenu.MainMenuCreator
{
var mcRef, sLinkage, sSubMenu, aMenu;
function MainMenuCreator (_mcRef, _sLinkage) {
mcRef = _mcRef;
sLinkage = _sLinkage;
sSubMenu = "";
aMenu = new Array();
}
function enterFrame() {
var _local2;
_local2 = 0;
while (_local2 < aMenu.length) {
aMenu[_local2].btn.enterFrame();
_local2++;
}
}
function addOption(_sDisplay, _sText, _fFunction) {
var _local2 = new Object();
_local2.sDisplay = _sDisplay;
_local2.sText = _sText;
if (_fFunction != null) {
_local2.fFunction = _fFunction;
} else {
_local2.fFunction = library.Delegate.create(this, displayOptions, _sText);
}
aMenu.push(_local2);
}
function displayOptions(_sDisplay) {
var _local2;
_local2 = 0;
while (_local2 < aMenu.length) {
aMenu[_local2].btn.Mc.removeMovieClip();
delete aMenu[_local2].btn;
_local2++;
}
var _local3;
var _local7 = 0;
var _local6 = 0;
var _local4 = 0;
var _local5 = 0;
_local2 = 0;
while (_local2 < aMenu.length) {
if (aMenu[_local2].sDisplay == _sDisplay) {
_local3 = mcRef.attachMovie(sLinkage, sLinkage + mcRef.getNextHighestDepth(), mcRef.getNextHighestDepth());
_local3._x = _local4;
_local3._y = _local5;
aMenu[_local2].btn = new library.MCDynamicButton(_local3, aMenu[_local2].sText, aMenu[_local2].fFunction);
_local4 = _local4 + nSUB_SPACING_X;
_local5 = _local5 + (nSUB_SPACING_Y + aMenu[_local2].btn.Mc._height);
} else if (aMenu[_local2].sDisplay == sMAIN) {
_local3 = mcRef.attachMovie(sLinkage, sLinkage + mcRef.getNextHighestDepth(), mcRef.getNextHighestDepth());
_local3._x = _local7;
_local3._y = _local6;
aMenu[_local2].btn = new library.MCDynamicButton(_local3, aMenu[_local2].sText, library.Delegate.create(this, clickButton, _local2));
if (aMenu[_local2].sText == _sDisplay) {
aMenu[_local2].btn.selected();
_local4 = (aMenu[_local2].btn.Mc._x + aMenu[_local2].btn.Mc._width) + nSPACING_X;
_local5 = aMenu[_local2].btn.Mc._y;
}
_local7 = _local7 + nSPACING_X;
_local6 = _local6 + (_local3._height + nSPACING_Y);
}
_local2++;
}
}
function clickButton(_nCpt) {
aMenu[_nCpt].fFunction();
}
static var nSPACING_X = 20;
static var nSPACING_Y = 45;
static var nSUB_SPACING_X = 20;
static var nSUB_SPACING_Y = 25;
static var sMAIN = "Menu";
}
Symbol 514 MovieClip [__Packages.library.MCDynamicButton] Frame 0
class library.MCDynamicButton extends library.State
{
var sText, fFunction, mcRef, setState;
function MCDynamicButton (_mcRef, _sText, _fFunction) {
super(_mcRef);
sText = _sText;
fFunction = _fFunction;
unselected();
}
function startIdle() {
mcRef.txtText.text = sText;
}
function startOver() {
mcRef.txtText.text = sText;
}
function startDown() {
mcRef.txtText.text = sText;
}
function startSelected() {
mcRef.txtText.text = sText;
}
function unselected() {
setState(sSTATE_IDLE);
mcRef.onRollOver = library.Delegate.create(this, setState, sSTATE_OVER);
mcRef.onRollOut = library.Delegate.create(this, setState, sSTATE_IDLE);
mcRef.onPress = library.Delegate.create(this, setState, sSTATE_DOWN);
mcRef.onMouseUp = library.Delegate.create(this, setState, sSTATE_IDLE);
mcRef.onRelease = fFunction;
}
function selected() {
setState(sSTATE_SELECTED);
mcRef.onRollOver = undefined;
delete mcRef.onRelease;
mcRef.onRollOut = undefined;
delete mcRef.onRelease;
mcRef.onPress = undefined;
delete mcRef.onRelease;
mcRef.onMouseUp = undefined;
delete mcRef.onRelease;
mcRef.onRelease = undefined;
delete mcRef.onRelease;
}
var sSTATE_IDLE = "Idle";
var sSTATE_OVER = "Over";
var sSTATE_DOWN = "Down";
var sSTATE_SELECTED = "Selected";
}