Gestion du temps

Répondre
Partager Rechercher
Bonjour à tous,

est ce que vous savez si il existe des sets de scripts qui permettent de gérer le passage du temps en monde permanent ? Par exemple, qui permet de déterminer qu'un personnage joueur a parler a un PNJ depuis plus de 24 heures, heures de jeu ou heure réelle?

Ou bien qu'un PJ a 10 minutes pour réaliser une quête, ou bien que le PJ a gagner 10% de son or en 24 heures IRL suite a un bon placement à la banque, par exemple....

Merci d'avance à tous :-)
Hélas, je n'arrive pas a faire fonctionner les scripts que j'ai trouvé...

La base de ce que je voudrais, c'est un ga_set_delay, qui permette de poser un délai variable permanent, et un gc_check_delay, qui permette de dire si TRUE/FALSE ce délai est expiré.
J'ai les scripts de base, mais je n'arrive pas à en faire un ga et un gc qui fonctionnent :-(

Voilà les scripts....



Code:
 
//::///////////////////////////////////////////////
//:: Name: eds_include
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    ENHANCED DELAY SYSTEM -
    Version: 1.1
    This system was developed, in part, to allow
        for long delays without the lag and CPU
        usage associated with the DelayCommand
        function.  The only difference with this
        system is that it's check-based.  Normal
        delays occur the moment the time has
        finished.  Delays using this system are
        activated once the check (verify if the
        delay has finished) has been made.
    To see the system in action, and/or how to
        implement it yourself check out the test
        module.
    Persistent delays are now supported!  This
        ability was added to help preserve lengthy
        delays used by this system.  In order to
        use this option, your module needs to use
        persistent time (system included in the
        test module).  Delays using this feature
        will resume where they left off (i.e
        server crash or restart).
    SYSTEM UPDATES -
    Version 1.1
        * Added support for persistent delays.
    Version 1.0
        * Initial release.
    //===================== VARIABLE CONFIGURATIONS ======================\\
    Set the following variable to:  Module Properties ->
        Advanced -> Minutes/Hour value.
        */const int MINUTES_PER_HOUR = 5;/*
    The following variables refer to the DB names
        used to store system-specific information.
        Edit these at will.
        */const string EDS_DB_MAIN = "EDS_MAIN";
          const string EDS_DB_TIME = "EDS_TIME";/*
    //====================================================================\\
*/
//:://////////////////////////////////////////////
//:: Created By: Adam Walenga
//:: Created On: September 9th, 2004
//:://////////////////////////////////////////////
//EDS_SetDelay -
//Sets a new delay for the specified object.
//    oObject: This is the object used to store the delay.
//    sVar: This is the variable name to refer to the delay with.
//    fDelay: This is the delay to apply.
//    iPersist: This enables/disables persistency for the delay.  Should only
//        be enabled for long delays (spanning one or more NWN days).
void EDS_SetDelay(object oObject, string sVar, float fDelay, int iPersist = TRUE);
void EDS_SetDelay(object oObject, string sVar, float fDelay, int iPersist)
{
    //=========================== CALCULATE TIME =========================\\
    int iTotal = (GetCalendarMonth() * 2592000) + (GetCalendarDay() * 86400) +
        (GetTimeHour() * (MINUTES_PER_HOUR * 60)) + (GetTimeMinute() * 60) +
        GetTimeSecond() + FloatToInt (fDelay);
    //======================= STORE TIME VARIABLES =======================\\
    if (iPersist)
    {
        SetCampaignInt(EDS_DB_MAIN, sVar + "_Year", GetCalendarYear(), oObject);
        SetCampaignInt(EDS_DB_MAIN, sVar + "_Time", iTotal, oObject);
    }
    else  //Delay is not to be stored for persistency (only locally).
    {
        SetLocalInt(oObject, sVar + "_Year", GetCalendarYear());
        SetLocalInt(oObject, sVar + "_Time", iTotal);
    }
}
//EDS_CheckDelay -
//Checks the current delay, and returns TRUE or FALSE based on whether or not
//the delay time has passed.
//    oObject: This is the object with the stored delay saved to it.
//    sVar: This is the variable name for the specific delay.
int EDS_CheckDelay(object oObject, string sVar);
int EDS_CheckDelay(object oObject, string sVar)
{
    int iBeginYear = GetCampaignInt(EDS_DB_MAIN, sVar + "_Year", oObject);
    int iBeginTotal;
    //Determine if delay was flagged as persistent.
    if (iBeginYear != 0)
        iBeginTotal = GetCampaignInt(EDS_DB_MAIN, sVar + "_Time", oObject);
    else  //Delay has not been flagged as persistent.  Retrieve local values.
    {
        iBeginYear = GetLocalInt(oObject, sVar + "_Year");
        iBeginTotal = GetLocalInt(oObject, sVar + "_Time");
    }
    //=========================== CALCULATE TIME =========================\\
    int iEndTotal = ((GetCalendarYear() - iBeginYear) * 31104000) +
        (GetCalendarMonth() * 2592000) + (GetCalendarDay() * 86400) +
        (GetTimeHour() * (MINUTES_PER_HOUR * 60)) + (GetTimeMinute() * 60) +
        GetTimeSecond();
    //Determine if the delay has passed.
    return (iEndTotal >= iBeginTotal);
}
//****************************************************************************\\
//****************************** TIME FUNCTIONS ******************************\\
//****************************************************************************\\
//Time_Load -
//Used for OnModuleLoad events.  This script will update the module time
//    for persistency.
void Time_Load()
{
    //Determine if there is a time period stored that we can load from.
    if (GetCampaignInt(EDS_DB_TIME, "Time_Initialized"))
    {
        int iYear   = GetCampaignInt(EDS_DB_TIME, "Time_Year");
        int iMonth  = GetCampaignInt(EDS_DB_TIME, "Time_Month");
        int iDay    = GetCampaignInt(EDS_DB_TIME, "Time_Day");
        int iHour   = GetCampaignInt(EDS_DB_TIME, "Time_Hour");
        int iMinute = GetCampaignInt(EDS_DB_TIME, "Time_Minute");
        int iSecond = GetCampaignInt(EDS_DB_TIME, "Time_Second");
        int iMilli  = GetCampaignInt(EDS_DB_TIME, "Time_Milli");
        //Update module calendar and time.
        SetCalendar(iYear, iMonth, iDay);
        SetTime(iHour, iMinute, iSecond, iMilli);
    }
    else  //First time initializing time for the module.
    {
        SetCampaignInt (EDS_DB_TIME, "Time_Initialized", TRUE);
        //Store current module time to be used in the future.
        SetCampaignInt(EDS_DB_TIME, "Time_Year", GetCalendarYear());
        SetCampaignInt(EDS_DB_TIME, "Time_Month", GetCalendarMonth());
        SetCampaignInt(EDS_DB_TIME, "Time_Day", GetCalendarDay());
        SetCampaignInt(EDS_DB_TIME, "Time_Hour", GetTimeHour());
        SetCampaignInt(EDS_DB_TIME, "Time_Minute", GetTimeMinute());
        SetCampaignInt(EDS_DB_TIME, "Time_Second", GetTimeSecond());
        SetCampaignInt(EDS_DB_TIME, "Time_Milli", GetTimeMillisecond());
    }
}
//Time_Update -
//This function, when called, while update the current module time and re-save
//    any values that have changed.
//Note: Time stored in the DB is updated once every NWN hour.
void Time_Update()
{
    int iHour   = GetTimeHour();
    int iMinute = GetTimeMinute();
    int iSecond = GetTimeSecond();
    int iMilli  = GetTimeMillisecond();
    //Update current module time.  There are two reasons for doing this:
    //    1. Large modules can be CPU intensive, slowing down time progress.
    //    2. Work-around for the known bug when changing time via scripts.
    SetTime(iHour, iMinute, iSecond, iMilli);
    //Every hour time is re-saved to the DB.
    if (iHour == GetCampaignInt(EDS_DB_TIME, "Time_Hour"))
        return;
    int iYear  = GetCalendarYear();
    int iMonth = GetCalendarMonth();
    int iDay   = GetCalendarDay();
    //Update the module calendar.
    SetCampaignInt(EDS_DB_TIME, "Time_Year", iYear);
    SetCampaignInt(EDS_DB_TIME, "Time_Month", iMonth);
    SetCampaignInt(EDS_DB_TIME, "Time_Day", iDay);
    SetCampaignInt(EDS_DB_TIME, "Time_Hour", iHour);
    SetCampaignInt(EDS_DB_TIME, "Time_Minute", iMinute);
    SetCampaignInt(EDS_DB_TIME, "Time_Second", iSecond);
    SetCampaignInt(EDS_DB_TIME, "Time_Milli", iMilli);
}
Code:
 
//::///////////////////////////////////////////////
//:: Name: eds_mod_heartbeat
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Heartbeat script for the module.
    This script will continually update the time
        in the DB to maintain persistency.
*/
//:://////////////////////////////////////////////
//:: Created By: Adam Walenga
//:: Created On: September 15th, 2004
//:://////////////////////////////////////////////
#include "eds_include"
void main()
{
    //Update time for the module (where necessary).
    Time_Update();
}
Code:
 
//::///////////////////////////////////////////////
//:: Name: eds_mod_load
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    OnLoad event for the module.
    This script will setup the current time for
        the module (i.e. persistency).
*/
//:://////////////////////////////////////////////
//:: Created By: Adam Walenga
//:: Created On: September 15th, 2004
//:://////////////////////////////////////////////
#include "eds_include"
void main()
{
    //Load the last saved time (for persistency).
    Time_Load();
}
Encore une fois, ces scripts me premettraient de mettre en place le système d'écrivain avançé pour frontières, ainsi qu'un rudiment de gestion de domaine...

Help, please :-(
Pour ce genre de besoin, je pense que tu devrai travailler avec une variable calculée représentant le temps total écoulé en secondes.

Je m'explique:

Ton temps est sauvegardé en plusieurs variables:

Code:
int iYear   = GetCampaignInt(EDS_DB_TIME, "Time_Year");
int iMonth  = GetCampaignInt(EDS_DB_TIME, "Time_Month");
int iDay    = GetCampaignInt(EDS_DB_TIME, "Time_Day");
int iHour   = GetCampaignInt(EDS_DB_TIME, "Time_Hour");
int iMinute = GetCampaignInt(EDS_DB_TIME, "Time_Minute");
int iSecond = GetCampaignInt(EDS_DB_TIME, "Time_Second");
Pour ton besoin, tu va calculer le temps passé en secondes qu'on va appeler le Timestamp:
Code:
int iTimestamp = iSecond +
                 iMinute*60 +
                 iHour*60*60 +
                 iDay*60*60*24 +
                 iMonth*60*60*24*28 +
                 iYear*60*60*24*28*12;
Ensuite, pour calculer ton temps de délai, il te suffit d'ajouter ce délai au Timestamp préalablement calculé, et de le sauvegarder dans une variable locale.
Dans ta condition d'exécution du dialogue, il te suffira de recalculer le Timestamp actuel, et de le comparer au Timestamp de délai stocké.

PS: Vu l'heure, j'ai peut être fait des erreurs de calcul
Voici un premier jet, mais je n'ai encore rien testé... à voir demain.
Code PHP:

/* ga_delaystart
 C'est ici que le chronomètre est enclenché, on stocke les données du calendrier
 sous un nom ( ex : "quest01") de façon spécifique pour un joueur.
*/
void main(string sVar)
{
 
object oPC GetPCSpeaker();
 
int nYear GetCalendarYear();
 
int nMonth GetCalendarMonth();
 
int nDay GetCalendarDay();
 
int nHour GetTimeHour();
 
int nMinute GetTimeMinute();
 
int nSecond GetTimeSecond();
 
  
SetCampaignInt("Start_DB_"+sVar,"nYear",nYearoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nMonth",nMonthoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nDay",nDayoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nHour",nHouroPC);
  
SetCampaignInt("Start_DB_"+sVar,"nMinute",nMinuteoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nSecond",nSecondoPC);
  
SetCampaignInt("Start_DB_"+sVar,"bFirstUse",1oPC);

Code PHP:

/*gc_delaycheck
 Entrer un nom concernant le délai ( exemple : "quest01"), ainsi que la durée totale du délai.
*/
int StartingConditional(string sVarint pSecondsint pMinutes=0int pHours=0int pDays=0int pMonths=0int pYears=0)
{
 
object oPC GetPCSpeaker();
 
int rSecondsrMinutesrHoursrDaysrMonthsrYears;
 
 
rSeconds pSeconds GetCampaignInt("Start_DB_"+sVar,"nSecond",oPC);
 if ( 
pMinutes!=0)  rMinutes pMinutes GetCampaignInt("Start_DB_"+sVar,"nMinute",oPC);
 if ( 
pHours!=0)  rHours pHours GetCampaignInt("Start_DB_"+sVar,"nHour",oPC);
 if ( 
pDays!=0)  rDays pDays GetCampaignInt("Start_DB_"+sVar,"nDay",oPC);
 if ( 
pMonths!=0)  rMonths pMonths GetCampaignInt("Start_DB_"+sVar,"nMonth",oPC);
 if ( 
pYears!=0)  rYears pYears GetCampaignInt("Start_DB_"+sVar,"nYear",oPC);
 
 if ( 
rSeconds 60*(rMinutes 60*(rHours 24*(rDays 30*rMonths 365*rYears))) > ) return FALSE;
 else return 
TRUE;
 

Oula ça risque pas de marcher mon truc vu que je ne regarde pas le calendrier dans le script conditionnel

Je corrige ça rapidement et j'édite, il faut voir aussi si c'est nécessaire de supprimer les variables après utilisation ou pas .

edit :
Voilà ça fonctionne à présent. Encore peut être parmi les choses à modifier, le multiplicateur pour les "mois" ( j'ai arrondis à "30") et le multiplicateur des années ( j'ai arrondis à "365").

je remets ga_delaystart car j'ai laissé un artefact ( le "bFirstUse") dans l'autre message.
Code PHP:

/* ga_delaystart
 C'est ici que le chronomètre est enclenché, on stocke les données du calendrier
 sous un nom ( ex : "quest01") de façon spécifique pour un joueur.
*/
void main(string sVar)
{
 
object oPC GetPCSpeaker();
 
int nYear GetCalendarYear();
 
int nMonth GetCalendarMonth();
 
int nDay GetCalendarDay();
 
int nHour GetTimeHour();
 
int nMinute GetTimeMinute();
 
int nSecond GetTimeSecond();
 
  
SetCampaignInt("Start_DB_"+sVar,"nYear",nYearoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nMonth",nMonthoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nDay",nDayoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nHour",nHouroPC);
  
SetCampaignInt("Start_DB_"+sVar,"nMinute",nMinuteoPC);
  
SetCampaignInt("Start_DB_"+sVar,"nSecond",nSecondoPC);

Code PHP:

/*gc_delaycheck
 Entrer un nom concernant le délai ( exemple : "quest01"), ainsi que la durée totale du délai.
*/
int StartingConditional(string sVarint dSecondsint dMinutesint dHoursint dDaysint dMonthsint dYears)
{
 
object oPC GetPCSpeaker();
 
int pSecondspMinutespHourspDayspMonthspYears;
 
 
// On récupère les données du calendrier
 
int nYear GetCalendarYear();
 
int nMonth GetCalendarMonth();
 
int nDay GetCalendarDay();
 
int nHour GetTimeHour();
 
int nMinute GetTimeMinute();
 
int nSecond GetTimeSecond();
 
 
// Que l'on compare (si nécessaire) aux données stockées. La différence donne pTime,
 // c'est à dire passed time, le temps écoulé.
 
if ( dSeconds!=0pSeconds nSecond GetCampaignInt("Start_DB_"+sVar,"nSecond",oPC);
 if ( 
dMinutes!=0)  pMinutes nMinute GetCampaignInt("Start_DB_"+sVar,"nMinute",oPC);
 if ( 
dHours!=0)  pHours nHour GetCampaignInt("Start_DB_"+sVar,"nHour",oPC);
 if ( 
dDays!=0)  pDays nDay GetCampaignInt("Start_DB_"+sVar,"nDay",oPC);
 if ( 
dMonths!=0)  pMonths nMonth GetCampaignInt("Start_DB_"+sVar,"nMonth",oPC);
 if ( 
dYears!=0)  pYears nYear GetCampaignInt("Start_DB_"+sVar,"nYear",oPC);
 
 
// On compare enfin la somme du délai total à la somme du temps déjà écoulé.
 
if ( dSeconds 60*(dMinutes 60*(dHours 24*(dDays 30*dMonths 365*dYears))) > pSeconds 60*(pMinutes 60*(pHours 24*(pDays 30*pMonths 365*pYears))) ) return FALSE;
 else return 
TRUE;
 

Génial, ça fonctionne ^^. Par contre, si je mets 120 secondes, ca fera 2 minutes, ou ca plantera?

Je me suis permis une petite modif pour faire en sorte que le délai soit posé sur le ga au lieu du gc....

Et, pour ta contribution, j'ai le plaisir de faire Viewtiful Citoyen d'Honneur de Fort Espérance.... ;-)


Encore merci, je me lance dès maintenant sur le métier d'écrivain, et sur la gestion de domaine....
Frontières te doit une fière chandelle.
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés