hitmark script for annihilation. Halp

This is the development community to discuss tribes mod coding or to ask questions.

Moderator: Moderators

Post Reply
S_hift
Lt Commander
Lt Commander
Posts: 497
Joined: Sat Sep 26, 2009 7:35 pm

hitmark script for annihilation. Halp

Post by S_hift » Wed Dec 03, 2014 3:30 pm

Code: Select all

function Hitmark::OnSound(%Sound) {
   if (Match::String(%Sound, "~button4")){
      newEvent("Hitmark::OnSound" @ %Sound("Hitmark.bmp", 512, 384, 100, 0.8)
   }
}





Not sure were to go from here Image
Some help would be appreciate also I'm new to this whole scripting deal, but I'm willing to learn. Yes I know it probably looks retarded to the more experienced eyes.


also the goal for this is to make a script that works on 1.3 and 1.4 with very little editing. Preferably just changing hitmark.bmp to hitmark.png


I'll explain further what I'm trying to do. The server I play in is modified to play a sound everytime I hit someone, kind of like the mid air in the LT server. I'm trying to detect that sound (button4.wav) and have tribes draw the desired image onto the center of my screen.

Perrinoia
Suggestion bot 10,000
Posts: 11185
Joined: Sat May 04, 2002 11:00 pm
Location: Rhode Island

Re: hitmark script for annihilation. Halp

Post by Perrinoia » Wed Dec 03, 2014 3:58 pm

Code: Select all

function onClientMessage(%client, %msg)
{
   if(%client)
      $lastClientMessage = %client;

   // filter messages here
      if(%msg == "~wButton3.wav")
         echo("Blink crosshair or whatever.");
   return true;
}


This will only detect hits in annihilation mod, because annihilation mod sends this sound effect to the shooter in a message whenever they damage something.

This will also detect when your turrets and mines damage someone, and any other circumstances which would cause this sound effect to be played through the chat.

It will not detect when a player messages the sound effect, as their name will be included in the message, and this script looks for an exact match, not just messages containing the sound effect.

S_hift
Lt Commander
Lt Commander
Posts: 497
Joined: Sat Sep 26, 2009 7:35 pm

Re: hitmark script for annihilation. Halp

Post by S_hift » Wed Dec 03, 2014 4:11 pm

you're awesome you know that :wow:

Perrinoia
Suggestion bot 10,000
Posts: 11185
Joined: Sat May 04, 2002 11:00 pm
Location: Rhode Island

Re: hitmark script for annihilation. Halp

Post by Perrinoia » Wed Dec 03, 2014 4:31 pm

Yup.

S_hift
Lt Commander
Lt Commander
Posts: 497
Joined: Sat Sep 26, 2009 7:35 pm

Re: hitmark script for annihilation. Halp

Post by S_hift » Wed Dec 03, 2014 5:18 pm

This might help you finish it. I'm looking through it myself trying to see how it works, this is just a segment.

Code: Select all

function mHUD::LoadBitmaps() {
   $mHUD::CmdHUD::ReticleState = true;
   
   if ($mHUD::ToggleViewState) {
      mHUD::SetVisible(Reticle, false);
      mHUD::SetVisible(RangeFinder, false);
      }
   else if ($mHUD::ToggleSniperState) {
      mHUD::SetVisible(Reticle, ($mHUD::ReticleVisible && $pref::mHUDreticles));
      mHUD::SetVisible(RangeFinder, false);
      }
   else {
      mHUD::SetVisible(Reticle, ($mHUD::ReticleVisible && $pref::mHUDreticles));
      mHUD::SetVisible(RangeFinder, ($mHUD::RangeFinderVisible && $pref::mHUDrangefinders));
      }
   
   mHUD::SetValue(Reticle, $mHUD::CurrentReticle);
   mHUD::SetValue(RangeFinder, $mHUD::CurrentRangeFinder @ $mHUD::resX @ ".bmp");

   if ($mHUD::DebugMode) { echo("Bitmaps Loaded"); echo(""); }
   }

S_hift
Lt Commander
Lt Commander
Posts: 497
Joined: Sat Sep 26, 2009 7:35 pm

Re: hitmark script for annihilation. Halp

Post by S_hift » Wed Dec 03, 2014 5:36 pm

update. I'm just messing around now.

something like this maybe?

Code: Select all

function onClientMessage(%client, %msg)
{
   if(%client)
      $lastClientMessage = %client;

   // filter messages here
      if(%msg == "~wButton3.wav");
     {
      function SetVisible("hitmark.bmp, 512, 384, idk, 0.8 ");
   return true;

I put idk there because I assume that the first two numbers are half my screen res/where it should appear and the last part is how long it shows?

Perrinoia
Suggestion bot 10,000
Posts: 11185
Joined: Sat May 04, 2002 11:00 pm
Location: Rhode Island

Re: hitmark script for annihilation. Halp

Post by Perrinoia » Thu Dec 04, 2014 6:38 am

Code: Select all

function onClientMessage(%client, %msg)
{
   if(%client)
      $lastClientMessage = %client;

   // filter messages here
   if(%msg == "~wButton3.wav");
   {
      %maxWinks = 2;
      %WinksPerSecond = 2;
      for(%i = 0; %i < %maxWinks * 2; %i++)
          Schedule("mHUD::SetVisible(reticle, "@ %i % 2 @");", %i / (%WinksPerSecond * 2));
   }
   return true;
}


Try this, it might make your reticle blink when you damage stuff.

S_hift
Lt Commander
Lt Commander
Posts: 497
Joined: Sat Sep 26, 2009 7:35 pm

Re: hitmark script for annihilation. Halp

Post by S_hift » Sat Dec 06, 2014 9:37 pm

ole winky :lol:


User avatar
Plasmatic
Lead Developer
Lead Developer
Posts: 8376
Joined: Mon Apr 29, 2002 11:00 pm
Location: 4th State of matter.
Contact:

Re: hitmark script for annihilation. Halp

Post by Plasmatic » Wed Dec 31, 2014 9:51 am

Perrinoia wrote:

Code: Select all

function onClientMessage(%client, %msg)
{
   if(%client)
      $lastClientMessage = %client;

   // filter messages here
   if(%msg == "~wButton3.wav");
   {
      %maxWinks = 2;
      %WinksPerSecond = 2;
      for(%i = 0; %i < %maxWinks * 2; %i++)
          Schedule("mHUD::SetVisible(reticle, "@ %i % 2 @");", %i / (%WinksPerSecond * 2));
   }
   return true;
}


Schedule("control::SetVisible(crosshairHud, "@ %i % 2 @");", %i / (%WinksPerSecond * 2));

Try this, it might make your reticle blink when you damage stuff.

Post Reply