Can you?

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Can you?
? Man, ? Amazing
Member # 5755
Profile #0
Make creatures only move in one compass direction?

I want to have all my creatures in group x only move to the west. If something is in their way, then try NW then SW, and if nothing is possible there, then to fidget and say "Hurry, get out of my way."

I would do a cutscene, but I think it would be more fun to have the party be able to move about. They will be trying to get east.

--------------------
WWtNSD?
Posts: 4114 | Registered: Monday, April 25 2005 07:00
Infiltrator
Member # 5576
Profile Homepage #1
Yes, you could do it, but it would be a good deal of work. I would do it by giving them a creature script that checks the terrain and floor to the west, and if the space is clear, uses relocate_character to actually do the move. Some thing like this:

variables dir,do_move,n,x,y;

beginstate WHATEVER_STATE_1;
dir = 1; //west
set_state_continue(WHATEVER_STATE_2);
break;

beginstate WHATEVER_STATE_2;
if((dir < 1) || (dir > 3)){
<complain>
end();
}
do_move = 1;
//find the coordinates of the new location to try
if(dir == 1){//west
x = char_loc_x(ME) - 1;
y = char_loc_y(ME);
}
else if(dir == 2){//NW
x = char_loc_x(ME) - 1;
y = char_loc_y(ME) - 1;
}
else if(dir == 3){//SW
x = char_loc_x(ME) - 1;
y = char_loc_y(ME) + 1;
}
//test if the terrain will allow stepping there
n = get_terrain(x,y);
if(<terrain cannot be stepped on>)
do_move = 0;
//test if the floor will allow stepping there
n = get_floor(x,y);
if(<floor cannot be stepped on>)
do_move = 0;
//make sure no one else is standing there
n = char_on_loc(x,y);
if(n != -1)
do_move = 0;
if(do_move == 1){ //if we can move, do it
if(dir == 1)
set_character_facing(ME,2);
else if(dir == 2)
set_character_facing(ME,1);
else if(dir == 3)
set_character_facing(ME,3);
relocate_character(ME,x,y);
}
else{ //otherwise try the next direction
dir = dir + 1;
set_state_continue(WHATEVER_STATE_2);
}
break;
(Note that this is mostly Avernum script but some pseudocode that needs to be replaced, mainly the state numbers and checking for whether a floor or terrain can be stepped on, which will require checking if the terrain is between 125 and 136, for instance, since these terrains are all boulders, and so on, and likewise for floors.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Agent
Member # 2820
Profile #2
The above script will be complex to implement because of all the general possibilities it must consider. Since you are the designer, I think you could make the map and script specific to each other and things would be much easier for you. For instance, if the only one narrow corridor or path to go from A to B, then the creature with the script will always move in the cardinal direction toward B because if it were blocked the pathfinding engine would tell it to stop. You can check for this halting and display your message then.

That example is pretty restrictive, but I think you get the idea.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00