Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-12-2011, 06:33 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Getting center of level (makescreenshot)

Alright i've run into a little problem making my own screenshot weapon.

Everything works fine except when trying to get the center of the level. I've tried fowlplay4's line of:
PHP Code:
temp.center = {player.+ (screenwidth 32), player.+ (screenheight 32)}; 
And i've also tried things like:
PHP Code:
temp.center = {(screenwidth 2), (screenheight 2)} 
And also 30, 30 for the center but no matter what i set it to, it always outputs the same image.

Why is this?

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  
temp.filename "screenshot_" int(random(100001000000)) @ ".png";
  
temp.center = {player.+ (screenwidth 32), player.+ (screenheight 32)};
  
ShowFlash();
  
makescreenshot2(temp.filename0x3ftemp.center[0], temp.center[1], player.zscreenwidthscreenheight);
}

function 
ShowFlash() {
  
with (findimg(200)) {
    
polygon = {
      
00640,
      
6464064
    
};
    
    for (
temp.1temp.>= 0temp.-= 0.1;) {
      
alpha -= 0.1;
      
sleep(0.05);
      
      if (
temp.== 0) {
        
hideimg(200);
      }
    }
  }

Thank you
Reply With Quote
  #2  
Old 10-12-2011, 07:14 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
A level's center position is { level.width / 2, level.height / 2 }
__________________
Reply With Quote
  #3  
Old 10-12-2011, 07:27 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Still, for some reason not taking the screenshot from the center
Reply With Quote
  #4  
Old 10-12-2011, 08:22 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Are the co-ordinates a screen co-ord or a tiles co-ord?
Reply With Quote
  #5  
Old 10-12-2011, 08:27 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Screen, i believe. But regardless, if i did screenheight and screenwidth its still the same position
Reply With Quote
  #6  
Old 10-12-2011, 08:36 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
No clue as to how to how you would take a screenshot of the whole level unless your screen's that big sorry.
Reply With Quote
  #7  
Old 10-12-2011, 08:52 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Assuming your resolution is high enough, this screenshots a level, at it's center, when alt + 1 is pressed.
PHP Code:
//#CLIENTSIDE
function GraalControl.onKeyDown(temp.keycodetemp.keystringtemp.scancode) {
  if (
keycode == 1073)
    
makescreenshot2("screenshot" int(random(100000,999999)) @ ".png"0x3fplayer.level.width 2player.level.height 2player.zplayer.level.width 16player.level.height 16);

__________________
Reply With Quote
  #8  
Old 10-12-2011, 09:01 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Not looking for it to take a shot of the whole level, just have the center of the screenshot, the center of the level.
Reply With Quote
  #9  
Old 10-12-2011, 09:11 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
No idea if it will work, but what about doing this...

PHP Code:
setFocus(player.level.width 2player.level.height 2); 
right before taking the screenshot?
__________________
Reply With Quote
  #10  
Old 10-13-2011, 01:31 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
No idea if it will work, but what about doing this...

PHP Code:
setFocus(player.level.width 2player.level.height 2); 
right before taking the screenshot?
Nope...
Reply With Quote
  #11  
Old 10-13-2011, 05:06 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Are you trying to find the center of the players screen or the center of the players level?

Finding the middle of the players screen would be half of the screen width.

Finding the center of a specific level would be half of the height (64) and half of the width (64) since a levels height and width are both 62
__________________

Last edited by Emera; 10-13-2011 at 06:14 PM..
Reply With Quote
  #12  
Old 10-13-2011, 05:15 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Quote:
Originally Posted by Emera View Post
Are you trying to find the center of the players screen or the center of the players level?

Finding the middle of the players screen would be half of the screen width.

Finding the center of a specific level would be half of the height (62) and half of the width (62) since a levels height and width are both 62
The makescreenshot2 parameters take level x and y. One level (nw) is 64 by 64.
__________________
Reply With Quote
  #13  
Old 10-13-2011, 05:16 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by 0PiX0 View Post
The makescreenshot2 parameters take level x and y. One level (nw) is 64 by 64.
Yeah that's what I was saying. I might play around with it and see what I can do
__________________
Reply With Quote
  #14  
Old 10-13-2011, 05:43 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Solution.
PHP Code:
//#CLIENTSIDE
function GraalControl.onKeyDown(temp.keycodetemp.keystringtemp.scancode) { 
  if (
keycode != 1073// ALT + 1
    
return;
  
  
// Limit size to level size or screen res
  
temp.pixel_width = (player.level.width screenwidth 16) ? screenwidth player.level.width 16;
  
temp.pixel_height = (player.level.height screenheight 16) ? screenheight player.level.height 16;
  
  
// Get coordinates for screenshot
  
temp.level_x player.level.width pixel_width 32;
  
temp.level_y player.level.height pixel_height 32;
  
  
makescreenshot2("screenshot" int(random(100000,1000000)) @ ".png"
    
0x3f// include everything
    
level_x
    
level_y
    
player.z
    
pixel_width
    
pixel_height); 

__________________
Reply With Quote
  #15  
Old 10-13-2011, 05:55 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Quote:
Originally Posted by Emera View Post
Yeah that's what I was saying. I might play around with it and see what I can do
Wouldn't it have been awesome if you actually said 64x64 instead of 62x62?
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.