Author Topic: Discussion: Zoom Sniper Scope  (Read 13378 times)

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Discussion: Zoom Sniper Scope
« on: February 15, 2008, 11:59:20 am »
OMCWannabe
Private

--------------------------------------------------------------------------------

  Posted: Mon Feb 11, 2008 7:58 pm  

--------------------------------------------------------------------------------

Now this is absolutely fantastic.

Don't give it to me, teach me!! I get so much more out of creating things and learning how it all comes together than simply plugging something in at line 1234.

Thanks SniperOne!

Off to do some homework!




Stretch
Major
 
--------------------------------------------------------------------------------

  Posted: Tue Feb 12, 2008 9:18 am  

--------------------------------------------------------------------------------

Great tut SniperOne. I really helps when there is an explanation as to how all this stuff works. Scripting isnt my bag, I usually gust grab code that works without knowing why.

Thanks for your contribution to the community.
 



cthirtias
Private

--------------------------------------------------------------------------------

  Posted: Thu Feb 14, 2008 8:03 pm  

--------------------------------------------------------------------------------

ok i understand pretty much how to do this...but when i do have lr rifles where do i put them on the server? there is not a weapons folder do i just create it in the mods/extreme directory? once that directory is made i put the lr rifles in there with the ex_zoom.gsc file correct? Thanks guys ahead of time!

*****edit*****
ok obviuosly i did not know and i found out!!! even though i know now and i have this file in the right spot on the iwd file it crashes my game every time i try to join the server...any ideas?
 



  Slow
Private

--------------------------------------------------------------------------------

  Posted: Thu Feb 14, 2008 10:16 pm  

--------------------------------------------------------------------------------

Quote from: "OMCWannabe"
Now this is absolutely fantastic.

Don't give it to me, teach me!!  I get so much more out of creating things and learning how it all comes together than simply plugging something in at line 1234.

Thanks SniperOne!

Off to do some homework!


Quote from: "Stretch"
Great tut SniperOne.  I really helps when there is an explanation as to how all this stuff works. Scripting isnt my bag, I usually gust grab code that works without knowing why.

Thanks for your contribution to the community.


That's right...thanks eXtreme crew for putting these forums up, will be a great help! :D




 Jonas
Private

--------------------------------------------------------------------------------

  Posted: Fri Feb 15, 2008 1:09 am  

--------------------------------------------------------------------------------

Brilliant!!

As you will have seen from posts I have made in the past, the mind and body is willing when it comes to coding but just dont have the knowledge to start....

To get a clear example and breakdown is hugely useful and appreciated!!

You guys rock!

Just one question though, is there an easy way to find the correct Function commands....?

E.g. "getCurrentweapon", "playerADS", and so on? I assume that the game will only recognise hard coded commands for the stock actions and custom ones need to be defined?

Or is it, as I suspect, more a case of experience?

Many thanks,
A willing student!
Jonas
 



 LFLN_The_Cleaner_A
Private

--------------------------------------------------------------------------------

  Posted: Fri Feb 15, 2008 2:03 am  

--------------------------------------------------------------------------------

Thanks for the tutorial, great idea  hope there's more to come, to help people like me who are wanting to learn things like this

Offline ASP-SniperOne

  • Rank: Private
  • *
  • Posts: 498
Discussion: Zoom Sniper Scope
« Reply #1 on: February 15, 2008, 04:54:04 pm »
Jonas please refference this awsome resource.

http://www.infinityward.com/Script/index.htm

Offline JackAttack

  • Rank: Private
  • *
  • Posts: 56
Discussion: Zoom Sniper Scope
« Reply #2 on: February 16, 2008, 02:31:12 pm »
Hey SniperOne!

i got a little ol' question for ya. I "borrowed" the ASP  long range weapon files and installed them on my server and they work great but I seem to not be able to get the zoomable option to work. I created the ex_zoom.gsc and copied the code off of the ASP website forum exactly and i guess i'm not sure where this is suppose to go? I have it in the cod4/mods/x4/extreme folder. Is that the right one?

