Topic đóng góp Snippet và System

  • Thread starter Thread starter dh-g
  • Ngày gửi Ngày gửi
đổi pj vùn vụt thế thím :| thế thím Daric h thầu pj gì?

- - - Updated - - -

đổi pj vùn vụt thế thím :| thế thím Daric h thầu pj gì?
 
gone it
 
Chỉnh sửa cuối:
a Mee dân voz?

h đang hk có gì làm, vì lý do lớn nên hk làm rpg nữa :4cool_doubt: chắc bỏ sang nghề viết lib như ông Hùng hay lại dịch tutorial
còn a đấy a Hùng, ăn nói toàn phóng đảng... ;;) hồi xưa em chửi tên nhóc trâu 97 a bảo để lại vết ố, h chắc là vết khét rồi =))
 
gì mà dân voz 8-} suy nghĩ thế nào mà phán thế vậy
 
gone it
 
Chỉnh sửa cuối:
đây là một system loop của Daric Nguyen nó giống như T32 vậy nhưng khác là dễ sử dụng hơn! tớ xin mạn phép up system này lên topic này vì muốn mọi người biết đến RepeatData của Daric Nguyen :">

P/S: đây là bản RepeatData32 nó loop liên tục với 1/32 giây khác hơn so với cái cũ là 0.03 giây :-s

PHP:
library RepeatData // v0.3 (System)
/****************************************************************************************************
 ____                       _   ____        _        
|  _ \ ___ _ __   ___  __ _| |_|  _ \  __ _| |_ __ _ 
| |_) / _ \ '_ \ / _ \/ _` | __| | | |/ _` | __/ _` |
|  _ <  __/ |_) |  __/ (_| | |_| |_| | (_| | || (_| |
|_| \_\___| .__/ \___|\__,_|\__|____/ \__,_|\__\__,_|
          |_|                         
by Daric Nguyen:        

 System nay la mot ban thay the cua Timer32, do' co the su dung rat de~ dang` va tien loi.
 
 day la phien ban Repeat32 thay doi timer loop se la 1/32 tuc 0.03125!!

 
R32_PERIOD = 0.03125
 - Easy to use
  - MUI for spell
   - Store data by Struct
   
  * HOW TO USE?
  
      + Method:
         - method onStart takes nothing returns nothing
         - method onLoop takes nothing returns nothing
         - method onEnd takes nothing returns nothing
***************************************************************************************************/
    private interface RepeatFace
    
    method onLoop takes nothing returns nothing defaults nothing
        method onStart takes nothing returns nothing defaults nothing
            method onEnd takes nothing returns nothing defaults nothing
                endinterface

globals
    real R32_PERIOD = 0.03125 //1/32
    private integer cn=0
    private timer rTime=CreateTimer()
endglobals

struct RepeatData extends RepeatFace
    public real rL
    public real nrL
    public real mrL
    public boolean rSt
    public real rnL
    
    private static thistype array rData
    static method create takes real Loop, real maxLoop returns thistype
        local thistype this=thistype.allocate()
            set this.rL=Loop
            set this.mrL=maxLoop
            set this.rSt=true
            set this.nrL=0
            set this.rnL=0
            set cn=cn+1
            set .rData[cn]=this
            if cn==1 then
                call TimerStart(rTime,R32_PERIOD,true,function RepeatData.rpLoop)
            endif
        return this
    endmethod
    
    method stop takes nothing returns nothing
        set this.mrL=R32_PERIOD
    endmethod
    
    static method rpLoop takes nothing returns nothing
        local thistype this
        local integer i=1
        loop
            exitwhen i>cn
            set this=.rData[i]
            if this.rL==0 then
                call this.stop()
            endif
            if this.rSt==true then
                set this.rSt=false
                call this.onStart()
            endif
            if this.mrL==0 then
                set this.nrL=this.nrL+R32_PERIOD
                set this.rnL=this.rnL+R32_PERIOD
                if this.rnL>=this.rL then
                    call this.onLoop()
                    set this.rnL=0
                endif
            else
                if this.nrL>=this.mrL then
                    call this.onEnd()
                    call this.destroy()
                    set .rData[i]=.rData[cn]
                    set i=i-1
                    set cn=cn-1
                else
                    set this.nrL=this.nrL+R32_PERIOD
                    set this.rnL=this.rnL+R32_PERIOD
                    if this.rnL>=this.rL then
                        call this.onLoop()
                        set this.rnL=0
                    endif
                endif
            endif
            set i=i+1
        endloop
        if cn<=0 then
            set cn=0
            call PauseTimer(rTime)
        endif
    endmethod
