Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Estaog on Thu 08/07/2004 09:21:49

Title: Fixed
Post by: Estaog on Thu 08/07/2004 09:21:49
So i was importing some walkable areas and i saved the game, loaded it and they were gone.It looks to me as the only way to save the areas is by clicking on another room.

Anyways this is the problem: I want to make a house with a roof, and when the player enters it he can see the hotspots etc.But what i cant figure out is how to make the roof fade out when he comes under it.For the hotsport i can easily use enable disable, and for when the character is under the in the house i can use a region.Is there a function to make an object fade out?

Thanks
Title: Re: Bug in ags and scripting problem.
Post by: Gilbert on Thu 08/07/2004 09:33:49
Hmmm are you sure the area mask you made was 256 colours and used only the first few colour slots for the areas?

For AGS V2.6SP1 or earlier, you can use a character for teh roof and use SetCharacterTransparency(). Or use RawDrawImageTransparent() if you're using newer version. I recommend the Character method though.
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 09:39:22
But will it fade out or just go away?
Title: Re: Bug in ags and scripting problem.
Post by: Mr Jake on Thu 08/07/2004 10:00:36
if you settransparency you can differ the amount so it fades out
Title: Re: Bug in ags and scripting problem.
Post by: Gilbert on Thu 08/07/2004 10:00:40
Depends on how you script it, if you use it in a while loop or something to adjust the transparency gradually it will fade out. (Of course, if only your game is on a colour depth of at least 16-bit).
Title: Re: Bug in ags and scripting problem.
Post by: Mr Jake on Thu 08/07/2004 10:36:10
or you could make the roof an object and animate it
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 11:23:45
  // script for region1: Player walks onto region
SetCharacterTransparency (0,10); 
SetCharacterTransparency (0,20); 
SetCharacterTransparency (0,30); 
SetCharacterTransparency (0,40); 
SetCharacterTransparency (0,50); 
SetCharacterTransparency (0,60); 
SetCharacterTransparency (0,70); 
SetCharacterTransparency (0,80); 
SetCharacterTransparency (0,90); 
SetCharacterTransparency (0,100); 

I used that script but it didnt fade out it just skipped to the last action.
Title: Re: Bug in ags and scripting problem.
Post by: Gilbert on Thu 08/07/2004 11:47:40
Because the function is not blocking. You have to use things like Wait() for it.
However, better, you cna use a while loop and simplify the code, eg:

int trans=0;
while (trans<=100) {
  SetCharacterTransparency (ROOF,10);
  Wait(1);
  trans++;
}

also I don't suggesting using character character #0 for the roof, and it's always better to use the character's script name rather than the exact number.
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 12:09:31
This script works better:
SetCharacterTransparency (0,10);
Wait(2); 
SetCharacterTransparency (0,20); 
Wait(2); 
SetCharacterTransparency (0,30);
Wait(2);   
SetCharacterTransparency (0,40);
Wait(2);   
SetCharacterTransparency (0,50);
Wait(2);   
SetCharacterTransparency (0,60);
Wait(2);   
SetCharacterTransparency (0,70);
Wait(2);   
SetCharacterTransparency (0,80); 
Wait(2); 
SetCharacterTransparency (0,90);
Wait(2);   
SetCharacterTransparency (0,100); 
Title: Re: Bug in ags and scripting problem.
Post by: Snarky on Thu 08/07/2004 15:08:06
You should take Gilbot's advice and use a loop and the script name. This will have the same effect as your code:

int trans=0;
while(trans<100)
{
   SetCharacterTransparency(ROOF,trans);
   trans+=10;
   Wait(2);
}

This will do the same thing, except more smoothly:

int trans=0;
while(trans<100)
{
   SetCharacterTransparency(ROOF,trans);
   trans+=5;
   Wait(1);
}

Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 18:51:19
Hmm, i cant understand the code but works fine.Just how do i make it fade in, change the 5 to a negatie number?
Title: Re: Bug in ags and scripting problem.
Post by: Snarky on Thu 08/07/2004 19:53:03
Loops are bits of code that are executed again and again as many times as you tell it to. The bit in between { and } is the loop, and the bit in while() controls whether run the code again (or at all). There's an explanation of how it works in the coding tutorial in the AGS manual.

You're right. To fade out you need to change +5 to a negative number (or change the += to a -=, which amounts to the same thing). You also need to make it start at 100% opaque and stop the loop when it reaches 0, like this:

int trans=100;
while(trans>0)
{
   SetCharacterTransparency(ROOF,trans);
   trans-=5;
   Wait(1);
}
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 20:17:27
if (chik1==0) {
  SetTimer (1,100);
if (IsTimerExpired(1)==1)
{  ChangeCharacterView (3,7);
chik1=1;   
}
  }
Changed it.But it didnt change the view.
Title: Re: Bug in ags and scripting problem.
Post by: Mr Jake on Thu 08/07/2004 20:22:38
if (chik1==0) {
Ã,  SetTimer (1,1000);
Ã,  chik1=2;
}
if (chik1==2){
Ã,  if (IsTimerExpired (1) == 1){
Ã,  ChangeCharacterView (3,7);
Ã,  chik1=1;
Ã,  }
}


the way you had it would mean that the timer would never change, you also never had the IsTimerExpired correct.
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 20:34:57
Thanks, btw you missed a bracketÃ,  Ã, ::)

I changed it to this but the view still isnt getting changed.
if (chik1==0) {
  SetTimer (1,10);
  chik1=2;
}
if (chik1==2){
  if (IsTimerExpired (1) == 1){
  ChangeCharacterView (3,7);
  chik1=3;
  }
}
}

Btw this is sopposed to be part of my AI.
Title: Re: Bug in ags and scripting problem.
Post by: Mr Jake on Thu 08/07/2004 21:20:01
where is this script being placed?
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Thu 08/07/2004 22:02:32
First time player enters screen.
Title: Re: Bug in ags and scripting problem.
Post by: Mr Jake on Thu 08/07/2004 22:17:54
ah ok
put this in first time player enters screen:

if (chik1==0) {
  SetTimer (1,1000);
}

and this is rep exe:
if (IsTimerExpired (1) == 1){
  if (chik1==0){
  ChangeCharacterView (3,7);
  chik1=1;
}
}
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Fri 09/07/2004 09:44:12
Works fine now, it wasent checking for the timer, it checked only once.
Anyways this code works fine:
if (chik1==2){
  if (IsTimerExpired (1) == 1){
  ChangeCharacterView (3,7);
  Display ("One of your chicks has grown!");
  chik1=3;
  }
}
But leaves the character a bit visible, which is very annoying.I was thinking of using a SetCharacterTransparency() to 0 fter it finished the loop but i cant figure out where to put it.Help is apppritiated.
Title: Re: Bug in ags and scripting problem.
Post by: Mr Jake on Fri 09/07/2004 11:14:00
I dont understand what you mean..... What you want to do
Title: Re: Bug in ags and scripting problem.
Post by: Estaog on Sat 10/07/2004 14:38:50
Never mind i fixed it