Jump to content

Playing character control


Goofy
 Share

Recommended Posts

I'm trying to post a piece of script that may be useful to some people but I get :

'Sorry, we do not permit this HTML tag:Parenthesis in HTML tag'

 

is the // used for script comments that create a problem ?

if this post get through probably not...

or is it the () parenthesis as stated?

 

this is a script to solve (work-around) the combat end bug, if any interested...

 

thanks for any help.

Link to comment
Share on other sites

End Combat bug workaround (some edits)

-------------------------

 

If no one has already written this, a piece of script to avoid the end-combat bug (the party moving one step forward and skipping encounters).

 

This is a piece of script to place in the Scenario Script, START_STATE (I don't know if START_STATE in the Scenario Script is run each turn in any situation but I think so).

 

It requires 9 stuff done flags, I used (0 to 8, 1)

 

To notice : since characters cannot be 'switched' in combat mode the leader remains the same and no encounter should be skipped (it would have been walked upon by the leader either before combat in town mode, or during the combat)

 

(Code updated below...)

Link to comment
Share on other sites

This thread should be renamed but I don't known who can do that, to 'End Combat bug workaround' probably.

 

Also a possible problem :

 

(leader = in slot order (0 to 3) the first living present character)

 

first the good : in fact the leader can change during combat... if he dies. But if the previous leader didn't cross a given special encounter, the others, following him in town mode, shouldn't have either.

 

second, the problem : if the terrain on which a playing character was sitting at the beginning of the turn has been swapped in the middle of this turn to a blocked terrain, and the combat ends, the leader at this moment and thus the party could remain stuck inside this spot when relocated.

 

this might be possible if terrain swapping is triggered by a creature script, or by a character walking on this spot for example.

 

so when swapping/flipping a terrain/floor to a blocked one it should be checked if char_on_me() == -1, but, in addition in combat mode, the script would have to check, with the flags used to record positions, if ANY character (since the leader may have changed since the beginning of the turn) was not upon this spot at the beginning of the current turn, and if so do not swap.

 

the problem is to avoid trapping the party in a position one of the characters had at the beginning of the last combat turn.

 

the modification is not to the script I gave, but to all scripts that swap/flip terrains/floors from a non-blocked one to a blocked one (set as blocked in scendata.txt).

Link to comment
Share on other sites

[updated]

 

A more complete scenario script to control how playing characters move

 

some may find that very useful, others very superfluous, at least it should be funny to look at when working

 

so it's a script for the scenario START_STATE (or a town state run each turn), and a bit of code for the scenario START_SCEN_STATE

 

it also requires a script to be run from one terrain in each town (second part of code), this can be any terrain

 

it allows to control how characters are positioned on combat end, and how they get positioned when the player uses the 'switch' buttons (under the portraits)

 

it's probably difficult to read but it can be tested directly inside a scenario by temporarily replacing thescenario.txt with this code

(except for the terrain script that updates characters positions during a combat turn, which must be done with the Editor)

 

First part :

------------

the code to place in the scenario main script file

(code updated below...)

 

Second part :

-------------

the code to place in a script file and to execute from one terrain in each town

(code updated below...)

Link to comment
Share on other sites

Lazarus : just tested your ever-running terrain script (did a script saying "hello" from a terrain), now I understand your previous answer...

It says "hello" 7 times per town mode move, and once per individual move in combat mode.

 

The recording of each character position could be put in one script terrain in each town...

with INIT_STATE 'set_script_mode(3)' (every turn)

Tried that : both functions (especially end combat relocation) work.

 

For the cpu load, I run a Sempron 2400 (very basic) and I tested with and without my script it makes no difference (I made my party run around a filled town with the mouse left click down). The reason is that it is not graphic operations but simple mathematical operations (should be nothing for a computer if BOE engine works normally)

 

I saw the marking character trick with a special ability and I could use it.

The advantage of my system is that it is more self-contained and can be inserted in a scenario without interfering (however it needs temporary variables and 4 flags for skills marking)

Link to comment
Share on other sites

Code update...

 

Part 1 : the scenario script parts

--------

 

Code:
// SCENARIO SCRIPTbeginscenarioscript;variables;	short count, result, done, pos_x, pos_y;	short i, j, k;body;// *************************************************************************************************// START_SCEN_STATE// *************************************************************************************************beginstate START_SCEN_STATE;// init unique stats for switching, to avoid switching effects on scenario start// uses flags (pos_x to pos_x+4, pos_y) = (30 to 30+4, 29)// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)	// take switch flags	pos_x = 30;	pos_y = 29;	i = 0;	while (i <= 3) {		if (char_status(i) != 0) {			done = 0;			j = 0;			// try stat from Strength (0) to Pathfinder (24), use bought levels			while (j <= 24 && done == 0) {				result = get_stat_levels_bought(i, j) % 10;				done = 0;				k = 0;				while (k <= 3 && done < 3) {					// don't check against himself					if (k != i) {						if (char_status(k) == 0) done = done + 1;						else if (result != (get_stat_levels_bought(k, j) % 10)) done = done + 1;					}					k = k + 1;				}				if (done == 3) done = 1;				else done = 0;				j = j + 1;			}			j = j - 1;			// can't get a unique stat for char (i), drop it			if (done == 0) set_flag(pos_x + i, pos_y, 250);			// got a unique stat for char (i)			else set_flag(pos_x + i, pos_y, (j * 10) + result);		}		// set to default value for non-existing char (i)		else set_flag(pos_x + i, pos_y, 250);		i = i + 1;	}// set switching difficulty level to 'reordering + lost a turn' (3), this can be changed at any time// uses flags (pos_x to pos_x+4, pos_y) = (30 to 30+4, 29)// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)	// take switch flags	pos_x = 30;	pos_y = 29;	set_flag(pos_x + 4, pos_y, 3);break;// *************************************************************************************************// LOAD_SCEN_STATE// *************************************************************************************************beginstate LOAD_SCEN_STATE;break;// *************************************************************************************************// START_STATE// *************************************************************************************************beginstate START_STATE;// relocation **************************************************************************************// check current game mode for relocation on combat end (0 : outdoor) (1 : town) (2 : combat)// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)// and flag (pos_x+12, pos_y) = (10+12, 29) (last turn mode flag)	// take position and last turn mode flags	pos_x = 10;	pos_y = 29;	// outdoor mode : just record	if (is_outdoor() == 1) {		set_flag(pos_x + 12, pos_y, 0);	}	// town mode : check for last turn mode, if it was combat relocate all chars	else if (is_town() == 1) {		// on combat end, in town mode only, relocate all chars to their last positions during the last combat turn		// and center screen on the first living, present, non joined-NPC character (the leader)		if (get_flag(pos_x + 12, pos_y) == 2) {			done = 0;			i = 0;			// while (i <= 3) { // if joined-NPCs relocation is not needed			while (i <= 5) {				if (char_status(i) == 1 && get_flag(pos_x + (2 * i), pos_y) != 250) {					relocate_character(i, get_flag(pos_x + (2 * i), pos_y), get_flag(pos_x + (2 * i) + 1, pos_y));					if (done == 0) {						force_view_center(get_flag(pos_x + (2 * i), pos_y), get_flag(pos_x + (2 * i) + 1, pos_y));						done = 1;					}				}				i = i + 1;			}			force_instant_terrain_redraw();			print_str_color("End combat.", 4);		}		set_flag(pos_x + 12, pos_y, 1);	}	// combat mode : just record	else if (is_combat() == 1) {		set_flag(pos_x + 12, pos_y, 2);	}// update chars positions **************************************************************************// update all chars positions between turns// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)	// take position flags	pos_x = 10;	pos_y = 29;	i = 0;	// while (i <= 3) { // if joined-NPCs relocation is not needed	while (i <= 5) {		if (char_status(i) == 1) {			set_flag(pos_x + (2 * i), pos_y, char_loc_x(i));			set_flag(pos_x + (2 * i) + 1, pos_y, char_loc_y(i));		}		else {			set_flag(pos_x + (2 * i), pos_y, 250);			set_flag(pos_x + (2 * i) + 1, pos_y, 250);		}		i = i + 1;	}// switching ***************************************************************************************// switching party order is prevented and/or paralyses whole party for one turn, not outdoor// switching difficulty level : 0 = normal, 1 = reordering, 2 = lost a turn, 3 = reordering + lost a turn// uses flags (pos_x to pos_x+4, pos_y) = (30 to 30+4, 29)// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)	// take switch flags (beware pos_x, pos_y will be swapped to position flags)	pos_x = 30;	pos_y = 29;	// check stats for switching	if (is_outdoor != 1) {		j = 0;		i = 0;		while (i <= 3 && j <= 2) {			count = get_flag(pos_x + i, pos_y);			// check all existing chars with their unique stat, if stats modulus 10 are !=, stats are !=			if (char_status(i) != 0 && count != 250) {				result = count % 10;				done = (count - result) / 10;				// if stat mismatch increase j by 1				if (get_stat_levels_bought(i, done) != result) j = j + 1;			}			i = i + 1;		}		// switching means at least two characters having their identification stat changed		if (j >= 2) {			// if flag(pos_x + 4, pos_y) = 1 or 3			// physical reordering is prevented (reversed to last chars positions)			if (get_flag(pos_x + 4, pos_y) == 1 || get_flag(pos_x + 4, pos_y) == 3) {				print_str_color("Reordering party...", 2);				i = 0;				while (i <= 3) {					if (char_status(i) == 1) {						count = get_flag(pos_x + i, pos_y);						result = count % 10;						done = (count - result) / 10;						// find the position the char had and relocate it there						j = 0;						while (j <= 3 && get_flag(pos_x + (2 * j), pos_y) != 250) {							if (get_stat_levels_bought(j, done) == result) {								// take positions flags (this heavy but used only when switching occurs)								pos_x = 10;								pos_y = 29;								relocate_character(i, get_flag(pos_x + (2 * j), pos_y), get_flag(pos_x + (2 * j) + 1, pos_y));								// take switch flags (this heavy but used only when switching occurs)								pos_x = 30;								pos_y = 29;							}							j = j + 1;						}					}					i = i + 1;				}				// center screen on the first living, present, non joined-NPC character (the leader)				done = 0;				i = 0;				while (i <= 3 && done == 0) {					if (char_status(i) == 1) {						// take positions flags (this heavy but used only when switching occurs)						pos_x = 10;						pos_y = 29;						force_view_center(get_flag(pos_x + (2 * i), pos_y), get_flag(pos_x + (2 * i) + 1, pos_y));						// take switch flags (this heavy but used only when switching occurs)						pos_x = 30;						pos_y = 29;						done = 1;					}					i = i + 1;				}				force_instant_terrain_redraw();			}			// if flag(pos_x + 4, pos_y) = 2 or 3, paralyse all chars, and joined-NPCs, one turn, unblockable			if (get_flag(pos_x + 4, pos_y) == 2 || get_flag(pos_x + 4, pos_y) == 3) {				if ((get_flag(pos_x + 4, pos_y) == 2) || is_town() == 1) {					print_str_color("You spend a turn reordering your party...", 3);				}				else {					print_str_color("You lost a turn trying to reorder your party...", 1);				}				i = 0;				while (i <= 5) {					if (char_status(i) != 0) set_char_status(i, 11, 1, 1, 0);					i = i + 1;				}			}		}	}	// refresh unique stats for switching	i = 0;	while (i <= 3) {		if (char_status(i) != 0) {			done = 0;			j = 0;			// try stat from Strength (0) to Pathfinder (24), use bought levels			while (j <= 24 && done == 0) {				result = get_stat_levels_bought(i, j) % 10;				done = 0;				k = 0;				while (k <= 3 && done < 3) {					// don't check against himself					if (k != i) {						if (char_status(k) == 0) done = done + 1;						else if (result != (get_stat_levels_bought(k, j) % 10)) done = done + 1;					}					k = k + 1;				}				if (done == 3) done = 1;				else done = 0;				j = j + 1;			}			j = j - 1;			// can't get a unique stat for char (i), drop it			if (done == 0) set_flag(pos_x + i, pos_y, 250);			// got a unique stat for char (i)			else set_flag(pos_x + i, pos_y, (j * 10) + result);		}		// set to default value for non-existing char (i)		else set_flag(pos_x + i, pos_y, 250);		i = i + 1;	}break;
Part 2 : the terrain script to place once in each town

--------

 

Code:
// TERRAIN SCRIPT// Script for updating characters positions in combat mode (to place on one terrain in each town)// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)beginterrainscript;variables;	short pos_x, pos_y, i;body;beginstate INIT_STATE;	// run script every move even if party is far	set_script_mode(3);break;beginstate START_STATE;// update all chars positions on each individual step during combat// uses flags (pos_x to pos_x+7(+4 for joined-NPCs), pos_y) = (10 to 10+7(+4 for joined-NPCs), 29)	// take position flags	pos_x = 10;	pos_y = 29;	if (is_combat() == 1) {		i = 0;		// while (i <= 3) { // if joined-NPCs relocation is not needed		while (i <= 5) {			if (char_status(i) == 1) {				set_flag(pos_x + (2 * i), pos_y, char_loc_x(i));				set_flag(pos_x + (2 * i) + 1, pos_y, char_loc_y(i));			}			else {				set_flag(pos_x + (2 * i), pos_y, 250);				set_flag(pos_x + (2 * i) + 1, pos_y, 250);			}			i = i + 1;		}	}break;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...