﻿--[女俠助戰]

--[[

生成戰鬥單位 (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 = 2
   end
   

--女俠隨著等級變化

   --1-4級山洞內「受傷戚如瀟」
   if unit.Level >= 1 and unit.Level < 5 then
                modelId = "n52009";

   end

   
   --5-15級俏夢閣「常粉」
   if unit.Level >= 5 and unit.Level < 16 then
                modelId = "n60164";
        
   end

   
   --16-25級「塞伊尹」
   if unit.Level >= 16 and unit.Level < 26 then
                modelId = "n80016";
        
   end

    
   --26-30級「艷雪」
   if unit.Level >= 26 and unit.Level < 31 then
                modelId = "n60106"; 
        
   end

   
   --31以後級「丁承澐」
   if unit.Level >= 31 then
                modelId = "n80097";
        
   end

--女性隊友 增傷50%
   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

