View unanswered posts | View active topics It is currently 25 May 2019 00:03

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.



Reply to topic  [ 5 posts ] 
Health level trigger 
Author Message
Beginner

Joined: 06 Feb 2019 18:28
Posts: 21
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 >:)


28 Feb 2019 21:50
Profile
Wizard
User avatar

Joined: 03 Mar 2014 13:03
Posts: 162
Location: US West
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.


01 Mar 2019 18:59
Profile
Wizard
User avatar

Joined: 03 Mar 2014 13:03
Posts: 162
Location: US West
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:
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:
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:
char.vitals.health
for the pattern, nothing happened. It might be worth using the
Code:
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.


01 Mar 2019 19:42
Profile
Beginner

Joined: 04 Oct 2018 17:20
Posts: 14
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'


01 Mar 2019 20:00
Profile
Wizard
User avatar

Joined: 03 Mar 2014 13:03
Posts: 162
Location: US West
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.


01 Mar 2019 20:42
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.