It actually has nothing to do with my other thread; I was going to have races coded 100% externally (now I'm just parsing through race configuration data, looks pretty though!). This one is referring to executing functions.
Let me clarify my problem for you then (I tried to in my first post), to avoid the XY problem. I'll assume you have a basic understand of a warcraft mod.
Each race in my mod is nothing more than an .inl file with functions and declarations. Each race file needs to have functions that need to be executed based on various events. These events are basic: player_attack, player_spawn, player_jump, etc.
Here's the question: how do you know which event to execute? Each player has nothing more than a number to discern his/her race. I can do something like:
PHP Code:
public event_player_killed(victim, attacker, shouldgib)
{
nwc_checkChangeRace(victim);
if (P_DATA[attacker][PB_HAS_ATTACK]) {
switch(P_DATA[attacker][P_RACE]) {
case EVERY_RACE_WITH_ATTACK_SKILL?!
}
}
}
However, if I can simply format a function call, I can (knowing beforehand that I've formatted the function names correctly) merely do this:
PHP Code:
public event_player_killed(victim, attacker, shouldgib)
{
nwc_checkChangeRace(victim);
if (P_DATA[attacker][PB_HAS_ATTACK]) {
new szAttackSkill[50];
format(szAttackSkill, charsmax(szAttackSkill), "%i_attack", P_DATA[attacker][P_RACE]);
callFunc(szAttackSkill);
}
}
*Edit
So after more snooping I found the callfunc native. Why would this not be the perfect solution? Let's find out & read some more.