[SYSTEM] Pick Spell From Item by Kul
.
Sơ lược: Dành cho ai đang làm map dạng giống như hoihoi8's. Nói chung là có phần pick skill cho hero .
Hướng dẫn sơ:
• Bạn cần có tarven, item đại diện cho ability, và ability.
• Lấy rawcode của item và ability (Ctrl + D lên sẽ thấy rawcode của nó)
• Copy cả code mình share ở dưới vào 1 trigger.
• Khi cần add thêm spell nào thì tạo thêm một trigger, cho nó event map initialization, Ctrl + R lên (bấm chữ "c" 2 lần) và tìm chọn mục Custom Script, nhập vào hàm "call IMPORTSKILL(id,rawcodeitem,rawcodeability)
• 2 cái raw code thì nói ở trên rùi, còn id bạn phải thay nó bằng số thứ tự của ability, số thứ tự là giống như đếm số z thui, 1 spell cần add phải có 1 số thứ tự riêng, nếu trùng sẽ lỗi ==", khuyên bạn nên đặt theo thứ tự từ 1 trở đi. Đừng có phang bậy con số 9999 gì đó sẽ làm chậm code
CODE đây
Sơ lược: Dành cho ai đang làm map dạng giống như hoihoi8's. Nói chung là có phần pick skill cho hero .
Hướng dẫn sơ:
• Bạn cần có tarven, item đại diện cho ability, và ability.
• Lấy rawcode của item và ability (Ctrl + D lên sẽ thấy rawcode của nó)
• Copy cả code mình share ở dưới vào 1 trigger.
• Khi cần add thêm spell nào thì tạo thêm một trigger, cho nó event map initialization, Ctrl + R lên (bấm chữ "c" 2 lần) và tìm chọn mục Custom Script, nhập vào hàm "call IMPORTSKILL(id,rawcodeitem,rawcodeability)
• 2 cái raw code thì nói ở trên rùi, còn id bạn phải thay nó bằng số thứ tự của ability, số thứ tự là giống như đếm số z thui, 1 spell cần add phải có 1 số thứ tự riêng, nếu trùng sẽ lỗi ==", khuyên bạn nên đặt theo thứ tự từ 1 trở đi. Đừng có phang bậy con số 9999 gì đó sẽ làm chậm code
CODE đây
- Chọt vào đây:
- Code:
//----------------------------------------------------------------------
//- PICK SKILL SYSTEM (PSS) by Ajen Kul (wc3maps.org) -
//- De cai dat thi tao 1 item cho ability can add -
//- Sau do ban phai dang ky cho spell do bang cach -
//- Neu su dung GUI thi` Custom Script va` go~ -
//- call IMPORTSKILL(so thu tu spell,raw code item, raw code skill)-
//----------------------------------------------------------------------
//- Luu Y: so thu tu spell, phai go~ dung theo thu tu, neu trung` so thu tu se~ bi loi~
//- Vi du: spell Death Coit ban dang ky dau tien thi` so thu tu la` 1
//- call IMPORTSKILL(1,'rawcode item','rawcode ability')
//- Tiep den dang ky spell Avatar thi so thu tu se la 2
//- call IMPORTSKILL(2,'rawcode item avatar','rawcode ability avatar')
//- Rawcode la gi? vao Object (F6) bam' Ctrl + D la` thay' ^^!
//----------------------------------------------------------------------
library PickSkillSystem initializer Dangky
globals
//Map maker cai dat phan` nay`
private integer GOLDTRALAI = 100 //Khi max skill max level thi tra lai bao nhieu gold
private integer MAXLEVEL = 20 //Cai dat level skill toi da co the hoc duoc
private string THANHCONG = "|r · häc thµnh c«ng kü n¨ng " //Noi dung khi hoc thanh cong spell
private string UPSKILLTHANHCONG = "|r §· nng cÊp thµnh c«ng kü n¨ng " //Noi dung khi nang cap skill thanh cong
private string THATBAI = "|r CÊp é kü n¨ng ¹t cÊp cao nhÊt" //Noi dung khi spell da max level
//------------------------------------------------------------------------------------------------------
private integer array RAWITEM_ID
private integer array RAWSKILL_ID
private integer array RAWITEM
private integer array RAWSKILL
private integer SKILL_COUNT = 0
//<SKILL>
private integer array IDSPELL
private integer array LVLSKILL
private string array ADDSKILLNAME
private string array COLOR
//<ENDSKILL>
endglobals
function IMPORTSKILL takes integer id, integer a, integer b returns nothing
set RAWITEM_ID[SKILL_COUNT] = id
set RAWSKILL_ID[SKILL_COUNT] = id
set RAWITEM[RAWITEM_ID[SKILL_COUNT]] = a
set RAWSKILL[RAWSKILL_ID[SKILL_COUNT]] = b
set SKILL_COUNT = SKILL_COUNT + 1
endfunction
private function SETSKILL takes nothing returns nothing
local integer i = 0
local integer id = GetPlayerId(GetTriggerPlayer())
local integer ite = GetItemTypeId(GetManipulatedItem())
loop
exitwhen i>SKILL_COUNT
if ite == RAWITEM[i] then
set ADDSKILLNAME[id] = GetAbilityName(RAWSKILL[i])
set IDSPELL[id] = i
endif
set i = i + 1
endloop
endfunction
private function ADDSKILL takes unit u returns nothing
local integer id = GetPlayerId(GetTriggerPlayer())
local player TRIGPLAYER = GetTriggerPlayer()
local unit TRIGUNIT = u
local integer i = 0
call SETSKILL()
set LVLSKILL[id] = GetUnitAbilityLevel(TRIGUNIT,RAWSKILL[IDSPELL[id]])
if LVLSKILL[id] < 1 then
call UnitAddAbility(TRIGUNIT,RAWSKILL[IDSPELL[id]])
if GetLocalPlayer() == TRIGPLAYER
call ClearTextMessages()
call DisplayTimedTextToPlayer(Player(id), 0,0, 5, COLOR[i] + GetPlayerName(TRIGPLAYER) + THANHCONG + ADDSKILLNAME[id])
endif
set LVLSKILL[id] = 0
else
if LVLSKILL[id] < MAXLEVEL then
call IncUnitAbilityLevel(TRIGUNIT,RAWSKILL[IDSPELL[id]])
if GetLocalPlayer() == TRIGPLAYER then
call ClearTextMessages()
call DisplayTimedTextToPlayer(Player(id), 0,0, 5, COLOR[i] + GetPlayerName(TRIGPLAYER) + UPSKILLTHANHCONG + ADDSKILLNAME[id] + " |rlªn cÊp : |r" + I2S(LVLSKILL[id]+1))
endif
set LVLSKILL[id] = 0
else
if GetLocalPlayer() == TRIGPLAYER then
call AdjustPlayerStateBJ(GOLDTRALAI,TRIGPLAYER,PLAYER_STATE_RESOURCE_LUMBER)
call ClearTextMessages()
call DisplayTimedTextToPlayer(Player(id), 0,0, 5, "KÜ n¨ng " + ADDSKILLNAME[id] + THATBAI)
endif
set LVLSKILL[id] = 0
endif
endif
endfunction
private function RunSystem takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = 1
local integer skill = GetItemTypeId(GetManipulatedItem())
loop
exitwhen i>SKILL_COUNT
if skill == RAWITEM[i] then
call ADDSKILL(u)
set i = SKILL_COUNT
endif
set i = i + 1
endloop
endfunction
private function Dangky takes nothing returns nothing
local trigger pss = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( pss, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction(pss, function RunSystem)
/* mau player */
set COLOR[ 0] = "|c00FF0000" // Red Color Code
set COLOR[ 1] = "|c000042FF" // Blue Color Code
set COLOR[ 2] = "|c001CE6B9" // Teal Color Code
set COLOR[ 3] = "|c00540081" // Purple Color Code
set COLOR[ 4] = "|c00FFFC01" // Yellow Color Code
set COLOR[ 5] = "|c00FEBA0E" // Orange Color Code
set COLOR[ 6] = "|c0020C000" // Green Color Code
set COLOR[ 7] = "|c00E55BB0" // Pink Color Code
set COLOR[ 8] = "|c00959697" // Gray Color Code
set COLOR[ 9] = "|c00FFFFBB" //Light Blue Color Code
set COLOR[10] = "|c00FF00FF" // Dark Green Color Code
set COLOR[11] = "|c004E2A04" // Brown Color Code
set pss = null
endfunction
endlibrary
Last edited by |͇̿K͇̿||͇̿U͇̿||͇̿L͇̿| on 18.02.13 20:18; edited 7 times in total (Reason for editing : http://www.phutu.org)