Users have to make a empty script and put these codes in onLoad, and calls doEvent()
-- input you have to modify --
isDebug = false;
-- to show some debug message
isAttack = false;
-- to attack other bidder or not
isSupport = false;
-- support account, is this character to support or to bid
regOptionText = "";
-- registration option text
objNameUnknow = "<UNKNOWN>";
friendName = "";
-- character who avoid to attack, ie, to support
target = player:findNearestNameOrId("");
-- I was intended to attack the first bidder, but I can't find a way to parse the message
bidTarget = 37;
-- in my experience, 37 is enough for 5 white bags
Code: Select all
isDebug = false;
isAttack = false;
isSupport = false;
regOptionText = "";
objNameUnknow = "<UNKNOWN>";
friendName = "";
target = player:findNearestNameOrId("");
bidTarget = 37;
---------------------------------------------------
npcName = GetIdName(121088);
regBuffName = GetIdName(623225);
eventBuffName = GetIdName(623229);
attackedBuffName = GetIdName(623228);
bidBuffName = GetIdName(623237);
bodyguardBuff = GetIdName(623226);
bidCount = 0;
skills = {
[1] = { Index = 1, CastTime = 0, Cooldown = (3-1), Range = 0 },
[2] = { Index = 2, CastTime = 0, Cooldown = (20-1), Range = 0 },
[3] = { Index = 3, CastTime = 0, Cooldown = 15, Range = 200 }
};
function skillCanUse(skill)
-- On cooldown?
if skill.Cooldown and skill.LastCastTime and skill.Cooldown > os.clock() - skill.LastCastTime then
if isDebug then
cprintf(cli.lightblue, "skill %d on cooldown.\n", skill.Index);
end
return false;
end
return true;
end;
function skillUse(skill)
RoMScript("UseExtraAction(" .. skill.Index .. ")");
if isDebug then
cprintf(cli.lightblue, "skill %d used.\n", skill.Index);
end
skill.LastCastTime = os.clock();
yrest(skill.CastTime * 1000);
end;
function doEvent()
-- Wait until NPC can be talked to
cprintf(cli.lightblue, "Waiting for event registration with %s!\n", npcName);
if (not player:hasBuff(regBuffName) and not player:hasBuff(eventBuffName)) then
repeat
-- Target NPC
repeat
if not player:target_NPC(npcName) then
error("Can't find NPC " .. npcName)
end;
yrest(1000);
until RoMScript("SpeakFrame:IsVisible()");
yrest(1000);
-- Register event
ChoiceOptionByName(regOptionText);
yrest(1000);
if not player:hasBuff(regBuffName) then
yrest(10000);
end
until player:hasBuff(regBuffName);
end;
if (not player:hasBuff(eventBuffName)) then
cprintf(cli.lightblue, "Waiting for event to start!\n");
while (not player:hasBuff(eventBuffName)) do
yrest(1000);
end;
cprintf(cli.lightblue, "Event started!\n");
else
cprintf(cli.lightblue, "Event already started!\n");
end;
-- Do event
repeat
local skill;
if (not isSupport) then
skill = skills[2];
if skillCanUse(skill) then
skillUse(skill);
end
skill = skills[1];
if not player:hasBuff(attackedBuffName) and skillCanUse(skill) then
skillUse(skill);
player:updateBuffs();
local bidBuff = player:getBuff(bidBuffName);
if (bidBuff) then
bidCount = bidBuff.Level + 1;
end;
if bidTarget ~= 0 and bidCount > bidTarget then
cprintf(cli.lightblue, "You has %d point achieved bidTarget (%d), stopped.\n", bidCount, bidTarget);
error("Finished");
end;
end
end
if isAttack then
skill = skills[3];
if (target == nil) then
local objectList = CObjectList();
objectList:update();
for i = 0, objectList:size() do
local obj = objectList:getObject(i);
-- some player will hide on the lower passage to the water
if obj ~= nil and obj.Type == PT_PLAYER and obj.Address ~= player.Address and obj.Name ~= objNameUnknow
and obj.Name ~= friendName
and skill.Range > distance(player.X, player.Z, player.Y, obj.X, obj.Z, obj.Y) then
local targetpawn = CPawn(obj.Address);
if (not targetpawn:hasBuff(attackedBuffName)) then
target = targetpawn;
break;
end;
end
end
end
player:target(target);
yrest(500);
if skillCanUse(skill) then
skillUse(skill);
end;
player:clearTarget();
end
until not player:hasBuff(eventBuffName);
-- And were done
cprintf(cli.lightblue, "You got %d points\n", bidCount);
error("Finished");
end;