Bienvenue sur JeuxOnLine - MMO, MMORPG et MOBA !
Les sites de JeuxOnLine...
 

Panneau de contrĂ´le

Recherche | Retour aux forums

JOL Archives

Script rencontres aléatoires

Par Aelthys le 2/10/2002 Ă  14:39:41 (#2270248)

Bon, j'ai récupéré un script qui génère des rencontres aléatoires en fonction du niveau du groupe de PJs. J'essaie de l(utiliser... Et çà plante. Le voilà. Je le place sur le OnEnter de la zone:

void SpawnCreatures(int Mode, string ResRef, string SpawnWP,int Count, int NumWP);
void main()
{
//** Figures the total levels in the party
int PCLevels = 0; //what is the total level of all players
int NumPCs = 0; //how many players are here?
int CurrPCLvl = 0; //track the current PC to determine highest level
string sPCLevels;
string sNum;
object oPC = GetFirstPC();
while (oPC!=OBJECT_INVALID)
{
CurrPCLvl = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC);
PCLevels += CurrPCLvl;
oPC=GetNextPC();
NumPCs++;
sPCLevels = IntToString(PCLevels);
sNum = IntToString(NumPCs);
}
//** Replace the variables below with the resrefs and CR or HD of the monsters in the spawn
//** Replace Difficulty with the multiplier you want for the encounter (2.0 will spawn twice the Party Levels)
string MonOne = "NW_PANTHER" ; float MLOne = 1.0; //resref and CR/HD spawn1
string MonTwo = "NW_OLDWARRA" ; float MLTwo = 2.0; //resref and CR/HD spawn2
string MonThree = "NW_OLDMAGEA" ; float MLThree = 4.0;//resref and CR/HD spawn3
string MonFour = "NW_OLDCHIEFB" ; float MLFour = 4.0; //resref and CR/HD spawn4
float Difficulty = 2.0; //Difficulty Multiplier
int SOne;int STwo;int SThree;int SFour; //Stores end # of each spawn
float TL = IntToFloat(PCLevels); //convert Levels for math
float Temp; //work variable
TL = TL * Difficulty; //apply multiplier
//** This part tries to spawn about the same number of HD in each group
//** Can be replaced with whatever you want your spawn determination to be
if (MLFour <= (TL / 4.0)) //if MonFour is not too big...
{
Temp = (TL / 4.0) / MLFour; //figures how many of MonFour it would take to
SFour = FloatToInt(Temp); //make 1/4 of the encounter, set SFour = # to
TL = TL - (SFour * MLFour); //spawn, decrement TL that many levels
}
if (MLThree <= (TL / 3.0)) //if MonThree not too big...
{
Temp = (TL / 3.0) / MLThree; //how many MonThree are 1/3 of TL
SThree = FloatToInt(Temp); //set SThree
TL = TL - (SThree * MLThree); //decrement TL
}
if (MLTwo <= (TL / 2.0)) //if MonTwo not too big...
{
Temp = (TL / 2.0) / MLTwo; //how many MonTwo are 1/2 of TL
STwo = FloatToInt(Temp); //set STwo
TL = TL - (STwo * MLTwo); //decrement TL
}
Temp = TL / MLOne; //divide TL by the HD of MonOne
SOne = FloatToInt(Temp); //set SOne
//** This part spawns the creatures, as determined above
SpawnCreatures(0, MonOne, "SP_01", SOne, 4); //Spawn SOne MonOne at WP Tag in the middle
SpawnCreatures(1, MonTwo, "SP", STwo, 4); //Spawn MonTwo
SpawnCreatures(2, MonThree, "SP", SThree, 4); //Spawn MonThree
SpawnCreatures(3, MonFour, "SP", SFour, 4); //Spawn MonFour
}
void SpawnCreatures (int Mode, string ResRef, string SpawnWP, int Count, int NumWP)
{
if (Mode == 0) //Mode 0 spawns the whole group
{ //at the given waypoint. NumWP
int curCnt = 0; //NumWP is not used in this mode
object WP = GetWaypointByTag(SpawnWP);
location Loc = GetLocation(WP);
for (curCnt = 0; curCnt < Count; curCnt++)
{
CreateObject(OBJECT_TYPE_CREATURE, ResRef, Loc);
}
}
if (Mode == 1) //Mode 1 spreads the group as
{ //evenly as possible over NumWP
int Spread = 0; //waypoints. They need to be named
int curCnt = 0; //XXX_01 thru XXX_0(NumWP)
string WPT;
object WP;
location Loc;
for (curCnt = 0; curCnt NumWP)
{
Spread = 1;
}
WPT = SpawnWP + "_0" + (IntToString(Spread));
WP = GetWaypointByTag(WPT);
Loc = GetLocation(WP);
CreateObject(OBJECT_TYPE_CREATURE, ResRef, Loc);
}
}
if (Mode == 2) //Mode 2 spreads the group randomly
{ //over NumWP waypoints.
int Spread; //Each creature has an equal chance
int curCnt = 0; //to go to each WP
string WPT; //WPs named as in Mode 1
object WP;
location Loc;
for (curCnt = 0; curCnt < Count; curCnt++)
{
Spread = (Random(NumWP) + 1);
WPT = SpawnWP + "_0" + (IntToString(Spread));
WP = GetWaypointByTag(WPT);
Loc = GetLocation(WP);
CreateObject(OBJECT_TYPE_CREATURE, ResRef, Loc);
}
}
if (Mode == 3) //Mode 3 spawns the group at one of
{ //the specified waypoints, determined
int Spread = (Random(NumWP) + 1); //randomly
int curCnt = 0; //WPs named as in Mode 1 & 2
string WPT = SpawnWP + "_0" + (IntToString(Spread));
object WP = GetWaypointByTag(WPT);
location Loc = GetLocation(WP);
for (curCnt = 0; curCnt < Count; curCnt++)
{
CreateObject(OBJECT_TYPE_CREATURE, ResRef, Loc);
}
}
}

Si vous savez ou est le problème...

Par callgirl le 2/10/2002 Ă  17:21:38 (#2270976)

Est ce qu'il compil ton scripte ? sinon c quoi l'erreur ?

Par Aelthys le 2/10/2002 Ă  18:25:30 (#2271400)

Provient du message de callgirl
Est ce qu'il compil ton scripte ? sinon c quoi l'erreur ?


Il compile comme il faut. Le seul problème c'est que le jeu freeze au momet du changement de zone.

JOL Archives 1.0.1
Par Mind