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

Topics - CB..

#1
a neighbour has asked me to make a random "poetry" generator..
so i have a text box that he can type different sentences into..
and he can then store those sentences in a listbox...

he wants to then be able to press a button and have a random sentence displayed by the "game"

i have got it to work but the code is getting a bit clunky as the number of entrys in the listbox increases
is there a short hand way to do this?

///////////////////////////////////this is what i have so far  ///////////get global in 3 is the button////

int notes;
notes = ListBoxGetNumItems(0,6);

if ((GetGlobalInt(3)==01) && (notes == 4)){
int ran=Random(3);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else ListBoxSetSelected(0,6,3);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 5)){
int ran=Random(4);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else ListBoxSetSelected(0,6,4);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 6)){
int ran=Random(5);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else ListBoxSetSelected(0,6,5);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 7)){
int ran=Random(6);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else ListBoxSetSelected(0,6,6);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 8)){
int ran=Random(7);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else ListBoxSetSelected(0,6,7);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 9)){
int ran=Random(8);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else if (ran==7) ListBoxSetSelected(0,6,7);
else ListBoxSetSelected(0,6,8);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 10)){
int ran=Random(9);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else if (ran==7) ListBoxSetSelected(0,6,7);
else if (ran==8) ListBoxSetSelected(0,6,8);
else ListBoxSetSelected(0,6,9);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 11)){
int ran=Random(10);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else if (ran==7) ListBoxSetSelected(0,6,7);
else if (ran==8) ListBoxSetSelected(0,6,8);
else if (ran==9) ListBoxSetSelected(0,6,9);
else ListBoxSetSelected(0,6,10);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 12)){
int ran=Random(11);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else if (ran==7) ListBoxSetSelected(0,6,7);
else if (ran==8) ListBoxSetSelected(0,6,8);
else if (ran==9) ListBoxSetSelected(0,6,9);
else if (ran==10) ListBoxSetSelected(0,6,10);
else ListBoxSetSelected(0,6,11);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 13)){
int ran=Random(12);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else if (ran==7) ListBoxSetSelected(0,6,7);
else if (ran==8) ListBoxSetSelected(0,6,8);
else if (ran==9) ListBoxSetSelected(0,6,9);
else if (ran==10) ListBoxSetSelected(0,6,10);
else if (ran==11) ListBoxSetSelected(0,6,11);
else ListBoxSetSelected(0,6,12);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}
else if ((GetGlobalInt(3)==01) && (notes == 14)){
int ran=Random(13);
if (ran==0) ListBoxSetSelected(0,6,0);
else if (ran==1) ListBoxSetSelected(0,6,1);
else if (ran==2) ListBoxSetSelected(0,6,2);
else if (ran==3) ListBoxSetSelected(0,6,3);
else if (ran==4) ListBoxSetSelected(0,6,4);
else if (ran==5) ListBoxSetSelected(0,6,5);
else if (ran==6) ListBoxSetSelected(0,6,6);
else if (ran==7) ListBoxSetSelected(0,6,7);
else if (ran==8) ListBoxSetSelected(0,6,8);
else if (ran==9) ListBoxSetSelected(0,6,9);
else if (ran==10) ListBoxSetSelected(0,6,10);
else if (ran==11) ListBoxSetSelected(0,6,11);
else if (ran==12) ListBoxSetSelected(0,6,12);
else ListBoxSetSelected(0,6,13);
string buffer;
ListBoxGetItemText (0,6,ListBoxGetSelected(0,6),buffer);Display ("%s",buffer);SetGlobalInt(3,00);}


///////it's going to get redicoulous as i get up towards 30 or so listbox entrys
#2
i know the soloution is to avoid dividing by 0 but im using ints and constantly changing global variables to try to create a damage sytem for my ye old "subsim"

heres the basic code

int damage1, damage2, result;
damage1 = 1000;
damage2 = dcdepth;
result = 1000/dcdepth;
Display("%d", result);



///dcdepth is GetGlobalInt (7) which is altered by the submarine changing depth/////

this is with the stable 2.61 release
any thoughts? shud i be trying to set it up to stop global int 7 from reaching 0 or is it a bug
#3
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)
#4
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..  
#5
i seem to be struggling a little with this one..
the graphic overlay appears as prescibed..but im getting confused with the correct way to remove it

the manual list the text overlay removal script which names the overlay in order to remove it..but the graphical overaly hasn't got a similar name and im a bit lost as to the way to remove it..

im using the overlay as the roof of a house,
as i walk into the house (it's a top down view)
i need to remove the overlay revealing the interior of the house (which is drawn on the background but hidden by the overlay)
i could use the move overlay script but might be neater to remove it entirely.

#6
i have a move character script which i want to repeat every five seconds ,
but if i place it in the repeatedly execute section it trys to execute the script every nano second ,not gving the character time to exexcute the movement before it restarts the timer...if i use wait so it completes the movement before it restarts ,then the player gets stuck in wait mode (because the script is in repeatedly execute etc)
im stuck in a bit of a catch twenty two loop here im afraid!

this would be wonderfull for populating towns with randomly moving characters that actually have a life of their own...

this is the script

SetTimer(1,200);
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);
}

