• QQ21031394

    工作时间

    周一至周五:9:30-18:30

    周末及节日:根据情况调休

  • 手机版二维码

    随时手机查素材

  • 扫描二维码

    加入官方QQ群

站长推荐
Rubbish 一级会员
  • 未知地域
  • 17发帖数
  • 4主题数
  • 1关注数
  • 1粉丝

【乐色】绿字属性

[复制链接]
Rubbish 发表于 2022-2-7 20:49:30 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
提莫作坊QQ群:提莫作坊www.tbwlm.cn

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
本帖最后由 Rubbish 于 2022-2-7 22:11 编辑
  1. llibrary UnitState initializer Main
  2.     //物编生成
  3.     <?
  4.         local cost = {
  5.             { 'AItg' , 'Stak' , '额外攻击' } ,
  6.             { 'AIsx' , 'Stas' , '额外攻速' } ,
  7.             { 'AId1' , 'Stdf' , '额外护甲' } ,
  8.             { 'AIl1' , 'Stlf' , '额外生命' } ,
  9.             { 'AImv' , 'Stmn' , '额外魔法' } ,
  10.             { 'Aamk' , 'Stag' , '额外敏捷' } ,
  11.             { 'Aamk' , 'Stst' , '额外力量' } ,
  12.             { 'Aamk' , 'Stin' , '额外智力' } ,
  13.             { 'ANre' , 'Strm' , '魔法恢复' } ,
  14.             { 'ACnr' , 'Strl' , '生命恢复' } ,
  15.         }
  16.         for _ , v in ipairs( cost ) do
  17.         local name = v[2]
  18.         local suff = v[3]
  19.         local old  = v[1]
  20.         local obj              = slk.ability[old]:new( name )
  21.             obj.name         = string.format( '[%s] 属性' , name )
  22.             obj.EditorSuffix = suff
  23.             obj.Buttonpos    = { 0 , 0 }
  24.             obj.UnButtonpos  = { 0 , 0 }
  25.             obj.hero         = 0
  26.             obj.item         = 0
  27.             obj.race         = 'orther'
  28.             obj.levels       = 2
  29.             obj.dataA        = { 0  , 0  }
  30.             if slk.ability[old].art ~= '' then
  31.                     obj.art          = ''
  32.             end
  33.             if old == 'ACnr' or old == 'ANre' then
  34.                     obj.dataB        = { 0  , 0 }
  35.                     obj.targs        = { "vulnerable,invulnerable,self"  , "vulnerable,invulnerable,self"  }
  36.                     obj.Area         = { 0  , 0 }
  37.             end
  38.             if old == 'Aamk' then
  39.                     obj.tip          = { '' , '' }
  40.                     obj.ubertip      = { '' , '' }
  41.                     obj.dataB        = { 0  , 0  }
  42.                     obj.dataC        = { 0  , 0  }
  43.                     obj.dataD        = { 1  , 1  }
  44.             end
  45.         end
  46.     ?>
  47.     globals
  48.         private integer   array AbilityId
  49.         private integer   array AbilityData
  50.         private hashtable       Ht          = InitHashtable( )
  51.         private trigger         Trigger     = CreateTrigger( )
  52.     endglobals
  53.     function GetHandleType takes handle h returns string
  54.         local  string func   = ""
  55.         local  string result = ""
  56.         set    func          = func + "(function ( handle )"                     + "\n"
  57.         set    func          = func + "local dbg      = require 'jass.debug'"    + "\n"
  58.         set    func          = func + "if handle == 0 or handle == nil then"     + "\n"
  59.         set    func          = func + "return ''"                                + "\n"
  60.         set    func          = func + "end"                                      + "\n"
  61.         set    func          = func + "local info = dbg.handledef(handle)"       + "\n"
  62.         set    func          = func + "if info and info.type then"               + "\n"
  63.         set    func          = func + "return info.type"                         + "\n"
  64.         set    func          = func + "end"                                      + "\n"
  65.         set    func          = func + "return ''"                                + "\n"
  66.         set    func          = func + "end)( " + I2S( GetHandleId( h ) ) + ")"   + "\n"
  67.         set    result        = EXExecuteScript( func )
  68.         return result
  69.     endfunction
  70.    
  71.     private function FlushUnitData takes unit whichUnit returns nothing
  72.         call FlushChildHashtable( Ht , GetHandleId( whichUnit ) )
  73.     endfunction
  74.     hook RemoveUnit FlushUnitData
  75.     private function UnitInitAbility takes unit whichUnit , integer whichSerial returns nothing
  76.         local ability thisAbility = null
  77.         if AbilityId[whichSerial] != 0 then
  78.             call UnitAddAbility( whichUnit , AbilityId[whichSerial] )
  79.             call UnitMakeAbilityPermanent( whichUnit , true , AbilityId[whichSerial] )
  80.             set  thisAbility = EXGetUnitAbility( whichUnit , AbilityId[whichSerial] )
  81.             call SetUnitAbilityLevel( whichUnit , AbilityId[whichSerial] , 2 )
  82.             call EXSetAbilityDataReal( thisAbility , 1 , AbilityData[whichSerial] , 0 )
  83.             call SetUnitAbilityLevel( whichUnit , AbilityId[whichSerial] , 1 )
  84.         endif
  85.         set thisAbility = null
  86.     endfunction
  87.     private function SetUnitAbility takes unit whichUnit , integer whichSerial , real value returns nothing
  88.         local ability thisAbility = null
  89.         if AbilityId[whichSerial] != 0 then
  90.             call UnitAddAbility( whichUnit , AbilityId[whichSerial] )
  91.             call UnitMakeAbilityPermanent( whichUnit , true , AbilityId[whichSerial] )
  92.             set  thisAbility = EXGetUnitAbility( whichUnit , AbilityId[whichSerial] )
  93.             call SetUnitAbilityLevel( whichUnit , AbilityId[whichSerial] , 2 )
  94.             call EXSetAbilityDataReal( thisAbility , 1 , AbilityData[whichSerial] , value )
  95.             call SetUnitAbilityLevel( whichUnit , AbilityId[whichSerial] , 1 )
  96.         endif
  97.         set thisAbility = null
  98.     endfunction
  99.     private function TriggerActions takes nothing returns boolean
  100.         local unit target = GetTriggerUnit( )
  101.         call BJDebugMsg( "死亡单位 ->" + GetUnitName( target ) )
  102.         if not IsUnitType( target , UNIT_TYPE_HERO ) then
  103.             call FlushUnitData( target )
  104.         endif
  105.         set target = null
  106.         return false
  107.     endfunction
  108.     private function Main takes nothing returns nothing
  109.         local integer index = 0
  110.         loop
  111.             exitwhen index > 15
  112.             call TriggerRegisterPlayerUnitEvent( Trigger , Player( index ) , EVENT_PLAYER_UNIT_DEATH , null )
  113.             call TriggerAddCondition( Trigger , Filter( function TriggerActions ) )
  114.             set index = index + 1
  115.         endloop
  116.         //生命恢复
  117.         set AbilityId[0x53] = 'Strl'
  118.         set AbilityData[0x53] = 0x6c
  119.         //魔法恢复
  120.         set AbilityId[0x54] = 'Strm'
  121.         set AbilityData[0x54] = 0x6c
  122.         //额外生命值
  123.         set AbilityId[0x71] = 'Stlf'
  124.         set AbilityData[0x71] = 0x6c
  125.         //额外魔法值
  126.         set AbilityId[0x73] = 'Stlm'
  127.         set AbilityData[0x73] = 0x6c
  128.         //额外攻击
  129.         set AbilityId[0x74] = 'Stak'
  130.         set AbilityData[0x74] = 0x6c
  131.         //额外护甲值
  132.         set AbilityId[0x75] = 'Stdf'
  133.         set AbilityData[0x75] = 0x6c
  134.         //额外攻击速度
  135.         set AbilityId[0x76] = 'Stas'
  136.         set AbilityData[0x76] = 0x6c
  137.         //额外力量
  138.         set AbilityId[0x81] = 'Stst'
  139.         set AbilityData[0x81] = 0x6e
  140.         //额外敏捷
  141.         set AbilityId[0x82] = 'Stst'
  142.         set AbilityData[0x82] = 0x6c
  143.         //额外力量
  144.         set AbilityId[0x83] = 'Stin'
  145.         set AbilityData[0x83] = 0x6d
  146.     endfunction
  147.     function EXGetUnitState takes unit whichUnit , unitstate whichUnitState returns real
  148.         local real    result = 0
  149.         local integer state  = GetHandleId( whichUnitState )
  150.         local real    attch  = 0
  151.         if AbilityId[state] != 0 then
  152.             if GetUnitAbilityLevel( whichUnit , AbilityId[state] ) > 0 then
  153.                 set result = LoadReal( Ht , GetHandleId( whichUnit ) , state )
  154.             endif
  155.         else
  156.             set result = GetUnitState( whichUnit , whichUnitState )
  157.             if state == 0x20 then
  158.                 set attch = LoadReal( Ht , GetHandleId( whichUnit ) , 0x75 )
  159.             elseif state == 0x51 then
  160.                 set attch = LoadReal( Ht , GetHandleId( whichUnit ) , 0x76 )
  161.             endif
  162.             set result = result - attch
  163.         endif
  164.         return result
  165.     endfunction
  166.     private struct TimerSetActions
  167.         private unit        target
  168.         private integer     state
  169.         private real        value
  170.         private timer       timer
  171.         private static constant hashtable ht = InitHashtable( )
  172.         method destroy takes nothing returns nothing
  173.             call DestroyTimer( .timer )
  174.             call RemoveSavedInteger( thistype.ht , GetHandleId( .target ) , .state )
  175.             call FlushChildHashtable( thistype.ht , GetHandleId( .timer ) )
  176.             set  .target = null
  177.             set  .state  = 0
  178.             set  .timer  = null
  179.             set  .value  = 0
  180.             call .deallocate( )
  181.         endmethod
  182.         static method TimerActions takes nothing returns nothing
  183.             local timer    Extime = GetExpiredTimer( )
  184.             local thistype this   = LoadInteger( thistype.ht , GetHandleId( Extime ) , <?=StringHash( 'UserData' )?> )
  185.             if UnitAlive( .target ) then
  186.                 call SetUnitAbility( .target , .state , .value )
  187.                 call .destroy( )
  188.             else
  189.                 if GetUnitName( .target ) == "" or GetHandleType( .target ) != "+w3u" then
  190.                     call .destroy( )
  191.                 endif
  192.             endif
  193.         endmethod
  194.         static method create takes unit whichUnit , integer state , real value returns thistype
  195.             local thistype this = 0
  196.             if Have( integer , thistype.ht , GetHandleId( whichUnit ) , state ) then
  197.                 set this = LoadInteger( thistype.ht , GetHandleId( whichUnit ) , state )
  198.             else
  199.                 set this             = thistype.allocate( )
  200.                 set .timer           = CreateTimer( )
  201.                 set .target          = whichUnit
  202.                 set .state           = state
  203.                 call SaveInteger( thistype.ht , GetHandleId( .timer )    , <?=StringHash( 'UserData' )?> , this )
  204.                 call SaveInteger( thistype.ht , GetHandleId( whichUnit ) , state , this )
  205.                 call TimerStart( .timer , 0.03 , true , function thistype.TimerActions )
  206.             endif
  207.             set .value = value
  208.             return this
  209.         endmethod
  210.     endstruct
  211.     function EXSetUnitState takes unit whichUnit , unitstate whichUnitState , real value returns nothing
  212.         local real        old   = 0
  213.         local integer     state = GetHandleId( whichUnitState )
  214.         local real        prof  = 0
  215.         local real        now   = 0
  216.         local real        max   = 0
  217.         if AbilityId[state] != 0 then
  218.             if GetUnitAbilityLevel( whichUnit , AbilityId[state] ) <= 0 then
  219.                 call UnitInitAbility( whichUnit , state )
  220.             endif
  221.             if not UnitAlive( whichUnit ) and ( state == 0x53 or state == 0x54 ) then
  222.                 call TimerSetActions.create( whichUnit , state , value )
  223.             else
  224.                 call SetUnitAbility( whichUnit , state , value )
  225.             endif
  226.             call SaveReal( Ht , GetHandleId( whichUnit ) , state , value )
  227.         else
  228.             if state == 0x01 or state == 0x02 then
  229.                 set now  = GetUnitState( whichUnit , ConvertUnitState( state - 1 ) )
  230.                 set max  = GetUnitState( whichUnit , ConvertUnitState( state ) )
  231.                 if max == 0 then
  232.                     set max = 1
  233.                 endif
  234.                 if now == 0 then
  235.                     set now = 1
  236.                 endif
  237.                 set prof = now / max
  238.             elseif state == 0x20 then
  239.                 call SetUnitAbility( whichUnit , 0x75 , 0 )
  240.             elseif state == 0x51 then
  241.                 call SetUnitAbility( whichUnit , 0x76 , 0 )
  242.             endif
  243.             call SetUnitState( whichUnit , whichUnitState , value )
  244.             if state == 0x01 or state == 0x02 then
  245.                 set max  = GetUnitState( whichUnit , ConvertUnitState( state ) )
  246.                 set now  = max * prof
  247.                 call SetUnitState( whichUnit , ConvertUnitState( state - 1 ) , now )
  248.             elseif state == 0x20 then
  249.                 call SetUnitAbility( whichUnit , 0x75 , LoadReal( Ht , GetHandleId( whichUnit ) , 0x75 ) )
  250.             elseif state == 0x51 then
  251.                 call SetUnitAbility( whichUnit , 0x76 , LoadReal( Ht , GetHandleId( whichUnit ) , 0x76 ) )
  252.             endif
  253.         endif
  254.     endfunction
  255.     function EXSetHeroStr takes unit whichUnit , integer newStr , boolean permanent returns nothing
  256.         if permanent then
  257.             call SetUnitAbility( whichUnit , 0x81 , I2R( newStr ) )
  258.         else
  259.             call SetHeroStr( whichUnit , newStr , true )
  260.         endif
  261.     endfunction
  262.     function EXSetHeroAgi takes unit whichUnit , integer newStr , boolean permanent returns nothing
  263.         if permanent then
  264.             call SetUnitAbility( whichUnit , 0x82 , I2R( newStr ) )
  265.         else
  266.             call SetHeroAgi( whichUnit , newStr , true )
  267.         endif
  268.     endfunction
  269.     function EXSetHeroInt takes unit whichUnit , integer newStr , boolean permanent returns nothing
  270.         if permanent then
  271.             call SetUnitAbility( whichUnit , 0x83 , I2R( newStr ) )
  272.         else
  273.             call SetHeroInt( whichUnit , newStr , true )
  274.         endif
  275.     endfunction
  276.     #define GetUnitState EXGetUnitState
  277.     #define SetUnitState EXSetUnitState
  278.     #define SetHeroStr   EXSetHeroStr
  279.     #define SetHeroAgi   EXSetHeroAgi
  280.     #define SetHeroInt   EXSetHeroInt
  281.    
  282. endlibrary
