|
恩~~一个系统,类似于Wow的元素抗性/什么的之类的东西。
不多说了,最大的优点是可以使用小于8192个元素,可以由你来定义有多少个,基本抗性是多少什么的。
代码(可能不是最新的):
[codes=jass]globals
gamecache Element_GC = null
constant integer ElementNumber = 5 //元素有几种
real array ElementATT_STATE_Basic //单位元素基本攻属性值为此Basic
real array ElementATT_Gene //单位元素附加攻击为此Gene * 单位这个元素的攻属性值 + Basic
real array ElementATT_Basic
real array ElementATTPercent_Gene //单位元素附加攻击倍数为此Gene * 单位这个元素的攻属性值 + Basic
real array ElementATTPercent_Basic
real array ElementDouble_Gene //单位元素几重攻击几率百分比为此Gene * 单位这个元素的攻属性值 + Basic
real array ElementDouble_Basic
real array ElementDouble_Damage //元素几重伤害倍率
real array ElementATTSome_Gene //单位元素附加攻击几率百分比为此Gene * 单位这个元素的攻属性值 + Basic
real array ElementATTSome_Basic
//--------------------------------------------------------------------------------------------------------------
real array ElementDEF_STATE_Basic //单位元素基本防属性值为此Basic
real array ElementDEF_Gene //单位元素附加防御为此Gene * 单位这个元素的防属性值 + Basic
real array ElementDEF_Basic
real array ElementDEFPercent_Gene //单位元素部分免疫倍数为此Gene * 单位这个元素的防属性值 + Basic
real array ElementDEFPercent_Basic
real array ElementDEFImmunity_All_Gene //单位元素完全免疫几率百分比为此Gene * 单位这个元素的防属性值 + Basic
real array ElementDEFImmunity_All_Basic
real array ElementDEFImmunity_Some_Gene //单位元素部分免疫几率百分比为此Gene * 单位这个元素的防属性值 + Basic
real array ElementDEFImmunity_Some_Basic
//--------------------------------------------------------------------------------------------------------------
boolean Element_Temp_DamageTarget_attack = false
boolean Element_Temp_DamageTarget_ranged = true
attacktype Element_Temp_DamageTarget_attacktype = ATTACK_TYPE_NORMAL
damagetype Element_Temp_DamageTarget_damagetype = DAMAGE_TYPE_NORMAL
weapontype Element_Temp_DamageTarget_weapontype = WEAPON_TYPE_WHOKNOWS
//以上作为ElementDamageTarget的参数使用
//--------------------------------------------------------------------------------------------------------------
endglobals
function InitElementSystem takes nothing returns nothing
local integer i = 0
call FlushGameCache( InitGameCache( "ElementGameCache.w3v" ) )
set Element_GC = InitGameCache( "ElementGameCache.w3v" )
loop
exitwhen i > ElementNumber
set ElementATT_STATE_Basic[ i ] = 5.0
set ElementATT_Gene[ i ] = 1.0
set ElementATT_Basic[ i ] = 0.0
set ElementATTPercent_Gene[ i ] = 0.25
set ElementATTPercent_Basic[ i ] = 103.0
set ElementDouble_Gene[ i ] = 0.07
set ElementDouble_Basic[ i ] = 1.5
set ElementDouble_Damage[ i ] = 2.0
set ElementATTSome_Gene[ i ] = 0.15
set ElementATTSome_Basic[ i ] = 2.5
//------------------------------------
set ElementDEF_STATE_Basic[ i ] = 5.0
set ElementDEF_Gene[ i ] = 1.0
set ElementDEF_Basic[ i ] = 0.0
set ElementDEFPercent_Gene[ i ] = 0.23
set ElementDEFPercent_Basic[ i ] = 2.5
set ElementDEFImmunity_All_Gene[ i ] = 0.05
set ElementDEFImmunity_All_Basic[ i ] = 1.15
set ElementDEFImmunity_Some_Gene[ i ] = 0.15
set ElementDEFImmunity_Some_Basic[ i ] = 2.35
set i = i + 1
endloop
endfunction
function H2I takes handle h returns integer
return h
return 0
endfunction
function H2S takes handle h returns string
return I2S(H2I( h ))
endfunction
//------------------------------------------------------------------------------------
//ATT
function SetUnitElementATT takes string u_s, string element, integer e, real ATT returns nothing
local real att = ATT + ElementATT_STATE_Basic[ e ]
call StoreReal( Element_GC, u_s, "ATTPoint" + element, att )
call StoreReal( Element_GC, u_s, "ATT" + element, att * ElementATT_Gene[ e ] + ElementATT_Basic[ e ] )
call StoreReal( Element_GC, u_s, "ATTPercent" + element, att * ElementATTPercent_Gene[ e ] + ElementATTPercent_Basic[ e ] )
call StoreReal( Element_GC, u_s, "Double" + element, att * ElementDouble_Gene[ e ] + ElementDouble_Basic[ e ] )
call StoreReal( Element_GC, u_s, "ATT_Some" + element, att * ElementATTSome_Gene[ e ] + ElementATTSome_Basic[ e ] )
endfunction
function SetUnitElementBuffATT takes string u_s, string element, integer e, real ATT returns nothing
call StoreReal( Element_GC, u_s, "Buff:ATTPoint" + element, ATT )
call StoreReal( Element_GC, u_s, "Buff:ATT" + element, ATT * ElementATT_Gene[ e ] )
call StoreReal( Element_GC, u_s, "Buff:ATT:ATTPercent" + element, ATT * ElementATTPercent_Gene[ e ] )
call StoreReal( Element_GC, u_s, "Buff:ATT:Double" + element, ATT * ElementDouble_Gene[ e ] )
call StoreReal( Element_GC, u_s, "Buff:ATT:ATT_Some" + element, ATT * ElementATTSome_Gene[ e ] )
endfunction
//=============================================================================================
function SetUnitElementBuffATTPercent takes string u_s, string element, real ATT returns nothing
call StoreReal( Element_GC, u_s, "Buff:ATTPercent" + element, ATT )
endfunction
function SetUnitElementBuffDouble takes string u_s, string element, real ATT returns nothing
call StoreReal( Element_GC, u_s, "Buff:Double" + element, ATT )
endfunction
function SetUnitElementBuffATT_Some takes string u_s, string element, real ATT returns nothing
call StoreReal( Element_GC, u_s, "Buff:ATT_Some" + element, ATT )
endfunction
//=============================================================================================
function GetUnitElementBuffATTPoint takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATTPoint" + element )
endfunction
function GetUnitElementATTPoint takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "ATTPoint" + element ) + GetUnitElementBuffATTPoint( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuffATT takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATT" + element )
endfunction
function GetUnitElementATT takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "ATT" + element ) + GetUnitElementBuffATT( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuff_ATT_ATTPercent takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATT:ATTPercent" + element )
endfunction
function GetUnitElementBuffATTPercent takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATTPercent" + element ) + GetUnitElementBuff_ATT_ATTPercent( u_s, element )
endfunction
function GetUnitElementATTPercent takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "ATTPercent" + element ) + GetUnitElementBuffATTPercent( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuff_ATT_Double takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATT:Double" + element )
endfunction
function GetUnitElementBuffDouble takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:Double" + element ) + GetUnitElementBuff_ATT_Double( u_s, element )
endfunction
function GetUnitElementDouble takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Double" + element ) + GetUnitElementBuffDouble( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuff_ATT_ATT_Some takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATT:ATT_Some" + element )
endfunction
function GetUnitElementBuffATT_Some takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:ATT_Some" + element ) + GetUnitElementBuff_ATT_ATT_Some( u_s, element )
endfunction
function GetUnitElementATT_Some takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "ATT_Some" + element ) + GetUnitElementBuffATT_Some( u_s, element )
endfunction
//ATT
//------------------------------------------------------------------------------------
//DEF
function SetUnitElementDEF takes string u_s, string element, integer e, real DEF returns nothing
local real def = DEF + ElementDEF_STATE_Basic[ e ]
call StoreReal( Element_GC, u_s, "DEFPoint" + element, def )
call StoreReal( Element_GC, u_s, "DEF" + element, def * ElementDEF_Gene[ e ] + ElementDEF_Basic[ e ] )
call StoreReal( Element_GC, u_s, "DEFPercent" + element, def * ElementDEFPercent_Gene[ e ] + ElementDEFPercent_Basic[ e ] )
call StoreReal( Element_GC, u_s, "Immunity_All" + element, def * ElementDEFImmunity_All_Gene[ e ] + ElementDEFImmunity_All_Basic[ e ] )
call StoreReal( Element_GC, u_s, "Immunity_Some" + element, def * ElementDEFImmunity_Some_Gene[ e ] + ElementDEFImmunity_Some_Basic[ e ] )
endfunction
function SetUnitElementBuffDEF takes string u_s, string element, integer e, real DEF returns nothing
call StoreReal( Element_GC, u_s, "Buff:DEFPoint" + element, DEF )
call StoreReal( Element_GC, u_s, "Buff:DEF" + element, DEF * ElementDEF_Gene[ e ] )
call StoreReal( Element_GC, u_s, "Buff:DEF:DEFPercent" + element, DEF * ElementDEFPercent_Gene[ e ] )
call StoreReal( Element_GC, u_s, "Buff:DEF:Immunity_All" + element, DEF * ElementDEFImmunity_All_Gene[ e ] )
call StoreReal( Element_GC, u_s, "Buff:DEF:Immunity_Some" + element, DEF * ElementDEFImmunity_Some_Gene[ e ] )
endfunction
//=============================================================================================
function SetUnitElementBuffDEFPercent takes string u_s, string element, real DEF returns nothing
call StoreReal( Element_GC, u_s, "Buff:DEFPercent" + element, DEF )
endfunction
function SetUnitElementBuffImmunity_All takes string u_s, string element, real DEF returns nothing
call StoreReal( Element_GC, u_s, "Buff:Immunity_All" + element, DEF )
endfunction
function SetUnitElementBuffImmunity_Some takes string u_s, string element, real DEF returns nothing
call StoreReal( Element_GC, u_s, "Buff:Immunity_Some" + element, DEF )
endfunction
//=============================================================================================
function GetUnitElementBuffDEF takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:DEF" + element )
endfunction
function GetUnitElementDEF takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "DEF" + element ) + GetUnitElementBuffDEF( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuff_DEF_DEFPercent takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:DEF:DEFPercent" + element )
endfunction
function GetUnitElementBuffDEFPercent takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:DEFPercent" + element ) + GetUnitElementBuff_DEF_DEFPercent( u_s, element )
endfunction
function GetUnitElementDEFPercent takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "DEFPercent" + element ) + GetUnitElementBuffDEFPercent( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuff_DEF_Immunity_All takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:DEF:Immunity_All" + element )
endfunction
function GetUnitElementBuffImmunity_All takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:Immunity_All" + element ) + GetUnitElementBuff_DEF_Immunity_All( u_s, element )
endfunction
function GetUnitElementImmunity_All takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Immunity_All" + element ) + GetUnitElementBuffImmunity_All( u_s, element )
endfunction
//=============================================================================================
function GetUnitElementBuff_DEF_Immunity_Some takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:DEF:Immunity_Some" + element )
endfunction
function GetUnitElementBuffImmunity_Some takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Buff:Immunity_Some" + element ) + GetUnitElementBuff_DEF_Immunity_Some( u_s, element )
endfunction
function GetUnitElementImmunity_Some takes string u_s, string element returns real
return GetStoredReal( Element_GC, u_s, "Immunity_Some" + element ) + GetUnitElementBuffImmunity_Some( u_s, element )
endfunction
//DEF
//------------------------------------------------------------------------------------
function InitUnitElementAllData takes unit u returns nothing
local integer i = 0
local string i_s = null
local string u_s = H2S( u )
local string id_s = I2S(GetUnitTypeId( u ))
loop
exitwhen i > ElementNumber
set i_s = I2S( i )
call SetUnitElementATT( u_s, i_s, i, GetStoredReal( Element_GC, id_s, "Init:ATT" ) )
call SetUnitElementDEF( u_s, i_s, i, GetStoredReal( Element_GC, id_s, "Init:DEF" ) )
set i = i + 1
endloop
set i_s = null
set u_s = null
set id_s = null
endfunction
function FlushUnitElementAllData takes unit u returns nothing
call FlushStoredMission( Element_GC, H2S( u ) )
endfunction
function ElementDamageTextTag takes unit target, real damage returns nothing
local real z = 3.0
local real size = 9.0 * 0.023 / 10
local integer red = 255
local integer green = 205
local integer blue = 125
local integer tran = 255
local real life = 5.0
local real fade = 3.7
local real speed = 45.0
local real angle = 90.0
local texttag tt = null
if damage > 0.0 then
set tt = CreateTextTag()
call SetTextTagPosUnit( tt, target, z )
call SetTextTagVelocityBJ( tt, speed, angle )
call SetTextTagColor( tt, red, green, blue, tran )
call SetTextTagText( tt, I2S(R2I( damage )), size )
call SetTextTagPermanent( tt, false )
call SetTextTagFadepoint( tt, fade )
call SetTextTagLifespan( tt, life )
endif
set tt = null
endfunction
function ElementDamageTarget takes unit source, unit target, integer element, real damage, boolean CanDouble, boolean CanSomeMoreDamage, boolean CanAllImmunity, boolean CanSomeImmunity, boolean IsWar3Damage, boolean ShowText returns real
local string s_s = H2S( source )
local string t_s = H2S( target )
local string e_s = I2S( element )
local real att = GetUnitElementATT( s_s, e_s )
local real attpercent = GetUnitElementATTPercent( s_s, e_s ) / 100.0
local real attdouble = GetUnitElementDouble( s_s, e_s )
local real attsome = GetUnitElementATT_Some( s_s, e_s )
local real def = GetUnitElementDEF( t_s, e_s )
local real defpercent = GetUnitElementDEFPercent( t_s, e_s ) / 100.0
local real defall = GetUnitElementImmunity_All( t_s, e_s )
local real defsome = GetUnitElementImmunity_Some( t_s, e_s )
local real att_r_p = GetRandomReal( 0.0, 100.0 )
local real def_r_p = GetRandomReal( 0.0, 100.0 )
local real att_damage = att + damage
if att_r_p <= attdouble and CanDouble then
set att_damage = att_damage * ElementDouble_Damage[ element ]
elseif att_r_p <= attsome and CanSomeMoreDamage then
set att_damage = att_damage * attpercent
endif
if def_r_p <= defall and CanAllImmunity then
set att_damage = 0.0
elseif def_r_p <= defsome and CanSomeImmunity then
set att_damage = att_damage * ( 1 - defpercent )
endif
set att_damage = att_damage - def
if att_damage < 0.0 then
set att_damage = 0.0
endif
if IsWar3Damage and att_damage > 0.0 then
call UnitDamageTarget( source, target, att_damage, Element_Temp_DamageTarget_attack, Element_Temp_DamageTarget_ranged, Element_Temp_DamageTarget_attacktype, Element_Temp_DamageTarget_damagetype, Element_Temp_DamageTarget_weapontype )
else
call SetUnitState( target, UNIT_STATE_LIFE, GetUnitState( target, UNIT_STATE_LIFE ) - att_damage )
endif
if ShowText then
call ElementDamageTextTag( target, att_damage )
endif
set s_s = null
set t_s = null
set e_s = null
return att_damage
endfunction
function ElementGetBuffData takes string id, string key returns real
return GetStoredReal( Element_GC, id, key )
endfunction
function ElementBuffUnit takes string u_s, string e_s, real value returns nothing
call StoreReal( Element_GC, u_s, e_s, GetStoredReal( Element_GC, u_s, e_s ) + value )
endfunction
function ElementUnitBuffTimed_Action takes nothing returns nothing
local timer ti = GetExpiredTimer()
local string t_s = H2S( ti )
local real att = ElementGetBuffData( t_s, "ATT" )
local real attpercent = ElementGetBuffData( t_s, "ATTPercent" )
local real attdouble = ElementGetBuffData( t_s, "Double" )
local real attsome = ElementGetBuffData( t_s, "ATT_Some" )
local real def = ElementGetBuffData( t_s, "DEF" )
local real defpercent = ElementGetBuffData( t_s, "DEFPercent" )
local real defall = ElementGetBuffData( t_s, "Immunity_All" )
local real defsome = ElementGetBuffData( t_s, "Immunity_Some" )
local string u_s = GetStoredString( Element_GC, t_s, "u_s" )
if att != 0.0 then
call ElementBuffUnit( u_s, "Buff:ATT", att )
endif
if attpercent != 0.0 then
call ElementBuffUnit( u_s, "Buff:ATTPercent", attpercent )
endif
if attdouble != 0.0 then
call ElementBuffUnit( u_s, "Buff:Double", attdouble )
endif
if attsome != 0.0 then
call ElementBuffUnit( u_s, "Buff:ATT_Some", attsome )
endif
if def != 0.0 then
call ElementBuffUnit( u_s, "Buff:DEF", def )
endif
if defpercent != 0.0 then
call ElementBuffUnit( u_s, "Buff:DEFPercent", defpercent )
endif
if defall != 0.0 then
call ElementBuffUnit( u_s, "Buff:Immunity_All", defall )
endif
if defsome != 0.0 then
call ElementBuffUnit( u_s, "Buff:Immunity_Some", defsome )
endif
call FlushStoredMission( Element_GC, t_s )
call PauseTimer( ti )
call DestroyTimer( ti )
set ti = null
endfunction
function ElementUnitBuffTimed takes unit u, integer element, integer id, real time returns nothing
local timer ti = CreateTimer()
local string u_s = H2S( u )
local string id_s = I2S( id )
local string t_s = H2S( ti )
local real att = ElementGetBuffData( id_s, "ATT" )
local real attpercent = ElementGetBuffData( id_s, "ATTPercent" )
local real attdouble = ElementGetBuffData( id_s, "Double" )
local real attsome = ElementGetBuffData( id_s, "ATT_Some" )
local real def = ElementGetBuffData( id_s, "DEF" )
local real defpercent = ElementGetBuffData( id_s, "DEFPercent" )
local real defall = ElementGetBuffData( id_s, "Immunity_All" )
local real defsome = ElementGetBuffData( id_s, "Immunity_Some" )
if att != 0.0 then
call ElementBuffUnit( u_s, "Buff:ATT", att )
call StoreReal( Element_GC, t_s, "ATT", -att )
endif
if attpercent != 0.0 then
call ElementBuffUnit( u_s, "Buff:ATTPercent", attpercent )
call StoreReal( Element_GC, t_s, "ATTPercent", -attpercent )
endif
if attdouble != 0.0 then
call ElementBuffUnit( u_s, "Buff:Double", attdouble )
call StoreReal( Element_GC, t_s, "Double", -attdouble )
endif
if attsome != 0.0 then
call ElementBuffUnit( u_s, "Buff:ATT_Some", attsome )
call StoreReal( Element_GC, t_s, "ATT_Some", -attsome )
endif
if def != 0.0 then
call ElementBuffUnit( u_s, "Buff:DEF", def )
call StoreReal( Element_GC, t_s, "DEF", -def )
endif
if defpercent != 0.0 then
call ElementBuffUnit( u_s, "Buff:DEFPercent", defpercent )
call StoreReal( Element_GC, t_s, "DEFPercent", -defpercent )
endif
if defall != 0.0 then
call ElementBuffUnit( u_s, "Buff:Immunity_All", defall )
call StoreReal( Element_GC, t_s, "Immunity_All", -defall )
endif
if defsome != 0.0 then
call ElementBuffUnit( u_s, "Buff:Immunity_Some", defsome )
call StoreReal( Element_GC, t_s, "Immunity_Some", -defsome )
endif
call StoreString( Element_GC, t_s, "u_s", u_s )
call TimerStart( ti, time, false, function ElementUnitBuffTimed_Action )
set ti = null
set t_s = null
set u_s = null
set id_s = null
endfunction
function Element_RegisterUnitIdTypeInitATT takes integer id, integer element, real ATT returns nothing
call StoreReal( Element_GC, I2S( id ), "Init:ATT" + I2S( element ), ATT )
endfunction
function Element_RegisterUnitIdTypeInitDEF takes integer id, integer element, real DEF returns nothing
call StoreReal( Element_GC, I2S( id ), "Init:DEF" + I2S( element ), DEF )
endfunction[/codes]
地图保证是最新的,大家自己看吧~~ |
评分
-
查看全部评分
|