hitmark script for annihilation. Halp

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

Moderator: Moderators

1 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.
S_hift
Lt Commander
Lt Commander
 
Posts: 497

2 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.
Perrinoia
Suggestion bot 10,000
 
Posts: 11185

3 Wed Dec 03, 2014 4:11 pm

you're awesome you know that :wow:
S_hift
Lt Commander
Lt Commander
 
Posts: 497

4 Wed Dec 03, 2014 4:31 pm

Yup.
Perrinoia
Suggestion bot 10,000
 
Posts: 11185

5 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

6 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?
S_hift
Lt Commander
Lt Commander
 
Posts: 497

7 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.
Perrinoia
Suggestion bot 10,000
 
Posts: 11185

8 Sat Dec 06, 2014 9:37 pm

ole winky :lol:
S_hift
Lt Commander
Lt Commander
 
Posts: 497

9 Mon Dec 15, 2014 1:52 am

DaJ4ck3L
Crow{OZ}
 
Posts: 118

10 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.
User avatar
Plasmatic
Lead Developer
Lead Developer
 
Posts: 8375


Return to Coder's Hangout

Who is online

Users browsing this forum: No registered users and 1 guest

cron