|
发表于 2010-12-14 17:36:34
本帖最后由 ou99孽缘 于 2010-12-14 17:39 编辑 //missionname:任务名字(要唯一)
//mission:任务内容(格式:十进制+数量举例:175219644910表示杀死10只1752196449多种类型怪依次将字符串连在一起就好了)
//taskunit:接任务人
//reward: 物品奖励(格式:十进制+数量,如果这里写多个十进制物品类型,那么将会从其中随机出)
//goldreward:金钱奖励
//xpreward:经验奖励
//tasklevel:需求任务等级(举例:必须先完成1级任务才可接2级任务)
//mess:任务内容说明
//mainmission:是否为主线任务(是,则true,那么只能接一次)
// 举例:set s="1734700404"+"1986290796"+"1651798900"+"1719104371"+"1936683617"+"1936683569"+"163527921***85825390"+"1936221300"+"1835955046"+"1668441204"
//call CreateTask("yongshichengzhang4","184865210701"+"184865236610"+"184865210401",shachengzhu,s+"01",100000,10000,3," 酒!只有酒才能让我解脱,想要我帮助你觉醒神之力量就去杀死10只白野猪,10只邪恶诅虫,10只变异神兽,1只祖玛卫士长,奖励极品祖玛装备,金钱10 万,经验10000",true)
//注意:修改I02Y为你的任务物品,物品或单位类型用十进制,缓存名一致(V)
function ChangeMissionToId takes trigger t,string mission returns nothing
local integer m=StringLength(mission)
local integer n=0
local string s
local string s2
local string s3
local string s4
loop
set s=SubString(mission,12*n,12*(n+1))
set s2=SubString(mission,12*(n+1),m)
set s3=SubString(s,0,10)
set s4=SubString(s,10,12)
call SetInteger(t,"missionALL",n)
call SetInteger(t,"missionID"+I2S(n),S2I(s3))
call SetInteger(t,"missionNU"+I2S(n),S2I(s4))
set n=n+1
exitwhen StringLength(s2)==0
endloop
endfunction
function ChangeRewardToId takes trigger t,string reward returns nothing
local integer m=StringLength(reward)
local integer n=0
local string s
local string s2
loop
exitwhen m<10
set s=SubString(reward,10*n,10*(n+1))
set s2=SubString(reward,10*(n+1),m)
call SetInteger(t,"reward"+I2S(n),S2I(s))
set n=n+1
exitwhen StringLength(s2)<=2
endloop
call SetInteger(t,"rewardID",n)
call SetInteger(t,"rewardNU",S2I(s2))
endfunction
function CreateTask_Init2 takes nothing returns nothing
local trigger lt=GetTriggeringTrigger()
local player p=GetPlayer(lt,"Player")
local unit u=GetTriggerUnit()
local integer m=GetInteger(lt,"missionALL")
local integer n=m
local integer redrum_ID=0local integer redrum_NU=0
local boolean kill=false
if GetOwningPlayer(GetKillingUnit())==p then
loop
exitwhen n<0
set redrum_ID=GetInteger(lt,"missionID"+I2S(n))
set redrum_KN=GetInteger(lt,"missionKN"+I2S(n))
if redrum_ID==GetUnitTypeId(u) then
set redrum_KN=redrum_KN+1
call SetInteger(lt,"missionKN"+I2S(n),redrum_KN)
set kill=true
endif
set n=n-1
endloop
if(kill) then
set n=m
loop
exitwhen n<0
set redrum_ID=GetInteger(lt,"missionID"+I2S(n))
set redrum_NU=GetInteger(lt,"missionNU"+I2S(n))
set redrum_KN=GetInteger(lt,"missionKN"+I2S(n))
call DisplayTimedTextToPlayer( p, 0, 0, 20,"|CFFFF0000"+GetObjectName(redrum_ID)+" :|R|CFFFF0080"+I2S(redrum_KN)+"|R|CFFFF0000/"+I2S(redrum_NU)+"|R")
set n=n-1
endloop
endif
endif
set lt=null
set p=null
set u=null
endfunction
function CreateTask_Finish takes nothing returns nothing
local trigger ltt=GetTriggeringTrigger()
local trigger lt
local trigger t
local unit u=GetUnit(ltt,"Unit")
local integer m=0
local integer n=0
local integer i=0
local player p
local integer goldreward=0
local integer xpreward=0
local integer tasklevel=0
local integer playertask=0
local integer int1=0
local integer int2=0
local item it
if GetTriggerUnit()==u then
set lt=GetTrigger(ltt,"LTrigger")
set i=GetInteger(lt,"missionALL")
set m=i
loop
exitwhen m<0
if GetInteger(lt,"missionKN"+I2S(n))>=GetInteger(lt,"missionNU"+I2S(n)) then
set n=n+1
endif
set m=m-1
endloop
if n>i then
set p=GetOwningPlayer(u)
set t=GetTrigger(ltt,"Trigger")
call DisplayTimedTextToPlayer( p, 0, 0, 20,"|CFFFFFF00恭喜你完成了任务|R")
set goldreward=GetInteger(t,"goldreward")
if goldreward>0 then
call DisplayTimedTextToPlayer( p, 0, 0, 20,"|CFFFFFF00获得金钱增加|R|CFFFF0000"+I2S(goldreward)+"金|R")
call SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)+goldreward)
endif
set xpreward=GetInteger(t,"xpreward")
if xpreward>0 then
call DisplayTimedTextToPlayer( p, 0, 0, 20,"|CFFFFFF00获得经验值增加|R|CFFFF0000"+I2S(xpreward)+"|R")
call AddHeroXP( u,xpreward, false )
endif
set int1=GetInteger(ltt,"rewardNU")
set int2=GetInteger(ltt,"rewardID")
if int1>0 then
loop
exitwhen int1==0
set it=CreateItem(GetInteger(ltt,"reward"+I2S(GetRandomInt(0,int2-1))), GetUnitX(u), GetUnitY(u))
call DisplayTimedTextToPlayer( p, 0, 0, 20,"|CFFFFFF00获得极品装备:|R|CFFFF0000"+GetItemName(it)+"|R")
set it=null
set int1=int1-1
endloop
endif
set tasklevel=GetInteger(t,"tasklevel")
if tasklevel+1>playertask then
set playertask=tasklevel+1
call SetInteger(p,"playertask",playertask)
endif
call SetInteger(p,GetString(t,"missionname"),2)
call Trigger_Destroy(lt)
call Trigger_Destroy(ltt)
endif
endif
set t=null
set lt=null
set ltt=null
set p=null
set u=null
endfunction
function CreateTask_Init takes nothing returns nothing
local unit u=GetTriggerUnit()
local trigger t=GetTriggeringTrigger()
local unit taskunit=GetUnit(t,"taskunit")
local integer tasklevel=GetInteger(t,"tasklevel")
local player p=GetOwningPlayer(GetBuyingUnit())
local integer playertask=GetInteger(p,"playertask")
local trigger lt
local trigger ltt
local string mission
local string reward
local string mess
if GetBoolean(t,"mainmission") and GetInteger(p,GetString(t,"missionname"))!=0 then
return
endif
if u==taskunit and playertask>=tasklevel and GetItemTypeId(GetSoldItem())=='I02Y' then
//注意:这里的I02Y修改成你的任务物品
set mission=GetString(t,"mission")
set reward=GetString(t,"reward")
set lt=CreateTrigger()
call ChangeMissionToId(lt,mission)
call TriggerRegisterAnyUnitEventBJ(lt,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(lt,Condition(function CreateTask_Init2))
set ltt=CreateTrigger()
call SetHandle(ltt,"LTrigger",lt)
call SetHandle(ltt,"Unit",GetBuyingUnit())
call SetHandle(ltt,"Trigger",t)
call ChangeRewardToId(ltt,reward)
call TriggerRegisterUnitInRangeSimple(ltt,256,taskunit)
call TriggerAddCondition(ltt,Condition(function CreateTask_Finish))
set mess=GetString(t,"mess")
call DisplayTimedTextToPlayer( p, 0, 0, 20,"|CFFFFFF00你接受了任务:|R|CFF00FF00"+mess+"|R")
call SetInteger(p,GetString(t,"missionname"),1)
endif
set u=null
set t=null
set taskunit=null
set p=null
set lt=null
set ltt=null
endfunction
function CreateTask takes string missionname,string mission,unit taskunit,string reward,integer goldreward,integer xpreward,integer tasklevel,string mess,boolean mainmission returns nothing
local trigger t=CreateTrigger()
call SetString(t,"mission",mission)
call SetHandle(t,"taskunit",taskunit)
call SetString(t,"reward",reward)
call SetInteger(t,"goldreward",goldreward)
call SetInteger(t,"xpreward",xpreward)
call SetInteger(t,"tasklevel",tasklevel)
call SetString(t,"mess",mess)
call SetString(t,"missionname",missionname)
call SetBoolean(t,"mainmission",mainmission)
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SELL_ITEM)
call TriggerAddCondition(t,Condition(function CreateTask_Init))
set t=null
endfunction
|
|