Problem initializing a character...
Displaying 1-20 of 33 total.
12 next
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Arkhan

I made a struct for characters, and then created a function to generate the main character.....

It doesnt seem to be working properly though....

heres the code. Did I do something wrong?

CHARACTER.VC
struct Character //character data
{
int level;
int MaxHP;
int CurHP;
int exp;
int tnl; //Til next Level
int atk;
int def;
int gold;

//STATE CHECKS
int ArmorWorn;
int WeaponReady;
int ShieldHeld;
int AccessoryWorn;
int isPoisoned;
}


GENERATE FUNCTION (Called/Defined in Autoexec)
void GenerateArkhan() //called to assign Arkhan's initial Statistics
{
Arkhan.level = 1;
Arkhan.MaxHP = 20;
Arkhan.CurHP = 20;
Arkhan.atk = 10;
Arkhan.def = 10;
Arkhan.gold = 0;
Arkhan.exp = 0;
Arkhan.tnl = 300;

Arkhan.ArmorWorn = 0;
Arkhan.WeaponReady = 0;
Arkhan.ShieldHeld = 0;
Arkhan.AccessoryWorn = 0;
Arkhan.isPoisoned = 0;
}


I stumbled on the problem when I started writing the menu system. I did something to the tune of

string level = str(Arkhan.level);

and then PrintRight()'d it, and it writes a 0 to screen. .... :(

Any help is appreciated. Thanks!

Posted on 2007-02-22 21:41:00

mcgrue

You need a:


Character Arkhan;


somewhere after you define the struct and before you use it. Like:


struct Character //character data
{
int level;
int MaxHP;
int CurHP;
int exp;
int tnl; //Til next Level
int atk;
int def;
int gold;

//STATE CHECKS
int ArmorWorn;
int WeaponReady;
int ShieldHeld;
int AccessoryWorn;
int isPoisoned;
}

Character Arkhan; //right here would do nicely.

Posted on 2007-02-22 21:54:22

Arkhan

I do have that.

I have

#include "Character.vc"
#more includes

Character Arkhan;

autoexec()

I forgot to mention, it compiles fine, but it prints 0's for everything....so for some reason GenerateArkhan() isnt doing anything....

Posted on 2007-02-22 21:55:42 (last edited on 2007-02-22 21:58:46)

Overkill

Are you calling the function GenerateArkhan in your autoexec, and is it before you try to print out the data about the character?

EDIT: Also, I think if you declare variables and initialize them on the same line, it might actually evaluate the initializer earlier than you want. Like, it might initialize EXACTLY when the function is called. I think that's what it does. Try just putting str(Arkhan.level) in PrintRight(), it works as expected, likely.

Posted on 2007-02-22 22:28:53 (last edited on 2007-02-22 22:59:54)

Arkhan

Yessir.

I have

GenerateArkhan();
HookKey(SCAN_M, "Menu");

in that order.

EDIT: I put str(Arkhan.level) into right, and it says it cant resolve identifier str

EDIT^2: I fixed the PrintRight() part ...sort of copied over the font parameter on accident......but this still doesnt work. I get Level = 0 in my menu :(

EDIT_TO_THE_MAX: Fixed. Note to self, Map() should be the last thing called in a list of things.....

Posted on 2007-02-22 23:00:26 (last edited on 2007-02-22 23:51:45)

Overkill

Yeah, Map() halts all script execution, so watch out.

Posted on 2007-02-23 01:12:49

Arkhan

Yeah. I knew that but forgot for some reason, and then I stared at it for like 30 minutes and finally realized it. ;)

Rather than make a new thread, ill just ask here....

How would I TBlit something on screen and have it STAY there at all times. Im trying to get a HUD to stay blitted onto the screen no matter which map you go to...

Posted on 2007-02-23 10:53:08

Beni

HookRetrace

EDIT: Remember to strip the PHPSESSID out of your links, kids. For a second, I was logged in as Beni :D -- Overkill.

Posted on 2007-02-23 12:55:54 (last edited on 2007-02-23 13:18:32)