Thanks much
Jack

Offline ASP-SniperOne

  • Rank: Private
  • *
  • Posts: 498
Discussion: Zoom Sniper Scope
« Reply #3 on: February 16, 2008, 03:49:31 pm »
You need to remember to add the command to thread the zoom code.  Did you put that in the _ex_main.gsc?

Code: [Select]
playerThreads()
{
            level endon("game_ended");
            self endon("disconnect");
            self endon("killed_player");

//Zoom self thread        
            self thread extreme\_ex_zoom::main();
//  




You also should not forget to add the hud clean up step as well.

Offline JackAttack

  • Rank: Private
  • *
  • Posts: 56
Discussion: Zoom Sniper Scope
« Reply #4 on: February 16, 2008, 06:38:46 pm »
Ya I didn't add either of those files lol I guess I should read the instructions a little more :oops:  The zoom works great now so thank you very much!!

Keep up the good work!
Jack

Offline Sgt_Brown

  • Rank: Private
  • *
  • Posts: 36
Discussion: Zoom Sniper Scope
« Reply #5 on: February 18, 2008, 04:34:37 am »
Not sure if this the right place to put this?

I followed the Tut (excellent by the way) but in game I re-mapped my Melee key to my mouse wheel ‘up’ (give’s me better control) which made me think could I add code for another key to go backwards. So when re-mapped to the mouse wheel ‘down’ moving the mouse wheel up and down would zoom in and out?

Sgt_Brown.

Offline ASP-SniperOne

  • Rank: Private
  • *
  • Posts: 498
Discussion: Zoom Sniper Scope
« Reply #6 on: February 18, 2008, 12:10:29 pm »
zoom down requires an additional key to trap on in the code.

One can easily use the the "use" key to move down. You know the one you map to the "F" key generally.

There are only a couple of keypresses that can be used to trigger things in your scripts like use and attack and melee.

Offline X4A_US_Wannabe

  • Rank: Private
  • *
  • Posts: 137
    • http://www.x4aftermath.com
Discussion: Zoom Sniper Scope
« Reply #7 on: February 18, 2008, 05:22:47 pm »
I like the idea of using another key to reduce the zoom, however if one uses the 'F' key or Use key, would it not interfere with the health packs or healing yourself??

Offline ASP-SniperOne

  • Rank: Private
  • *
  • Posts: 498
Discussion: Zoom Sniper Scope
« Reply #8 on: February 18, 2008, 06:27:59 pm »
well if you only trap on it while ADS then you will eliminate that problem.

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Discussion: Zoom Sniper Scope
« Reply #9 on: February 18, 2008, 10:08:11 pm »
What I did in the PST server was use the V key to zoom IN and the G key to zoom out

Melee and Frag

Offline ASP-SniperOne

  • Rank: Private
  • *
  • Posts: 498
Discussion: Zoom Sniper Scope
« Reply #10 on: February 19, 2008, 01:34:09 am »
Yes that is not a bad button for sniper servers my friend.

For info.

here are the known (by me anyway) button press stock functions:

They are all to be qualified with the player - self - entity

like self attackButtonPressed() - they return a true or false (1 or 0 )

here they are:

attackButtonPressed()
fragButtonPressed()
secondaryOffhandButtonPressed()
meleeButtonPressed()

Offline Sgt_Brown

  • Rank: Private
  • *
  • Posts: 36
Discussion: Zoom Sniper Scope
« Reply #11 on: February 19, 2008, 08:23:01 am »
I'm going to go with the frag key, as it’s not use on our sniper server.

Can I add this to the original _ex_zoom.gsc or do I need to create a new one?

Thanks,

Sgt_Brown

P.S. Maybe worth adding on to your original Tutorial  (Just a thought)

Offline Sgt_Brown

  • Rank: Private
  • *
  • Posts: 36
Discussion: Zoom Sniper Scope
« Reply #12 on: February 21, 2008, 05:16:49 am »
OK, I sorted it in the same _ex_zoom.gsc and now have a scope that zoom’s in and out with melee and frag buttons, which I’ve mapped to my mouse wheel.

The question I have for you know is, if I’m zoomed in to say level +4 and zoom out, if I move my mouse wheel too quick and go passed level -1 I go to maximum zoom +6!

Is there a way I can stop it going below level -1 on the zoom out, and passed level +6 on the zoom in?

Hope the above make sense.

Thanks,

Sgt_Brown.

Offline ASP-SniperOne

  • Rank: Private
  • *
  • Posts: 498
Discussion: Zoom Sniper Scope
« Reply #13 on: February 21, 2008, 10:38:11 am »
sure.  it is an easy proposition.


for you melee code:

zoom++;
if (zoom == 7) zoom = 6;

for you frag part

zoom--;
if (zoom == 0 zoom = 1;

Offline Sgt_Brown

  • Rank: Private
  • *
  • Posts: 36
Discussion: Zoom Sniper Scope
« Reply #14 on: February 21, 2008, 02:24:36 pm »
OK When I changed it to what you suggested the zoom in works fine, it goes to 6 and stops. But when I zoom out it keeps counting up to 100+ and it zooms in, I must be doing something mega wrong.

My file is as follows:


main()

{
self endon("disconnect");
self endon("death");
self endon("joined_spectators");

switch( self getCurrentWeapon() )
{
case "m21_mp":
zoom = 1;
self setclientDvar ("cg_fovmin", "40");
break;

case "barrett_mp":
zoom = 1;
self setclientDvar ("cg_fovmin", "40");
break;

case "dragunov_mp":
zoom = 1;
self setclientDvar ("cg_fovmin", "40");
break;

case "m40a3_mp":
zoom = 1;
self setclientDvar ("cg_fovmin", "40");
break;

case "remington700_mp":
zoom = 1;
self setclientDvar ("cg_fovmin", "40");
break;

default:
zoom = 0;
break;
}

while(isAlive( self ) && zoom != 0)
{
wait .05;

if ( self playerADS() == 1)
{
if(!isdefined(self.hud_zoom))
{
self.hud_zoom = newClientHudElem(self);
self.hud_zoom.x = 320;
self.hud_zoom.y = 450;
self.hud_zoom.alignx = "center";
self.hud_zoom.aligny = "middle";
self.hud_zoom.horzAlign = "fullscreen";
self.hud_zoom.vertAlign = "fullscreen";
self.hud_zoom.alpha = .9;
self.hud_zoom.fontScale = 2;
}
self.hud_zoom.label = &"ZOOM^1"; //comment this out if you do not have localized strings defined here
self.hud_zoom setvalue(zoom);

if ( self meleeButtonPressed())
{
zoom++;

if (zoom == 7) zoom = 6;

if (zoom == 1) self setclientDvar ("cg_fovmin", "40");
if (zoom == 2) self setclientDvar ("cg_fovmin", "20");
if (zoom == 3) self setclientDvar ("cg_fovmin", "15");
if (zoom == 4) self setclientDvar ("cg_fovmin", "10");
if (zoom == 5) self setclientDvar ("cg_fovmin", "5");
if (zoom == 6) self setclientDvar ("cg_fovmin", "3");
}

if ( self fragButtonPressed())
{
zoom++;
 
if (zoom == 0) zoom = 1;
 
if (zoom == 6) self setclientDvar ("cg_fovmin", "3");
if (zoom == 5) self setclientDvar ("cg_fovmin", "5");
if (zoom == 4) self setclientDvar ("cg_fovmin", "10");
if (zoom == 3) self setclientDvar ("cg_fovmin", "15");
if (zoom == 2) self setclientDvar ("cg_fovmin", "20");
if (zoom == 1) self setclientDvar ("cg_fovmin", "40");
}
}

if(isDefined(self.hud_zoom) && self playerADS() != 1 ) self.hud_zoom destroy();
}
}