Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 RPG Experimentation... some things I need help with
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mr. Gruntsworthy




PostPosted: Sun Feb 25, 2007 1:14 pm   Post subject: RPG Experimentation... some things I need help with

Right now im working on an RPG in Turing. There is already a plethora of them, I know, but it's an interesting game to try and do for your first gametype.

The main two things im having trouble with are the following:

1) each character has four attacks. each attack is a string variable, with the variables your_attack_1, your_attack_2, your_attack_3, and your_attack_4. i have my attacks set up as procedures, for instance I have the punch_attack procedure, which sets up the stats for the attack and provides the name of the current attack.

In it, the main player starts off with one of two attacks (punch, or telekinesis, both of which are functional). The your_attack_1 inherits the attack's name.

In my combat engine, the user selects one of his four attacks, and here is where my problem starts: I would like to know how to get your_attack_1 to not only inherit the attacks name, but have it so that when the user selects this choice (your_attack_1) it runs the punch_attack procedure. Doing that is easy enough with a direct run, but your_attack_1 should be modifiable to any attack in the library and inherit that attack's procedure somehow.

For instance, say that your_attack_1 is now the attack "Eye Poke." Before, your_attack_1 was "Punch". how would i keep it inheriting the different attack procedures as the attack changed?

2) saving. i read the I/O tutorial, and i only understand a little of it. What I want to know is, what do i have to do to modify a variable already in the file?
for instance: i have a boolean variable named GameSave that is true if the game has a save and false if it hasn't. I have false set as default in the file, but I want it to become true if the game is saved. the file is gamesave.txt.
Also, the going from line to line in the txt file i need expanded upon too. all the information i need about this is contained in the I/O tutorial (except the mod command, to modify pre-existing data, which i will need to modify data after a character saves again), i just need it expanded upon so i can understand it.

for instance: i want to save the character's name, level, experience points, the max amount of experience points he needs to get to the next level, his HP, his total HP, his attack, his defense, his special attack, his special defense, and the player's money.

how would i go about putting that into a file, retrieving it at the next game startup, and modifying it at the next save?


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answers to these questions would be GREATLY appreciated, and i would be indebted to you.
As to aid you, here is the turing source code for the project i am working on. I have it as neat as i can (could be neater, I know) but I hope it is organized enough for you. As well, working with a limited knowledge of Turing's features, please don't tell me to change anything already existing (unless it pertains to helping one of the above two problems). Chances are if i should've done something differently, i didn't know how to do it, so an explanation for that would be needed (or else how will i know how to build off of the change?



RPG experimentation.t
 Description:
will work if you run it, but dead-ends at menu choice in battle

Download
 Filename:  RPG experimentation.t
 Filesize:  9.57 KB
 Downloaded:  127 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: Sun Feb 25, 2007 3:10 pm   Post subject: Re: RPG Experimentation... some things I need help with

Mr. Gruntsworthy @ Sun Feb 25, 2007 1:14 pm wrote:
1) each character has four attacks. each attack is a string variable, with the variables your_attack_1, your_attack_2, your_attack_3, and your_attack_4. i have my attacks set up as procedures, for instance I have the punch_attack procedure, which sets up the stats for the attack and provides the name of the current attack.
When I first read this, the word array came to mind. Wouldn't it be better to address it as your_attack[i] instead?

Mr. Gruntsworthy @ Sun Feb 25, 2007 1:14 pm wrote:
In my combat engine, the user selects one of his four attacks, and here is where my problem starts: I would like to know how to get your_attack_1 to not only inherit the attacks name, but have it so that when the user selects this choice (your_attack_1) it runs the punch_attack procedure. Doing that is easy enough with a direct run, but your_attack_1 should be modifiable to any attack in the library and inherit that attack's procedure somehow.
...no idea.

Mr. Gruntsworthy @ Sun Feb 25, 2007 1:14 pm wrote:
for instance: i have a boolean variable named GameSave that is true if the game has a save and false if it hasn't. I have false set as default in the file, but I want it to become true if the game is saved. the file is gamesave.txt.
So you have a game save file that tells the game if the player's game is saved? Doesn't make much sense to me, prompt the user to save every time they exit.

One thing really confuses me here.
code:
procedure attack_punch
    attack_name := "Punch"
    damage := 15
    accuracy := 85
    attack_type := 0
end attack_punch

procedure attack_telekinesis
    attack_name := "Telekinesis"
    damage := 12
    accuracy := 90
    attack_type := 1
end attack_telekinesis
I assume you will have a procedure for every attack? Is there not a better way to do this? I'm throwing records out here, but really I haven't use Turing in so long to remember what to do Confused.
kicknock




PostPosted: Sun Feb 25, 2007 3:50 pm   Post subject: Re: RPG Experimentation... some things I need help with

below is the code i used for my own rpg. it saves all characters stats and stuff.

the name of the file in which the stats will be saved to is 'saveData.t'
then it just saves all the numbers into the file
afterwards, it closes the file

code:

open : saveFile, "saveData.t", put
put : saveFile, umaxstr
put : saveFile, umaxdef
put : saveFile, umaxmag
put : saveFile, umaxhp
put : saveFile, umaxmp
put : saveFile, usp
put : saveFile, lvl
close : saveFile


this is the code i use to load my saved stats
some parts are unnecessary but i was just too lazy to delete them

code:

open : loadFile, "saveData.t", get, seek

        loop
            seek : loadFile, location
            get : loadFile, strength, defence, magic, hitpoint, manapoint, speed, level

            umaxstr := strint (strength)
            ustr := umaxstr
            umaxdef := strint (defence)
            udef := umaxdef
            umaxmag := strint (magic)
            umag := umaxmag
            umaxhp := strint (hitpoint)
            uhp := umaxhp
            umaxmp := strint (manapoint)
            ump := umaxmp
            usp := strint (speed)
            lvl := strint (level)

            exit when (eof (loadFile))
        end loop

        close : loadFile


i have my rpg game submitted in the turing submissions. y dont u take a look at it. it would answer some of u questions,
though the code is a bit messy!
the attachment in the later post contains the version that u can save in, so be sure to download that one and not the one in the first post.
i hope this helps u
Mr. Gruntsworthy




PostPosted: Sun Feb 25, 2007 11:46 pm   Post subject: Re: RPG Experimentation... some things I need help with

what the GameSave boolean variable is for is when the game loads up, it can tell if there's a previous game save or if it's the game's first boot.

but thank you for that code (the other guy) i will try to implement it.


also, why do you have loops for the load?
kicknock




PostPosted: Mon Feb 26, 2007 8:32 pm   Post subject: Re: RPG Experimentation... some things I need help with

Mr. Gruntsworthy @ Sun Feb 25, 2007 11:46 pm wrote:


also, why do you have loops for the load?


without a loop, it will only read and load the first line of the file
Clayton




PostPosted: Mon Feb 26, 2007 8:45 pm   Post subject: Re: RPG Experimentation... some things I need help with

This is where the sort of thing like flexible arrays are very useful. This would allow you to load n number of characters' stats and such without having to know exactly how many characters you are saving and loading for.
Mr. Gruntsworthy




PostPosted: Tue Feb 27, 2007 3:59 pm   Post subject: Re: RPG Experimentation... some things I need help with

oh, i did mine differently, but it works...

i also solved my other problems

the only thing now is to weave together the combat engine
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: