Plug-in system for Latikai's client

Forum for game modifications and custom clients.

Re: Plug-in system for Latikai's client

Postby Chrumps » Thu May 25, 2017 3:49 pm

blitzkrieg wrote:Is there a way to make a plugin that chip stone the same way as the pickup plugin?

Yes.
Chrumps
 
Posts: 594
Joined: Wed Apr 09, 2014 9:51 pm
Location: Poland

Re: Plug-in system for Latikai's client

Postby Taipion » Sun Jul 02, 2017 8:24 pm

Now adding a false sense of security for everyone...

I present to you, a player alert plugin!

Someone came to me and asked for a plugin like this, and I sent him to Marp to get it approved, as I did not think this would be OK.
Much to my surprise, Marp said that he AND JC think it's ok!
And to cast away the last of my doubts, Marp even made the icon for this one!
And no, it's not a phallic symbol, at least if you don't turn it upside down...

HEYQcDD.png
HEYQcDD.png (2.69 KiB) Viewed 13891 times


Shamelessly salvaging code from Kandarims Frog/Critter Plugin, and some code from the clients timers that were originally made by Ender,
I basically had not much to do myself to make it work, or in other words, it really is so simple.

Note: You can use a custom wave file as alert sound, simply name it alertsound.wav and place it in your salem folder, usually found under "Users/YourUser/Salem".
Note2: You can also use a custom wave file for the timers of the custom clients, by placing a file there named timer.wav in the same place.


Usage:

Simply turn it on by clicking the icon, or using the hotkey "j".

It will use the timers alarm sound as default.

And it will go off if anything with a player model (except yourself) is nearby, this may include: other players, NPCs, friends, mannequins, the recently deceased, ....

After a successful alarm, you need to manually re-activate it for another use.



Here's the most important java part of the code:
Code: Select all
package haven.plugins;

import haven.*;

import static java.lang.Thread.sleep;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;

import org.ender.timer.Timer;

public class PlayerAlertPlugin extends Plugin {

   private static UI ui = null;

   private static boolean isRunning = false;
   private static boolean signalToStop = false;

   public void load(UI ui) {
      Glob glob = ui.sess.glob;
      Collection<Glob.Pagina> p = glob.paginae;
      p.add(glob.paginafor(Resource.load("paginae/add/playeralertplugin")));
      XTendedPaginae.registerPlugin("playeralertplugin", this);
   }

   public void execute(UI ui) {

      PlayerAlertPlugin.ui = ui;

      if (!isRunning) {
         isRunning = true;
         new Thread(new Runnable() {
            @Override
            public void run() {
               perform_task();
            }
         }, "Pickup Plugin").start();
      } else {
         signalToStop = true;
         ui.message("[PlayerAlertPlugin] Stopping...", GameUI.MsgType.INFO);
      }

   }

   private void perform_task() {

      ui.message("[PlayerAlertPlugin] Turning on player detection... ", GameUI.MsgType.INFO);

      while (!signalToStop) {

         Collection<Gob> gobs = ui.sess.glob.oc.getGobs();
         Iterator<Gob> gobs_iterator = gobs.iterator();
         Gob current_gob = null;
         int bodyCount = 0;
         String nm = null;

         // Pretty standard iterating over gobs code from Kandarim...
         while (gobs_iterator.hasNext()) {
            current_gob = gobs_iterator.next();
            try {
               ResDrawable rd = current_gob.getattr(ResDrawable.class);
               Composite cmp = current_gob.getattr(Composite.class);
               if (cmp != null) {
                  nm = cmp.base.get().name;
               }
            } catch (Loading l) {
            }

            // This will match players, yourself, other players, npcs,
            // mannequins, recently deceased,...
            if (nm != null && nm.contains("gfx/borka/body")) {
               bodyCount++;
            }
            nm = null;
         }

         // If there is more than one player visible...
         if (bodyCount > 1) {
            // ...put a nice, red message out
            ui.message("[PlayerAlertPlugin] Nearby Player detected!!!", GameUI.MsgType.BAD);
            try {
               Object file1;
               // ...play a (customizeable) sound
               try {
                  // place a file called "alertsound.wav" in your Salem
                  // folder for custom sound,
                  // code taken from the clients timers (made by Ender)
                  file1 = new FileInputStream(Config.userhome + "/alertsound.wav");
               } catch (FileNotFoundException arg4) {
                  file1 = Timer.class.getResourceAsStream("/timer.wav");
               }
               Audio.play((InputStream) file1, 1.0D, 1.0D);
            } catch (Exception e) {
               ui.message("[PlayerAlertPlugin] Error on the Audio thingy: " + e.getMessage(), GameUI.MsgType.INFO);
            }
            // ...and exit the outer loop to stop the plugin
            break;
         }

         // Interval in between checks
         try {
            sleep(500);
         } catch (InterruptedException ignored) {
         }
      }

      if (!signalToStop) {
         // wait a sec to not overwrite the red alert message...
         try {
            sleep(3000);
         } catch (InterruptedException ignored) {
         }
      }
      
      ui.message("[PlayerAlertPlugin] Stopped", GameUI.MsgType.INFO);
      
      isRunning = false;
      signalToStop = false;
   }

}


