You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

695 lines
16 KiB

8 years ago
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- $Id$ -->
<muclient>
<plugin
name="xBroadcast_CP"
author="Bast"
id="aaa66f81c50828bbbfda7100"
language="Lua"
purpose="Broadcasts when anything happens related to a cp"
save_state="y"
date_written="2009-02-18 12:31:01"
requires="4.73"
version="6.1"
>
<description trim="y">
<![CDATA[
[FOR PLUGIN AUTHORS ONLY]
TODO: add a variable to prevent cp check command
Broadcasts when anything happens in a campaign
Broadcasts
1 - Mob list, get var.mobs and loadstring it
mobs = { 1 = {name = 'Some name', location = 'Some location', clean = 'A name with some stuff removed'},
2 = {name = 'Another name', location = 'Another location', clean = 'Another name with some stuff removed'}, }
It will be resent when a mob is killed and will be nil when a cp is not active
2 - timer, will be updated every 60 seconds, get var.timer and loadstring it
timer = {secs = num, text = 'time in text format', days = days, hours = hours, mins = minutes}
3 - rewards, get var.rewards and loadstring it, this can also be used to check when a cp is finished
see below
4 - campaign failed
see below
5 - just taken new cp
Example
function OnPluginBroadcast (msg, id, name, text)
if id == "aaa66f81c50828bbbfda7100" and msg == 1 then
local pvar = GetPluginVariable( "aaa66f81c50828bbbfda7100", mobs )
-- get the mobs
loadstring( pvar )()
cp_mobs = mobs
end
end
xBroadcast_CP : Broadcast 1
mobs = {}
mobs[1] = {}
mobs[1].mobdead = false
mobs[1].location = "Desert Doom"
mobs[1].name = "Tjac's personal advisor"
mobs[1].clean = "tjac's personal advisor"
mobs[2] = {}
mobs[2].mobdead = false
mobs[2].location = "Desert Doom"
mobs[2].name = "A Sunset herbalist"
mobs[2].clean = "a sunset herbalist"
mobs[3] = {}
mobs[3].mobdead = false
mobs[3].location = "Desert Doom"
mobs[3].name = "A Sunset scavenger"
mobs[3].clean = "a sunset scavenger"
mobs[4] = {}
mobs[4].mobdead = false
mobs[4].location = "Desert Doom"
mobs[4].name = "A Sunrise warrior"
mobs[4].clean = "a sunrise warrior"
mobs[5] = {}
mobs[5].mobdead = false
mobs[5].location = "Desert Doom"
mobs[5].name = "A Sunrise guard"
mobs[5].clean = "a sunrise guard"
mobs[6] = {}
mobs[6].mobdead = false
mobs[6].location = "Into the Long Night"
mobs[6].name = "an animated body"
mobs[6].clean = "an animated body"
mobs[7] = {}
mobs[7].mobdead = false
mobs[7].location = "The Archipelago of Entropy"
mobs[7].name = "the playwright"
mobs[7].clean = "the playwright"
mobs[8] = {}
mobs[8].mobdead = false
mobs[8].location = "The Casino"
mobs[8].name = "Method Man"
mobs[8].clean = "method man"
mobs[9] = {}
mobs[9].mobdead = false
mobs[9].location = "The Dark Temple of Zyian"
mobs[9].name = "A Eunuch"
mobs[9].clean = "a eunuch"
mobs[10] = {}
mobs[10].mobdead = false
mobs[10].location = "The Drageran Empire"
mobs[10].name = "Aliza"
mobs[10].clean = "aliza"
mobs[11] = {}
mobs[11].mobdead = false
mobs[11].location = "The Slaughter House"
mobs[11].name = "Asmodeus"
mobs[11].clean = "asmodeus"
mobs[12] = {}
mobs[12].mobdead = false
mobs[12].location = "The Slaughter House"
mobs[12].name = "Sepulchrumalum"
mobs[12].clean = "sepulchrumalum"
mobs[13] = {}
mobs[13].mobdead = false
mobs[13].location = "Tir na nOg"
mobs[13].name = "The goddess Morrigan"
mobs[13].clean = "the goddess morrigan"
xBroadcast_CP : Broadcast 2
timer = {}
timer.secs = 604620
timer.mins = 57
timer.text = "1 w"
timer.days = 6
timer.hours = 23
Broadcast 3
cp_info = {}
cp_info.level = "125"
cp_info.tp = 0
cp_info.qp = "31"
cp_info.failed = 0
cp_info.oncp = false
cp_info.cantake = true
cp_info.finishtime = 1340386171
cp_info.gold = "23780"
cp_info.starttime = 1340385212
cp_info.trains = 0
cp_info.pracs = 0
cp_info.mobs = {}
cp_info.mobs[1] = {}
cp_info.mobs[1].location = "Faerie Tales II"
cp_info.mobs[1].mobdead = false
cp_info.mobs[1].name = "the big bad wolf"
cp_info.mobs[1].clean = "the big bad wolf"
cp_info.mobs[2] = {}
cp_info.mobs[2].location = "Faerie Tales II"
cp_info.mobs[2].mobdead = false
cp_info.mobs[2].name = "the miller's wife"
cp_info.mobs[2].clean = "the miller's wife"
cp_info.mobs[3] = {}
cp_info.mobs[3].location = "Faerie Tales II"
cp_info.mobs[3].mobdead = false
cp_info.mobs[3].name = "the third little pig"
cp_info.mobs[3].clean = "the third little pig"
cp_info.mobs[4] = {}
cp_info.mobs[4].location = "Gilda And The Dragon"
cp_info.mobs[4].mobdead = false
cp_info.mobs[4].name = "an ant"
cp_info.mobs[4].clean = "an ant"
cp_info.mobs[5] = {}
cp_info.mobs[5].location = "Sanctity of Eternal Damnation"
cp_info.mobs[5].mobdead = false
cp_info.mobs[5].name = "a slime"
cp_info.mobs[5].clean = "a slime"
cp_info.mobs[6] = {}
cp_info.mobs[6].location = "The Archipelago of Entropy"
cp_info.mobs[6].mobdead = false
cp_info.mobs[6].name = "a Kism banker"
cp_info.mobs[6].clean = "a kism banker"
cp_info.mobs[7] = {}
cp_info.mobs[7].location = "The Fabled City of Stone"
cp_info.mobs[7].mobdead = false
cp_info.mobs[7].name = "Citadel Wizard"
cp_info.mobs[7].clean = "citadel wizard"
cp_info.mobs[8] = {}
cp_info.mobs[8].location = "The Fabled City of Stone"
cp_info.mobs[8].mobdead = false
cp_info.mobs[8].name = "Grectza"
cp_info.mobs[8].clean = "grectza"
cp_info.mobs[9] = {}
cp_info.mobs[9].location = "The Fortress of Angband"
cp_info.mobs[9].mobdead = false
cp_info.mobs[9].name = "The orc"
cp_info.mobs[9].clean = "the orc"
cp_info.mobs[10] = {}
cp_info.mobs[10].location = "The Misty Shores of Yarr"
cp_info.mobs[10].mobdead = false
cp_info.mobs[10].name = "a pirate hunter"
cp_info.mobs[10].clean = "a pirate hunter"
cp_info.mobs[11] = {}
cp_info.mobs[11].location = "The Slaughter House"
cp_info.mobs[11].mobdead = false
cp_info.mobs[11].name = "a lesser demon"
cp_info.mobs[11].clean = "a lesser demon"
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<triggers>
<trigger
enabled="y"
match="Welcome to Aardwolf. May your adventures be mystical, challenging and rewarding."
sequence="100"
send_to="10"
>
<send>cp check</send>
</trigger>
<trigger
enabled="y"
match="############# Reconnecting to Game #############"
sequence="100"
send_to="10"
>
<send>cp check</send>
</trigger>
<trigger
enabled="y"
match=".* tells you 'Type 'campaign info' to see what you must kill.'"
sequence="100"
send_to="10"
regexp="y"
script="cp_new"
>
<send>cp check</send>
</trigger>
<trigger
enabled="n"
match="You are not currently on a campaign."
name="cp_none"
script="cp_none"
sequence="100"
group="campaigncheck"
>
</trigger>
<trigger
enabled="n"
match="You have * to finish this campaign."
name="cp_time"
script="cp_time"
sequence="100"
group="campaigncheck"
omit_from_output="y"
>
</trigger>
<trigger
enabled="n"
match="^You still have to kill(?&lt;num&gt;[ \d]*) \* (?&lt;name&gt;.*?) \((?&lt;location&gt;.*?)(?&lt;dead&gt; - Dead|)\)(|\.)$"
name="campaign_item"
script="campaign_item"
sequence="100"
regexp="y"
group="campaigncheck"
omit_from_output="y"
>
</trigger>
<trigger
enabled="n"
match="You will have to level before you can go on another campaign."
send_to="10"
sequence="100"
script="level"
group="campaignin"
name="needtolevel"
omit_from_output="y"
>
</trigger>
<trigger
enabled="n"
match="You may take a campaign at this level."
send_to="10"
sequence="100"
script="level"
group="campaignin"
name="cantake"
omit_from_output="y"
>
</trigger>
<trigger
enabled="n"
match="You cannot take another campaign for *."
send_to="10"
sequence="100"
script="level"
group="campaignin"
name="shtime"
omit_from_output="y"
>
</trigger>
<trigger
enabled="n"
match="Congratulations, that was one of your CAMPAIGN mobs!"
send_to="10"
sequence="100"
script="cp_mob_dead"
group="campaignin"
>
</trigger>
<trigger
enabled="n"
match="CONGRATULATIONS! You have completed your campaign."
sequence="100"
script="campaign_complete"
group="campaignin"
>
</trigger>
<trigger
enabled="n"
match="^(\s*)Reward of (?&lt;amount&gt;\d+) (?&lt;type&gt;.+) (.+) added.$"
sequence="100"
script="campaign_reward"
group="campaignrew"
regexp="y"
>
</trigger>
<trigger
enabled="n"
match="--------------------------------------------------------------"
sequence="100"
script="campaign_done"
group="campaigndone"
>
</trigger>
<trigger
enabled="n"
match="*"
name="catchall"
script="nextline"
group="getnextline"
sequence="101"
>
</trigger>
<trigger
enabled="n"
match="Campaign cleared."
sequence="100"
script="campaign_fail"
group="campaignin"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
name="cp_check"
script="cp_check"
match="^(cp|campaign) check$"
enabled="y"
regexp="y"
sequence="100"
>
<send>cp check</send>
</alias>
</aliases>
<!-- Timers -->
<timers>
<timer
script="update_timer"
enabled="n"
second="59.00"
name="cp_timer"
>
</timer>
<timer
script="mob_timer"
enabled="n"
minute="5"
name="mob_timer"
>
</timer>
</timers>
<!-- Script -->
<script>
<![CDATA[
internalrevision = "$Rev$"
dofile (GetPluginInfo (GetPluginID (), 20) .. "luapath.lua")
require "var"
require "pluginhelper"
require "serialize"
require "commas"
require "verify"
require "copytable"
require "ldplugin"
require "utils"
rewardtable = {
quest = 'qp',
training = 'trains',
gold = 'gold',
trivia = 'tp',
practice = 'pracs',
}
char = {}
cp_info = {}
mobsleft = {}
timer = {}
curlevel = -1
function cleanname(name)
return string.lower(string.gsub(name, ",", ""))
end
function level(name, line, wildcards)
if name == 'cantake' then
cp_info['cantake'] = true
elseif name == 'shtime' then
cp_info['shtime'] = wildcards[1]
end
end
function campaign_item (name, line, wildcards)
name = wildcards.name
mobdead = false
location = wildcards.location
if wildcards.dead == ' - Dead' then
mobdead = true
end
if mobdead then
if GetTimerInfo("mob_timer", 6) == false then
check(EnableTimer("mob_timer", true))
end
end
if not name or not location then
print("error parsing line: ", line)
tprint(wildcards)
else
table.insert(mobsleft, {name=name, location=location, clean=cleanname(name), mobdead=mobdead})
end
end -- campaign_item
function cp_mob_dead (name, line, wildcards)
Execute("cp check")
end
function cp_time (name, line, wildcards)
local text = wildcards [1]
-- work out when campaign ends
when_required = os.time ()
local days = string.match (text, "(%d+) days?")
if days then
when_required = when_required + tonumber (days) * 60 * 60 * 24
end -- some days left
local hours = string.match (text, "(%d+) hours?")
if hours then
when_required = when_required + tonumber (hours) * 60 * 60
end -- some days left
local minutes = string.match (text, "(%d+) minutes?")
if minutes then
when_required = when_required + tonumber (minutes) * 60
end -- some days left
phelper:enabletriggroup("campaigncheck", false)
phelper:enabletriggroup("campaignin", true)
if cp_info['mobs'] == nil or (type(cp_info['mobs']) == 'table' and not next(cp_info['mobs'])) then
cp_info['mobs'] = copytable.shallow(mobsleft)
SaveState()
end
var.mobs = serialize.save( "mobs", mobsleft )
phelper:broadcast(1, var.mobs)
build_time()
if GetTimerInfo("cp_timer", 6) == false then
check(EnableTimer("cp_timer", true))
end
end -- cp_time
function campaign_done (name, line, wildcards)
phelper:enabletriggroup("getnextline", true)
end -- campaign_done
function nextline(name, line, wildcards)
phelper:enabletriggroup("getnextline", false)
if string.find(line, 'first campaign completed today') then
local bonusqp = string.match(line, "^You receive (%d*) quest points bonus for your first campaign completed today.$")
cp_info['bonusqp'] = bonusqp
end
cp_info['oncp'] = false
var.cp_info = serialize.save( "cp_info", cp_info )
SaveState()
phelper:broadcast(3, var.cp_info)
cp_none()
end -- nextline
function campaign_fail (name, line, wildcards)
cp_info.failed = 1
cp_info['oncp'] = false
var.cp_info = serialize.save( "cp_info", cp_info )
SaveState()
phelper:broadcast(4, var.cp_info)
cp_none()
end -- campaign_done
function campaign_reward (name, line, wildcards)
local type = wildcards.type
local amount = wildcards.amount
cp_info[rewardtable[type]] = amount
phelper:enabletriggroup("campaigndone", true)
end
function campaign_complete(name, line, wildcards)
phelper:enabletriggroup("campaignrew", true)
cp_info['finishtime'] = GetInfo(304)
cp_info['oncp'] = false
end
function build_time()
-- how long to go
local time_to_go = when_required - os.time ()
timer['secs'] = time_to_go
timer['text'] = convert_time(time_to_go)
local years, days, hours, mins, seconds = SecondsToDHMS(time_to_go)
timer['days'] = days
timer['hours'] = hours
timer['mins'] = mins
timer['cantake'] = cp_info['cantake']
timer['shtime'] = cp_info['shtime']
var.timer = serialize.save( "timer", timer )
phelper:broadcast(2, var.timer)
end
function update_timer()
build_time()
end
function mob_timer()
for i,v in ipairs(mobsleft) do
if v.mobdead == true then
Execute("cp check")
return
end
end
if GetTimerInfo("mob_timer", 6) == true then
check(EnableTimer("mob_timer", false))
end
end
function cp_check( name, line, wildcards)
phelper:enabletriggroup("campaigncheck", true)
mobsleft = {}
timer = {}
end -- cp_check
function cp_new()
cp_info = {}
cp_info['mobs'] = {}
cp_info['trains'] = 0
cp_info['pracs'] = 0
cp_info['gold'] = 0
cp_info['tp'] = 0
cp_info['qp'] = 0
cp_info['bonusqp'] = 0
cp_info['failed'] = 0
cp_info['level'] = curlevel
cp_info['starttime'] = GetInfo(304)
cp_info['finishtime'] = 0
cp_info['oncp'] = true
cp_info['cantake'] = false
cp_info['shtime'] = nil
SaveState()
phelper:broadcast(5)
end
function cp_none( name, line, wildcards)
cp_info['oncp'] = false
phelper:enabletriggroup("campaigncheck", false)
phelper:enabletriggroup("campaignin", false)
phelper:enabletriggroup("campaignrew", false)
phelper:enabletriggroup("campaigndone", false)
check(EnableTimer("cp_timer", false))
timer = {}
end
function isoncp()
if cp_info['oncp'] then
return cp_info.level
else
return -1
end
end
]]>
</script>
<script>
<![CDATA[
function OnPluginBroadcast (msg, id, name, text)
if id == '3e7dedbe37e44942dd46d264' then
if text:find("char") then
res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval", "char")
tt = assert (loadstring ('return ' .. gmcparg or ""))()
if tt['status'] then
curlevel = tt.status.level
end
end
end
phelper:OnPluginBroadcast(msg, id, name, text)
end
function OnPluginInstall ()
--OnPluginEnable is automatically called by pluginhelper
assert (loadstring (GetVariable ("cp_info") or "")) ()
phelper:OnPluginInstall()
end -- OnPluginInstall
function OnPluginClose ()
phelper:OnPluginClose()
end -- OnPluginClose
function OnPluginEnable ()
ldplugin ("aard_GMCP_handler", "3e7dedbe37e44942dd46d264")
phelper:OnPluginEnable()
end -- OnPluginEnable
function OnPluginDisable ()
phelper:OnPluginDisable()
end -- OnPluginDisable
function OnPluginConnect ()
phelper:OnPluginConnect()
end -- function OnPluginConnect
function OnPluginDisconnect ()
phelper:OnPluginDisconnect()
end -- function OnPluginConnect
function OnPluginSaveState ()
var.cp_info = serialize.save( "cp_info", cp_info )
phelper:OnPluginSaveState()
end -- function OnPluginSaveState
]]>
</script>
<script>
<![CDATA[
phelper:set_default('cmd', 'bcp')
phelper:set_default('plugin_colour', 'orange')
phelper:enable()
]]>
</script>
</muclient>