endstruct
endlibrary

Thiếu 1 phần rất hay của T32 nhé, T32_Tick ^^
 
gone it
 
Chỉnh sửa cuối:
gone it
 
Chỉnh sửa cuối:
PHP:
library GroupLable initializer Init// v0.1 (Snippet) 
/**************************************************************************************************** 
  ____                       _          _     _      
 / ___|_ __ ___  _   _ _ __ | |    __ _| |__ | | ___ 
| |  _| '__/ _ \| | | | '_ \| |   / _` | '_ \| |/ _ \
| |_| | | | (_) | |_| | |_) | |__| (_| | |_) | |  __/
 \____|_|  \___/ \__,_| .__/|_____\__,_|_.__/|_|\___|
                      |_|                                                 
by dhguardianes:         

Automatically initialize all 120 of the group is available for your map
***************************************************************************************************/ 

    globals
        private integer Id
        private integer Index
        private boolean array Then
        group array StoreGroup
        private constant integer safe = 120
    endglobals
    function CleanGroup takes group g returns nothing
        local integer i = GetHandleId(g) - Id
        if i < 0 or i > safe then
        else
            call GroupClear(g)
            set Then[i] = false
            set Index = i
        endif
    endfunction

    function GetGroup takes nothing returns group
        local integer i = Index
        loop
            exitwhen i==Index - 1
            if Then[i]==false then
                set Index = i + 1
                if Index==safe then
                    set Index = 0
                endif
                set Then[i] = true
                return StoreGroup[i]
            endif
            set i = i + 1
            if i==safe then
                set i = 0
            endif
        endloop
        call BJDebugMsg("|c00ff0303CRITICAL ERROR: FOUND NO AVAILABLE GROUPS|r")
        return CreateGroup()
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        local integer i = 0
        set Index = 0
        set StoreGroup[i] = CreateGroup()
        set Then[i] = false
        set i = i + 1
        set Id = GetHandleId(StoreGroup[0])
        loop
            exitwhen i==safe
            set StoreGroup[i] = CreateGroup()
            set Then[i] = false
            set i = i + 1
        endloop
    endfunction
endlibrary

tự động tạo đủ 120 cái group có sẵn trong map! nó giống như GroupUltis:-?
bạn sẽ không cần destroy nó chỉ cần sử dụng dòng lệnh CleanGroup thay vì phải destroy:-"

cách xài

set TempGroup = GetGroup()
call Enum...
call CleanGroup(TempGroup)

có gì hay hơn GroupUtils ?
 
gone it
 
Chỉnh sửa cuối:
gone it
 
Chỉnh sửa cuối:
gone it
 
