Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - CB..

#21
Beginners' Technical Questions / Re:timer
Fri 05/03/2004 00:12:15
try this instead note the two == sign instead of the !=

if (IsTimerExpired (1)==1 {
///code here
}




///


im not sure what the diference between != and == amounts to  might handy to know if anyone can fill me in?
#23
many thanks that clears that up, it seems to be better if i avoid opening the main script window if i get prompted if i want to edit my script..(and stick to editing via the run script etc)

one thought tho...the latest beta version says it's for windows XP// does this mean it's not compatible with older OS's like windows ME for instance?
#24
im allso having some slightly odd occurances with the latest AGS.(2.6 sp1)

sometimes when i open for example the rooms /repeatedly execute/ run script/ editing window to make an alteration...it shows me entrys from the other room functions...such as when player enters room..etc....and once or twice ive had an error been prompted to edit my script..(which opens the main script window) ive edited the repeatedly execute section as prompted  (in this case) and when i go back to the actual rooms repeatedly execute script (the run script editing window ) theres been no code in there at all..forcing me to load a back up..not seen this in the older versions of AGS..

mind yu i installed the latest 2.6 version by simply extracting the zip into the normal AGS directory letting it overwrite the lder files...any thoughts?
#25
this works ok for a character that periodically picks it self up and moves towards the player..

set  timer3 in as room loads..

then in repeatedly ex

if (IsTimerExpired(3)==1)
{MoveCharacterPath(1, character[EGO].x, character[EGO].y);
SetTimer(3,400);}




///
use yur characters number instead of its name in the MoveCharacterPath(1,etc....

been experimenting with this and it doesnt ever seem to throw the too many moves error..
tho this might hapen with the wrong timer settings and or character movement speeds..
got to allow the following character to stop before it moves again(?) or perhaps this doesnt matter as it goes to the x,y position of the player character as selected when the timer expired..in which case it's probably perfectly reliable no matter what the timer /character speed is (within reason?)

i did try this as well for something else


if (character[EGO].walking!=0){
if (IsTimerExpired(2)==1)
{int ran=Random(3);
if (ran==0) MoveCharacter(DD,character[DD].x,character[DD].y-70);
else if (ran==1) MoveCharacter(DD,character[DD].x,character[DD].y+70);
else if (ran==2) MoveCharacter(DD,character[DD].x+70,character[DD].y);
else MoveCharacter(DD,character[DD].x-70,character[DD].y);
SetTimer(2,200);}
}    
if (character[EGO].walking!=1){
if (IsTimerExpired(3)==1)
{MoveCharacterPath(1, character[EGO].x, character[EGO].y);
SetTimer(3,200);}}



////

but it doesnt work as yud expect..the DD character starts to move towards the ego character when the ego character is stopped...which seems to be the wrong way round?
i wanted the DD charater to wander randomly when the player is stationary and only start to move towards th player if he starts to move...(motion sensor in effect) but the opposite happens..and the random movements still occur canceling out the movecharacterpath command . meaning that im confused..as usual



ok this seems to work..enemy character (DD) moves randomly when player is stationary. and moves to the last checked player x y position when the player moves...

if (character[EGO].walking==0){
if (IsTimerExpired(2)==1)
{int ran=Random(3);
if (ran==0) MoveCharacter(DD,character[DD].x,character[DD].y-70);
else if (ran==1) MoveCharacter(DD,character[DD].x,character[DD].y+70);
else if (ran==2) MoveCharacter(DD,character[DD].x+70,character[DD].y);
else MoveCharacter(DD,character[DD].x-70,character[DD].y);
SetTimer(2,200);}
}    
else if (IsTimerExpired(2)==1)
{MoveCharacterPath(1, character[EGO].x, character[EGO].y);
SetTimer(2,200);}


//////

its still a little bit odd in that the DD characters speed seems to be alered slowed down but thats probably something simple ive not understood    
#26
Quote from: TK on Sat 24/01/2004 14:01:09
SetLabelText (1,1,energy); //We're displaying the energy points on the object 1 of the GUI 1

I'd say...



Cheers TK
that was it, many thanks all for the help
i'd was about to decide i was going mad... :o
#27
i'm trying to understand why i can't get this tutorial to work can any one help?

i get an undefined  token error on the SetLabelText line

here it is )my apologies to the author if im just not reading it correctly..

...........

********************** DISPLAY ENERGY/TIME/POINTS ETC ON A GUI ***********************************************

First you have to make the GUI.
Let's say it's GUI 1.

The energy of the hero is stored in a Global Integer. We will use Global Integer 10.
If we want our hero to start with an energy of 100 we put this in the game_start function :
SetGlobalInt(10,100); // The energy at the beginning is 100.

When we want to add energy we use this script:
SetGlobalInt(10,GetGlobalInt(10) + 10); // Add 10 points of energy.

When we want to subtract energy we use this:
SetGlobalInt(10,GetGlobalInt(10) - 10) // remove 10 points of energy
if (GetGlobalInt(10)>0) {} // If energy is greater than 0 do nothing
else Display ("You are dead"); // else our hero is dead

Then we want to display this on a GUI.

We make two labels in the GUI. On the first (OBJECT 0) we write "Energy"
and on the other (OBJECT 1) we write whatever we want (or nothing )

On the top of the global script we declare the energy string , by writing:

string energy;

In the Global script's repeatedly execute function we write:

StrFormat(energy,"%d", GetGlobalInt(10)); // we're passing the global int's quantity in the string "energy"
SetLabeltext (1,1,energy); //We're displaying the energy points on the object 1 of the GUI 1

That's all. This way you can display whatever you want on a GUI (names. points, money etc)
#28
yu could use the picture yu have for the background the one yu have now has the door shown closed?
create a new back ground with the door shown open
import in as one of the animated frames for the background /
then in as room loads

run script

edit script then copy this into the window and save

SetBackgroundFrame(0);


this will ensure that the background is the correct one showing the closed door as yu enter the room/ frame(0) is the view shown in the editor main window)

