Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > The real world > Idle chatter

Reply
 
Thread Tools Display Modes
Old February 18, 2009, 18:30   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Roguelike development practice

I've attempted (and mostly failed ;-) to gain experience with C++ and the *band builds in various ways and here I go again.

This time I'm going to keep it simple (if I can) - just produce code to add one feature to the latest Angband code.

Code:
^T  Talk    Attempt to strike up conversation with an adjacent monster.
            (Monster will reply with single line based on its type)
If I get it to work I'll take suggestions of appropriate lines for monsters in the game.
PaulBlay is offline   Reply With Quote
Old February 18, 2009, 21:09   #2
pav
Administrator
 
pav's Avatar
 
Join Date: Apr 2007
Location: Prague, Czech republic
Age: 39
Posts: 782
pav is on a distinguished road
Send a message via ICQ to pav
Ogres need to have a line 'Heee did it.'
__________________
See the elves and everything! http://angband.oook.cz
pav is offline   Reply With Quote
Old February 19, 2009, 01:59   #3
bio_hazard
Knight
 
bio_hazard's Avatar
 
Join Date: Dec 2008
Posts: 618
bio_hazard is on a distinguished road
Quote:
Originally Posted by pav View Post
Ogres need to have a line 'Heee did it.'
"That's Brimstone."
bio_hazard is offline   Reply With Quote
Old February 19, 2009, 15:14   #4
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Well, I got close this time, but it looks like no cigar for me.

I thought I'd added everything I needed for an extra parameter in the monster text, but now it is no longer recognizing the D: line! (Which I don't think I've touched)

Error at line 121 of 'monster.txt'.
Record 1 contains a 'undefined directive' error.
Parsing 'D:He looks squalid and thoroughly revolting.'.


Code:
	/* Process 'D' for "Description" */
	if (buf[0] == 'D')
	{
		/* Store the text */
		if (!add_text(&(r_ptr->text), head, buf+2))
			return (PARSE_ERROR_OUT_OF_MEMORY);
	}

	/* Process 'T' for "Talk" */ 
	if (buf[0] == 'T')
	{
		/* Store the line of speech */
		if (!add_text(&(r_ptr->talk), head, buf+2)) 
			return (PARSE_ERROR_OUT_OF_MEMORY);
	}
Oh well, better luck next scheme.
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 15:18   #5
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
Well, I got close this time, but it looks like no cigar for me.

I thought I'd added everything I needed for an extra parameter in the monster text, but now it is no longer recognizing the D: line! (Which I don't think I've touched)

Error at line 121 of 'monster.txt'.
Record 1 contains a 'undefined directive' error.
Parsing 'D:He looks squalid and thoroughly revolting.'.


Code:
	/* Process 'D' for "Description" */
	if (buf[0] == 'D')
	{
		/* Store the text */
		if (!add_text(&(r_ptr->text), head, buf+2))
			return (PARSE_ERROR_OUT_OF_MEMORY);
	}

	/* Process 'T' for "Talk" */ 
	if (buf[0] == 'T')
	{
		/* Store the line of speech */
		if (!add_text(&(r_ptr->talk), head, buf+2)) 
			return (PARSE_ERROR_OUT_OF_MEMORY);
	}
Oh well, better luck next scheme.
That second 'if' should be 'else if'. Follow through the code and you'll see why.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old February 19, 2009, 15:49   #6
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by takkaria View Post
That second 'if' should be 'else if'. Follow through the code and you'll see why.
That improved things - although it looks like I broke it elsewhere.

Obviously I need more practice.
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 15:54   #7
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,424
Donated: $40
Pete Mack is on a distinguished road
@paul --
Do you have a working debugger? I assume from what you are saying, that you are using MSDEV. Even the free version has a line-by-line stepping debugger/IDE. You can put "breakpoints" in and stop the program at any point, then step from there. It can be very useful. (It can also be a huge time-waster.)
Pete Mack is offline   Reply With Quote
Old February 19, 2009, 16:13   #8
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
@paul --
Do you have a working debugger?
Presumably.

I haven't actually tried it yet though. Basically it's been decades since I sort-of-knew what I was doing with this stuff and I'm very slowly getting back up to speed.

Quote:
I assume from what you are saying, that you are using MSDEV. Even the free version has a line-by-line stepping debugger/IDE. You can put "breakpoints" in and stop the program at any point, then step from there. It can be very useful. (It can also be a huge time-waster.)
I'm familiar with breakpoints and stepping from Visual Basic. I'm not sure whether I've ever tried it with a C++ debugger.

What I did so far required changes to:
cmd0.c
cmds.h
cmd3.c
monster.txt
init1.c
init2.c
init.h
and
monster/types.h

Everything seems to be spread out to heck and gone.
PaulBlay is offline   Reply With Quote
Old February 19, 2009, 17:46   #9
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,424
Donated: $40
Pete Mack is on a distinguished road
Debugging with a C compiler isn't any harder. The tough part is setting up the compile environment from scratch :/

And your changes aren't really spread out "to heck and gone." I could have told you what files would need modifying.

For the record:

Adding a new command:
cmds.h to add the new command declaration
* [ED: this is broken, since some of them are also in externs.h]
cmd0.c, to add a new command to the command m enus & list.
* [pre-3.0.8: was dungeon.c, and was that ever a lousy place!]

cmd[1-3].c to add the new command implementation, depending on what type it is. (This depends on which menu in cmd0.c)
(cmd4.c is for meta-commands like options and knowledge)


To change the behavior of individual monsters: (NOT by monster "genus", like 'T', 'o', 'D', etc.)

monster.txt: to add the new flag/descriptor to the individual monster data field.
monster/types.h to add the new field in the basic monster type.
init1.c to add to the tokens (string constants) tables for initialization.
Also, the spoken strings may go here too.
init2.c to add to the monster.txt parser.
init.h to add the appropriate #defines for token_ids.
Pete Mack is offline   Reply With Quote
Old February 19, 2009, 18:00   #10
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
And your changes aren't really spread out "to heck and gone." I could have told you what files would need modifying.
In other words somebody who already knows where to go can find stuff. For somebody coming to the whole thing from scratch working out which bit does what is rather more of an uphill struggle.

Last edited by PaulBlay; February 19, 2009 at 20:05.
PaulBlay is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My variant development journal CJNyfalt Variants 107 June 6, 2009 08:25
Noob's development journal PaulBlay ToME 8 February 12, 2009 19:16
[FA] FAangband development Nick Variants 174 May 30, 2008 03:02
more fun with the development branch of 3.1.0 pesachyonah Vanilla 6 May 17, 2008 18:13
Roguelike development diary andrewdoull Variants 0 May 14, 2007 12:35


All times are GMT +1. The time now is 23:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.