i can set it with a lot of regions and have it run as a walk on walk of region run script appraoch but this just isnt satisfying enough and very untidy..with a repeat/loop command it would simply take care of itself

(for example im using it in the escape from colditz game for two gaurds searching for the player as he trys to escape across some fields..)

if there is an easy way to ad a simple loop command to the scripting of movements etc then with all the possible
if
else if's available in the editor some sort of developing AI behaviuor could develop...for instance if a player has an inventory item this can be added into the else ifs and change the behaviuor of the characters  and so on...please tell me its just a matter of adding asome sort of loop command at the end of it!!  
#7
is it possible to tell a character to go to a specific walkable area
im using quite a lot of switchable walkable areas and bringing in chracters to be randomly placed like this

character[GDTHREE].x=Random(320);
character[GDTHREE].y=Random(200);
MoveToWalkableArea(GDTHREE);

before fade in as i enter the rooms

it would be extremely handy if i could somtimes specify which walkable area the character
randomly appeared on..ie number 4 or 2 etc...

ive been getting round this by disable-ing certain areas then re-enabling them after the character has appeared..but it's messy stuff to write

allso is there by any chance a way to disable/enable ALL walkable areas (or regions ,hot spots etc) in one script

im using this approach at the moment

int ran=Random(5);
if (ran==0) GiveScore(-150) && SetObjectFrame(0,7,0,0);
else if (ran==1) RestoreWalkableArea(11) && RemoveWalkableArea(12) && RemoveWalkableArea(13) && RemoveWalkableArea(14) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,1);
else if (ran==2) RestoreWalkableArea(12) && RemoveWalkableArea(11) && RemoveWalkableArea(13) && RemoveWalkableArea(14) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,2);
else if (ran==3) RestoreWalkableArea(13) && RemoveWalkableArea(12) && RemoveWalkableArea(11) && RemoveWalkableArea(14) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,3);
else if (ran==4) RestoreWalkableArea(14) && RemoveWalkableArea(12) && RemoveWalkableArea(13) && RemoveWalkableArea(11) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,4);
else RestoreWalkableArea(15)&& RemoveWalkableArea(12) && RemoveWalkableArea(13) && RemoveWalkableArea(14) && RemoveWalkableArea(11) && SetObjectFrame(0,7,0,5);  


and it ain't pretty at all (excuse the word wrap)

would be so nice to be able to just script


RemoveWalkableArea(s)

and remove them all at one go..same with enable again etc.


or

RemoveWalkableArea(s)(2)(3)(4);  

to remove sets of areas etc

rather than naming them all one at a time?


#8
the reference manual gives the code for scripting a random script as

int ran=Random(2);
if (ran==0) NewRoom(1);
else if (ran==1) NewRoom(2);
else NewRoom(3);



but implys that more than three "ifs /else/else ifs" can be added

but im not sure how to add the extra randomisations
how would i script more than these three in the same script?

i want to script a random response on the basis of a dice throw , so i need six options in the same randomisation

and more if i can have them (for perhaps a full deck of cards)
#9
AGS Games in Production / mini colditz demo
Mon 20/10/2003 19:40:07
[glow=color,glow width, #characters wide]a little escape from colditz demo game...with some randomisation involved...
the trick is to raise yur escape points either to 500 or use the items and interactions to open up escape routes and new rooms...(now four in the demo)
[/glow]




[glow=color,glow width, #characters wide]UP-DATED[/glow]

COLDITZ DEMO
#10
using givescore(-x) and a "go to room x" command if the score gets below a set amount...(with room x being a dead end with the message you have been killed (can use the reset game option to start game again or the gui to load a save)
am thinking about a bog simple battle system based on interactions between characters
(playing perhaps a combat animation instead of the talking view) where the conversation choices might somthing like  

player character topic choices

"strike with sword"
play talking view 1
random score reduction on NPC between x and x

"defend"
play talking view 2
random score increase for player character between x and x

"escape"
return to normal view end converstation
reduce player score by x


and the same options randomly chosen for the NPC

if it's not possible for the NPC to carry a score then perhaps

if in region x
if player score is above x
give player inventory item x
play animation /
remove NPC x from room/

i have only a limited ability to use the scripting st the moment.


#11
my apologies for this question straight away as it is most definitely somthing very simple ..what occurs is every thing runs ok untill text appears on screen in the from of a pop up area such as the F1 help text in the demo...then apart from the sound effects and music, AGS freezes  doesn't respond to the mouse movement/keyboard commands and can only be exited via a complete shut down of the PC (turning it off completely) ;

i have a windows ME 800Mhz PIII computer with 64 mb ram ,

in windowed mode everything runs perfectly with no difficulty at all...



SMF spam blocked by CleanTalk