then create a region near the door
and use the if player has inventory item  ie a key or similar (or whatever idea yu have employed for opening the door)

run script

edit script and enter this

SetBackgroundFrame(1);
NewRoom(2);


#29
wouldn't some thing like this do the trick?

blinking object view animation

//at room load

SetTimer(1,200);
SetTimer(2,300);

//repeatedly execute

if (IsTimerExpired(1)==1)
{SetObjectFrame(0,7,0,0);
SetTimer(1,200);}
if (IsTimerExpired(2)==1)
{SetObjectFrame(0,7,0,1);
SetTimer(2,300);}

#30
heres the code for a very simple weapon fired by the player at another named character...

repeatedly execute   run script  edit script copy this in..use yu own chraracters ie EGO instead of SUB and ARROW instead of TP etc..


if (IsKeyPressed(407) == 1)
SetTimer(10,40); //set a timer for one second
character[TP].room=character.room; //moves weapon to current room
character[TP].x=character.x ;//places weapon at same left right position as player
character[TP].y=character.y-10;//places weapon slightly above player
if (IsTimerExpired(10)==1)//after one second has elapsed
{MoveCharacterDirect(TP, character.x-1,character.y-300);}
if (AreCharactersColliding(TP,DD)==1){
GiveScore(100);
}  

pressing the ALT key on yur keyboard sets a timer for one second  

after the timer has expired the weapon character (choose a view like an arrow or such like) is moved from the players position up the screen...if the weapon/arrow collides with the target character yu are given some points .but it could allso do other things like play an animation and stop that character moving etc.

this creates a animation type effect for the weapon as it travels up the screen as the game flashes the character from the start postion to it's current position evry game cycle..which is quite effective (tho it had me confused for a while..the key press only activated the first command in the group not them all)

this could allso be written like this to remove the flashing effect and avoid having the weapon on view all the time

