Page 1 of 1

Help with some code...

PostPosted: Mon Jul 28, 2008 11:04 pm
by Eliminator
There is a code (Dialogue - a face of speaker, a text and a background in the bottom of screen).
GLOBAL CODE:
Code: Select all
void talk(int npcid)
{
    Dialogue.x=Guy.x; //Place the dialogue box near the guy
    Dialogue.y=Guy.y;
    if(npcid==1 && pultquest==0)//Beavis and Butthead
    {
        ChangeAnimation("DialFace", "Beavis", FORWARD); //Beavis says "Slysh baklan!" (translit)
        strcpy(DialText.text,"Slysh baklan!");
        Dialog(); //pause
        strcpy(DialText.text, "My poteriali 3 pylta ot teleka!");
        Dialog();
        ChangeAnimation("DialFace", "Butthead", FORWARD); //Butthead face
        strcpy(DialText.text,"Eto polnyi otstoi :(");
        Dialog();
        ChangeAnimation("DialFace", "Beavis", FORWARD);
        strcpy(DialText.text,"Naidi ix i prinesi nam za $100");
        Dialog();
        Dialogue.x=2000; //Kick the dialogue box out of here
        Dialogue.y=2000;
        pultquest=1; //activate the quest
    }
}


Dialog(); pauses the game and shows the Unpause button.

And NPC, Beavis and Butthead - code: talk(1);

"Dialogue" is the filled region and is a parent of all elements - Face, background and text

But works only "ChangeAnimation" and Dialog()... GE ignores the strcpy and Dialogue.x=Guy.x; Dialogue.y=Guy.y;. Why?

Re: Help with some code...

PostPosted: Mon Jul 28, 2008 11:56 pm
by feral
Eliminator wrote:But works only "ChangeAnimation" and Dialog()... GE ignores the strcpy and Dialogue.x=Guy.x; Dialogue.y=Guy.y;. Why?


this is a common first time mistake so don't worry too much :)

OK... not sure exactly why some of the code doesn't work.. but I can tell you the ChangeAnimation doesn't really work either..

if you tried to change back to Beavis ie: a third change, you would have notice that the only animation you had was of beavis.

the dialogue and dialogue box are also moved into screen, then out of screen, before the next redraw

this is because the function is run "in-between" draws, so only the last animation and last move would be drawn.

basically most of the action happening in the function, really needs to happen over several screen "draws"

to "move" the dialogue box your function could set global variables, rather then attempt to move the items directly,
eg : set two new global variables DialX,DialY and a flag DialShows
then in the function

dialX=Guy.x
dialY=Guy.y
DialShows=1

then use the draw script of the dialogue to position it
if (DialShows==1)
{
x=DialX
y=DialY
}
else
{
y=x=2000;
}

I'll let you work on the rest :) your coding skills seem to be up to the task :)

Re: Help with some code...

PostPosted: Tue Jul 29, 2008 9:42 am
by Eliminator
OMG cool thanks. Here is a windows executable of my program. Inventory system, experience, dialogue ( :D ).