• T端单机定时间随机召唤生物的脚本


    下面是以个T端335版本WOTLK版本的随机召唤生物,并公告的脚本。。
    
    注意:你需要定义好比较好的时间设置,否则容易当机。最好多测试一下
    
    
     #include "ScriptPCH.h" 
    #define MIN_INTERVAL_TIMER 900000 // 15 minutes, in miliseconds.... 1 second = 1000 miliseconds
    #define MAX_INTERVAL_TIMER 1800000 // 30 minutes
    #define RANDOM_NPC_ENTRY 00000
    #define RANDOM_ITEM_REWARD_ENTRY 10000
    // edit all this shit ^
    class Random_Appearance : public WorldScript
    {
    public:
        Random_Appearance() : WorldScript("Random_Appearance") {}
        uint32 Timer;
     
        void DoRandomShit()
        {
            SessionMap Players = sWorld->GetAllSessions();
            if(Players.empty())
                return;
            SessionMap::iterator itr = Players.find(urand(0, Players.size()));
            Player* player = itr->second->GetPlayer();
            Position *pos;
            player->GetPosition(pos);
            pos->m_positionX -= 3;
            pos->m_positionY -= 3;
            Creature* Summoned = player->SummonCreature(RANDOM_NPC_ENTRY, *pos, TEMPSUMMON_MANUAL_DESPAWN, 5000);
            const ItemTemplate* rewardedItem = sObjectMgr->GetItemTemplate(RANDOM_ITEM_REWARD_ENTRY);
            std::ostringstream ss;
            ss << "Congratulations, you have been randomly gifted with ";
            ss << rewardedItem->Name1;
            ss << " !";
            Summoned->MonsterSay(ss.str().c_str(), LANG_UNIVERSAL, player->GetGUID());
            player->AddItem(RANDOM_ITEM_REWARD_ENTRY, 1);
            Timer = urand(MIN_INTERVAL_TIMER, MAX_INTERVAL_TIMER); 
        }
     
        void OnStartup()
        {
            Timer = urand(MIN_INTERVAL_TIMER, MAX_INTERVAL_TIMER);
        }
     
        void OnUpdate(uint32 diff)
        {
            if(diff > Timer)
                DoRandomShit();
            else
                Timer -= diff;
        }
    };
    void AddSC_Random_Appearance()
    {
        new Random_Appearance();
    }
  • 相关阅读:
    五、面向对象模型OOM(ObjectOriented Model)
    四、物理数据模型PDM(Physical Data Model )
    Asp.net WebForm中应用Jquery EasyUI Layout
    七、模型文档
    六、PowerDesigner 正向工程 和 逆向工程 说明
    JQuery 原理
    三、概念数据模型CDM(Conceptual Database Model )
    C#基础Func,Action
    Ioc容器应用浅析
    Discuz上面找到的不错的分页算法
  • 原文地址:https://www.cnblogs.com/needly/p/3751533.html
Copyright © 2020-2023  润新知