﻿--[女俠助戰]

--[[

生成戰鬥單位 (id, 單位, 位置x, 位置y, 位置z)
part => 1: 主角群 ,2 :友方 ,4: 敵方 ,8: 第三方
CreateInfo(string id, int part, float x, float y, float z)

]]

local modelId = "";      	--女侠ID
local IsCreated = false;	--是否創立完成


--掛上「擲果潘郎」稱號圖標
function BeginBattle()
    Event();
    unit.AddBuff("nick041buff")
end


--創立女侠事件
function Event()
	--如果創立了就不創了
   if IsCreated == true then return; 
   end
   

--找到歸屬
   local part = 4
   if unit.UnitParty == Party.Enemy then
		part = 4
   elseif unit.UnitParty == Party.Third then
		part = 8
   else
		part = 1
   end
   


--隨機出現女性

local value = math.random(3)
                
        --「解長寧」
        if value == 4 then
		modelId = "n88801"; 
                controller.Talk("n6999999004");
	end        


        --「艷雪」
	if value == 3 then
		modelId = "n60106"; 
                controller.Talk("n6999999003");
              
	end

	
        --「錦衣衛繡眉」
        if value == 2 then
		modelId = "n00029b"; 
                controller.Talk("n6999999002");
    
	end

        --「梅紅綺」
        if value == 1 then
		modelId = "n60230"; 
                controller.Talk("n6999999001");
     
	end
		

--女性隊友 增傷52%
   require "helper"
   local allies =  GetAllyUnit()
    for i, v in ipairs(allies) do
        if(v.Gender == Gender.Female) then
            v[Prop.AttackFactor] = v[Prop.AttackFactor] + 52
   end

--玩家開戰對所有敵對NPC產生仇恨3000點
   AddHateForAll(unit,3000)
   end

--創立完成
   controller.CreateInfo(modelId, part, unit.Position.x, unit.Position.y, unit.Position.z)
   IsCreated = true 

end
   
