intfiction.org

The Interactive Fiction Community Forum
It is currently Fri Sep 22, 2017 7:06 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Sep 11, 2017 9:46 pm 
Offline

Joined: Mon Sep 11, 2017 9:28 pm
Posts: 1
I've done a few unpublished (outside of friends at least) IF games before and I decided to ramp things up a bit. I want to include combat in this next one but I'm running into a weird issue with the I7 compiler.

The combat system itself is heavily influenced by the D&D rulesets.

Below is the error followed by the block of code in general. Even after pasting the entire code into Notepad++ I still cannot figure out where Inform is getting the error from. The only thing I can think of at this point is I'm getting programmer's blindness, so I'm turning to the internet for help!

The Error:
Code:
Problem. The phrase or rule definition 'To make (attacker - a person) strike a blow against (defender - a person)'   is written using the 'colon and indentation' syntax for its 'if's, 'repeat's and 'while's, where blocks of phrases grouped together are indented one tab step inward from the 'if ...:' or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can't determine the structure. The first phrase going awry in the definition seems to be 'if the instrument is a weapon'  , in case that helps. 


The code:
Code:
To make (attacker - a person) strike (defender - a person):
	if the attacker is the player, say "You attack ";
	otherwise, say "[The attacker] attacks ";
	if the defender is the player, say "you, ";
	otherwise, say "[the defender], ";
	let the damage done be the hit dice of the attacker;
	let the armament be nothing;
	if the attacker wears a weapon:
		let the damage done be the hit dice of the armament;
		say "with [the weapon worn by the player]";
	otherwise:
		say atkType of the attacker;
	change the AC to die roll 1d20;
	say ", making an attack roll (1d20) of [AC] ";
	let DC be the defense of the defender;
	if AC = 1;
		if the armament is a weapon; [attacker wields weapon on crit failure]
			if the attacker is the player;
				say "You completely botch your attack! You deal [run paragraph on]";
				let hits be damage done;
				let hits be the hits divided by 2;
				say "[hits] [paragraph run on]";
				if the hits is 1, say "point of damage to yourself!";
				otherwise say "points of damage to yourself!";
			otherwise:
				say "[the attacker] botches their attack! They deal [run paragraph on]";
				let hits be damage done;
				let hits be the hits divided by 2;
				say "[hits] [paragraph run on]";
				if the hits is 1, say "point of damage to themself!";
				otherwise say "points of damage to themself!";
		otherwise: [attacker is unarmed on crit failure]
			let hits be 1;
			if the attacker is the player;
				say "You deal 1 damage to yourself!";
			otherwise:
				say "[the attacker] deals 1 damage to themself!";
                stop;
	if AC <= DC; [2 to whatever DC is]
		say " - Miss!";
	        stop;
	if AC > DC;
		say "- hit, doing [damage done] damage: ";
		let hits be the roll of damage done;
	        stop;
	if AC = 20;
		say "- a critical hit! You deal [paragraph run on]";
		let hits be damage done;
		let hits be the hits multiplied by 2;
		say "[hits] of damage!";
	make the defender take hits points of damage.


Top
 Profile Send private message  
 
PostPosted: Mon Sep 11, 2017 10:44 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5001
Location: Burlington, VT
You have

Code:
if AC = 1;


which should end with a colon rather than a semicolon. Ditto for the two "if" lines immediately after that.

By the way, which version of Inform 7 are you using? The latest one has a bug that causes an internal error for mistakes like that, so it might be helpful to know if you're using an earlier version. And welcome to the forum!


Top
 Profile Send private message  
 
PostPosted: Tue Sep 12, 2017 4:00 am 
Offline
User avatar

Joined: Sun Nov 22, 2009 12:58 pm
Posts: 703
Location: Malmö, Sweden
The if statements require a colon between head and body. More to the point, the error message is actually appropriate: you're using the colon and indentation syntax

Code:
if x:
        stop;


side by side with if statements that use a comma delimiter. And even if you change the semicolons to the proper colons, one-liner if statements can't be used inside colon-and-indent if statements.

Since the code relies on definitions not present in the block you posted, it's tricky to give any more assistance than that. For future reference, it may be helpful to post complete examples of your problem, i.e. snippets that compile.

_________________
~Björn Paulsen


Top
 Profile Send private message  
 
PostPosted: Tue Sep 12, 2017 9:19 am 
Offline

Joined: Fri Oct 18, 2013 10:13 am
Posts: 2428
Location: The Midwest
One tip for simplifying your code: if you're using a recent version of I7 you can say "[The attacker] [attack] ... and [deal] ... damage." It will conjugate the verbs appropriately if you define them as "To attack is a verb. To deal is a verb."

_________________
Daniel Stelzer


Top
 Profile Send private message  
 
PostPosted: Wed Sep 13, 2017 1:47 am 
Offline
User avatar

Joined: Sun Nov 22, 2009 12:58 pm
Posts: 703
Location: Malmö, Sweden
Additionally, inline if statements are still viable in colon-and-indentation syntax. Thus, you could do something like this:

Code:
say "You completely botch your attack! You deal [hits] point[if hits is not 1]s[end if] of damage to yourself!"


and it would work inside a nested if statement.

_________________
~Björn Paulsen


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group