#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
  
 | 
##@package SummonNPC  
 | 
# ÔÚÉí±ßË¢NPC <NPCID> [ÊýÁ¿] Ä¬ÈÏÊýÁ¿:1  
 | 
#  
 | 
# @author Mark  
 | 
# @date 2010-4-23  
 | 
# @version 1.0  
 | 
#  
 | 
# ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  
 | 
# VER = "2010-05-12 18:30" zhengyang Ìí¼Ó×¢ÊÍ  
 | 
#  
 | 
# Ä£¿éÏêϸ˵Ã÷  
 | 
import GameMap  
 | 
import ChConfig  
 | 
import GameWorld  
 | 
import NPCCommon  
 | 
import PlayerFB  
 | 
import PlayerControl  
 | 
import ShareDefine  
 | 
  
 | 
#  
 | 
#Â߼ʵÏÖ  
 | 
## ÔÚÉí±ßË¢ÕÙ»½NPC <NPCID> [ÊýÁ¿] Ä¬ÈÏÊýÁ¿:1  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param paramList ²ÎÊýÁбí [tagID, NPCCount]  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def OnExec(curPlayer, paramList):  
 | 
    #ÊäÈëÃüÁî¸ñʽ´íÎó  
 | 
    if not paramList:  
 | 
        GameWorld.DebugAnswer(curPlayer, "SummonNPC npcID ¸öÊý")  
 | 
        GameWorld.DebugAnswer(curPlayer, "SummonNPC npcID ¸öÊý Ç°¶Ë³¡¾°ID lineID ÑªÁ¿")  
 | 
        return  
 | 
      
 | 
    #NPC¶ÔÏóID  
 | 
    npcID = paramList[0]  
 | 
    npcCount = max(paramList[1] if len(paramList) > 1 else 1, 1)  
 | 
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)  
 | 
      
 | 
    if not npcData:  
 | 
        return  
 | 
      
 | 
    npcType = npcData.GetType()  
 | 
    if npcType in [ChConfig.ntPriWoodPilePVE, ChConfig.ntPriWoodPilePVP]:  
 | 
        mapID = paramList[2] if len(paramList) > 2 else 0  
 | 
        lineID = paramList[3] if len(paramList) > 3 else 0  
 | 
        setHP = paramList[4] if len(paramList) > 4 else 0  
 | 
        if not mapID:  
 | 
            GameWorld.DebugAnswer(curPlayer, "ľ׮¹Ö±ØÐëÖ¸¶¨µØÍ¼ID²ÅÄÜÕÙ»½!")  
 | 
            return  
 | 
          
 | 
        customMapID = PlayerControl.GetCustomMapID(curPlayer)  
 | 
        customLineID = PlayerControl.GetCustomLineID(curPlayer)  
 | 
        if mapID != customMapID or lineID != customLineID:  
 | 
            if customMapID:  
 | 
                PlayerFB.DoExitCustomScene(curPlayer)  
 | 
            tick = GameWorld.GetGameWorld().GetTick()  
 | 
            PlayerFB.DoEnterCustomScene(curPlayer, mapID, lineID, tick)  
 | 
              
 | 
        hp = setHP % ShareDefine.Def_PerPointValue  
 | 
        hpEx = setHP / ShareDefine.Def_PerPointValue  
 | 
        NPCCommon.SummonPriWoodPile(curPlayer, npcID, npcCount, hp, hpEx)  
 | 
        return  
 | 
      
 | 
    for _ in range(npcCount):  
 | 
        #ÔÚÍæ¼ÒÖÜΧѡÔñÒ»¸öÎÞÍæ¼ÒµÄµã  
 | 
        resultPos = GameMap.GetEmptyPlaceInArea(curPlayer.GetPosX(), curPlayer.GetPosY(), 6)  
 | 
        #Éú³ÉNPC  
 | 
        summonNPC = curPlayer.SummonNewNPC()  
 | 
        summonNPC.SetNPCTypeID(npcID)  
 | 
        summonNPC.SetAIType(200)  
 | 
        summonNPC.GetNPCAngry().Init(ChConfig.Def_SummonNPC_Angry_Count)  
 | 
        #³õʼ»¯  
 | 
        NPCCommon.InitNPC(summonNPC)   
 | 
        summonNPC.SetOwner(curPlayer)  
 | 
          
 | 
        #Íæ¼ÒÕÙ»½ÊÞÁбíÌí¼ÓÕÙ»½ÊÞ,ÕÙ»½ÊÞÌí¼ÓÖ÷ÈË  
 | 
        summonNPC.Reborn(resultPos.GetPosX(), resultPos.GetPosY())  
 | 
    return  
 | 
          
 | 
          
 | 
      
 | 
      
 | 
  
 |