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

Panneau de contrôle

Recherche | Retour aux forums

JOL Archives

[SCRIPT] Réaprovisionnement de marchand

Par Jedaï le 10/11/2002 à 21:45:19 (#2528556)

Ca peut intéresser certaines personnes (j'ai déjà vu plusieurs questions qui peuvent être réglés ainsi).

Ces scripts permettent de simuler un réapprovisionnement toutes les semaines d'un marchand, remettant ainsi son stock à zéro (ça peut aussi servir à éliminer la myriade d'objets vendus par les PCs qui rendent impossible les achats... ;) ) :


//::///////////////////////////////////////////////
//:: Custom On Spawn In
//:: File Name onsp_marchand
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*spawn pour marchand qui enregistre les objets present dans son stock au debut
du jeu pour simuler un reapprovisionnement
*/
//:://////////////////////////////////////////////
//:: Created By: Jedai
//:://////////////////////////////////////////////
#include "NW_O2_CONINCLUDE"
#include "NW_I0_GENERIC"
void main()
{
SetListeningPatterns();
WalkWayPoints();
GenerateNPCTreasure();

DelayCommand(10.0, SignalEvent(OBJECT_SELF, EventUserDefined(999)));
}



///////////////////////////////////////////////////////////////////////////////
/*
*Ce script est mettre sur le OnHeartbat d'un marchand qui sera rapprovisionne
regulierement
*/
///////////////////////////////////////////////////////////////////////////////
//// file : onhb_marchand
//// Jedai
///////////////////////////////////////////////////////////////////////////////


void main()
{
object oStore = GetObjectByTag("tagdumagasin");

if (GetLocalInt(oStore, "nDay") <= GetCalendarDay()
&& GetLocalInt(oStore, "nMonth") <= GetCalendarMonth()
&& GetLocalInt(oStore, "nYear") <= GetCalendarYear())
{
SignalEvent(OBJECT_SELF, EventUserDefined(666));
}
}



///////////////////////////////////////////////////////////////////////////////
/*
*Ce script est mettre sur le OnUserDefined d'un marchand qui sera rapprovisionne
regulierement
*/
///////////////////////////////////////////////////////////////////////////////
//// file : onud_marchand
//// Jedai
///////////////////////////////////////////////////////////////////////////////

void main()
{
int nUser = GetUserDefinedEventNumber();

switch (nUser)
{
case 666 :
{
object oStore = GetObjectByTag("tagdumagasin");
int nItem = GetLocalInt(oStore, "nItem");
int n;

object oStock = GetFirstItemInInventory();
while (GetIsObjectValid(oStock))
{
DestroyObject(oStock);
oStock = GetNextItemInInventory();
}

for (n = 1; n 28)
{
nDay = nDay-28;
nMonth = nMonth+1;
if (nMonth > 12)
{
nYear++;
nMonth = 1;
}
}
SetLocalInt(oStore, "nDay", nDay);
SetLocalInt(oStore, "nMonth", nMonth);
SetLocalInt(oStore, "nYear", nYear);

break;
}
case 999 :
{
object oStore = GetObjectByTag("tagdumagasin");
object oStock = GetFirstItemInInventory(oStore);
int n, nStock;
n=0;
while (GetIsObjectValid(oStock))
{
n++;
nStock = GetNumStackedItems(oStock);
SetLocalString(oStore, "oItem"+IntToString(n), GetResRef(oStock)+";"+IntToString(nStock));
oStock = GetNextItemInInventory(oStore);
}
SetLocalInt(oStore, "nItem", n);
int nDay = GetCalendarDay()+7;
int nMonth = GetCalendarMonth();
int nYear = GetCalendarYear();
if (nDay > 28)
{
nDay = nDay-28;
nMonth = nMonth+1;
if (nMonth > 12)
{
nYear++;
nMonth = 1;
}
}
SetLocalInt(oStore, "nDay", nDay);
SetLocalInt(oStore, "nMonth", nMonth);
SetLocalInt(oStore, "nYear", nYear);

break;
}
default :
}
}


J'ai préféré mettre l'enregistrement du stock initial dans un UserDefined parce que je ne suis pas sûr que le magasin ait déjà été généré lorsque le marchand spawn.

Par eMRaistlin le 11/11/2002 à 11:26:12 (#2532880)

Tres bon... tres tres bon... Je note... Merchi ^^

JOL Archives 1.0.1
@ JOL / JeuxOnLine