J'ai fait un script de génerration de population je voulais savoir ce que vous en pensiez... il est pas fini encore, j'ai pas le temps de tout expliquer je reviendrez avec les détails...
struct sIndividu
{
string sTemplate;
int nbrRapport;// 1 pour le premier 2 pour le deuxieme, donc 1 chance sur 3 et 2 chance sur 3
};
//Signie qu'un individu est mort, doit personnaliné le on dead de la créature
void reduirePopulation(string nomPop);
//Naissance d'un individu
void augmenterPopulation(string nomPop);
//Permet d'ajouter un type d'individu a une population, au moins un doit etre specifier
//nomPop : identifiant de la population cible
//structIndividu : structure contenant l'information sur l'individu
void ajouterIndividu(string nomPop, struct sIndividu structIndividu);
//Permet de creer un population precise, se script doit etre utilise une fois
//preference dans une area.
//nomPop : identifiant de la population cible
//maxInd : le maximum d'individu pouvant etre contenu dans cette population
//reproduction : le pourcentage de reproduction a tout les nbrJour specifier
//nbrJour : a tout les combiens de jour la population se reproduit du pourcentage
// reproduction.
void creerPopulation(string nomPop, int maxInd, float reproduction, int nbrJour,int popDepart);
//Ce script permet la reproduction de la population, il doit etre dans une area
//ou la fonction creerPopulation a ete utilise. Elle peut etre utilise soit dans
//le OnHeartbeat ou dans le OnEnter (de preference, et detecter que c'est un pc
//qui entre). Si la population tombe a zero elle ne se reproduit plus.
//nomPop : identifiant de la population cible
void gererPopulation(string nomPop);
//Ce script permet d'ajouter une location ou les individus apparaitrons,
//au moins une location doit etre specifier
void ajouterLocationApparition(string nomPop, location loc);
void ajouterIndividu(string nomPop,struct sIndividu structIndividu)
{
int nbrInd = GetLocalInt(OBJECT_SELF,nomPop + "_individuDiff");
int nbrRapportTotal = GetLocalInt(OBJECT_SELF,nomPop + "_nbrRapportTotal");
nbrInd++;
nbrRapportTotal += structIndividu.nbrRapport;
SetLocalString(OBJECT_SELF,nomPop + "_sTemplate_" + IntToString(nbrInd), structIndividu.sTemplate);
SetLocalInt(OBJECT_SELF,nomPop + "_nbrRapport_" + IntToString(nbrInd),nbrRapportTotal);
SetLocalInt(OBJECT_SELF,nomPop + "_nbrRapportTotal",nbrRapportTotal);
SetLocalInt(OBJECT_SELF,nomPop + "_individuDiff",nbrInd);
}
void creerPopulation(string nomPop, int maxInd, float reproduction, int nbrJour, int popDepart)
{
int i;
SetLocalInt(OBJECT_SELF,nomPop + "_maxIndividu",maxInd);
SetLocalInt(OBJECT_SELF,nomPop + "_nbrJour",nbrJour);
SetLocalFloat(OBJECT_SELF,nomPop + "_reproduction",reproduction);
SetLocalInt(OBJECT_SELF,nomPop + "_dateDernierMAJ",GetCalendarDay());
for(i=0 ; i < popDepart ; i++)
augmenterPopulation(nomPop);
}
void gererPopulation(string nomPop)
{
int reproductionPopulation;
int dateCreation;
int datePresente;
int nbrJourEcoule;
int nbrIndividu;
int maxInd;
int nbrAjoute;
int i;
int y;
int nbrRapportTotal = 0;
string sTemplate = "";
int rapportCourant = 0;
int indiviRand = 0;
int locationRand = 0;
location locApparition;
int indDifferent = GetLocalInt(OBJECT_SELF,nomPop + "_individuDiff");
nbrIndividu = GetLocalInt(OBJECT_SELF,nomPop + "_nbrIndividu");
maxInd = GetLocalInt(OBJECT_SELF,nomPop + "_maxIndividu");
nbrRapportTotal = GetLocalInt(OBJECT_SELF,nomPop + "_nbrRapportTotal");
datePresente = GetCalendarDay();
dateCreation = GetLocalInt(OBJECT_SELF,nomPop + "_dateDernierMAJ");
nbrJourEcoule = datePresente - dateCreation;
reproductionPopulation = nbrJourEcoule / GetLocalInt(OBJECT_SELF,nomPop + "_nbrJour");
nbrAjoute = FloatToInt(reproductionPopulation * GetLocalFloat(OBJECT_SELF,nomPop + "_reproduction") / 100);
if (nbrAjoute + nbrIndividu > maxInd)
nbrAjoute = maxInd - nbrIndividu;
for (i = 0 ; i < nbrAjoute ; i++)
{
augmenterPopulation(nomPop);
}
SetLocalInt(OBJECT_SELF,nomPop + "_dateDernierMAJ",GetCalendarDay());
}
void ajouterLocationApparition(string nomPop, location loc)
{
int nbrLocation = GetLocalInt(OBJECT_SELF,nomPop + "_locationDiff");
nbrLocation++;
SetLocalLocation(OBJECT_SELF,nomPop + "_location_" + IntToString(nbrLocation), loc);
SetLocalInt(OBJECT_SELF,nomPop + "_locationDiff",nbrLocation);
}
void reduirePopulation(string nomPop)
{
int nbrIndividu;
nbrIndividu = GetLocalInt(GetArea(OBJECT_SELF),nomPop + "_nbrIndividu");
nbrIndividu--;
SetLocalInt(GetArea(OBJECT_SELF),nomPop + "_nbrIndividu",nbrIndividu);
SendMessageToPC(GetFirstPC(),"Nbr individu : " + IntToString(nbrIndividu));
}
void augmenterPopulation(string nomPop)
{
int nbrIndividu;
int y;
int nbrRapportTotal = 0;
string sTemplate = "";
int rapportCourant = 0;
int indiviRand = 0;
int locationRand = 0;
location locApparition;
int indDifferent = GetLocalInt(OBJECT_SELF,nomPop + "_individuDiff");
nbrRapportTotal = GetLocalInt(OBJECT_SELF,nomPop + "_nbrRapportTotal");
nbrIndividu = GetLocalInt(GetArea(OBJECT_SELF),nomPop + "_nbrIndividu");
SetLocalInt(GetArea(OBJECT_SELF),nomPop + "_nbrIndividu",nbrIndividu);
SendMessageToPC(GetFirstPC(),"Nbr individu : " + IntToString(nbrIndividu));
indiviRand = Random(nbrRapportTotal) + 1;
SendMessageToPC(GetFirstPC(),"indiviRand" + IntToString(indiviRand));
for (y = 1; y <= indDifferent && sTemplate == "" ; y++)
{
rapportCourant = GetLocalInt(OBJECT_SELF,nomPop + "_nbrRapport_" + IntToString(y));
if (rapportCourant >= indiviRand){
sTemplate = GetLocalString(OBJECT_SELF,nomPop + "_sTemplate_" + IntToString(y));
}
}
locationRand = Random(GetLocalInt(OBJECT_SELF,nomPop + "_locationDiff")) + 1;
locApparition = GetLocalLocation(OBJECT_SELF,nomPop + "_location_" + IntToString(locationRand));
CreateObject(OBJECT_TYPE_CREATURE,sTemplate,locApparition,FALSE);
nbrIndividu++;
SendMessageToPC(GetFirstPC(),"Nbr individu : " + IntToString(nbrIndividu));
sTemplate = "";
SetLocalInt(OBJECT_SELF,nomPop + "_nbrIndividu",nbrIndividu);
}
voici un exemple d'utilisation c'est dans le on enter de la zone
void main()
{
object personnage = GetEnteringObject();
if (GetIsPC(personnage))
{
struct sIndividu individu;
ExecuteScript(tempgivexp,personnage);
individu.sTemplate = "pop_goblin_1";
individu.nbrRapport = 3;
ajouterIndividu("goblin",individu);
individu.nbrRapport = 3;
ajouterIndividu("goblin",individu);
ajouterLocationApparition("goblin",GetLocation(GetObjectByTag("location")));
ajouterLocationApparition("goblin",GetLocation(GetObjectByTag("location2")));
creerPopulation("goblin",2,10.0,1,5);
gererPopulation("goblin");
}
}
la gestion de la reproduction dans gererPopulation n'est pas bonne car elle ne tient pas compte des mois ou année et aussi les pourcentage ne sont pas cumulatif...
Si vous avez des question gêné vous pas je vais revenir demain
p.s. : vous mettez la premier partie dans un fichier et vous faites un include dans les zone désirer et dans le script personnalisé du onDeath de la créature...