Chỉnh sửa cuối:
lần đầu tiên viết 1 system k phụ thuộc vào các system khác của map mình :))
tuy nhiên vẫn cần TimerUtils nhé @-)
Mã:
library SystemKnockBack requires TimerUtils
//---made by Meepolisk, neu co dung thi credits nhe :D
//---cach su dung:
//-------call KnockBack (<location>, <unit> , <range knockback>, <thoi gian>)
//---> lam <unit> bi knockback vang ra xa <range knockback>
//tu huong <location> trong <thoi gian> giay.
    globals
         private constant real interval = 0.03
    endglobals
    private struct KBdata
        real time
        real timemax
        real angle
        unit u
        real move
        real rangemax
    endstruct
    
    private function KnockBackEnd takes nothing returns nothing
        local KBdata this = GetTimerData(GetExpiredTimer())
        local real fly = (this.rangemax/3)*Sin(this.time/this.timemax * 180 * bj_DEGTORAD)
        local location loc1 = GetUnitLoc(this.u)
        local location loc2 = PolarProjectionBJ(loc1, this.move, this.angle)
        set this.time = this.time - interval
        if this.time > 0 then
            call SetUnitFlyHeight(this.u, fly, 0.00)
            call SetUnitPositionLoc(this.u, loc2)
        else
            call UnitRemoveAbility(this.u,'Amrf')
            call SetUnitFlyHeight(this.u, GetUnitDefaultFlyHeight(this.u), 0.00)
            call ReleaseTimer(GetExpiredTimer())
            call PauseUnit(this.u, false)
            call this.destroy()
        endif
        call RemoveLocation(loc1)
        call RemoveLocation(loc2)
        set loc1 = null
        set loc2 = null
    endfunction
    
    function KnockBack takes location loc, unit u, real range, real time returns nothing
        local KBdata this = KBdata.create()
        local timer t = NewTimer()
        set this.u = u
        set this.timemax = time
        set this.time = time
        set this.angle = bj_RADTODEG * Atan2(GetUnitY(u) - GetLocationY(loc), GetUnitX(u) - GetLocationX(loc))
        set this.rangemax = range
        set this.move = this.rangemax/(this.timemax/interval)
        call SetTimerData(t, this)
        call PauseUnit(u, true)
        call UnitAddAbility(u,'Amrf')
        call TimerStart(t, interval, true, function KnockBackEnd)
    endfunction
endlibrary

