Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ GMCP questions

GMCP questions

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Niax   (1 post)  Bio
Date Tue 24 Nov 2020 10:10 PM (UTC)
Message
Hi. I am curious if anybody can help me understand how to use GMCP in plugins. I've been pouring over the threads on the forum and feel like i have maybe a basic idea, but am struggling to actually utilize them.

I've yet to create anything that works, i am curious what i would need to do to get the following schenario to work correctly.

GMCP sends a packet of information during combat to indicate if your damage to an NPC is immune (thus doing no damage). I would like a note to be printed that states that the mob i am fighting is immune.

Here is the GMCP information the game sends when a mob is immune.

char.combat_immunity {"combat_immunity": "a tame dragon is immune to your attack"}


i'm embarrased to show what i've written so far but i'll go ahead and do so just so you can see what i've attempted.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, November 22, 2020, 7:28 PM -->
<!-- MuClient version 5.03 -->

<!-- Plugin "immunedamage" generated by Plugin Wizard -->

<muclient>
<plugin
   name="immunedamage"
   author="Niax"
   id="e96785ac51b51fbcc18d90e0"
   language="Lua"
   purpose="checks for immune damage and says something"
   save_state="y"
   date_written="2020-11-22 19:27:43"
   requires="5.03"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   custom_colour="1"
   enabled="y"
   expand_variables="y"
   group="immune"
   keep_evaluating="y"
   match="^You hit (.*) (.*), missing (.*) and (.*?) defends (.*?)\, leaving (.*?) at (.*?) percent. You are hit (.*?)\, are missed (.*?)\, and defend (.*?)\."
   regexp="y"
   send_to="12"
   sequence="100"
  >
  </trigger>
</triggers>

<![CDATA[

--requires gmcp_handler for mm
--char.combat_immunity {"combat_immunity": "a tame dragon is immune to your attack"}

local res, gmcparg = CallPlugin("f67c4339ed0591a5b010d05b"), "gmcpval", "char.combat_immunity")
loadstring ("gmcpdata = " .. gmcparg)

Print ("this is a test. should proc on immune damage")

end

]]>


</muclient>


i have a feeling that part of the reason this isn't working is because this isn't something that i can request from gmcp behind the scenes but is instead something that is sent by the game. It doesn't happen every single combat round which i thought was odd but i'm not overly familiar with how these packets would be sent.

any insight into this would be very helpful. I am attempting to build this for blind players who are using the combat mode superbrief in materia magica. (as well as myself who isn't blind but doesn't like spam)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 25 Nov 2020 02:21 AM (UTC)

Amended on Wed 25 Nov 2020 02:22 AM (UTC) by Nick Gammon

Message

GMCP generally provides “events” (things that happen without you requesting them) from time to time, like entering a new room, or your HP changing.

You can download a generic GMCP handler plugin from GMCP_handler_NJG.

This basically does the “low level” stuff, and then does a BroadcastPlugin function call to send that information to all interested plugins.

An example of what you might do is GMCP_message_receiver_test.

That basically does this:

The GMCP_handler_NJG plugin is plugin ID 74f8c420df7d59ad5aa66246, so you can see that this responds to messages from that plugin.

It does a JSON decode of the message, and then passes the decoded message to a “handler” of which there is a table of handlers in this plugin.

So in your case you would want a handler for char.combat_immunity, and in that handler you would get a table, and I am presuming that inside that table would be combat_immunity set to “a tame dragon is immune to your attack” in your example.

So then in that function you could print the message that you want.

You might need to put in a few debugging displays to see what is happening, plus turn debugging on in the GMCP handler (type “gmcpdebug 1”).


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


9,995 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.