Bon et bien voila le resultats de 3 jours de travail.
Inspiré d’un idée de Mercius, j’ai décidé de faire un Panneau Dynamique. Ce système s’adresse a des scripteur ayant un niveau correcte ( bah oui je precise car j'entend deja ceux qui commence juste a scripter me dire comment on fait pour rajouter des fonction o_O) car ce code est un genre de « noyau ». En effet l’idée de Mercius etait de faire un Tableau Dynamique pour savoir qui etait connecte sur le module.
La fonction est realisée sur ce code mais ceci est bien la seule. Car je ne veux pas divulguer ni ses idées sur ce que l’on peux faire ni les miennes d’ailleur J *veux pas voir la meme chose sur tout les module.
Pourquoi ce systeme ne s’adresse pas au newbee en script tres simple vous pouvez tres bien utiliser se systeme mais je doute que les nb scripteur arrive a créer des fonction pour le dynamisme.
Le dynamisme est un dialogue qui permet se créer dynamiquement en fonction de la selection choisi.
Bref je met le code disponible car avec un noyau comme ca sa ouvre de grande porte aussi bien pour les serveurs rp que les arenes ou autre. Comme vous l’aurez compris pour le moment le systeme liste les joueurs connecte et met le nom de leur compte ^^. Tout ceci est reglable bien evidement.
Preliminaire :
- Il vous faut créer une pencarte (enfin un placable) cocher la case utilisable et met le script qui convient dans son OnUsed (ceci si on veux que le systeme marche sur un panneau)
- Ou sinon et bien créer tout betement un objet et mettez le script approprié dans le OnActivateItem des propriete du module.
Création du Dialogue :
Créer un nouveau dialogue et sauvegardez le sous le nom «dynamique» (noter bien que si vous changer le nom du dialogue il vous faudra le changer dans le script du OnUsed du placeable ou celui du onActivateItem)
Le dialogue doit etre comme il suis et pas autrement car sinon sa ne marchera pas !! Le dynamisme requiert une vigilance elevée ^^
[Proprietaire]<CUSTOM2000>
è <CUSTOM2001>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2002>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2003>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2004>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2005>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2006>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2007>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2008>
(ici faire un lien de retour au <CUSTOM2000>)
è <CUSTOM2009>
(ici faire un lien de retour au <CUSTOM2000>)
è Rien. [FIN DE DIALOGUE]
Voila le dialogue est fini (et oui sa ressemble a rien J mais c’est normal
)
Maintenant on va s’occuper du dialogue branche par branche :
Commencons par les actions consequentes :
Il ni a rien a mettre dans celle du proprietaire (<CUSTOM2000>)
Celle de <CUSTOM2001> :
#include "biblio_dial"
void main()
{
int nSelection = 1;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2002> :
#include "biblio_dial"
void main()
{
int nSelection = 2;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2003> :
#include "biblio_dial"
void main()
{
int nSelection = 3;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2004> :
#include "biblio_dial"
void main()
{
int nSelection = 4;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2005> :
#include "biblio_dial"
void main()
{
int nSelection = 5;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2006> :
#include "biblio_dial"
void main()
{
int nSelection = 6;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2007> :
#include "biblio_dial"
void main()
{
int nSelection = 7;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2008> :
#include "biblio_dial"
void main()
{
int nSelection = 8;
ChoixDialogue(nSelection);
}
Celle de <CUSTOM2009> :
#include "biblio_dial"
void main()
{
int nSelection = 9;
ChoixDialogue(nSelection);
}
Bon une bonne chose de fait mais c’est pas fini J ca c’est le cote chiant J
Le Condition d’execution
Celle du propietaire <CUSTOM2000>
#include "biblio_princ"
#include "biblio_demarrage"
int StartingConditional()
{
int nSelection = 0;
int nDemarrage = GetLocalInt(oPJ, "demarrage");
if(!nDemarrage)
{
SetLocalInt(oPJ, "demarrage", 1);
DemarrageConversation();
}
string sLien = GetLocalString(oPJ, "dialogue" + IntToString(nSelection));
if(sLien == "")
{
return FALSE;
}
else
{
SetCustomToken(CUSTOM_TOKEN + nSelection, sLien);
return TRUE;
}
}
Celle de <CUSTOM2001>, <CUSTOM2002> ….jusqu’a <CUSTOM2009>
/!\ Pensez de modifier le script a l’endroit indiqué
#include "biblio_princ"
int StartingConditional()
{
int nSelection = 1; //Laissez 1 pour CUSTOM2001, mettre 2 pour CUSTOM2002 , etc...
string sLien = GetLocalString(oPJ, "dialogue" + IntToString(nSelection));
if(sLien == "")
{
return FALSE;
}
else
{
SetCustomToken(CUSTOM_TOKEN + nSelection, sLien);
return TRUE;
}
}
Les bibliotheques :
Creer un nouveau script pour chacune d’elle et sauvegardés les sous le nom qui ai indiqué dans l’en-tête de chacune d’elles
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
/// A mettre dans un script nouveau et ////
/// l'enregistrer sous : ////
/// biblio_convers ////
///////////////////////////////////////////////////
#include "biblio_list_fnct"
int Construit_Dialogue_Conv(int nCurrent, int nChoix, string sConversation, string sParametre)
{
if(TestStringAgainstPattern(sConversation, "ListeJoueurs"))
{
return LancerListagePJs(nCurrent, nChoix, sParametre);
}
if(TestStringAgainstPattern(sConversation, "Start"))
{
return DemarrerConversation(nCurrent, nChoix, sParametre);
}
return FALSE;
}
void Contruit_Conversation(string sConversation, string sParametre)
{
int nLast;
int nTemp;
int nChoix = 1;
int nCurrent = 1;
int nMatch;
if(TestStringAgainstPattern(sParametre, "precedent"))
{
nCurrent = GetLocalInt(oPJ, "dialprec");
SetLocalString(oPJ, "dialogue9", "-*- Suivant -*-");
SetLocalString(oPJ, "fonction9", "conv_" + sConversation);
SetLocalString(oPJ, "parametre9", "suivant");
SetLocalInt(oPJ, "dialsuivant", nCurrent);
nChoix = 8;
for(;nChoix >= 0; nChoix--)
{
int nTemp1 = nCurrent;
int nTemp2 = nCurrent;
nMatch = nTemp2;
while((nCurrent == nMatch) && (nTemp2 > 0))
{
nTemp2--;
nMatch = Construit_Dialogue_Conv(nTemp2, nChoix, sConversation, sParametre);
}
if(nTemp2 <= 0)
{
SetLocalString(oPJ, "dialogue" + IntToString(nChoix), "");
SetLocalString(oPJ, "fonction" + IntToString(nChoix), "");
SetLocalString(oPJ, "parametre" + IntToString(nChoix), "");
}
nLast = nTemp;
nTemp = nTemp1;
nTemp1 = nMatch;
nCurrent = nMatch;
}
if(nMatch > 0)
{
SetLocalString(oPJ, "dialogue1", "-*- Precedent -*-");
SetLocalString(oPJ, "fonction1", "conv_" + sConversation);
SetLocalString(oPJ, "parametre1", "precedent");
SetLocalInt(oPJ, "dialprec", nLast);
}
Construit_Dialogue_Conv(0, 0, sConversation, sParametre);
}
else
{
Construit_Dialogue_Conv(0, 0, sConversation, sParametre);
//Liste les options en partant du haut
if(sParametre == "")
{
nChoix = 1;
nCurrent = 1;
}
//Si l'option Suivant a ete selectionne
if(TestStringAgainstPattern(sParametre, "suivant"))
{
//Recupere le "numero" de la derniere page
nCurrent = GetLocalInt(oPJ, "dialsuivant");
//Creer le numero de la page precedente
SetLocalInt(oPJ, "dialprec", nCurrent);
//Place l'option Precedente
nChoix = 2;
SetLocalString(oPJ, "dialogue1", "-*- Precedent -*-");
SetLocalString(oPJ, "fonction1", "conv_" + sConversation);
SetLocalString(oPJ, "parametre1", "precedent");
}
//Construit la liste de dialogue
for(;nChoix <= 10; nChoix++)
{
nMatch = Construit_Dialogue_Conv(nCurrent, nChoix, sConversation, sParametre);
//nLast enregistre la derniere page consulte pour pouvoir la rappeler
nLast = nTemp;
nTemp = nMatch;
if(nMatch > 0) { nCurrent = nMatch; }
if(nMatch == 0) { nLast = 0; }
nCurrent++;
}
//Si il y a plus de 10 choix possible creer option Suivant et creer la page suivante
if(nLast > 0)
{
SetLocalString(oPJ, "dialogue9", "-*- Suivant -*-");
SetLocalString(oPJ, "fonction9", "conv_" + sConversation);
SetLocalString(oPJ, "parametre9", "suivant");
SetLocalInt(oPJ, "dialsuivant", nLast);
}
}
}
//////////////////////////////
//// Fonctions Dialogue ////
//////////////////////////////
//Fonction de structuration pour entree des dialogues
/*
int NomDeLaFonction(int nCurrent, int nChoix, string sParametre = "")
{
string sText = "";
string sParole = "";
string sParametreParole = "";
//Entrees du dialogue
switch(nCurrent)
{
case 0:
nCurrent = 0;
sText = "";
sParole = "";
sParametreParole = "";
break;
default:
nCurrent = 0;
sText = "";
sParole = "";
sParametreParole = "";
break;
}
//Enregistre les variables necessaires au dialogue
SetLocalString(oPJ, "dialogue" + IntToString(nChoix), sText);
SetLocalString(oPJ, "fonction" + IntToString(nChoix), sParole);
SetLocalString(oPJ, "parametre" + IntToString(nChoix), sParametreParole);
return nCurrent;
} */
//Fonction de Listage des joueurs connectes
int LancerListagePJs(int nCurrent, int nChoix, string sParametre = "")
{
string sText = "";
string sParole = "";
string sParametreParole = "";
object oPlayer;
int nCache;
if((!TestStringAgainstPattern(sParametre, "suivant")) && (!TestStringAgainstPattern(sParametre, "precedent")))
{
SetLocalString(oPJ, "fonctionpj", sParametre);
int nCount = 1;
oPlayer = GetFirstPC();
while(GetIsObjectValid(oPlayer))
{
SetLocalObject(oPJ, "memoirepj" + IntToString(nCount), oPlayer);
oPlayer = GetNextPC();
nCount++;
}
nCount--;
SetLocalInt(oPJ, "memoirepj", nCount);
}
string sFunc = GetLocalString(oPJ, "fonctionpj");
nCache = GetLocalInt(oPJ, "memoirepj");
switch(nCurrent)
{
case 0:
nCurrent = 0;
sText = "Joueurs connectes";
sParole = "";
sParametreParole = "";
break;
default:
oPlayer = GetLocalObject(oPJ, "memoirepj" + IntToString(nCurrent));
while((! GetIsObjectValid(oPlayer)) && (nCurrent <= nCache))
{
nCurrent++;
oPlayer = GetLocalObject(oPJ, "memoirepj" + IntToString(nCurrent));
}
if(nCurrent > nCache)
{
nCurrent = 0;
sText = "";
sParole = "";
sParametreParole = "";
}
else
{
sText = GetName(oPlayer) + " [" + GetPCPlayerName(oPlayer) + "]";
sParole = sFunc;
sParametreParole = IntToString(nCurrent);
}
break;
}
SetLocalString(oPJ, "dialogue" + IntToString(nChoix), sText);
SetLocalString(oPJ, "fonction" + IntToString(nChoix), sParole);
SetLocalString(oPJ, "parametre" + IntToString(nChoix), sParametreParole);
return nCurrent;
}
int DemarrerConversation(int nCurrent, int nChoix, string sParametre = "")
{
string sText = "";
string sParole = "";
string sParametreParole = "";
switch(nCurrent)
{
case 0:
nCurrent = 0;
sText = "Que voulez-vous faire ?";
sParole = "";
sParametreParole = "";
break;
case 1:
nCurrent = 1;
sText = "Lister les joueurs connectes.";
sParole = "conv_ListeJoueurs";
sParametreParole = "func_AfficherListeJoueur";
break;
default:
nCurrent = 0;
sText = "";
sParole = "";
sParametreParole = "";
break;
}
SetLocalString(oPJ, "dialogue" + IntToString(nChoix), sText);
SetLocalString(oPJ, "fonction" + IntToString(nChoix), sParole);
SetLocalString(oPJ, "parametre" + IntToString(nChoix), sParametreParole);
return nCurrent;
}
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
/// A mettre dans un script nouveau et ////
/// l'enregistrer sous : ////
/// biblio_demarrage ////
///////////////////////////////////////////////////
#include "biblio_list_fnct"
///////////////////////////////////////
//// Appel des fonctions dialogues ////
///////////////////////////////////////
int DemarrerConversation(int nCurrent, int nChoix, string sParametre = "")
{
string sText = "";
string sParole = "";
string sParametreParole = "";
switch(nCurrent)
{
case 0:
nCurrent = 0;
sText = "Que voulez-vous ?";
sParole = "";
sParametreParole = "";
break;
case 1:
nCurrent = 1;
sText = "Lister les joueurs connecte.";
sParole = "conv_ListeJoueurs";
sParametreParole = "func_AfficherListeJoueur";
break;
default:
nCurrent = 0;
sText = "";
sParole = "";
sParametreParole = "";
break;
}
SetLocalString(oPJ, "dialogue" + IntToString(nChoix), sText);
SetLocalString(oPJ, "fonction" + IntToString(nChoix), sParole);
SetLocalString(oPJ, "parametre" + IntToString(nChoix), sParametreParole);
return nCurrent;
}
int Construit_Dialogue_Conv(int nCurrent, int nChoix, string sConversation, string sParametre)
{
if(TestStringAgainstPattern(sConversation, "Start"))
{
return DemarrerConversation(nCurrent, nChoix, sParametre);
}
return FALSE;
}
void Contruit_Conversation(string sConversation, string sParametre)
{
int nLast;
int nTemp;
int nChoix = 1;
int nCurrent = 1;
int nMatch;
if(TestStringAgainstPattern(sParametre, "precedent"))
{
//Creation de l'option selectionne
nCurrent = GetLocalInt(oPJ, "dialprec");
SetLocalString(oPJ, "dialogue9", "-*- Suivant -*-");
SetLocalString(oPJ, "fonction9", "conv_" + sConversation);
SetLocalString(oPJ, "parametre9", "suivant");
SetLocalInt(oPJ, "dialsuivant", nCurrent);
nChoix = 8;
for(;nChoix >= 0; nChoix--)
{
int nTemp1 = nCurrent;
int nTemp2 = nCurrent;
nMatch = nTemp2;
while((nCurrent == nMatch) && (nTemp2 > 0))
{
nTemp2--;
nMatch = Construit_Dialogue_Conv(nTemp2, nChoix, sConversation, sParametre);
}
if(nTemp2 <= 0)
{
SetLocalString(oPJ, "dialogue" + IntToString(nChoix), "");
SetLocalString(oPJ, "fonction" + IntToString(nChoix), "");
SetLocalString(oPJ, "parametre" + IntToString(nChoix), "");
}
nLast = nTemp;
nTemp = nTemp1;
nTemp1 = nMatch;
nCurrent = nMatch;
}
if(nMatch > 0)
{
SetLocalString(oPJ, "dialogue1", "-*- Precedent -*-");
SetLocalString(oPJ, "fonction1", "conv_" + sConversation);
SetLocalString(oPJ, "parametre1", "precedent");
SetLocalInt(oPJ, "dialprec", nLast);
}
Construit_Dialogue_Conv(0, 0, sConversation, sParametre);
}
else
{
Construit_Dialogue_Conv(0, 0, sConversation, sParametre);
//Liste les options en partant du haut
if(sParametre == "")
{
nChoix = 1;
nCurrent = 1;
}
//Si option "Suivant" a ete selectionne
if(TestStringAgainstPattern(sParametre, "suivant"))
{
//Recupere le dernier dialogue
nCurrent = GetLocalInt(oPJ, "dialsuivant");
//Assigner la commande Precedent
SetLocalInt(oPJ, "dialprec", nCurrent);
//Placer en premier choix l'option "Precedent"
nChoix = 2;
SetLocalString(oPJ, "dialogue1", "-*- Precedent -*-");
SetLocalString(oPJ, "fonction1", "conv_" + sConversation);
SetLocalString(oPJ, "parametre1", "precedent");
}
//Boucle pour construire la liste du dialogue
for(;nChoix <= 10; nChoix++)
{
nMatch = Construit_Dialogue_Conv(nCurrent, nChoix, sConversation, sParametre);
//nLast enregistre la derniere page consulte pour pouvoir la rappeler
nLast = nTemp;
nTemp = nMatch;
if(nMatch > 0)
{
nCurrent = nMatch;
}
if(nMatch == 0)
{
nLast = 0;
}
nCurrent++;
}
//Si il y a plus de 10 choix possible creer option Suivant et creer la page suivante
if(nLast > 0)
{
SetLocalString(oPJ, "dialogue9", "-*- Suivant -*-");
SetLocalString(oPJ, "fonction9", "conv_" + sConversation);
SetLocalString(oPJ, "parametre9", "suivant");
SetLocalInt(oPJ, "dialsuivant", nLast);
}
}
}
void DemarrageConversation()
{
if(! GetIsObjectValid(oPJ))
{
return;
}
Contruit_Conversation("Start", "");
}
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
/// A mettre dans un script nouveau et ////
/// l'enregistrer sous : ////
/// biblio_dial ////
///////////////////////////////////////////////////
#include "biblio_princ"
#include "biblio_list_fnct"
#include "biblio_convers"
#include "biblio_fonction"
///////////////////////////////////
//// Mise en place des options ////
///////////////////////////////////
void ChoixDialogue(int nChoix)
{
string sParoleFonction = GetLocalString(oPJ, "fonction" + IntToString(nChoix));
string sParametreParole = GetLocalString(oPJ, "parametre" + IntToString(nChoix));
string sNav = "";
string sStart = GetStringLeft(sParoleFonction, 5);
int nLen = GetStringLength(sParoleFonction) - 5;
string sParole = GetSubString(sParoleFonction, 5, nLen);
if(TestStringAgainstPattern("conv_", sStart))
{
Contruit_Conversation(sParole, sParametreParole);
}
else
{
if(TestStringAgainstPattern("AfficherListeJoueur", sParole))
{
AfficherListeJoueur(sParametreParole);
return;
}
}
}
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
/// A mettre dans un script nouveau et ////
/// l'enregistrer sous : ////
/// biblio_fonction ////
///////////////////////////////////////////////////
#include "biblio_list_fnct"
void AfficherListeJoueur(string sParametre)
{
int nPlayer = StringToInt(sParametre);
int nCache;
int nCount;
object oPlayer = GetLocalObject(oPJ, "memoirepj" + IntToString(nPlayer));
Contruit_Conversation("Start", "");
}
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
/// A mettre dans un script nouveau et ////
/// l'enregistrer sous : ////
/// biblio_list_fnct ////
///////////////////////////////////////////////////
//////////////////////////////////////
//// Bibliotheque des fonctions ////
//////////////////////////////////////
//Construit le niveau de conversation et ajoute les option Suivant et precedent si besoin
void Contruit_Conversation(string sConversation, string sParametre);
//Utiliser par Construit_Conversation pour relier les fonctions avec les noms de dialogue
int Construit_Dialogue_Conv(int nCurrent, int nChoix, string sConversation, string sParametre);
//Lister les joueurs connectes
int LancerListagePJs(int nCurrent, int nChoix, string sParametre = "");
//Demarrer la Conversation
int DemarrerConversation(int nCurrent, int nChoix, string sParametre = "");
//Listage des joueurs pour retour ou poursuivre la conversation
void AfficherListeJoueur(string sParametre);
//Distribu suivant le choix selectionne
void ChoixDialogue(int nChoix);
//Fonction de demarrage de la boucle de dialogue
void DemarrageConversation();
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
/// A mettre dans un script nouveau et ////
/// l'enregistrer sous : ////
/// biblio_princ ////
///////////////////////////////////////////////////
///////////////////////////////////
//// Declration universel ////
///////////////////////////////////
int CUSTOM_TOKEN = 2000;
object oPJ = GetLastSpeaker();
///////////////////////////////////////////////////
///// Dialogue Dynamique ////
///// Cree par Tyrion ////
///// Inspire d'une idee de Mercius ////
///////////////////////////////////////////////////
///// A enregistrer sous : ////
///// fin_conversation ////
///////////////////////////////////////////////////
#include "biblio_princ"
void main()
{
int nCount;
int nCache;
nCache = GetLocalInt(oPJ, "memoirepj");
for(nCount = 1; nCount <= nCache; nCount++)
{
DeleteLocalObject(oPJ, "memoirepj" + IntToString(nCount));
}
DeleteLocalInt(oPJ, "memoirepj");
for(nCount = 1; nCount <= 10; nCount++)
{
DeleteLocalString(oPJ, "dialogue" + IntToString(nCount));
DeleteLocalString(oPJ, "fonction" + IntToString(nCount));
DeleteLocalString(oPJ, "parametre" + IntToString(nCount));
}
DeleteLocalString(oPJ, "fonctionpj");
DeleteLocalInt(oPJ, "demarrage");
}
Fin des bibliotheques. Certain dirons que c’est lourd mais c’est prevu pour eclaircir les codes et s’y retrouver dans les codes lorsqu’on a beaucoup de fonction (ben oui la y en a une et c’est a vous de faire les autres)