I just need some help in figuring out a new way to script this.
Ok, let's say that, in my game, I have about 10 (or possibly many more) characters, any one of which could be the player character at any given time. Every character in the game has it's own default interactions, but for the player character, I have a specific set of interactions I'd like to use.
I could script it like this:
function cZachary_Interact()
{
if (player.ID == cZachary.ID) {
DisplayMessage(998);
}
else {
cZachary.Say ("Pervert!");
}
}
I already know that this will work just fine. It will take extra scripting efforts, having to go through every interaction on every possible character that could be the player, and inputting the "(player.ID == character.ID)" if/else statement.
However, what if there is an interaction that's available for the player character, but isn't available for that specific character alone?
function cZachary_Talk()
{
if (player.ID == cZachary.ID) {
DisplayMessage(997);
}
else {
// do nothing
}
}
The only reason why this poses a problem in my game is because of my interaction interface; it's a verb coin-kind of deal. I use the IsInteractionAvailable command to enable, or disable certain buttons on the verb coin. If I use the above codes, and I click on a character who isn't the player character, and that character doesn't posess a specific interaction (like the "talk to" interaction listed above), the button would still show up on the verb coin, but upon clicking on it, it does absolutely nothing.
So, I suppose that I could start by making a function for each interaction that is unique to the player character, but how would I go about making AGS ignore the character's default interactions, and just focus on the player interactions?
EDIT: Sorry I wasted the bandwidth to post this... about an hour or so after I posted this, I finally came up with an idea to solve my problem.
One approach would be to modify on_mouse_click so that rather than just calling ProcessClick all the time, it checks if the click was on the player character and if so processes the player character specific interactions instead.
That's sort of what I did to fix it. In the script that checks for interactions, I put an if statement to check if you're clicking on the player character beforehand, which if true, will activate the proper buttons on the verb coin, followed by an else statement, with the code that checks for available interactions.
Then, on each of the verb coin's buttons, I did basically the same thing. I set them to run a check if the character in question is the player. That would execute the player's interactions.
Thanks for the advice. :)