I am trying to figure out how to check if my item (which I added to the game ok) has been deleted by the player (so that I can add it back to the merchant [I have successfully added the item ok, but I have not been able to make the item respawn if the player deletes it from their inventory]).
I am using a plot file with the following code:
// ---- SCRIPT STARTS HERE ----
#include "utility_h"
#include "wrappers_h"
#include "events_h"
// edit line below
#include "plt_gam_lfgloves_plot"
void main()
{
string myMerchantName = "store_camp_bodahn";
// edit 5 lines below
string myProjectName = "gam_lfgloves";
string myItemName = "gam_lfgloves";
resource myUtiName = R"gam_lfgloves.uti";
string MyPlotCheck = PLT_GAM_LFGLOVES_PLOT;
int MyCheckFlag = GAM_LFGLOVES_CHECK_FLAG;
object oPlayer = GetHero();
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
switch ( nEventType )
{
case EVENT_TYPE_MODULE_START:
{
WR_SetPlotFlag( MyPlotCheck, MyCheckFlag, FALSE );
break;
}
case EVENT_TYPE_MODULE_LOAD:
{
object oItem = GetObjectByTag(myItemName);
if (!IsObjectValid(oItem)) WR_SetPlotFlag( MyPlotCheck, MyCheckFlag, FALSE );
break;
}
case EVENT_TYPE_INVENTORY_REMOVED:
{
object oDeletedItem = GetEventObject(ev, 0);
string MyTest = ObjectToString(oDeletedItem);
if (MyTest == myItemName)
{
object oItem = GetObjectByTag(myItemName);
if (!IsObjectValid(oItem)) WR_SetPlotFlag( MyPlotCheck, MyCheckFlag, FALSE );
break;
}
break;
}
case EVENT_TYPE_CREATURE_ENTERS_DIALOGUE:
{
if ( WR_GetPlotFlag( MyPlotCheck, MyCheckFlag ) == TRUE ) return;
object[] oNearestStores = GetNearestObjectByTag(oPlayer, myMerchantName, OBJECT_TYPE_STORE, TRUE);
if(GetArraySize(oNearestStores) == 0) return;
object oNearbyStore = oNearestStores[0];
if(oNearbyStore == OBJECT_INVALID) return;
CreateItemOnObject(myUtiName, oNearbyStore, 1);
WR_SetPlotFlag( MyPlotCheck, MyCheckFlag, TRUE );
break;
}
default:
{
break;
}
}
}
// ---- SCRIPT ENDS HERE ----
The following area is the area I have just tried to create, but wont work:
--------------------------------------------------------------------------------------------------
case EVENT_TYPE_INVENTORY_REMOVED:
{
object oDeletedItem = GetEventObject(ev, 0);
string MyTest = ObjectToString(oDeletedItem);
if (MyTest == myItemName)
{
object oItem = GetObjectByTag(myItemName);
if (!IsObjectValid(oItem)) WR_SetPlotFlag( MyPlotCheck, MyCheckFlag, FALSE );
break;
}
break;
}
--------------------------------------------------------------------------------------------------
I dont think this event is firing anything at all.
I have used the plot file so I can deal with the item being stored somewhere else other than at the camp or in my inventory (or on a follower), and if it is deleted.
Really I just want a code that will check if the vendor has an item (without saving and re-loading) and give it to him if he doesnt have it. I have used >>>> dialog [event] + start [event] + load [event] + some event triggered when items are removed <<<<< to reduce lag from my coding whilst playing the game, and handle situations that normal item checks dont resolve.
Modifié par Gambler1971, 13 décembre 2009 - 11:02 .





Retour en haut






