发新话题
打印

[JASS] [转载]完美的刷怪系统

[转载]完美的刷怪系统

只需要在地图初始化的时候call InitCreep(),然后在Unit Die事件中call CreepDie(GetDyingUnit())就行了,注意要加一个
GameCache的变量CC, 这里设定的90s后自动复活,你可以自己修改.
特点:
1. 刷怪功能完美,,刷的新怪和原来的怪物初始位置相同,而且我这里设定了有50%的几率会刷出一个同等级但
是随机类型的怪物出来。可以自行取舍。召唤的出来的怪物不会被误刷。
2. 只需要利用地图的GameCache,不需要变量。
3. 我这里设定了当怪物原来所在的位置有建筑物时则不会复活,一直等到没有建筑物了再复活。这个设定是为了
避免已经清理矿区造好基地了,怪物还在不停的刷。可以自行取舍。
4. 里面附带了掉宝系统。
//Creep Die,只需要调用CreepDie()函数和InitCreep()函数
function H2HI takes handle h returns integer
   return h
   return 0
endfunction

function NearToBuildingFilter0 takes nothing returns boolean
   return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetPlayerId(GetOwningPlayer(GetFilterUnit()))<=11
endfunction

function NearToBuilding takes real X, real Y returns boolean
   local location loc=Location(X,Y)
   local group g=GetUnitsInRangeOfLocMatching(800, loc, Condition(function NearToBuildingFilter0))
   local boolean yn=( FirstOfGroup(g)!=null )
   call RemoveLocation(loc)
   call DestroyGroup(g)
   return yn
endfunction

function CreepRevive takes nothing returns nothing
   local timer tm= GetExpiredTimer()
   local string tmMis="CreepTimer"+I2S(H2HI(tm))
   local string creepMis
   local integer TypeId=GetStoredInteger(udg_CC,tmMis,"TypeId")
   local real X=GetStoredReal(udg_CC,tmMis,"X")
   local real Y=GetStoredReal(udg_CC,tmMis,"Y")
   local real Facing=GetStoredReal(udg_CC,tmMis,"Facing")
   local unit u
   if NearToBuilding(X,Y) then
      call TimerStart(tm,60,false,function CreepRevive)
      return
   endif

   call FlushStoredMission(udg_CC,tmMis)
   call DestroyTimer(tm)
   set u=CreateUnit(Player(12),TypeId,X,Y,Facing)
   call SetUnitAcquireRange( u, 200 )
   set creepMis="Creep"+I2S(H2HI(u))
   call StoreInteger(udg_CC,creepMis,"TypeId",TypeId)
   call StoreReal(udg_CC,creepMis,"X",X)
   call StoreReal(udg_CC,creepMis,"Y",Y)
   call StoreReal(udg_CC,creepMis,"Facing",Facing)
endfunction

function CreepDie takes unit u returns nothing
   local integer itemId=0
   local string mis="Creep"+I2S(H2HI(u))
   local timer tm=CreateTimer()
   local string tmMis="CreepTimer"+I2S(H2HI(tm))
   local integer TypeId=0
   //drop item
   if GetRandomInt(1,100)<=20 then
      loop
        exitwhen itemId!=0
        set itemId=ChooseRandomItemEx(ConvertItemType(GetRandomInt(0,4)),GetUnitLevel(u)*GetRandomInt(7,10)/10)
      endloop
      call CreateItem(itemId,GetUnitX(u),GetUnitY(u))
   endif
   //revive creep
   set TypeId=GetStoredInteger(udg_CC,mis,"TypeId")
   if TypeId==0 then
      //unknown creep, no revive
      return
   endif
   if GetRandomInt(1,2)<=1 then
      set TypeId=ChooseRandomCreep(GetUnitLevel(u))
   endif
   call StoreInteger(udg_CC,tmMis,"TypeId",TypeId)
   call StoreReal(udg_CC,tmMis,"X",GetStoredReal(udg_CC,mis,"X"))
   call StoreReal(udg_CC,tmMis,"Y",GetStoredReal(udg_CC,mis,"Y"))
   call StoreReal(udg_CC,tmMis,"Facing",GetStoredReal(udg_CC,mis,"Facing"))
   call FlushStoredMission(udg_CC,mis)
   call TimerStart(tm,90,false,function CreepRevive)
endfunction

//Init Creep
function InitCreepEnum takes nothing returns nothing
   local unit u=GetEnumUnit()
   local string mis
   if IsUnitType(u,UNIT_TYPE_STRUCTURE)==false then
      set mis="Creep"+I2S(H2HI(u))
      call StoreInteger(udg_CC,mis,"TypeId",GetUnitTypeId(u))
      call StoreReal(udg_CC,mis,"X",GetUnitX(u))
      call StoreReal(udg_CC,mis,"Y",GetUnitY(u))      
      call StoreReal(udg_CC,mis,"Facing",GetUnitFacing(u))
   endif
endfunction

function InitCreep takes nothing returns nothing
   local group g=CreateGroup()
   call GroupEnumUnitsOfPlayer(g,Player(12),null)
   call ForGroup(g, function InitCreepEnum )
   call DestroyGroup(g)
endfunction

TOP

为什么都是E文?看不懂啊
一定要加入心魔.通灵王大战V1.30.

TOP

只有这样才算完美耶..用T写会有BUG

TOP

引用:
引用第2楼ghq1882007-08-04 11:10发表的“”:
只有这样才算完美耶..用T写会有BUG
我不同意用T写会有BUG.也可以完美无缺
法律規定:第一,吳大俠是無敵的;第二,當吳大俠有敵時,請參照第一條……
[img]<a href="http://cry.travianteam.com/"><img src="http://cry.travianteam.com/sig-9-cn-2-cn1_52101.gif" alt="Travian" /></a>[img]

TOP

引用:
引用第1楼邪恶dē菲菲2007-08-04 09:25发表的“”:
为什么都是E文?看不懂啊
这个叫JASS脚本。。晕。

TOP

这是lars大人写野生怪物刷怪系统  LZ转载应该标注下

不过我没用这个    我自己写了个刷怪系统
“风的精灵啊
  请转告泰兰德
  说我很好地遵守了承诺
  然后长眠于此”

像尤迪安一样无法得到族人认同,无法得到所期待的爱情,但我更要像他那样勇敢、坚韧、能够为爱付出一切,勇往直前的战斗下去……

TOP

JASS都是一长串一长串的。。看着不是很舒服。。

TOP

好像有人写过
调戏,赤裸裸的调戏!威胁,光溜溜的威胁!

TOP

但很多人不懂JASS,还是喜欢用T写...
一定要加入心魔.通灵王大战V1.30.

TOP

T没那么完美啊
调戏,赤裸裸的调戏!威胁,光溜溜的威胁!

TOP

转载也要注明下吧。。。

TOP

看不懂啊,有没有T版的?

TOP

E文没学好.....根本看不懂
有一种感觉总在失眠时,才承认是“相思”;
有一种缘分总在梦醒后,才相信是“永恒”;
有一种目光总在分手时,才看见是“眷恋”;
有一种心情总在离别后,才明白是“失落”;
有一种态度总在放弃后,才知道是“美丽”!

TOP

哎~一点都看不动‘

TOP

用T的确会有BUG。。。。
所以任物者谓之心;心有所忆谓之意;意之所存谓之志;因志而存变谓之思;因思而远慕谓之虑;因虑而处物谓之智。

TOP

发新话题