___________________________________________
############################################################################################
ERROR in action number 1
of Step Event0 for object oBattle:
Invalid callv target #2
at gml_Object_oBattle_Step_0 (line 1) - battleState();
############################################################################################
gml_Object_oBattle_Step_0 (line 1)
This is the error i keep getting ive gone through so many times and i cant understand to why it wont work heres my code
instance_deactivate_all(true);
units = [];
turn = 0;
unitTurnOrder = [];
unitRenderOrder = [];
turnCount = 0;
roundCount = 0;
battleWaitTimeFrames = 30;
battleWaitTimeReamining = 0;
currentUser = noone;
currentAction = -1;
currentTargets = noone;
//Make enemies
for (var i = 0; i < array_length(enemies); i++)
{
enemyUnits[i] = instance_create_depth(x+250+(i*0), y+60+(i*25), depth-10, oBattleUnitEnemy, enemies[i]);
array_push(units, enemyUnits[i]);
}
//Make party
for (var i = 0; i < array_length(global.party); i++)
{
partyUnits[i] = instance_create_depth(x+60+(i*0), y+48+(i*25), depth-10, oBattleUnitPC, global.party[i]);
array_push(units, partyUnits[i]);
}
//Shuffle turn order
unitTurnOrder = array_shuffle(units);
//Get render order
RefreshRenderOrder = function()
{
unitRenderOrder = [];
array_copy(unitRenderOrder,0,units,0,array_length(units));
array_sort(unitRenderOrder,function(_1, _2)
{
return _1.y - _2.y;
});
}
RefreshRenderOrder();
function BattleStateSelectAction()
{
//Get current unit
var _unit = unitTurnOrder[turn];
//is the unit dead or unable to act
if (!instance_exists(_unit)) || (_unit.hp <= 0)
{
battleState = BattleStateVictoryCheck;
exit;
}
//Select an action to perform
BeginAction(_unit.id, global.actionLibrary.attack, _unit.id);
}
function BeginAction(_user, _action, _targets)
{
currentUser = _user;
currentAction = _action;
currentTargets = _targets;
if(!is_array(currentTargets)) currentTargets = [currentTargets];
battleWaitTimeReamining = battleWaitTimeFrames;
with (_user)
{
acting = true;
//play user animation if it is defined for that action, and that user
if (!is_undefined(_action[$ "userAnimation"])) && (!is_undefined(_user.sprites[$ _action.userAnimation]))
{
sprite_index = sprites[$ _action.userAnimation];
image_index = 0;
}
}
battleState = BattleStatePerformAction;
}
function BattleStatePerformAction()
{
//if animation etc is still playing
if (currentUser.acting)
{
//when it ends, perform action effect if it exists
if(currentUser.image_index >= currentUser.image_number - 1)
{
with (currentUser)
{
sprite_index = sprites.idle;
image_index = 0;
acting = false;
}
if (variable_struct_exists(currentAction, "effectSprite"))
{
if (currentAction.effectOnTarget == MODE.ALWAYS) || ( (currentAction.effectOnTarget == MODE.VARIES) && (array_length(currentTargets) <= 1) )
{
for (var i = 0; i < array_length(currentTargets); i++)
{
instance_create_depth(currentTargets[i].x,currentTargets[i].y,currentTargets[i].depth-1,oBattleEffect,{sprite_index : currentAction.effectSprite});
}
}
else //play it at 0,0
{
var _effectSprite = currentAction.effectSprite
if (variable_struct_exists(currentAction, "effectSpriteNoTarget")) _effectSprite = currentAction.effectSpriteNoTarget;
instance_create_depth(x,y,depth-100,oBattleEffect,{sprite_index : _effectSprite});
}
}
currentAction.func(currentUser, currentTargets);
}
}
else //wait for delay and then end the turn
{
if (!instance_exists(oBattleEffect))
{
battleWaitTimeReamining--
if (battleWaitTimeReamining == 0)
{
battleState = BattleStateVictoryCheck();
}
}
}
}
function BattleStateVictoryCheck()
{
battleState = BattleStateTurnProgression;
}
function BattleStateTurnProgression()
{
turnCount++;
turn++;
//loop turns
if (turn > array_length(unitTurnOrder) - 1)
{
turn = 0;
roundCount++;
}
battleState = BattleStateSelectAction;
}
battleState = BattleStateSelectAction;