And some links...

... one for the bold and reckless, to an already compiled jar

... and one to a .zip of the project
Need something? Here is my Shop (Including some useful info for new/returning players at the bottom of the first post)
Taipion
 
Posts: 2659
Joined: Fri Mar 08, 2013 4:12 pm

Re: Plug-in system for Latikai's client

Postby gorniksam » Sun Jul 02, 2017 9:32 pm

Pls spoil that game even more
User avatar
gorniksam
 
Posts: 2233
Joined: Mon Mar 30, 2015 11:49 am
Location: Shame Corner

Re: Plug-in system for Latikai's client

Postby Kandarim » Sun Jul 02, 2017 9:48 pm

I will check it tomorrow and put it up on the first page. Cool stuff!
I have neither the crayons nor the time to explain it to you.
JC wrote:I'm not fully committed to being wrong on that yet.
User avatar
Kandarim
Customer
 
Posts: 5321
Joined: Mon Jan 21, 2013 4:18 pm

Re: Plug-in system for Latikai's client

Postby Chrumps » Sun Jul 02, 2017 10:19 pm

Why not:
if (body count > lastbodycount) sound_alarm
lastbodycount = bodycount

:?:
Chrumps
 
Posts: 594
Joined: Wed Apr 09, 2014 9:51 pm
Location: Poland

Re: Plug-in system for Latikai's client

Postby Taipion » Sun Jul 02, 2017 10:48 pm

Chrumps wrote:Why not:
if (body count > lastbodycount) sound_alarm
lastbodycount = bodycount

:?:


I intended to keep it simple, and to drop it once an alarm is triggered, one less thing running in the background. :D

Also, if you'd do it like you said, and it did an alarm everytime the number increases,
(needs to be set to actual count on each iteration, so an alarm is triggered anytime the number increases)
then people would get used to it and dont mind it anymore. ^^

I intended to only manually activate it when you want an alarm, which also sharpens your senses of when you actually leave the safety of home/Provi, be that for hunting other players, or escaping them,
instead of having it run all the time and forgetting about it.

But ofc, you can do as you please, the code is there.
Need something? Here is my Shop (Including some useful info for new/returning players at the bottom of the first post)
Taipion
 
Posts: 2659
Joined: Fri Mar 08, 2013 4:12 pm

Re: Plug-in system for Latikai's client

Postby Chrumps » Sun Jul 02, 2017 11:51 pm

You cannot use it if someone else, alt / friend /mannequin is around because it will trigger immediately.
Chrumps
 
Posts: 594
Joined: Wed Apr 09, 2014 9:51 pm
Location: Poland

Re: Plug-in system for Latikai's client

Postby Taipion » Mon Jul 03, 2017 12:21 am

Chrumps wrote:You cannot use it if someone else, alt / friend /mannequin is around because it will trigger immediately.


Yes, this is exactly what I said, you should only activate it once you leave the safety of your home, Provi and such, where there are no mannequins and such. :D

Taipion wrote:And it will go off if anything with a player model (except yourself) is nearby, this may include: other players, NPCs, friends, mannequins, the recently deceased, ....


And as I also said, feel free to make it in a different way, if you want to have it run all the time and react to the change in "bodys" around, while out hunting with a friend you will have a false positive whenever you lose visual contact with that friend and then close in again, after a while you will not even notice it as an alarm anymore.



I guess there is a way to do this via the map icons, where you can have different colours, so you can ignore friends and alts, but I have not looked into that yet, and it still is the same for mannequins and NPCs.
Need something? Here is my Shop (Including some useful info for new/returning players at the bottom of the first post)
Taipion
 
Posts: 2659
Joined: Fri Mar 08, 2013 4:12 pm

Re: Plug-in system for Latikai's client

Postby Heffernan » Mon Jul 03, 2017 12:10 pm

oh nice, a kuku alert thx

or in Taipions Case a Darwoth alert ¦]
User avatar
Heffernan
 
Posts: 8564
Joined: Mon Sep 08, 2014 3:07 pm
Location: Marps Closet

Re: Plug-in system for Latikai's client

Postby Qiresea » Mon Jul 03, 2017 12:24 pm

this alert system doesnt sound very balanced. does it add a huge amount of insanity to the player who has activated it every time a player appears on the minimap? if not, i should like to suggest it does.
Darwoth wrote:It really is not fair that every time you try to jab at me you make yourself look more retarded than any retort i could come up with.

Image
Γιά την Κυρία των τριών βασιλείων: της γης, του ουρανού και της θάλασσας.
User avatar
Qiresea
Customer
 
Posts: 1089
Joined: Tue Feb 17, 2015 3:01 pm

PreviousNext

Return to Artifice & Arcana

Who is online

Users browsing this forum: No registered users and 23 guests

cron