|
发表于 2007-10-18 15:33:54
|
显示全部楼层
算鸟,把我遗弃了2个多月的地图里的DD贴上来参考吧
技能最大等级=4,所以4进制的算法可能看着很别扭~
//************** 自定义技能系统 **********************
1~30 可叠加类
01 攻击 -4096~4095
02 防御 -4096~4095
03 攻速 -4096%~4095%
31~40 穷举类, 不可叠加存在多个时取最大值的技能
31 闪避 0~100%, limit=50
32 魔法抗性 -100%~100%, limit=50
33 吸血 0~64%
41~50 利用升级技能Bug(比如生命晶体)
41 生命 无上下限
42 魔法
43 视野
51~XX 自定义类
51 金钱获取率 (可叠加)
52 经验获取率 (可叠加)
53 魔导力 增加魔法威力 (该属性作用在技能中定义)
54 忽视敌人魔抗 (该属性作用在技能中定义)
55 杀死敌人取得1全属性 (不可叠加)
56 %攻击发动霜冻新星 (可叠加)
57 吸血 可开启/关闭 (点击带吸血效果的物品可以开启/关闭吸血)
58 移动速度 (可叠加)
59 施法时%几率重置CD (可叠加)
[codes=jass]function AddSkill1_Dec takes unit u,integer s,integer value,integer total returns nothing
local integer a
local integer b
local integer i=0
local integer p=0
loop
set a=value-value/4*4
set value=value/4
set b=total-total/4*4
set total=total/4
if a+p>0 then
if a+p+b<4 then
set p=0
else
set p=1
endif
if b==0 then
call UnitRemoveAbility(u,udg_SkillId[s*100+i])
else
call UnitAddAbility(u,udg_SkillId[s*100+i])
call SetUnitAbilityLevel(u,udg_SkillId[s*100+i],b)
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100+i])
endif
endif
exitwhen value==0
set i = i+1
endloop
if p==1 then
loop
set b=total-total/4*4
set total=total/4
set i=i+1
exitwhen b!=3
call UnitAddAbility(u,udg_SkillId[s*100+i])
call SetUnitAbilityLevel(u,udg_SkillId[s*100+i],b)
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100+i])
endloop
if b==0 then
call UnitRemoveAbility(u,udg_SkillId[s*100+i])
else
call SetUnitAbilityLevel(u,udg_SkillId[s*100+i],b)
endif
endif
endfunction
function AddSkill1 takes unit u,integer s,integer v returns nothing
local integer origin = GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s))
local integer total = origin+v
local integer a
local integer b
local integer i=0
local integer p=0
call StoreInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s),total)
if origin<0 then
set a = GetUnitAbilityLevel(u,udg_SkillId[s*100-1])
if a==1 then
set origin=origin+16
elseif a==2 then
set origin=origin+256
else
set origin=origin+4096
endif
if total>=0 then
call UnitRemoveAbility(u,udg_SkillId[s*100-1])
endif
endif
if total<0 then
if total>=-16 then
set total=total+16
set a=1
elseif total>=-256 then
set total=total+256
set a=2
else
set total=total+4096
set a=3
endif
call UnitAddAbility(u,udg_SkillId[s*100-1])
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100-1])
call SetUnitAbilityLevel(u,udg_SkillId[s*100-1],a)
endif
set v=total-origin
if v<0 then
call AddSkill1_Dec(u,s,-v,total)
else
loop
set a=v-v/4*4
set v=v/4
set b=total-total/4*4
set total=total/4
if a+p>0 then
if b>=a+p then
call UnitAddAbility(u,udg_SkillId[s*100+i])
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100+i])
call SetUnitAbilityLevel(u,udg_SkillId[s*100+i],b)
set p=0
elseif b==0 then
call UnitRemoveAbility(u,udg_SkillId[s*100+i])
set p=1
else
call SetUnitAbilityLevel(u,udg_SkillId[s*100+i],b)
set p=1
endif
endif
exitwhen v==0
set i = i+1
endloop
if p==1 then
loop
set b=total-total/4*4
set total=total/4
set i=i+1
exitwhen b!=0
call UnitRemoveAbility(u,udg_SkillId[s*100+i])
endloop
if b==1 then
call UnitAddAbility(u,udg_SkillId[s*100+i])
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100+i])
else
call SetUnitAbilityLevel(u,udg_SkillId[s*100+i],b)
endif
endif
endif
endfunction[/codes]
[codes=jass]function AddSkill2 takes unit u,integer s,integer v returns nothing
local integer origin = GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s))
local integer total = origin+v
local integer a=udg_SkillLimit[s*100]//最小值
local integer b=udg_SkillLimit[s*100+1]//最大值
local integer c
local integer d
local integer i
call StoreInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s),total)
if origin<a then
set origin=a
elseif origin>b then
set origin=b
endif
if total<a then
set total=a
elseif total>b then
set total=b
endif
if origin<0 then
set i=-1
else
set i=1
endif
if udg_SkillUI[s*100]==0 then
set a=(origin+i-2)/4
call UnitRemoveAbility(u,udg_SkillId[s*100+a])
else
set a=(origin+7*i-8)/16
call UnitRemoveAbility(u,udg_SkillUI[s*100+a])
endif
if total<0 then
set i=-1
elseif total>0 then
set i=1
else
return
endif
set a = (total+i-2)/4
set b = total*i + (1-total*i)/4*4
if udg_SkillUI[s*100]==0 then
call UnitAddAbility(u,udg_SkillId[s*100+a])
else
set c = (total+7*i-8)/16
set d = (total*i+3)/4+(1-total*i)/16*4
call UnitAddAbility(u,udg_SkillUI[s*100+c])
call UnitMakeAbilityPermanent(u,true,udg_SkillUI[s*100+c])
call SetUnitAbilityLevel(u,udg_SkillUI[s*100+c],d)
endif
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100+a])
call SetUnitAbilityLevel(u,udg_SkillId[s*100+a],b)
endfunction[/codes]
[codes=jass]function AddSkill3 takes unit u,integer s,integer v returns nothing
local integer a=1024
local integer b=8
local integer c
local integer i
if v<0 then
set i=-1
else
set i=1
endif
set v=v*i
loop
if v>=a then
set c=b/3*i
call UnitAddAbility(u,udg_SkillId[s*100+c])
call UnitMakeAbilityPermanent(u,true,udg_SkillId[s*100+c])
call SetUnitAbilityLevel(u,udg_SkillId[s*100+c],b+2-b/3*3)
call UnitRemoveAbility(u,udg_SkillId[s*100+c])
set v = v-a
exitwhen v<=0
else
set a=a/4
set b=b-1
endif
endloop
endfunction[/codes]
[codes=jass]function Trig_AbilityValue55_Cond takes nothing returns nothing
set udg_TempUnit = GetKillingUnit()
if IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) and GetStoredInteger(udg_GC,I2S(h2i(udg_TempUnit)),"AbilityValue55") >0 and IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(udg_TempUnit)) then
set udg_TempInt = 0
loop
if GetItemTypeId(UnitItemInSlot(udg_TempUnit,udg_TempInt)) == 'I036' then
set udg_TempItem = UnitItemInSlot(udg_TempUnit,udg_TempInt)
exitwhen true
endif
set udg_TempInt=udg_TempInt+1
endloop
call SetItemCharges(udg_TempItem,GetItemCharges(udg_TempItem)+1)
call SetHeroStr(udg_TempUnit,GetHeroStr(udg_TempUnit,false)+1,true)
call SetHeroAgi(udg_TempUnit,GetHeroAgi(udg_TempUnit,false)+1,true)
call SetHeroInt(udg_TempUnit,GetHeroInt(udg_TempUnit,false)+1,true)
endif
endfunction
function Trig_AbilityValue56_Cond takes nothing returns nothing
if GetRandomInt(0,99) < GetStoredInteger(udg_GC,I2S(h2i(GetTriggerUnit())),"AbilityValue56") and IsUnitEnemy(GetEventTargetUnit(),GetOwningPlayer(GetTriggerUnit())) then
set udg_TempUnit = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'e000',GetUnitX(GetEventTargetUnit()),GetUnitY(GetEventTargetUnit()),0)
call UnitApplyTimedLife(udg_TempUnit,'BHwe',0.3)
call UnitAddAbility(udg_TempUnit,'A06G') //霜华之锋
call IssueTargetOrderById(udg_TempUnit,852226,GetEventTargetUnit())
endif
endfunction
function Trig_AbilityValue59_Cond takes nothing returns nothing
if GetRandomInt(0,99) < GetStoredInteger(udg_GC,I2S(h2i(GetTriggerUnit())),"AbilityValue59") then
call ResetHeroSkillCD(GetTriggerUnit(),GetSpellAbilityId())
endif
endfunction
function AddSkillCustom takes unit u,integer s,integer v returns nothing
local integer origin = GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s))
local integer total = origin+v
call StoreInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s),total)
if s==51 then //金钱获取率
if u == udg_Hero[GetPlayerId(GetOwningPlayer(u))] then
call DisableTrigger(trg_GoldRate)
set udg_GoldRate[GetPlayerId(GetOwningPlayer(u))] = udg_GameGoldRate*(100+total)
call SetPlayerState(GetOwningPlayer(u), PLAYER_STATE_GOLD_UPKEEP_RATE, 100 - udg_GoldRate[GetPlayerId(GetOwningPlayer(u))]*(100 - udg_UpkeepRate[GetPlayerId(GetOwningPlayer(u))])/10000)
call EnableTrigger(trg_GoldRate)
endif
elseif s==52 then //经验获取率
if u == udg_Hero[GetPlayerId(GetOwningPlayer(u))] then
call SetPlayerHandicapXP(GetOwningPlayer(u),udg_GameExpRate*(1.+total/100.)/100.)
endif
//elseif s==53 then //魔导力 增加魔法威力
//elseif s==54 then //忽视敌人魔抗
elseif s==55 then //杀死敌人取得1全属性
if v>0 then
if GetStoredBoolean(udg_GC,"AbilityValue55","Trigger")==false then
call TriggerAddCondition(trg_UnitDie,Condition(function Trig_AbilityValue55_Cond))
call StoreBoolean(udg_GC,"AbilityValue55","Trigger",true)
endif
call SetHeroStr(u,GetHeroStr(u,false)+GetItemCharges(GetManipulatedItem()),true)
call SetHeroAgi(u,GetHeroStr(u,false)+GetItemCharges(GetManipulatedItem()),true)
call SetHeroInt(u,GetHeroStr(u,false)+GetItemCharges(GetManipulatedItem()),true)
elseif v<0 then
call SetHeroStr(u,GetHeroStr(u,false)-GetItemCharges(GetManipulatedItem()),true)
call SetHeroAgi(u,GetHeroStr(u,false)-GetItemCharges(GetManipulatedItem()),true)
call SetHeroInt(u,GetHeroStr(u,false)-GetItemCharges(GetManipulatedItem()),true)
endif
elseif s==56 then // %几率攻击时发动霜冻新星
if origin==0 then
set udg_TempInt = GetStoredInteger(udg_GC,"AbilityValue56","Trigger")
if udg_TempInt==0 then
set udg_TempInt = h2i(CreateTrigger())
call TriggerAddCondition(i2tg(udg_TempInt),Condition(function Trig_AbilityValue56_Cond))
call StoreInteger(udg_GC,"AbilityValue56","Trigger",udg_TempInt)
endif
if not GetStoredBoolean(udg_GC,I2S(h2i(u)),"Ability56_Event") then
call TriggerRegisterUnitEvent(i2tg(udg_TempInt),u,EVENT_UNIT_TARGET_IN_RANGE)
call StoreBoolean(udg_GC,I2S(h2i(u)),"Ability56_Event",true)
endif
endif
elseif s==57 then //吸血(33)可开启/关闭
if GetStoredBoolean(udg_GC,I2S(h2i(u)),"Ability57On") then
call AddSkill2(u,33,GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue57")-GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue33"))
endif
elseif s==58 then //移动速度
call SetUnitMoveSpeed(u,GetUnitDefaultMoveSpeed(u)+total)
elseif s==59 then // %几率无视CD施法
if origin==0 then
if not GetStoredBoolean(udg_GC,I2S(h2i(u)),"Ability59_TrgCond") then
call TriggerAddCondition(trg_HeroSpellEff[GetPlayerId(GetOwningPlayer(u))],Condition(function Trig_AbilityValue59_Cond))
call StoreBoolean(udg_GC,I2S(h2i(u)),"Ability59_TrgCond",true)
endif
endif
endif
endfunction[/codes]
[codes=jass]function AddSkill takes unit u,integer s,integer v returns nothing
if s<=30 then
call AddSkill1(u,s,v)
elseif s<=40 then
call AddSkill2(u,s,v)
elseif s<=50 then
call AddSkill3(u,s,v)
else
call AddSkillCustom(u,s,v)
endif
endfunction[/codes]
[codes=jass]function GetSkillValue takes unit u,integer s returns integer
return GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue"+I2S(s))
endfunction
function GetWiz takes unit u returns integer //魔导力
return GetStoredInteger(udg_GC,I2S(h2i(u)),"AbilityValue53")
endfunction
//! define AddAttack(u,v) AddSkill1(u,1,v)
//! define AddDef(u,v) AddSkill1(u,2,v)
//! define AddAttackSpeed(u,v) AddSkill1(u,3,v)
//! define AddEvasion(u,v) AddSkill2(u,31,v)
//! define AddRes(u,v) AddSkill2(u,32,v)
//! define AddMaxLife(u,v) AddSkill3(u,41,v)
//! define AddMaxMana(u,v) AddSkill3(u,42,v)
//! define AddSight(u,v) AddSkill3(u,43,v)
//! define AddGoldRate(u,v) AddSkillCustom(u,51,v)
//! define AddExpRate(u,v) AddSkillCustom(u,52,v)
//! define AddWiz(u,v) AddSkillCustom(u,53,v)
//! define AddLeech(u,v) AddSkillCustom(u,57,v)
//! define AddMoveSpeed(u,v) AddSkillCustom(u,58,v)
//====== 白字攻击增加(只能使用正数)
function AddBaseAttack takes unit u,integer v returns nothing
local integer a=16
local integer b=8
local integer i='I05K'
if GetUnitAbilityLevel(u,'AInv')==0 then
call UnitAddAbility(u,'Aihn')
endif
loop
exitwhen v<=0
if v>=a then
call UnitAddItemById(u,i)
set v = v-a
else
set a=a/4
set i=i-1
endif
endloop
call UnitRemoveAbility(u,'Aihn')
endfunction[/codes] |
|