复制代码


上方是代码

使用方式
    call SetUnitState( whichUnit , ConvertUnitState(Serial) , value ) //设置单位的属性 这个函数会自动被更改为EXSetUnitState
    call SetUnitState( whichUnit , ConvertUnitState(Serial) ) //获取单位的属性 这个函数会自动被更改为EXSetUnitState
    //whichUnit 为单位
    //Serial 为以下值:
    // 0x53:生命回复
    // 0x54:魔法回复
    // 0x71:额外生命
    // 0x73:额外魔法值
    // 0x74:额外攻击
    // 0x75:额外护甲
    // 0x76:额外攻速
    //value 为设置值
    call SetHeroStr( whichUnit , value , bool ) //函数制动替换为 EXSetHeroStr
    call SetHeroAgi( whichUnit , value , bool ) //函数制动替换为 EXSetHeroAgi
    call SetHeroInt( whichUnit , value , bool ) //函数制动替换为 EXSetHeroInt
    //whichUnit 为单位
    //value 为设置值
    //bool 为是否为绿字,true为绿字,false为白字

参与人数 1蓝钻 +100 贡献 +5 收起 理由
提百万 + 100 + 5 赞一个!

查看全部评分总评分 : 蓝钻 +100 贡献 +5

楼主热帖
免责条款:本站仅提供学习的平台,所有资料均来自于网络,版权归原创者所有!本站不提供任何保证,并不承担任何法律责任,如果对您的版权或者利益造成损害,请提供相应的资质证明,我们将于3个工作日内予以删除。