Đây là system KnockBack có độ cao, nghĩa là knockback ra sẽ làm văng các chú khác lên trời (gần như toss)
Cách dùng rõ hơn (cụ thể là skill thunder clap)
Mã:
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Thunder Clap
    Actions
        Set AALoc1 = (Position of (Triggering unit))
        Unit Group - Pick every unit in (Units within 300.00 of AALoc1 matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
            Loop - Actions
                Custom script:   call KnockBack (udg_AALoc1, GetEnumUnit(), 500, 1)


Bạn ơi.. bạn có thể làm cho nó ra 2 trường hợp.. 1 là knockback có bay lên và 1 là chỉ knockback thôi không có bay lên không ?..
Vì có lúc thì cần nó bay , nhưng có lúc lại không cần.. nếu được chuyển mấy cái loc thành tọa độ x,y luôn được k :D.. để mình nhập tọa độ vô thôi khỏi gọi location ..
 
Chỉnh sửa cuối:
Bạn ơi.. bạn có thể làm cho nó ra 2 trường hợp.. 1 là knockback có bay lên và 1 là chỉ knockback thôi không có bay lên không ?..
Vì có lúc thì cần nó bay , nhưng có lúc lại không cần.. nếu được chuyển mấy cái loc thành tọa độ x,y luôn được k :D.. để mình nhập tọa độ vô thôi khỏi gọi location ..

bạn có thể chỉnh sửa snippet của mình, làm thêm 1 cái tương tự và xóa tất cả biến liên quan tới độ cao unit là đc mà :D
 
bạn có thể chỉnh sửa snippet của mình, làm thêm 1 cái tương tự và xóa tất cả biến liên quan tới độ cao unit là đc mà :D
hì...ý mình là bạn nên làm cho nó có tính tùy biến cao hơn. Như là bay và không bay như mình nói.. rồi ngoài ra còn tùy biến nhập cho người nhập tọa độ và người dùng location nữa..
MÌnh thì code được rồi nhưng code thì gớm lắm :D.. mình không phải dân lập trình chỉ học lõm thôi nên không dám chỉnh sữa của bạn :D.. nếu bạn chỉnh được chút thì tuyệt.. code của bạn mà :1cool_byebye:
 
H nay ngồi móc đ, á nhầm móc tài liệu, :9cool_pudency: moi ra mấy cái system đồ cổ hồi mới học type code jass:
Check sự di chuyển (req: R32, AutoIndex)
PHP:
library IsUnitMoving initializer init requires RepeatData, AutoIndex
/*================================================
Dua tren y tuong cua thang gi day quen roi:
Credit to: Anh dep zai nao day viet ra isUnitMoving ben 4rum nc ngoai
/ Someone who wrote isUnitMoving in another 4rum :-*
System co the kiem tra rieng le unit co dang di chuyen hay khong

Can phai dang ky lenh de xac dinh unit co di chuyen hay khong

Khac voi system IsUnitMoving cua nn, system nay tien loi hon vi muon check unit nao
chi can nhap lenh add vao lenh de check, ko can phai add tat ca unit
Giam thieu leak cho map.

=================================================*/
globals
    private boolean array IsMove
    private boolean array Unregist
endglobals

private struct moving extends RepeatData
    unit wmove
    real lx
    real ly
    method onLoop takes nothing returns nothing
        local real x=GetUnitX(this.wmove)
        local real y=GetUnitY(this.wmove)
        if (x != this.lx or y != this.ly) or (x != this.lx and y != this.ly) then
            if IsMove[GetUnitId(this.wmove)]==false then
                set IsMove[GetUnitId(this.wmove)]=true
                set this.lx=GetUnitX(this.wmove)
                set this.ly=GetUnitY(this.wmove)
            endif
        else
            if x== this.lx and y == this.ly then
                if IsMove[GetUnitId(this.wmove)]==true then
                    set IsMove[GetUnitId(this.wmove)]=false
                endif
            endif
        endif
        if Unregist[GetUnitId(this.wmove)]== true then
            call this.stop()
        endif
    endmethod
    method onEnd takes nothing returns nothing
        set this.wmove=null
    endmethod
endstruct

    function IsUnitMoving takes unit which returns boolean
        return IsMove[GetUnitId(which)]
    endfunction

    function RegisterUnitMoving takes unit which returns nothing
        local moving this=moving.create(0.10,0)
        set this.wmove=which
        set IsMove[GetUnitId(which)]=false
        set this.lx=GetUnitX(which)
        set this.ly=GetUnitY(which)
    endfunction
    
    function UnregisterUnitMoving takes unit which returns nothing
        set Unregist[GetUnitId(which)]=true
    endfunction

    private function init takes nothing returns nothing
        local integer i=0
        loop
            exitwhen i>=8120
            set IsMove[i]=false
            set Unregist[i]=false
            set i=i+1
        endloop
    endfunction
endlibrary

và system hữu dụng cho Multiboard cho ai muốn làm đẹp:
PHP:
library MultiboardText initializer init
globals 
    private timer saveTimer
    private integer sN
    private MultiboardText array sMT
endglobals

struct MultiboardText
    multiboard saveMulti
    integer saveColumn
    integer saveRow
    real saveTime
    real thisTime
    string saveText
    boolean saveStatus
    integer saveMax
    integer saveMin
    string saveColor
    
    static method create takes multiboard Multi, string Text, integer c, integer r, real t, string tclr returns thistype
        local thistype this=thistype.allocate()
        set this.saveMulti=Multi 
        set this.saveText=Text
        set this.saveColumn=c
        set this.saveRow=r
        set this.saveTime=t
        set this.saveStatus=false
        set this.thisTime=0
        set this.saveColor=tclr
        return this
    endmethod
    
    method onDestroy takes nothing returns nothing
        set .saveMulti=null
    endmethod
endstruct

function MultiboardTextLoop takes nothing returns nothing
    local MultiboardText this
    local MultiboardText revers
    local integer i=1
    local integer i2=sN
    local string s
    loop
        exitwhen i>sN
        set this=sMT[i]
        if this.saveStatus==false then
            if i>1 then
                loop
                    exitwhen i2<=0
                    if i2<i then
                        set revers=sMT[i2]
                        if revers.saveRow==this.saveRow then
                            set revers.saveStatus=true
                        endif
                    endif
                    set i2=i2-1
                endloop
                if this.saveStatus==false then
                    if this.saveMin>= (this.saveMax-3) then
                        call MultiboardSetItemValueBJ(this.saveMulti,this.saveColumn,this.saveRow,"")
                        call this.destroy()
                        set sMT[i]=sMT[sN]
                        set sN=sN-1
                        set i=i-1
                    else
                        if this.thisTime>= this.saveTime then
                            set this.thisTime=0
                            set this.saveMin=this.saveMin+1
                            set s=SubString(this.saveText,this.saveMin,this.saveMax)
                            call MultiboardSetItemValueBJ(this.saveMulti,this.saveColumn,this.saveRow,s)
                        else
                            set this.thisTime=this.thisTime+0.04
                        endif
                    endif
                endif
            else
                if this.saveMin>= (this.saveMax-3) then
                    call MultiboardSetItemValueBJ(this.saveMulti,this.saveColumn,this.saveRow,"")
                    call this.destroy()
                    set sMT[i]=sMT[sN]
                    set sN=sN-1
                    set i=i-1
                else
                    if this.thisTime>= this.saveTime then
                        set this.thisTime=0
                        set this.saveMin=this.saveMin+1
                        set s=SubString(this.saveText,this.saveMin,this.saveMax)
                        call MultiboardSetItemValueBJ(this.saveMulti,this.saveColumn,this.saveRow,s)
                    else
                        set this.thisTime=this.thisTime+0.04
                    endif
                endif
            endif
        else
            set this.saveStatus=false
        endif
        set i=i+1
    endloop
    
    if sN<=0 then
        set sN=0
        call PauseTimer(saveTimer)
    endif
endfunction

function MultiboardSetItemText takes multiboard which, integer c, integer r, string txt, string cl, real t returns nothing
    local MultiboardText mt
    local string txtt="                                                                              " +txt+"         " 
    if t<=0 then
        set t=0.1
    endif
    set mt=MultiboardText.create(which,txtt,c,r,t,cl)
    set mt.saveMax=StringLength(txtt)
    set mt.saveMin=0
    set sN=sN+1
    set sMT[sN]=mt
    if sN==1 then
        call TimerStart(saveTimer,0.04,true,function MultiboardTextLoop)
    endif
endfunction

private function init takes nothing returns nothing
    set saveTimer=CreateTimer()
    set sN=0
endfunction

endlibrary

Vài hướng dẫn sử dụng cho system multiboard text trên:
call MultiboardSetItemText( multiboard , so cot, so dong, doan text dai`, mau, toc do chay (0.04~1))
trong đó, so cot (column) là vị trí cột trong multiboard, nên để là 1
số dòng (row) là dòng trong multiboard. Khi sử dụng nhớ set độ dài của row này = tổng độ rộng của Multiboard (ví dụ multiboard là 100% size, có 4 cột thì set cột 1 dòng x 100%, cột 2 dòng x 0%, cột 3,4 dòng x 0%.

System này chạy chữ từ phải sang trái cho đẹp.
Ý tưởng dựa trên sự góp ý của a Thiên

Ai thấy hay + rep nhóe :-*
 
Chỉnh sửa cuối:
Sao toàn là Jass và V-Jass không vậy ...
GUI như em sao dám post lên ạ mấy bác :))
 
gone it
 
Chỉnh sửa cuối:
cái multiboard đó dc cái hấp dẫn. nhưng nó đã ăn khá nhiều hiệu suất map :-<





cứ tự nhiên mà post hãy post theo cách thức của mình >:D<
Không tự tin thím ơi :)) sợ gạch quá há há
 
cái multiboard đó dc cái hấp dẫn. nhưng nó đã ăn khá nhiều hiệu suất map :-<

Convert tích hợp với R32 đc hem a nhỉ :9cool_pudency:
 
Back
Top