Archives des forums MMO/MMORPG > Neverwinter Nights > NWN - Maskado > re-emplir un coffre
re-emplir un coffre
Par Blam le 31/1/2003 à 17:28:39 (#3142836)
1)Comment faire pour qu'un coffre une fois vidé par un joueur se ré emplisse au bout d'un certain temps
2)même chose mais quand la zone est vide de tout joueur !
Par Kaïba le 31/1/2003 à 17:37:23 (#3142924)
http://forums.jeuxonline.info/showthread.php?s=&threadid=132214
bien bien
Par Blam le 31/1/2003 à 18:14:29 (#3143262)
en fait il donne deux emplacements !!!!
Par Kaïba le 31/1/2003 à 19:18:49 (#3143718)
Par Jaha Effect le 31/1/2003 à 19:34:15 (#3143848)
C'est un include, ça se met pas directement mais dans ton scripte de OnOpen il faudra y faire appel par un #include "nom du scripte de spawn" et bien sur utiliser les fonctions définies dans l'include, dans ton scripte OnOpen :)
Jaha Effect :D
pas tres bien compris ton explication jaha
Par Blam le 3/2/2003 à 17:43:44 (#3162793)
Par Jedaï le 3/2/2003 à 19:31:34 (#3163643)
Merci a toi jedai
Par Blam le 5/2/2003 à 10:22:01 (#3173963)
Hé ho ! du calme (je t'ai entendu rigoler ;) )
Marchi :)
Par Jaha Effect le 5/2/2003 à 10:43:55 (#3174071)
#include "nom_de_ta_biblio_de_respawn_de_coffre"
void main()
{
InitTreasureRespawn( OBJECT_SELF, 1);//pour un spawn de 1h
}
Placer dans le coffre ce que tu veux voir respawn dedans out le temps
Par contre il semblerait que le script ai eu des soucis de mis en forme, comme ça ça devrait aller
//::///////////////////////////////////////////////
//:: Name tp_tb_i0_re_inv
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Include Script for treasure respawn.
ResRef of the items in the inventory and Respawn delay is stored
on the first
opening of the container. Later usage of the container will check
if the time
for respawning the inventory is reached. Then all items in the
container will
be destroyed and the original items will be created.
*/
//:://////////////////////////////////////////////
//:: Created By: Thomas Buckermann (tabu_niw@freenet.de)
//:://////////////////////////////////////////////
//**************************************************
//Function Declaration
//init Respawn function, called only once
//object oContainer = the container which inventory should respawn,
//default is the calling object
//int iTime = intervall between respawn in hours, default is 1 hour
void InitTreasureRespawn(object oContainer = OBJECT_SELF, int iTime = 1);
//check if respawn time is reached, if true destroy inventory amd respawn items
void TreasureRespawn(object oContainer = OBJECT_SELF);
//The actual CreateObject Function.
void CreateTreasure(object oContainer = OBJECT_SELF);
//***************************************************
//Function implementation
void InitTreasureRespawn(object oContainer = OBJECT_SELF, int iTime = 1)
{
if (GetLocalInt(oContainer, "TP_INIT_RESPAWN") == TRUE)
return;
int iItemCount = 0;
string sItemResRef = ";
//Count all objects in oContainer and store their ResRef
object oItem = GetFirstItemInInventory(oContainer);
int iStackSize = GetNumStackedItems(oItem);
while (oItem != OBJECT_INVALID)
{
iItemCount ++;
sItemResRef = GetResRef(oItem);
SetLocalString(oContainer,
"sItemResRef"+IntToString(iItemCount), sItemResRef);
SetLocalInt(oContainer, "iStackSize"+IntToString(iItemCount),
iStackSize);
oItem = GetNextItemInInventory(oContainer);
iStackSize = GetNumStackedItems(oItem);
}
SetLocalInt(oContainer, "iItemCount", iItemCount);
//Set Respawn Time
int iReHour = GetTimeHour() + iTime;
int iReDay = GetCalendarDay();
int iReMonth = GetCalendarMonth();
int iReYear = GetCalendarYear();
while (iReHour > 23)
{
iReHour = iReHour - 24;
iReDay ++;
if (iReDay > 28)
{
iReDay = iReDay - 28;
iReMonth ++;
if (iReMonth > 12)
{
iReMonth = iReMonth -12;
iReYear ++;
}
}
}
SetLocalInt(oContainer, "iRespawnDelay", iTime);
SetLocalInt(oContainer, "iReHour", iReHour);
SetLocalInt(oContainer, "iReDay", iReDay);
SetLocalInt(oContainer, "iReMonth", iReMonth);
SetLocalInt(oContainer, "iReYear", iReYear);
SetLocalInt(oContainer, "TP_INIT_RESPAWN", TRUE);
}
void TreasureRespawn(object oContainer = OBJECT_SELF)
{
//check if InitTreasureRespawn() function has already been executed.
//If not, abort script.
if (GetLocalInt(oContainer, "TP_INIT_RESPAWN") == FALSE)
return;
object oItem;
int iReYear = GetLocalInt(oContainer, "iReYear");
int iReMonth = GetLocalInt(oContainer, "iReMonth");
int iReDay = GetLocalInt(oContainer, "iReDay");
int iReHour = GetLocalInt(oContainer, "iReHour");
// iTotalReTime is the respawn "combined" date in hours
int iTotalReTime =
(iReYear*(12*28*24))+(iReMonth*(28*24))+(iReDay*24)+ iReHour;
// iTotalNowTime is the current "combined" date in hours
int iTotalNowTime =
(GetCalendarYear()*(12*28*24))+(GetCalendarMonth()*(28*24))+(GetCalendarDay()*24) + GetTimeHour();
//check for respawn time
if (iTotalReTime > iTotalNowTime)
return;
//Set Respawn Time
int iTime = GetLocalInt(oContainer, "iRespawnDelay");
iReHour = GetTimeHour() + iTime;
iReDay = GetCalendarDay();
iReMonth = GetCalendarMonth();
iReYear = GetCalendarYear();
if (iReHour > 24)
{
iReHour = iReHour - 24;
iReDay ++;
if (iReDay > 28)
{
iReDay = iReDay - 28;
iReMonth ++;
if (iReMonth > 12)
{
iReMonth = iReMonth -12;
iReYear ++;
}
}
}
SetLocalInt(oContainer, "iRespawnDelay", iTime);
SetLocalInt(oContainer, "iReHour", iReHour);
SetLocalInt(oContainer, "iReDay", iReDay);
SetLocalInt(oContainer, "iReMonth", iReMonth);
SetLocalInt(oContainer, "iReYear", iReYear);
//destroy current inventory
oItem = GetFirstItemInInventory(oContainer);
while (oItem != OBJECT_INVALID)
{
DestroyObject(oItem);
oItem = GetNextItemInInventory(oContainer);
}
//create inventory
//Because of timing problems this had to be moved to
//its own function and delayed for 0.2 seconds.
DelayCommand(0.2, CreateTreasure(oContainer));
}
void CreateTreasure(object oContainer = OBJECT_SELF)
{
int iItemCount = GetLocalInt(oContainer, "iItemCount");
string sItemResRef;
int iStackSize;
int x; //generic counter
for (x = 1; x < (iItemCount+1); x++)
{
sItemResRef = GetLocalString(oContainer, "sItemResRef" +
IntToString(x));
iStackSize = GetLocalInt(oContainer, "iStackSize" +
IntToString(x));
object oItem = CreateItemOnObject(sItemResRef, oContainer,
iStackSize);
if (oItem == OBJECT_INVALID)
{
//+++++++++++Debug Message+++++++++++\
PrintString("!! Failed to create item nr " + IntToString(x) +
" with ResRef " + sItemResRef + " on container "
+ GetTag(oContainer) + " in Area " + GetTag(GetArea(oContainer)) +
"!!");
//+++++++++++++++++++++++++++++++++++\
}
}
}
MERCIIIIIIIIIIIII
Par Blam le 5/2/2003 à 10:47:42 (#3174091)
Meuh non, je blague, c'est tellement plus agréable quand c'est personnalisé et personnel.
;)
JOL Archives 1.0.1
@ JOL / JeuxOnLine