if (IsKeyPressed(407) == 1)
SetTimer(10,40);
if (IsKeyPressed(407) == 1)
character[TP].room=character.room;
if (IsKeyPressed(407) == 1)
character[TP].x=character.x ;
if (IsKeyPressed(407) == 1)
character[TP].y=character.y-10;
if (IsTimerExpired(10)==1)
{MoveCharacterDirect(TP, character.x-1,character.y-300);}
if (AreCharactersColliding(TP,DD)==1){
GiveScore(100);
}  



then its a matter of naming the character yu want to shoot at

here

if (AreCharactersColliding(TP,DD)==1)

im shooting the weapon  character TP at the non player character DD

susbstitute yur own characters names  

ie

if (AreCharactersColliding(ARROW,ENEMY)==1)  and so on..


some minor details need tidying up but it works and  once yu have the hang of using the run script option in AGS  is something to mess around with (as i am doing) while yur learning (again im in the same boat)


this might make it a little clearer  yu might use this in yur game


if (IsKeyPressed(407) == 1)
SetTimer(10,40);
if (IsKeyPressed(407) == 1)
character[ARROW].room=character[EGO].room;
if (IsKeyPressed(407) == 1)
character[ARROW].x=character[EGO].x ;
if (IsKeyPressed(407) == 1)
character[ARROW].y=character[EGO].y-10;
if (IsTimerExpired(10)==1)
{MoveCharacterDirect(ARROW, character[EGO].x-1,character[EGO].y-300);}
if (AreCharactersColliding(ARROW,ENEMY)==1){
GiveScore(100);
}



im pretty sure this will work


i did try and set it up so one button would load the weapon and another different buton would fire it, as this was more interactive and fun..
like this

if (IsKeyPressed(407) == 1)//alt key for load
character[TP].room=character.room;
character[TP].x=character.x;
character[TP].y=character.y-10;
if (IsKeyPressed(371) == 1)//home key for fire
SetTimer(10,40);
if (IsTimerExpired(10)==1)
{MoveCharacterDirect(TP, character.x-1,character.y-300);}
if (AreCharactersColliding(TP,DD)==1){
GiveScore(100);
}  

with a longer delay on the timer for loading and firing etc it made it feel quite realistic and much more interesting/fun ...but it was posible to try and fire the weapon before loading it which didnt work and caused an error of course..but im sure with a litle more work that having the extra load and fire facility can be worked so if yu try to fire the weapon before loadng it the game just displays a message or does nothing ..which i think would be a nice addition..
#31
Advanced Technical Forum / Re:Raw draw help?
Wed 19/11/2003 11:06:54
Cheers Gilbot,
i was hoping that would be the case as most everything im doing seems to need to be in repeatedly execute to work ...sorry about the ten seconds thing , i posted an older version of the code by mistake .  
#32
he he !! am niggling away at this myself (as a newbie myself so only using pretty newbie style coding)

i have for a submarine warfare simulation concept managed to create a destroyer (character DD) which randomly (at the moment) moves around on one walkable area at the top of the screen
using a timer to slow it's progress which is set in as room loads (run script)

SetTimer(3,200);

then in repeatedly execute (run script)....(thanks colosuss!)

if (IsTimerExpired(3)==1)
{if (character[DD].walking!=1){
MoveCharacter(DD, Random(320),Random(200));
}
SetTimer(3,200);
}    



this means every 5 second or so it randomly moves around the top walkable area which is the surface of the sea etc

it drags another character around in the second walkable area (underwater etc)
by using this to tie its movements to the destroyer

repeatedly execute(runscript)

character[SONAR].x=character[DD].x;


this character as yu might have guessed acts as the  destoyers sonar detector beam

then for the sensor to work i used (again setting the timer in as room loads)

SetTimer(3,200);

this in repeatdly execute

if (IsTimerExpired(5)==1)
{if ((character.x-character[SONAR].x<80 && character.x-character[SONAR].x>-80 && character.y-character[SONAR].y<80 && character.y-character[SONAR].y>-80)){
character[DC].room=character[DD].room;
character[DC].x=character[DD].x + 10;
character[DC].y=character[DD].y + 50;
PlaySoundEx(10, 5) && SetTimer(7,150) && MoveCharacter(DC, character[DD].x-20,character[DD].y+300);
}
SetTimer(5,160);
}    

