no, i want to input some code, and in the code is the name of 2(or 4 in some cases) non-function macros that are replaced with the name of variables or values, but these variable names and values are changed halfway through
here is some code that im using right now (i came up with a solution for what i want to do, but it's slower than if i'd just type the code twice)
Code:
GroupCode(for (x=0, temp2=0;x<NUMGROUP;x++)
{
if (GROUPCHAR[x].set && (GROUPCHAR[x].atb >= 30-GROUPCHAR[x].speed && GROUPCHAR[x].hp > 0))
{
temp = rand()%NUMGROUP2;
if (GROUPCHAR2[temp].hp < 1)
{
while (GROUPCHAR2[temp].hp < 1 && temp2 < NUMGROUP2)
{
temp++;
if (temp >= NUMGROUP2) temp = 0;
temp2++;
}
}
GROUPCHAR[x].atb = 0;
fight(groupchar[x], GROUPCHAR2[temp]);
}
},;);
GroupCode is a macro that prints out the code twice and changes some variables (im hoping that it'll just change the value of some defines though, because the variable solution is slower and now always compatable)
this is GroupCode right now
Code:
#define GroupCode(code, code2) GROUPCHAR = partychar; \
GROUPCHAR2 = enemychar; \
NUMGROUP = NUMPARTY; \
NUMGROUP2 = NUMENEMY; \
code \
code2 \
GROUPCHAR = enemychar; \
GROUPCHAR2 = partychar; \
NUMGROUP = NUMENEMY; \
NUMGROUP2 = NUMPARTY; \
code
groupchar and groupchar2 are pointers to arrays of structures that contain a character's stats
numgroup and numgroup2 are integer variables that contain the maximum amount of enemies or party members
however, this code needs to set some variables, which is slower than if i'd just type it by hand and change which values are being used
what i want it to do is this (using incorrect code, indented to show you where it would go)
Code:
#define GroupCode(code, code2) #define GROUPCHAR partychar \
#define GROUPCHAR2 enemychar \
#define NUMGROUP NUMPARTY \
#define NUMGROUP NUMENEMY \
code \
code2 \
#define GROUPCHAR enemychar \
#define GROUPCHAR2 partychar \
#define NUMGROUP NUMENEMY \
#define NUMGROUP2 NUMPARTY \
code
NUMENEMY and NUMPARTY are defined to be 6 and 4 respectively