Use array to apply effects to a whole team?
#1
Posté 17 janvier 2010 - 11:35
So far I had something like this:
object[] oDeadPeople = GetTeam(2, OBJECT_TYPE_CREATURE);
object oCorpses = oDeadPeople[];
SetCreatureGoreLevel(oCorpses, 1.0);
ApplyEffectVisualEffect(oCorpses, oCorpses, 1127, EFFECT_DURATION_TYPE_PERMANENT, 0.0f);
All the array examples I have seen work with getting 1 item of the array, like the 1st one found, and applying something, so they had 0 between those brackets. If I want all those creatures in team 2, no matter how many, what do I do?
Basically, I want to be able to retrieve team members and give them all a command, or apply something on them (like VFX, or buffs, well you get the idea!).
#2
Posté 18 janvier 2010 - 12:43
wyvern14 wrote...
Mind you, I'm really not familiar with arrays, but from the look of things with functions like object GetTeam, it seems like it would be possible to say, set active a whole team at the same time. The problem is that I don't know how to use them propertly, so I'm looking for help.
So far I had something like this:
object[] oDeadPeople = GetTeam(2, OBJECT_TYPE_CREATURE);
object oCorpses = oDeadPeople[];
SetCreatureGoreLevel(oCorpses, 1.0);
ApplyEffectVisualEffect(oCorpses, oCorpses, 1127, EFFECT_DURATION_TYPE_PERMANENT, 0.0f);
All the array examples I have seen work with getting 1 item of the array, like the 1st one found, and applying something, so they had 0 between those brackets. If I want all those creatures in team 2, no matter how many, what do I do?
Basically, I want to be able to retrieve team members and give them all a command, or apply something on them (like VFX, or buffs, well you get the idea!).
You'd want to setup a for loop, like this:
object[] oDeadPeople = GetTeam(2, OBJECT_TYPE_CREATURE);
int nSize = GetArraySize(oDeadPeople);
int index;
for (index = 0; index < nSize; index++)
{
SetCreatureGoreLevel(oDeadPeople[index] , 1.0);
ApplyEffectVisualEffect(oDeadPeople[index], oDeadPeople[index], 1127, EFFECT_DURATION_TYPE_PERMANENT, 0.0f);
}
EDIT - I tried to find something about loops on the WIKI, but I guess there isn't anything there. You may want to do a Google search on it, just for general purpose knowledge.
Modifié par Challseus, 18 janvier 2010 - 12:49 .
#3
Posté 18 janvier 2010 - 01:37
I can save so much on coding this way, makes my life much easier!





Retour en haut