本网站所收集的部分公开资料来源于互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。本站部分作品是由网友自主投稿和发布、编辑整理上传,对此类作品本站仅提供交流平台,不为其版权负责。如果您发现网站上有侵犯您的知识产权的作品,请与我们取得联系,我们会及时修改或删除。

本网站所提供的信息,只供参考之用。本网站不保证信息的准确性、有效性、及时性和完整性。本网站及其雇员一概毋须以任何方式就任何信息传递或传送的失误、不准确或错误,对用户或任何其他人士负任何直接或间接责任。在法律允许的范围内,本网站在此声明,不承担用户或任何人士就使用或未能使用本网站所提供的信息或任何链接所引致的任何直接、间接、附带、从属、特殊、惩罚性或惩戒性的损害赔偿。

精彩评论2

容夏至 发表于 2022-2-7 20:53:36 | 显示全部楼层
大佬,这是用在哪里的
安圣基 发表于 2022-2-8 15:36:29 | 显示全部楼层
能直接弄成演示图吗?
QQ:477368098
不接单,随缘捣鼓模型![/b

强调下版规的规定,如有恶意灌水从重处罚:
=====发表主题规则=======
1.主题内容请一定要附带预览图片,谢谢;
2.搬运来的东西请尽量不要卖钱!;
3.发帖有任何疑问请联系QQ21031394;
=====发表回复规则=======
1.禁止直接复制标题内容的;
2.禁止纯数字或者纯字母的;
3.禁止乱打一通文不对题;
4.禁止屠版和刷分行为;
第一次扣分处理,第二次扣分+警告,警告三次禁言三天,绝不手软,情况严重的直接封号,请大家珍惜自己的账号!

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

猜你喜欢
天工维度唯一QQ群
786014245

欢迎进群交流,入群答案:编辑器

  • 官方在线客服

    QQ客服:小雪

    点击交谈

    QQ客服:砂糖

    点击交谈

    团队老大:荀公子

    商务合作
  • 上海市静安区共和新路4718号宏慧新汇园6号楼603室

  • 手机扫码查看手机版

    手机查找资源更方便

  • 扫一扫关注官方微信

    加入官方QQ群

Powered by 天天RPG&DZX3.4 ©2020-2021 Comsenz Inc.提百万设计( 沪ICP备18032615号-1 )营业执照