关灯
开启左侧

仿官方魔兽世界私服模拟器-物品召唤NPC的脚本代码(M端TBC)

  [复制链接]
admin实名认证 发表于 2016-4-20 22:57:55 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
diff -Nuar oregoncore-current/sql/CMakeLists.txt oregoncore-pq/sql/CMakeLists.txt--- oregoncore-current/sql/CMakeLists.txt        2011-01-01 10:03:07.000000000 -0500
+++ oregoncore-pq/sql/CMakeLists.txt        2011-01-01 10:15:59.000000000 -0500
@@ -1,6 +1,7 @@
add_subdirectory(updates)
add_subdirectory(tools)
add_subdirectory(scripts)
+add_subdirectory(oc-patch)


########### install files ###############
diff -Nuar oregoncore-current/sql/oc-patch/CMakeLists.txt oregoncore-pq/sql/oc-patch/CMakeLists.txt
--- oregoncore-current/sql/oc-patch/CMakeLists.txt        1969-12-31 19:00:00.000000000 -0500
+++ oregoncore-pq/sql/oc-patch/CMakeLists.txt        2011-01-01 10:15:59.000000000 -0500
@@ -0,0 +1,6 @@
+
+########### install files ###############
+
+FILE(GLOB _SQL *.sql)
+
+install(FILES ${_SQL} DESTINATION share/oregon/sql/oc-patch)
diff -Nuar oregoncore-current/sql/oc-patch/world-itemsummonnpc.sql oregoncore-pq/sql/oc-patch/world-itemsummonnpc.sql
--- oregoncore-current/sql/oc-patch/world-itemsummonnpc.sql        1969-12-31 19:00:00.000000000 -0500
+++ oregoncore-pq/sql/oc-patch/world-itemsummonnpc.sql        2011-01-01 10:15:59.000000000 -0500
@@ -0,0 +1,20 @@
+DELETE FROM `item_template` WHERE `entry` = 100035;
+
+INSERT INTO `item_template` (`entry`, `class`, `subclass`, `unk0`, `name`, `displayid`, `Quality`, `Flags`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `dmg_min3`, `dmg_max3`, `dmg_type3`, `dmg_min4`, `dmg_max4`, `dmg_type4`, `dmg_min5`, `dmg_max5`, `dmg_type5`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`, `Duration`) VALUES
+(100035, 13, 0, -1, 'Summon the Supreme Mage', 12735, 4, 524353, 1, 0, 0, 0, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28750, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 3, 'Summon the Buff Master', 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 'item_summonnpc', 0, 0, 0, 0, 0);
+
+DELETE FROM `creature_template` WHERE `entry` = 91000;
+
+INSERT INTO `creature_template` (`entry`, `heroic_entry`, `modelid_A`, `modelid_A2`, `modelid_H`, `modelid_H2`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `minhealth`, `maxhealth`, `minmana`, `maxmana`, `armor`, `faction_A`, `faction_H`, `npcflag`, `speed`, `scale`, `rank`, `mindmg`, `maxdmg`, `dmgschool`, `attackpower`, `baseattacktime`, `rangeattacktime`, `unit_flags`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `class`, `race`, `minrangedmg`, `maxrangedmg`, `rangedattackpower`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `PetSpellDataId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `RacialLeader`, `RegenHealth`, `equipment_id`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`) VALUES
+(91000, 0, 3348, 0, 3348, 0, 'Alaresque', 'Supreme Mage', NULL, 0, 80, 80, 25000, 25000, 100000, 100000, 10000, 35, 35, 1, 1, 1, 1, 1763, 1763, 0, 1511, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 3, 0, 1, 0, 0, 0, 'npc_buff');
+
+CREATE TABLE IF NOT EXISTS `item_summonnpc` (
+  `item_entry` mediumint(8) NOT NULL COMMENT 'item_template.entry',
+  `creature_entry` mediumint(8) NOT NULL COMMENT 'creature_template.entry',
+  `despawn` mediumint(8) unsigned NOT NULL default '60' COMMENT 'Time before despawn sec',
+  PRIMARY KEY  (`item_entry`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Reference data for item_summonnpc script';
+
+INSERT INTO `item_summonnpc` (`item_entry`, `creature_entry`, `despawn`) VALUES
+(100035, 91000, 60);
+
diff -Nuar oregoncore-current/src/game/ScriptLoader.cpp oregoncore-pq/src/game/ScriptLoader.cpp
--- oregoncore-current/src/game/ScriptLoader.cpp        2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/ScriptLoader.cpp        2011-01-01 10:15:59.000000000 -0500
@@ -11,6 +11,9 @@

#ifdef SCRIPTS

+//custom
+void AddSC_item_summonnpc();
+
//examples
//void AddSC_custom_example();
//void AddSC_custom_gossip_codebox();
@@ -379,6 +382,10 @@
void AddScripts()
{
#ifdef SCRIPTS
+
+    //Custom
+    AddSC_item_summonnpc();
+
//    AddSC_custom_example();
//    AddSC_custom_gossip_codebox();
//    AddSC_test();
diff -Nuar oregoncore-current/src/scripts/Custom/item_summonnpc.cpp oregoncore-pq/src/scripts/Custom/item_summonnpc.cpp
--- oregoncore-current/src/scripts/Custom/item_summonnpc.cpp        1969-12-31 19:00:00.000000000 -0500
+++ oregoncore-pq/src/scripts/Custom/item_summonnpc.cpp        2011-01-01 10:15:59.000000000 -0500
@@ -0,0 +1,77 @@
+/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
+ * Modified for OregonCore - Copyright (2010) Oregon <http://www.oregoncore.com>
+ * Modifications by Celtus - 2010-09-13
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* ScriptData
+SDName: item_summonnpc
+SD%Complete: 100
+SDComment: Summon NPC
+SDCategory: Items
+EndScriptData */
+
+#include "ScriptPCH.h"
+#include <cstring>
+
+bool ItemUse_item_summonnpc(Player* pPlayer, Item* pItem, const SpellCastTargets &pTargets)
+{
+
+    // Declare Variables
+    uint32 itemId = pItem->GetEntry();
+    uint32 npcId;
+    uint32 despawnSec;
+    extern DatabaseType WorldDatabase;
+
+if ((pPlayer->isInCombat()) || (pPlayer->isInFlight()) || (pPlayer->isDead()))
+{
+      pPlayer->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT, pItem, NULL);
+        return false;
+}
+if (pPlayer->IsMounted()) // Is player mounted
+{
+      pPlayer->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, pItem, NULL);
+        return true;
+}
+{
+        // Fetch the NPC Id
+        QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT `creature_entry`, `despawn` FROM `item_summonnpc` WHERE `item_entry` = '%i' LIMIT 1",itemId);
+    if(result)
+    {
+        Field *fields = result->Fetch();
+        // Read NPC Id from the query result
+        npcId = fields[0].GetInt32();
+        // Read time before despawn
+        despawnSec = fields[1].GetUInt32() * 1000;
+        // Summon the NPC
+        pPlayer->SummonCreature(npcId,pPlayer->GetPositionX() ,pPlayer->GetPositionY()-2, pPlayer->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, despawnSec);
+        return true;
+    } else {
+        // Summons failed - show info in log
+        outstring_log ("Item_SummonNPC Failed: %i)",itemId);
+    }
+}
+        return false;
+}
+void AddSC_item_summonnpc()
+{
+    Script *newscript;
+
+    newscript = new Script;
+    newscript->Name="item_summonnpc";
+    newscript->pItemUse = &ItemUse_item_summonnpc;
+    newscript->RegisterSelf();
+}

回复下载完整代码


游客,如果您要查看本帖隐藏内容请回复



 

精彩评论6

倒序浏览
52vista 发表于 2021-8-14 14:05:43 | 显示全部楼层
 
官方魔兽世界私服模拟器-物品召唤NPC的脚本代码
 
蒋佳李 发表于 2021-7-21 12:07:51 | 显示全部楼层
 
幻化系统幻化系统幻化系统幻化系统
 
zhang4288 发表于 2021-3-28 20:27:41 | 显示全部楼层
 
楼主好棒,终于找到需要的了!有需求就来吾爱尚玩!
 
53506457 发表于 2021-3-27 22:10:10 | 显示全部楼层
 
非常感谢感谢
 
orphen008 发表于 2020-7-5 14:42:41 | 显示全部楼层
 
非常感谢楼主分享!!!
 
duck 发表于 2020-7-1 14:55:31 | 显示全部楼层
 
楼主好棒,终于找到需要的了!有需求就来吾爱尚玩
 
VIP介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 最佳新人

    注册账号后积极发帖的会员
  • 活跃会员

    经常参与各类话题的讨论,发帖内容较有主见
  • 热心会员

    经常帮助其他会员答疑
  • 推广达人

    积极宣传本站,为本站带来更多注册会员
  • 宣传达人

    积极宣传本站,为本站带来更多的用户访问量
  • 灌水之王

    经常在论坛发帖,且发帖量较大
  • 突出贡献

    长期对论坛的繁荣而不断努力,或多次提出建设性意见
  • 优秀版主

    活跃且尽责职守的版主
  • 荣誉管理

    曾经为论坛做出突出贡献目前已离职的版主
  • 论坛元老

    为论坛做出突出贡献的会员

0关注

5粉丝

3421帖子

排行榜
作者专栏

QQ交流群&&微信订阅号

QQ交流群

微信订阅号

吾爱尚玩资源基地永久域名:

Www.523Play.Com

在线管理员QQ:1589479632

邮箱:Email@523play.com

QQ交流群:558936238

Copyright   ©2015-2116  吾爱尚玩资源基地|523play.comPowered by©523Pplay.Com技术支持:吾爱尚玩资源基地