//

which breaks down into

if the submarine (character SUB) is within 80 pixels in any direction of the sonar beam (character SONAR)

if ((character.x-character[SONAR].x<80 && character.x-character[SONAR].x>-80 && character.y-character[SONAR].y<80 && character.y-character[SONAR].y>-80)){

then it moves a new character into the room.. in this case a depth charge (character DC)

character[DC].room=character[DD].room;

places it just underneath the destroyer

character[DC].x=character[DD].x + 10;
character[DC].y=character[DD].y + 50;

then plays a sound (a sonar ping..PlaySoundEx (10, 5) and shoots the depthcharge down the screen //MoveCharacter(DC, character[DD].x-20,character[DD].y+300)// allso seting a new timer to set when the depth charge will explode//SetTimer(7,150)

PlaySoundEx(10, 5) && SetTimer(7,150) && MoveCharacter(DC, character[DD].x-20,character[DD].y+300);
}
SetTimer(5,160);
}  

then in repeatedly execute again to get the damage caused to the sub (if any) by the depth charge..

if (IsTimerExpired(7)==1)
{if ((character.x-character[DC].x<40 && character.x-character[DC].x>-40 && character.y-character[DC].y<40 && character.y-character[DC].y>-40)){
GiveScore(-20) && PlaySoundEx(12, 4) && ShakeScreen(1);}
PlaySoundEx(12, 4);
}



when the timer 7 has counted down if the character SUB is within 40 pixels in any direction of the character DC  (depth charge) it reduces my score by 20 plays an explosion sound and shakes the screen and if character sub isn't that close to the DC, then it just plays a different sound PlaySoundEx(12, 4); which is a muffled explosion sound..



this is something like yu are working on only i suppose in reverse..ie something shoots a weapon at the player rather than the other way round...it passes as real time because first the destroyer must detect the player character, thru yu being within a certain distance of it's sonar character before it drops the depth charge, then only if the depth charge (which travels more or less straight down the screen from directly underneath the moving destroyer) is within a set distance of the player when the timer counts down does it do damage ..if not then it passes harmlessly by  

argh didnt explain that too well..but i reckon that counts as real time?
its a bit of fun anyway..

am going to have to do something similar to yur idea to allow the players submarine to shoot torpedoes at moving ships etc..im going to really just do the depth charge routine in reverse at least till i can write something better    


heres the entire room code just in case it helps


/////////

// room script file
function room_a() {
 // script for room: Player enters screen (before fadein)
SetTimer(1,200);
SetTimer(2,400);
SetTimer(3,200);
SetTimer(5,200);
SetTimer(6,300);
SetTimer(8,300);
SetBackgroundFrame(1);
}

