这是13年时帮19写的一个脚本,有点老了
6 G4 p, i6 m8 g5 W5 e7 G5 T: ~
: M# o; D( R" h6 m4 ]+ F9 Z. F7 x魔力私服,最新魔力宝贝私服技术交流其中关于属性的算法,由于当时的理解原因,有一些偏差,所以仅供参考。
复制内容到剪贴板
代码:
Delegate.RegDelTalkEvent("CharTalk");
local gmkey = "gm"; --GM口令
function CharTalk(player,msg,color,range,size)
if(Char.GetData(player,%对象_GM%) == 1) then --要求GM权限
local len = string.len(gmkey) + 1 + string.len(" makerdpet "); --计算长度
if(string.sub(msg,1,len) == "["..gmkey.." makerdpet " and string.sub(msg,-1) == "]") then --判断前缀和后缀,形成GM指令形式
local newmsg = string.sub(msg,len + 1,-2);
local takenlist = Split(newmsg," ");
local PetID = tonumber(takenlist[1]);
local Vital = tonumber(takenlist[2]);
local Str = tonumber(takenlist[3]);
local Tough = tonumber(takenlist[4]);
local Quick = tonumber(takenlist[5]);
local Magic = tonumber(takenlist[6]);
--判断参数数量以及参数是否为空
if(#takenlist ~= 6 or PetID == nil or Vital == nil or Str == nil or Tough == nil or Quick == nil or Magic == nil) then
NLG.SystemMessage(player,"所输入的参数存在错误。");
return;
end
--通过编号获取对应EnemyBase信息
local EnemyIndex = Data.EnemyGetIndex(PetID);
if(EnemyIndex < 0) then
NLG.SystemMessage(player,"获取EnemyIndex时出错。");
return;
end
local EnemyTempID = Data.EnemyGetData(EnemyIndex,1);
local EnemyTempIndex = Data.EnemyTempGetIndex(EnemyTempID);
if(EnemyTempIndex < 0) then
NLG.SystemMessage(player,"获取EnemyTempIndex时出错。");
return;
end
--先随机生成一个宠物
local PetIndex = Char.AddPet(player,PetID);
--判断宠物索引
if(VaildChar(PetIndex) == true) then
--判断获取时等级是否为1级
if(Char.GetData(PetIndex,%对象_脸%) ~= 1) then
NLG.SystemMessage(player,"该宠物获取时非1级宠物,无法修改档数。");
return;
end
--取基础BP
local initnum = Data.EnemyTempGetData( EnemyTempIndex,1) + 2; --基础点数
local floatbp = math.random(0,Data.EnemyTempGetData( EnemyTempIndex,2)); --浮动点数
--获取满档成长值
local MaxVital = Data.EnemyTempGetData( EnemyTempIndex,4) + 2; --满档体成长
local MaxStr = Data.EnemyTempGetData( EnemyTempIndex,5) + 2; --满档攻成长
local MaxTough = Data.EnemyTempGetData( EnemyTempIndex,6) + 2; --满档防成长
local MaxQuick = Data.EnemyTempGetData( EnemyTempIndex,7) + 2; --满档敏成长
local MaxMagic = Data.EnemyTempGetData( EnemyTempIndex,8) + 2; --满档魔成长
--获取指定掉档后成长值
local CurVital = MaxVital - Vital;
local CurStr = MaxStr - Str;
local CurTough = MaxTough - Tough;
local CurQuick = MaxQuick - Quick;
local CurMagic = MaxMagic - Magic;
--更新成长值信息
Pet.SetArtRank(PetIndex,%宠档_体成%, CurVital );
Pet.SetArtRank(PetIndex,%宠档_力成%, CurStr );
Pet.SetArtRank(PetIndex,%宠档_强成%, CurTough );
Pet.SetArtRank(PetIndex,%宠档_敏成%, CurQuick );
Pet.SetArtRank(PetIndex,%宠档_魔成%, CurMagic );
--计算基础BP结果
CurVital = CurVital * initnum;
CurStr = CurStr * initnum;
CurTough = CurTough * initnum;
CurQuick = CurQuick * initnum;
CurMagic = CurMagic * initnum;
--分配随机点数 + BP浮动
for i = 0, 10 + floatbp do
local type = math.random(0,4);
if(type == 0) then
CurVital = CurVital + 1;
elseif(type == 1) then
CurStr = CurStr + 1;
elseif(type == 2) then
CurTough = CurTough + 1;
elseif(type == 3) then
CurQuick = CurQuick + 1;
else
CurMagic = CurMagic + 1;
end
end
--计算血量和魔量
local CurHP = 20 + ((CurVital * 8 + CurStr * 2 + CurTough * 3 + CurQuick * 3 + CurMagic * 1) /100);
local CurMP = 20 + ((CurVital * 1 + CurStr * 2 + CurTough * 2 + CurQuick * 2 + CurMagic * 10) /100);
--更新数据
Char.SetData(PetIndex,%对象_体力%,CurVital);
Char.SetData(PetIndex,%对象_力量%,CurStr);
Char.SetData(PetIndex,%对象_强度%,CurTough);
Char.SetData(PetIndex,%对象_速度%,CurQuick);
Char.SetData(PetIndex,%对象_魔法%,CurMagic);
Char.SetData(PetIndex,%对象_血%,CurHP);
Char.SetData(PetIndex,%对象_魔%,CurMP);
Char.SetData(PetIndex,%对象_最大血%,CurHP);
Char.SetData(PetIndex,%对象_最大魔%,CurMP);
--发送宠物信息封包
Pet.UpPet(player, PetIndex);
--发送更新信息
NLG.SystemMessage(player,"指定掉档["..Vital..","..Str..","..Tough..","..Quick..","..Magic.."]宠物生成成功,宠物编号["..PetID.."],宠物索引值["..PetIndex.."]。");
return;
else
NLG.SystemMessage(player,"创建宠物时发生错误,请检查宠物栏是否已满或宠物编号是否正确。");
return;
end
end
end
end