Arkhan

I used HookRetrace("Overlay");

and now my overlay does indeed show up at all times.

Two problems though....

1) Its an overlay...so no entities should be walking around on it. is there a way to accomplish that? If I go into a town, NPCs wander around on top of it :(

2).....it crashes after a bit with
 HandleForImage() -- Out of Image Handles increase MAX_ima...or sto.....leaking  nevermind im a retard 


So how do I make it so the game only renders in say 3/4 of the screen?

Posted on 2007-02-23 17:07:48

Overkill

Move the "Special: Retrace" layer to the topmost layer in Maped (that is, closest to foreground). Also, for your menus, just load the required images as global variables, and don't free them until the end of the program (Really, just let Verge free them for you automatically, when you close the program). That way it won't leak on every call to the hookretrace function. If you're using commonly shared resources like fonts, and background images, it only makes sense to put them as globals.

Posted on 2007-02-23 17:45:20

Arkhan

Im a tard i just make and free them in the functions lol. I havent implemented exiting the game yet, so Ill get to that when the time arises! :)

This is working good so far. Maybe ill actually finish this game...ive only been wanting to since the 8th grade haha

edit: When I move the retrace layer up to the top, it doesnt show up anymore. I assume its under my map...

Also if its relevant I call hookretrace() in autoexec()...

Posted on 2007-02-23 17:48:03 (last edited on 2007-02-23 17:51:15)

Overkill

I meant, top when you look at the drawn screen (as in the retrace layer is in the frontmost position, the foreground), not top when you look at the layer orderings in Maped, where it'd have to be the bottom layer on the list, only obstructions and zones should be after it. Look at the part where it says something like "1,2,3,E,4,R" in the layer dialogue, keep moving the layers until R is the rightmost of that comma-seperated list.

Posted on 2007-02-23 18:28:23

Arkhan

Ah ok, got it. There is a still a problem though...I can walk under the overlay, and then basically not see where Im going..... :(

Any solution for that? or do I need to make my maps 4 tiles longer to accomodate the overlay maybe?..

Posted on 2007-02-23 18:35:11

Beni

Edit: I was writing the answer at the same time as Overkill. But he posted before me.

Posted on 2007-02-23 18:36:43 (last edited on 2007-02-23 18:39:31)

Beni

I have a solution, but I'm hesitant to give it to you. Because what you're asking here is not a problem of programming, but a problem of creativity. So first think of what would need to happen to fix this problem. And if you can't figure out how to implement it, then ask that. But yeah, making your map 4 tiles longer would be one possible solution.

Posted on 2007-02-23 18:51:05

Arkhan

Ah ok, got it. There is a still a problem though...I can walk under the overlay, and then basically not see where Im going..... :(

Any solution for that? or do I need to make my maps 4 tiles longer to accomodate the overlay maybe?..

Posted on 2007-02-23 18:55:16

Overkill

Well, in your HookRetrace, you could override the default camera functionality through setting cameratracking = 0 and then manipulating xwin and ywin based on the player's entity position.

Posted on 2007-02-23 19:17:52

Arkhan

How do I access all of that?..

Posted on 2007-02-23 21:26:47

Overkill

Try looking at the entity variables and camera variables in the documentation.

Posted on 2007-02-23 21:30:42

Arkhan

Quote:Originally posted by Beni

I have a solution, but I'm hesitant to give it to you. Because what you're asking here is not a problem of programming, but a problem of creativity. So first think of what would need to happen to fix this problem. And if you can't figure out how to implement it, then ask that. But yeah, making your map 4 tiles longer would be one possible solution.


I have no idea what you're talking about if it has nothing to do with programming.

Oh, and overkill, erm, maybe I should have asked WHERE do I find those variables exactly.....and how do I over ride stuff in my Hookretrace()? The only thing you can pass to it is a function name...

thanks!

Posted on 2007-02-24 01:10:55 (last edited on 2007-02-24 01:14:28)


Displaying 1-20 of 33 total.
12 next
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.