Edit: I've solved this myself.
Firstly, and most obviously, I had a brain fart and forgot to add brackets to my function imports. This fixed that problem.
I was then making the mistake of thinking char.FaceDirection could check, as well as set, the direction, but I was wrong. This error was fixed by checking which animation loop the characters are using.
As you were.
Hello, me again.
I know there is already a thread about this, but I couldn't figure out a way to apply it to this specific situation and I'm stumped.
I'm trying to create a pair of global functions that will allow the player to shoot another character, who then dies. This occurs repeatedly in various bits of the game, so I want to do this globally rather than one at a time, for efficiency.
I'm creating and importing two functions: shoot() and zombie_die(). shoot() handles the player shooting the zombie and associated variables, while zombie_die() handles the zombie's death animation and associated variables. shoot() will be called when the player interacts with the zombie with a gun inventory item equipped; the zombie_die() function is then called within shoot(), so I've made sure zombie_die() is above shoot() in the global script.
However, when I go to run the game, I get the error "Type of identifier differs from original description" pointing to the zombie_die() function in the global script.
The error still occurs if I comment out literally the entire section of code inside function, so it's definitely something to do with the function itself.
Header script:
import function zombie_die;
import function shoot;
Global script:
function zombie_die()
{
if (cZombie.FaceDirection==eDirectionDown)
{
cZombie.ChangeView(12);
cZombie.Animate(0, 5, eOnce, eBlock, eForwards);
cZombie.FollowCharacter(null);
zombie_dead=true;
}
else if (cZombie.FaceDirection==eDirectionLeft)
{
cZombie.ChangeView(12);
cZombie.Animate(1, 5, eOnce, eBlock, eForwards);
cZombie.FollowCharacter(null);
zombie_dead=true;
}
else if (cZombie.FaceDirection==eDirectionRight)
{
cZombie.ChangeView(12);
cZombie.Animate(2, 5, eOnce, eBlock, eForwards);
cZombie.FollowCharacter(null);
zombie_dead=true;
}
else
{
cZombie.ChangeView(12);
cZombie.Animate(3, 5, eOnce, eBlock, eForwards);
cZombie.FollowCharacter(null);
zombie_dead=true;
}
function shoot()
{
if (ammo<1)
{
SetSpeechStyle(eSpeechLucasarts);
cPlayer.Say("I'm out of ammo!");
SetSpeechStyle(eSpeechSierra);
}
else
{
cPlayer.FaceCharacter(cZombie);
if (player.FaceDirection==eDirectionDown)
{
cPlayer.ChangeView(13);
cPlayer.Animate(0, 3, eOnce, eBlock, eForwards);
ammo=ammo-1;
cPlayer.ChangeView(4);
zombie_die();
cZombie.FollowCharacter(null);
}
else if (player.FaceDirection==eDirectionLeft)
{
cPlayer.ChangeView(13);
cPlayer.Animate(1, 3, eOnce, eBlock, eForwards);
ammo=ammo-1;
cPlayer.ChangeView(4);
zombie_die();
cZombie.FollowCharacter(null);
}
else if (player.FaceDirection==eDirectionRight)
{
cPlayer.ChangeView(13);
cPlayer.Animate(2, 3, eOnce, eBlock, eForwards);
ammo=ammo-1;
cPlayer.ChangeView(4);
zombie_die();
cZombie.FollowCharacter(null);
}
else
{
cPlayer.ChangeView(13);
cPlayer.Animate(3, 3, eOnce, eBlock, eForwards);
ammo=ammo-1;
cPlayer.ChangeView(4);
zombie_die();
cZombie.FollowCharacter(null);
}
}
}
I'm sure this isn't the most efficient code but I can't fathom any reason why it shouldn't work - so clearly I'm missing something blindingly obvious. Any help appreciated!
Just for reference, this error happens because internally, function is treated as int, so you used a line that tried to import an integer variable.