function room_b() {
 // script for room: Repeatedly execute
if (IsKeyPressed(403) == 1)  
SetBackgroundFrame(0);
if (IsKeyPressed(404) == 1)  
SetBackgroundFrame(2);
if (IsKeyPressed(405) == 1)  
SetBackgroundFrame(3);
if (IsKeyPressed(406) == 1)  
SetBackgroundFrame(1);
if (IsTimerExpired(1)==1)
{PlaySoundEx(1, 3);
SetTimer(1,200);}
if (IsKeyPressed(380) == 1)
 MoveCharacter(SUB,character.x,character.y+53) && MoveCharacter(EGO, character.x-5,character.y-10) && DisplaySpeechBackground (EGO, "Coming to new depth, Sir");
else if (IsKeyPressed(372) == 1)
 MoveCharacter(SUB,character.x,character.y-53) && MoveCharacter(EGO, character.x-5,character.y-10) && DisplaySpeechBackground (EGO, "Coming to new depth, Sir");
else if (IsKeyPressed(377) == 1)
 MoveCharacter(SUB,character.x+53,character.y) && MoveCharacter(EGO, character.x-5,character.y-10) && DisplaySpeechBackground (EGO, "Coming to new heading, Sir");
else if(IsKeyPressed(375) == 1)
 MoveCharacter(SUB,character.x-53,character.y) && MoveCharacter(EGO, character.x-5,character.y-10) && DisplaySpeechBackground (EGO, "Coming to new heading, Sir");
if (IsTimerExpired(2)==1)
{int ran=Random(7);
if (ran==0) PlaySoundEx(2, 4);
else if (ran==1) PlaySoundEx(3, 4);
else if (ran==2) PlaySoundEx(4, 4);
else if (ran==3) PlaySoundEx(5, 4);
else if (ran==4) PlaySoundEx(6, 4);
else if (ran==5) PlaySoundEx(7, 4);
else PlaySoundEx(9, 4);
SetTimer(2,1200);
}
if (IsTimerExpired(3)==1)
{if (character[DD].walking!=1){
MoveCharacter(DD, Random(320),Random(200));
}
SetTimer(3,200);
}    
character[SONAR].x=character[DD].x;
if (IsTimerExpired(5)==1)
{if ((character.x-character[SONAR].x<80 && character.x-character[SONAR].x>-80 && character.y-character[SONAR].y<80 && character.y-character[SONAR].y>-80)){
character[DC].room=character[DD].room;
character[DC].x=character[DD].x + 10;
character[DC].y=character[DD].y + 50;
PlaySoundEx(10, 5) && SetTimer(7,150) && MoveCharacter(DC, character[DD].x-20,character[DD].y+300);
}
SetTimer(5,160);
}  
if (IsTimerExpired(7)==1)
{if ((character.x-character[DC].x<40 && character.x-character[DC].x>-40 && character.y-character[DC].y<40 && character.y-character[DC].y>-40)){
GiveScore(-20) && PlaySoundEx(12, 4) && ShakeScreen(1);}
PlaySoundEx(12, 4);
}


character[GG].x=character[GetPlayerCharacter()].x;

}





function region4_a() {
 // script for region4: While player stands on region
if (IsTimerExpired(6)==1)
{if ((character.y>60 && character.y<90))
{DisplaySpeechBackground (EGO, "Periscope Depth");}
else if ((character.y>90 && character.y<150))
{DisplaySpeechBackground (EGO, "Depth 50 Metres");}
else if ((character.y>150 && character.y<190))
{DisplaySpeechBackground (EGO, "Depth 100 Metres");}
else if ((character.y>190 && character.y<230))
{DisplaySpeechBackground (EGO, "Depth 150 Metres");}
else if ((character.y>230 && character.y<260))
{DisplaySpeechBackground (EGO, "Depth 175 Metres");}
else if ((character.y>260 && character.y<280))
{DisplaySpeechBackground (EGO, "Depth 200 Metres");}
else if ((character.y>280 && character.y<290))
{DisplaySpeechBackground (EGO, "Depth 225 Metres ..Now Below Test Depth");}
else if ((character.y>290 && character.y<295))
{DisplaySpeechBackground (EGO, "Depth 250 Metres Minor Flooding") && GiveScore(-1);}
else {DisplaySpeechBackground (EGO, "Depth 275 Metres Pressure Hull Damaged") && GiveScore(-2);}
SetTimer(6,1000);}
if (IsTimerExpired(8)==1)
{if ((character.x>190 && character.x<210))
{DisplaySpeechBackground (SUB, "Heading 00 Degrees");}
else if ((character.x>210 && character.x<250))
{DisplaySpeechBackground (SUB, "Heading 15 Degrees");}
else if ((character.x>250 && character.x<300))
{DisplaySpeechBackground (SUB, "Heading 30 Degrees");}
else if ((character.x>300 && character.x<350))
{DisplaySpeechBackground (SUB, "Heading 45 Degrees");}
else if ((character.x>350 && character.x<400))
{DisplaySpeechBackground (SUB, "Heading Due East");}
else if ((character.x>170 && character.x<190))
{DisplaySpeechBackground (SUB, "Heading 345 Degrees");}
else if ((character.x>150 && character.x<170))
{DisplaySpeechBackground (SUB, "Heading 330 Degrees");}
else if ((character.x>100 && character.x<150))
{DisplaySpeechBackground (SUB, "Heading 315 Degrees");}
else {DisplaySpeechBackground (SUB, "Heading Due West");}
SetTimer(8,1000);}
 
}

