用ABLUA写了一个类似原地石的道具

2019-11-0610:21石器单机版石器

模仿石器时代里恶魔宝石(原地石),这个道具比原地石要高级一些,可以自定义怪物ID,无论在任何地图下都可以遇到定义的怪物,并且没有使用次数限制,这个LUA主要是运用了循环事件和怪物数组和随机数,注释我就不给了,请自行研究,这应该是我第一次直接贴出这么多代码。这LUA还没有测试过,有问题请自己解决,学习还得靠自己。

C
function Loop(meindex)
	if char.Finditem(meindex, itemid) > -1 then        if char.getWorkInt(meindex, "NPC临时1") == 0 then	        char.delFunctionPointer(meindex, "循环事件")
	        return
        end		
        if char.getWorkInt(meindex, "摆摊") >= 1 then 	        char.delFunctionPointer(meindex, "循环事件")
	 	    char.TalkToCli(meindex, -1, "不能在摆摊时使用", "黄色")
    return
        end		
	    if char.getWorkInt(meindex, "战斗") == 0 then	        if char.getInt(meindex, "地图号") == enemymap then  		        if char.getWorkInt(meindex, "战斗") == 0 then
	                    rarepetid1 = {1794,1795,1796,1797,2943,2944,2945,2890,2891,2892,2893,2941}
	                    rarepetid2 = {333,310,324,367,1624,2786,2787,2788,2789,341,46,50,337,333,310,324,367,1624,2786,2787,2788,2789,341,46,50,337,2993,2994,2995,2830,2831,2832,2833,2834}
  		                rarepetid3 = {346,347,348,349,75,76,78,307,308,309,42,43,44,45,476,56,57,55,54,307,308,309,321,319,320,322,325,340,339,481,331,330,332,483}
enemytable = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
                irnd = math.random(1,10)
            for i = 1, irnd do
            rnd = math.random(10000)
                if rnd > 9950 then
                    enemytable[i] = rarepetid1[math.random(table.getn(rarepetid1))]
            elseif rnd <= 1000 then
            enemytable[i] = rarepetid2[math.random(table.getn(rarepetid2))]
            else
            enemytable[i] = rarepetid3[math.random(table.getn(rarepetid3))]
            end
                end
	                    battleindex = battle.CreateVsEnemy(meindex, -2, enemytable)
                end			else
   		        if char.getWorkInt(meindex, "战斗") == 0 then
                    enemytable = {0, 0, 0, 0, 0, 0, 0, 0, 0 }
                    battleindex = battle.CreateVsEnemy(meindex, -1, enemytable)
                end
            end
        end    else
       char.delFunctionPointer(meindex, "循环事件")
    end
end
function encount(itemindex, charaindex, toindex, haveitemindex)
    if char.getWorkInt(charaindex, "摆摊") >= 1 then 	    char.TalkToCli(charaindex, -1, "不能在摆摊时使用", "黄色")
return
    end	
	if char.getInt(charaindex, "地图号") ~= enemymap then		char.TalkToCli(charaindex, -1, "只能在" .. map.getFloorName(enemymap) .. "上使用", "黄色")
return
	end	if char.getWorkInt(charaindex, "组队") ~= 2 then		char.setFunctionPointer(charaindex, "循环事件", "Loop", "")
char.setInt(charaindex, "循环事件时间", 2000)
	end
item.UpdataItemOne(charaindex, itemindex)
	char.setFunctionPointer(charaindex, "登出事件", "CharLogout", "")
	char.setWorkInt(charaindex, "NPC临时1", 1)
	char.TalkToCli(charaindex, -1, "你感受到周边突然充满杀气!", "黄色")end
function CharLogout( talkerindex )
	char.delFunctionPointer(talkerindex, "循环事件")end
function data()
	itemid = 21000
	enemymap = 125end
function main()
	data()
	item.addLUAListFunction( "ITEM_ENCOUNT", "encount", "")end



石器时代历史 PC端石器任务 石器时代俱乐部 石器cc 石器时代7.5