3DMGAME 3DM首页 新闻中心 前瞻 | 评测 游戏库 热门 | 最新 攻略中心 攻略 | 秘籍 下载中心 游戏 | 汉化 购买正版 论坛

注册 登录

QQ登录

只需一步,快速开始

查看: 3382|回复: 6
打印 上一主题 下一主题

[原创] Toolset 里自己做物品Script 无法保存的又一解决方法

[复制链接]

2

主题

395

帖子

508

积分

高级玩家

Rank: 4

贡献度
52
金元
2999
积分
508
精华
0
注册时间
2008-12-1
跳转到指定楼层
主题
发表于 2009-11-14 15:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
今天下了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 ----------
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|3DMGAME ( 京ICP备14006952号-1  沪公网安备 31011202006753号

GMT+8, 2026-5-20 00:58 , Processed in 0.033893 second(s), 16 queries , Memcached On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表