高级玩家

- 贡献度
- 52
- 金元
- 2999
- 积分
- 508
- 精华
- 0
- 注册时间
- 2008-12-1
|
今天下了toolset想自己整个法杖玩,结果按照教学贴的做总是保存script的时候卡死,整了几个小时终于搞定了。
其实很简单哈,就是教学贴里面那个代码
#include "utility_h"
这一行有问题,不晓得那个文件哪里有错,反正下面的代码里用到这个文件的就一个函数,所以我就干脆直接把这个函数写出来,不调用这个文件,就ok了。
代码如下
// Includes for utility functions and event definitons
#include "wrappers_h"
#include "events_h"
object UT_AddItemToInventory(resource rItem, int nNumToAdd = 1, object oInvOwner = OBJECT_INVALID, string sTag = "", int bSuppressNote = FALSE, int bDroppable = TRUE)
{
if ( oInvOwner == OBJECT_INVALID )
oInvOwner = GetPartyLeader();
Log_Trace( LOG_CHANNEL_SYSTEMS, "utility_h:UT_AddItemToInventory",
"Total to Add: [" + ResourceToTag(rItem) + " x " + ToString(nNumToAdd) + "]", oInvOwner );
return CreateItemOnObject(rItem,oInvOwner,nNumToAdd,sTag,bSuppressNote,bDroppable);
}
void main()
{
// We need to retrieve the event that called our script
// and only act if it is the one we are waiting for
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
// We also need the object representing the player's main character.
object oPC = GetHero();
// We use the CHRIS_GS_GIVEN variable to check whether we already run the
// script in this play session and gave the sword to the player!
// This is an arbitrary variable name chosen by me, you could
// chose something else if you wished so.
int nDoOnce = GetLocalInt(OBJECT_SELF, "CHRIS_GS_GIVEN");
// If we have not run the script yet:
if ( nDoOnce != 1 )
{
// We look for the even that we need
switch(nEventType)
{
// If our module just loaded - which happenessomewhere during
// the loading of a savegame or resuming an old game -
// we add the sword to the player during the loading screen
case EVENT_TYPE_MODULE_LOAD:
{
// First we make sure that we don't have the item yet
// fro manother gameplay session!
int nHas = CountItemsByTag(oPC, "wep_mel_gsw_atiash");
// If we do not, then we add it to the inventory
if ( nHas == 0 )
UT_AddItemToInventory(R"wep_mel_gsw_atiash.uti");
break;
}
}
// We update our CHRIS_GS_GIVEN variable to signal that the script
// finished properly and does not have to run again during this session.
SetLocalInt(OBJECT_SELF,"CHRIS_GS_GIVEN", 1);
}
// Once we are done with all our stuff, we pass the stuff back to the
// original script, so it can deal with the rest of the core functions.
// FIX: Commented out the HandleEvent line. It seems that this refers to
// this script itself - not the module script of the single player // campaign - causing issues with doubling stuff later on.
// HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
}
// ---------- Script Ends Here ---------- |
|