Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Set Effect (https://forums.graalonline.com/forums/showthread.php?t=134256830)

sssssssssss 11-06-2009 08:06 AM

Set Effect
 
Simple question.
What set effect values would make an image seem slightly transparent, but still have the regular colors and stuff, then what set effect puts it back to normal?
Ill go ahead and post my script, because its blocking and from what I know, it shouldn't be. Besides someone probably knows a better way to do what I'm trying to do anyways.

PHP Code:

function onCreated(){
  
setimg("armageddon-bridge11.png");
}
function 
onPlayerTouchsMe(){
  if (
this.touched == 1){
    
setcoloreffect(1,1,1,0.44);
    
setTimer(2);
  }
  if (
this.touched != 1){
    
this.touched 1;
  }
}

function 
onTimeout(){
  
setcoloreffect(0,0,0,1);
  
this.touched 0;
}
//#CLIENTSIDE
function onPlayerTouchsMe(){
  
dontblocklocal();
  
drawoverplayer();



cbk1994 11-06-2009 08:44 AM

It'll need to be clientside, try something like

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe() {
  
setEffectMode(1); // draw as opacity rather than alpha, if that makes sense
  
setColorEffect(111.7); // R, G, B, opacity — change opacity as needed



Codein 11-06-2009 12:21 PM

Quote:

Originally Posted by cbk1994 (Post 1536852)
It'll need to be clientside, try something like

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe() {
  
setEffectMode(1); // draw as opacity rather than alpha, if that makes sense
  
setColorEffect(111.7); // R, G, B, opacity — change opacity as needed



Thank you, once again.

Sage_Shadowbane 11-07-2009 01:46 AM

You should probably also make it non-blocking under an onCreated() function. As this will make it non-blocking as soon as its created for the client, rather than waiting until the player touches it, From my experience it will take a quick second to become non-blocking waiting for the players touch, as apposed to it already being non-blocking before the player reaches it. ^^

sssssssssss 11-07-2009 02:05 AM

Ahh, ok ty. :)

sssssssssss 11-07-2009 02:09 AM

Actually, i noticed using this, that the trans shows up too, any way around that?

cbk1994 11-07-2009 05:00 AM

Quote:

Originally Posted by sssssssssss (Post 1536984)
Actually, i noticed using this, that the trans shows up too, any way around that?

What do you mean?

sssssssssss 11-07-2009 05:32 AM

the trans for that image is yellow, its transparent normally, but after touching it and setting the image to be more transparent, the yellow shows up too

sssssssssss 11-08-2009 08:53 PM

3 Attachment(s)
Here are some screens to show what i mean, the code im using is:


PHP Code:

//#CLIENTSIDE
function onCreated(){

}
function 
onPlayerTouchsMe(){
  
dontblocklocal();
  
drawoverplayer();
  
setEffectMode(1);
  
setColorEffect(111.7);
  
setTimer(7);

}

function 
onTimeout(){
  
setEffectMode(1);
  
setColorEffect(1111);


order of the screens should be before touching the image, while in the image, and after leaving the image.

Ive tried a few different things, like using showimg, not including setEffectMode(1) on the timeout and stuff, but regardless of the timeout, when i touch it and it turns more transparent, thats when the yellow shows up.

Crow 11-08-2009 08:58 PM

Looks like a problem with the image. I suggest you get yourself IrfanView and re-save the file, then try again.

cbk1994 11-08-2009 09:10 PM

Can you upload the image here?

fowlplay4 11-08-2009 10:47 PM

Try changing this.mode = 1;

I'm under the impression setEffectMode() changes the mode for setEffect which affects the entire screen, not setColorEffect.

When you use setColorEffect this is basically what happens:

PHP Code:

//#CLIENTSIDE
function setColorEffect(rgba) {
  
this.red r;
  
this.green b;
  
this.blue b;
  
this.alpha a;


So try using this instead.

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
setColorEffect(1110.7);
  
this.mode 1;



Crow 11-08-2009 11:18 PM

Quote:

Originally Posted by fowlplay4 (Post 1537366)
I'm under the impression setEffectMode() changes the mode for setEffect which affects the entire screen, not setColorEffect.

Sorry, wrong.

fowlplay4 11-09-2009 01:18 AM

Quote:

Originally Posted by Crow (Post 1537372)
Sorry, wrong.

Well, never was a fan of mode then.

sssssssssss 11-11-2009 03:39 AM

Still doing the same thing. For whatever reason, changing the alpha is showing up the trans in the image. Any other idea around it?

Imperialistic 11-11-2009 04:07 PM

Quote:

Originally Posted by sssssssssss (Post 1537352)
but regardless of the timeout, when i touch it and it turns more transparent, thats when the yellow shows up.

Wouldn't that BE a timeout problem? I'm not much of a scripter but I quite remember having a problem like that.

Try asking someone the proper way to set the timer in it.

Crow 11-11-2009 06:30 PM

Cyril, I was on Armageddon earlier, also talking to Decus, and while doing so, I checked out that bridge, and it's working fine, not showing the yellow. Seems to be a problem with your computer (or maybe your locally saved image of that bridge). Try deleting the local copy of the bridge, then restart Graal and let it re-download it. See if it works. If it doesn't, try updating your graphics card drivers.

sssssssssss 11-11-2009 08:18 PM

That was it. xD Oh man a two page post on something stupid. Oh man. xD

Samposse 11-29-2009 12:18 PM

:o

sssssssssss 12-02-2009 07:22 AM

Actually decided to take it off a timer, and put it in x, y coordinates, to eliminate the use of timers. I have this, but now its not setting, any obvious reason why?

PHP Code:

//#CLIENTSIDE
function onPlayerEnters(){
  
setColorEffect(1111);
  
this.mode 1;
}
function 
onPlayerTouchsMe(){
  
dontblocklocal();
  
drawoverplayer();
  
setTimer(.05);
}

function 
onTimeout(){
  if (
player.x+1.5 in |1725| && player.y+2 in |1337|){
    
setColorEffect(1110.7);
    
this.mode 1;
  }else{
    
setColorEffect(1111);
    
this.mode 1;
  }
  
setTimer(.05);



fowlplay4 12-02-2009 07:58 AM

Since you set the mode in the player enters event, you don't need to keep setting it in the timeout but that's not the issue.

Have tried you placing player.chat = "tests"; in the loop to see if it's actually executing the code you want? You could also use my debugger class, and insert breakpoints instead.

sssssssssss 12-08-2009 09:04 PM

Finally got time to come back to this. All it says on player is "out", which its in the correct coordinates, so I dont know why its not saying "IN".

PHP Code:

//#CLIENTSIDE
function onPlayerEnters()
{
  
setColorEffect(1111);
  
this.mode 1;
  
player.chat "START";
}
function 
onPlayerTouchsMe()
{
  
dontblocklocal();
  
drawoverplayer();
  
setTimer(0.05);
}
function 
onTimeout()
{
  if (
player.x+1.5 in |1725| && player.y+2 in |1337|)
  {
    
setColorEffect(1110.7);
    
this.mode 1;
    
player.chat "IN";
  }else
  {
    
setColorEffect(1111);
    
this.mode 1;
    
player.chat "out";
  }



fowlplay4 12-08-2009 09:09 PM

Try putting parenthesis' around

player.x+1.5 and player.y+2

like so:

if ((player.x+1.5) in |17, 25| && (player.y+2) in |13, 37|)

Nvm, that's not the issue but for clarity purposes I would.

Is this script on a gmap? because if it is you start dealing with coordinates in the 100s in some cases, a way to get around this would be to use relative coordinates like: this.x, this.x + 10, etc.

sssssssssss 12-08-2009 09:12 PM

Still saying out and doing nothing.

fowlplay4 12-08-2009 09:28 PM

Try displaying the coordinate values using echo or player.chat, so you can actually see what the values are, instead of just in and out.

I.e: player.chat = player.x SPC player.y;

Grey 12-08-2009 09:44 PM

If you're working on a GMAP those arent going to be the actual x and y of the player

Switch 12-08-2009 10:04 PM

Personally, I would do something like this:
PHP Code:

//#CLIENTSIDE
function onPlayerEnters(){
  
setEffectMode(1);
  
setColorEffect(1111);
  
dontBlockLocal();
  
drawOverPlayer();
  
setTimer(0.05);
}

function 
onTimeout(){
  if (
player.x+1.5 in |this.x-1this.x+this.width+1| && player.y+2 in |this37|){
    
setColorEffect(1110.7);
  } else {
    
setColorEffect(1111);
  }
  
setTimer(0.05);


Then you can put it in a class and use it for other things like it.

Deas_Voice 12-08-2009 10:12 PM

i've played around with the scripts on both a gmap and a level, on the level, the script worked fine, on the gmap, it didn't.
so, i'm guessing it's the x/y that needs to be compared to the x/y on the map.

i've heard of "getmapx/y()" but i've never used it, i suggest you play around with it :)
(between, u can use this.alpha to change the trans instead of setColorEffect() )

EDIT:
switch found out how to fix it, by setting the shape to the width and height of the img (i think).

Switch 12-08-2009 11:43 PM

Quote:

Originally Posted by Deas_Voice (Post 1543285)
switch found out how to fix it, by setting the shape to the width and height of the img (i think).

The level's NPC image was only set and not actually joined to the class. Then I did that so the clientside would work.


All times are GMT +2. The time now is 06:08 PM.

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