Health level trigger

General discussion about the Genesis Web Client located at https://www.genesismud.org/play/

Moderator: Eowul

Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
Post Reply
Arsonist
Beginner
Posts: 21
Joined: 06 Feb 2019 18:28

Health level trigger

Post by Arsonist » 28 Feb 2019 21:50

I am just introducing myself to this javascript stuff so I apologies if my question is a really simple answer.

I was wondering how to make a trigger that recognizes when you are at a set health, like the "wimpy trigger" but only it activates a command of my choosing.
Signed
Kolvar

"Build a man a fire, he'll be warm for a day.
Set a man on fire, he'll be warm for the rest of his life." Terry Pratchett >:)

User avatar
Shanoga
Wizard
Posts: 168
Joined: 03 Mar 2014 13:03
Location: US West

Re: Health level trigger

Post by Shanoga » 01 Mar 2019 18:59

Good question! This would be using a GMCP trigger and checking the gmcp.data.character.vitals.health value. I haven't really tested to see EXACTLY what needs to be set up - maybe someone else has some experience using this kind of trigger? I might have some time to test this out today.

User avatar
Shanoga
Wizard
Posts: 168
Joined: 03 Mar 2014 13:03
Location: US West

Re: Health level trigger

Post by Shanoga » 01 Mar 2019 19:42

Alright, so I figured out something that could be done...

You can create a trigger of the GMCP style with the trigger pattern being:

Code: Select all

char.vitals
so that every time the vitals gmcp package is received, the webclient will run your trigger.

Beware, though....this can get VERY spammy and you have to build in some really explicit triggers or you can spam yourself. An example:

Code: Select all

Pattern:
  char.vitals

Script:
  if (gwc.gmcp.data.character.vitals.health == 'feeling very well')
  {
    gwc.connection.send('say I am healthy!');
  }

Result:
  > say I am healthy!
  say I am healthy!
  say I am healthy!
  say I am healthy!
  say I am healthy!
  say I am healthy!
  You say: I am healthy!
  > 
  You say: I am healthy!
  > 
  You say: I am healthy!
  > 
  You say: I am healthy!
  > 
  You say: I am healthy!
  > 
  You say: I am healthy!
  >
So this can be done, but generally the vitals package has several different components, but when I tried using

Code: Select all

char.vitals.health
for the pattern, nothing happened. It might be worth using the

Code: Select all

gwc.trigger.disable
function to disable the trigger once it fires, then re-enable it a few seconds later after a timeout of a few seconds (or even a minute, depending on the action you are triggering).

A couple of things are happening here. I don't have a complete understanding of how this gmcp trigger is working (which is at least part of the issue), plus a lot of the more complicated code/trigger/script people use something other than the official webclient.

Anyway, I am always glad to try and troubleshoot! Feel free to respond here or hop on over to the most popular Discord server (https://discord.gg/UBVbBrY)and check out the #code-stuff channel where you can get faster responses from a variety of helpful players.

Lionel
Beginner
Posts: 19
Joined: 04 Oct 2018 17:20

Re: Health level trigger

Post by Lionel » 01 Mar 2019 20:00

Not familiar with this client. Can you use variables?
If so, something like that:

if (currentHealth != gwc.gmcp.data.character.vitals.health) {
if (gwc.gmcp.data.character.vitals.health == 'feeling very well') {
// do stuff
}
}

currentHealth = gwc.gmcp.data.character.vitals.health;

would let you do the thing you want once, when currentHealth changes from any other value to 'feeling very well',
and not spam if it stays at 'feeling very well'

User avatar
Shanoga
Wizard
Posts: 168
Joined: 03 Mar 2014 13:03
Location: US West

Re: Health level trigger

Post by Shanoga » 01 Mar 2019 20:42

That problem is that the GMCP package is sent multiple times at each health level, so it is sending 4 packages at "feeling very well" even if it is rapidly changing.

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/