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.

442 lines
9.9 KiB

8 years ago
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- $Id$ -->
<muclient>
<plugin
name="xBroadcast_Level"
author="Bast"
id="aaa0ab9ed92f8fc614664bd1"
language="Lua"
purpose="broadcast info from leveling"
save_state="y"
date_written="2009-02-22 14:20:07"
requires="4.73"
version="6.1"
>
<description trim="y">
<![CDATA[
[FOR PLUGIN AUTHORS ONLY]
Broadcasts stats when leveling
Example
function OnPluginBroadcast (msg, id, name, text)
if id == "aaa0ab9ed92f8fc614664bd1" and msg == 2 then
local pvar = GetPluginVariable( "aaa0ab9ed92f8fc614664bd1", levelinfo )
-- get the info
loadstring( pvar )()
info = levelinfo
end
end
Broadcasts
1 - level info, get var.levelinfo and loadstring it
levelinfo = {}
levelinfo.starttime = 1340385935
levelinfo.hp = "30"
levelinfo.mv = "31"
levelinfo.luc = 0
levelinfo.blessingtrains = 0
levelinfo.pracs = "10"
levelinfo.level = "126"
levelinfo.str = 1
levelinfo.con = 0
levelinfo.totallevels = 1734
levelinfo.bonustrains = 0
levelinfo.mp = "25"
levelinfo.int = 0
levelinfo.type = "level"
levelinfo.trains = "4"
levelinfo.wis = 1
levelinfo.dex = 0
2 - Created
3 - Heroed
4 - SuperHeroed
5 - Preremort
6 - Remorted to Level 1
7 - Pre-Tiered
8 - Tiered
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<triggers>
<trigger
enabled="y"
match="Congratulations, hero. You have increased your powers!"
name="pup"
script="level"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="You gain a powerup."
name="pupbless"
script="level"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="You raise a level! You are now level *."
name="level"
script="level"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="You gain a level - you are now level *."
name="levelbless"
script="level"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="You gain * hit points, * mana, * moves, * practices and * trains."
name="levelgains"
script="levelgains"
group="linfo"
sequence="100"
>
</trigger>
<trigger
enabled="n"
regexp="y"
match="^You gain (.*) extra trains? daily blessing bonus.$"
name="blessingtrains"
script="levbonus"
group="linfo"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="You gain * trains."
name="pupgains"
script="levelgains"
group="linfo"
sequence="100"
>
</trigger>
<trigger
enabled="n"
regexp="y"
match="^Lucky! You gain an extra (\d) training sessions?!$"
name="bonustrains"
script="levbonus"
group="linfo"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="You gain a bonus * point!"
name="bonusstat"
script="levbonus"
group="linfo"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="*"
name="catchall"
script="levbonus"
group="linfo"
sequence="101"
>
</trigger>
<trigger
enabled="y"
regexp="y"
match="^ Congratulations %1, you have now completed character creation.$"
name="created"
script="created"
sequence="100"
>
</trigger>
<trigger
enabled="y"
regexp="y"
match="^Congratulations! You are now a superhero!$"
name="superhero"
script="superhero"
sequence="100"
>
</trigger>
<trigger
enabled="y"
regexp="y"
match="^\* Remort transformation complete\!$"
name="remort"
script="remort"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="## You have already remorted the max number of times."
name="tier"
script="tier"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="You are now flagged as remorting."
name="preremort"
script="preremort"
sequence="100"
>
</trigger>
</triggers>
<script>
<![CDATA[
internalrevision = "$Rev$"
dofile (GetPluginInfo (GetPluginID (), 20) .. "luapath.lua")
require "var"
require "serialize"
require "commas"
require "pluginhelper"
require "verify"
require "ldplugin"
require "aardutils"
-- keys - type, time, newlevel, hp, mana, mov, trains, pracs, bonustrains, bonusstats = {}
-- bonusstats subtable keys are the bonus stat names
levelinfo = {}
waitcreated = false
lasttier = -1
lastremort = -1
function tier(name, line, wildcards)
phelper:broadcast('7')
lasttier = tonumber(char.base.tier)
lastredo = tonumber(char.base.redos)
waittier = true
end
function created( name, line, wildcards )
waitcreated = true
end
function superhero( name, line, wildcards )
levelinfo.level = 201
levelinfo.totallevels = getactuallevel(tonumber(levelinfo.level), char.base.remorts, char.base.tier, char.base.redos)
phelper:broadcast(4)
end
function preremort(name, line, wildcards)
phelper:broadcast(5)
end
function remort(name, line, wildcards)
resetinfo()
levelinfo.level = 1
levelinfo.type = 'level'
levelinfo.starttime = GetInfo(304)
levelinfo.totallevels = getactuallevel(tonumber(levelinfo.level), char.base.remorts, char.base.tier, char.base.redos)
var.levelinfo = serialize.save( "levelinfo", levelinfo )
phelper:broadcast(6)
end
function resetinfo()
levelinfo = {}
levelinfo.type = ""
levelinfo.level = -1
levelinfo.str = 0
levelinfo.int = 0
levelinfo.wis = 0
levelinfo.dex = 0
levelinfo.con = 0
levelinfo.luc = 0
levelinfo.starttime = -1
levelinfo.hp = 0
levelinfo.mp = 0
levelinfo.mv = 0
levelinfo.pracs = 0
levelinfo.trains = 0
levelinfo.bonustrains = 0
levelinfo.blessingtrains = 0
levelinfo.totallevels = 0
end
function level ( name, line, wildcards )
resetinfo()
if name == 'levelbless' then
name = 'level'
end
if name == 'pupbless' then
name = 'pup'
end
if name == 'pup' then
levelinfo.level = tonumber(char.status.level)
end
if superf then
levelinfo.level = 201
superf = false
end
levelinfo.type = name
if levelinfo.type == "level" then
levelinfo.level = wildcards[1]
if tonumber(levelinfo.level) == 200 then
phelper:broadcast(3)
end
if tonumber(levelinfo.level) == 201 then
phelper:broadcast(4)
end
end
levelinfo.totallevels = getactuallevel(tonumber(levelinfo.level), char.base.remorts, char.base.tier, char.base.redos)
levelinfo.starttime = GetInfo(304)
phelper:enabletriggroup( "linfo", true )
end
function levelgains (name, line, wildcards)
if name == "pupgains" then
levelinfo.trains = wildcards[1]
elseif name == "levelgains" then
levelinfo.hp = wildcards[1]
levelinfo.mp = wildcards[2]
levelinfo.mv = wildcards[3]
levelinfo.pracs = wildcards[4]
levelinfo.trains = wildcards[5]
end
end
function levbonus (name, line, wildcards)
if name == "bonustrains" then
levelinfo.bonustrains = wildcards[1]
elseif name == 'blessingtrains' then
levelinfo.blessingtrains = tonumber(wildcards[1])
elseif name == "bonusstat" then
levelinfo[string.lower(string.sub(wildcards[1], 1, 3))] = 1
elseif name == "catchall" and trim(line) == "" and tonumber(levelinfo.trains) > 0 then
phelper:enabletriggroup( "linfo", false )
var.levelinfo = serialize.save( "levelinfo", levelinfo )
phelper:broadcast(1, var.levelinfo)
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")
char = assert (loadstring ('return ' .. gmcparg or ""))()
if waittier and tonumber(char.status.state) == 2 then
sawstate2 = true
end
if char.status then
state = char.status.state
statestring = statestrings[tonumber(state)]
if statestring == 'active' and waitcreated then
waitcreated = false
phelper:broadcast(2)
end
if statestring == 'active' and waittier and sawstate2 and
(tonumber(char.base.tier) == lasttier + 1 or (tonumber(char.base.tier) == lasttier and tonumber(char.base.redos) == lastredo + 1)) and
tonumber(char.base.remorts) == 1 then
waittier = false
sawstate2 = false
lasttier = -1
lastremort = -1
resetinfo()
levelinfo.level = 1
levelinfo.type = 'level'
levelinfo.starttime = GetInfo(304)
levelinfo.totallevels = getactuallevel(tonumber(1), char.base.remorts, char.base.tier, char.base.redos)
var.levelinfo = serialize.save( "levelinfo", levelinfo )
phelper:broadcast(8)
end
end
end
end
phelper:OnPluginBroadcast(msg, id, name, text)
end
function OnPluginInstall ()
--OnPluginEnable is automatically called by pluginhelper
assert (loadstring (GetVariable ("levelinfo") or "")) ()
phelper:OnPluginInstall()
end -- OnPluginInstall
function OnPluginClose ()
phelper:OnPluginClose()
end -- OnPluginClose
function OnPluginEnable ()
phelper:OnPluginEnable()
ldplugin ("aard_GMCP_handler", "3e7dedbe37e44942dd46d264")
if IsConnected () then
CallPlugin("3e7dedbe37e44942dd46d264","Send_GMCP_Packet","request char")
end -- if already connected
end -- OnPluginEnable
function OnPluginDisable ()
phelper:OnPluginDisable()
end -- OnPluginDisable
function OnPluginConnect ()
phelper:OnPluginConnect()
end -- function OnPluginConnect
function OnPluginDisconnect ()
phelper:OnPluginDisconnect()
end -- function OnPluginConnect
function OnPluginSaveState ()
phelper:OnPluginSaveState()
end -- function OnPluginSaveState
function OnPluginCommand (stext)
stext = trim(stext)
if stext == 'superhero loud' or stext == 'superhero silent' or stext == 'superhero confirm' then
local wildcards = {}
wildcards.newlevel = 201
level ( 'level', 'You raise a level! You are now level 201.', wildcards )
end
end
]]>
</script>
<script>
<![CDATA[
phelper:set_default('cmd', 'blev')
phelper:set_default('plugin_colour', 'orange')
phelper:enable()
]]>
</script>
</muclient>