#33
Advanced Technical Forum / Re:Raw draw help?
Tue 18/11/2003 20:47:51
ive been using the timer functions a lot in repeatedly execute to create events thats i want up-dated or repeated only every few seconds or so

and settings a timer in enters room
SetTimer(6,200);

then
in the repeat ex

if (IsTimerExpired(6)==1)
{if ((character.y>70 && character.y<90))
{DisplaySpeechBackground (EGO, "Periscope Depth");}
else if ((character.y>90 && character.y<110))
{DisplaySpeechBackground (EGO, "Depth 50 Metres");}
else if ((character.y>110 && character.y<130))
{DisplaySpeechBackground (EGO, "Depth 100 Metres");}
else if ((character.y>130 && character.y<150))
{DisplaySpeechBackground (EGO, "Depth 150 Metres");}
else if ((character.y>150 && character.y<180))
{DisplaySpeechBackground (EGO, "Depth 175 Metres");}
else if ((character.y>180 && character.y<200))
{DisplaySpeechBackground (EGO, "Depth 200 Metres");}
else if ((character.y>200 && character.y<220))
{DisplaySpeechBackground (EGO, "Depth 225 Metres");}
else {DisplaySpeechBackground (EGO, "were too deep!");}
SetTimer(6,1000);}


this one tells me my current position on the screen evry ten seconds;

(im a submarine so it tells me my depth)
im hoping this saves a lot of processing going on as well?
(as it only runs the code if the timer expires or does it read the code still but only execute it if the timers expired)
anyhuw i still havent grasped the basics of setting my own variables etc so this is how im getting things done..
#34
yu can alter the score text in the gui bar to read as money instead of score to add interest

GUI

status bar

Money @SCORE@ of @TOTALSCORE@ .


or

members of the voting public@SCORE@ of @TOTALSCORE@ .

whatever yu need

hmm a game to simulate a general election? as in that new republic idea? dont see why not..get enough votes win the game  
#35
many thanks from me allso  ive been doing it with all this messy stuff!

if (IsTimerExpired(1)==1)
{int ran=Random(7);
if (ran==0) MoveCharacter(GDTWO,character[GDTWO].x-36,character[GDTWO].y);
else if (ran==1) MoveCharacter(GDTWO,character[GDTWO].x+34,character[GDTWO].y);
else if (ran==2) MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y-36);
else if (ran==3) MoveCharacter(GD,character[GD].x+34,character[GD].y);
else if (ran==4) MoveCharacter(GD,character[GD].x,character[GD].y-36);
else if (ran==5)MoveCharacter(GD,character[GD].x,character[GD].y+36);
else MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y+36);
SetTimer(1,200);
}  

then put this in enters room after fade in

SetTimer(1,200);

you saved me a lot of messing around !  

great source this forum many thanks all!
#36
thanks for the confirmation SB
#37
righto, many thanks guys  
#38
i dunno,  i read them thru and they didn't sound likely candidates etc ..seemed to refer to the whole screen rather than the specific line or image...i should really have tried them but i must admit i wasn;t at all sure..i don't think theyre the ones ..unless i need to save the screen before using the rawdraw script then restore it again in order to remove it..sounds bit heavy going for continued and frequent use..
#39
be a "man of steel" join to-day ..picture of superman etc..
#40
after using this

RawDrawLine(0,0,160,100); or RawDrawImage(100,100,134);  

how do i then remove the line/image from the screen..?

allso on the same area can i have the game draw the line from one character to another?

thought this might be a handy way to depict some form of attack element..a bullet perhaps or an arrow..rather than using a sprite and animation..  
SMF spam blocked by CleanTalk