Understated Ur-Drakon Celtic Minstrel Posted December 17, 2007 Posted December 17, 2007 I'm trying to create a terrain script which makes a space act like a conveyor belt. It works, but there's one problem: when several conveyor spaces are chained together, you are taken instantly to the end of the chain rather than being pushed a single space. Is there any way to fix this? I thought of setting an SDF which is reset in, say, the scenario start state, but then only one belt space would operate per turn. My code: Code: if (char_on_me() == -1) end(); willPush = 1; // If hasted, the character may not be pushed. if (get_char_status(char_on_me(),3) > get_ran(1,1,100)) willPush = 0; // If flying or hovering feet, the character will not be pushed. if (get_char_status(char_on_me(),25) > 0 || get_char_status(char_on_me(),27) > 0) willPush = 0; if (willPush == 1) { print_named_str(char_on_me()," is pushed!"); relocate_character(char_on_me(),xTarget,yTarget); force_instant_terrain_redraw(); } (It's in the START_STATE.) Quote
Unflappable Drayk Lazarus. Posted December 17, 2007 Posted December 17, 2007 I'm pretty sure you could do this in the town start_state, thus eliminating the need to lay down tons of terrain scripts. Run a check for each NPC, seeing if they are on a conveyor belt. If they are, move them one space forward (in either the +- x or +- y depending on what direction belt it is.) Make sure the belts' blockage are defined so that you can't walk backwards on them. Quote
Understated Ur-Drakon Celtic Minstrel Posted December 17, 2007 Author Posted December 17, 2007 Well... I never thought of this. Only one minor problem – I wanted to be able to set an SDF to turn it off (so it stops pushing). However it's fairly unlikely I'll have two completely separate conveyor networks in the same town, so that shouldn't be a significant problem. I actually made the terrain script be set automatically, but I still had to go through and set the direction appropriately. I wonder... could I make this work outdoors? Quote
Unflappable Drayk Lazarus. Posted December 17, 2007 Posted December 17, 2007 If you wanted to turn off a conveyor belt and leave others on, you'd have to swap the entire belt to a different 'dummy' belt, which would look the same but be a different number that isn't recognized in the start_state as being a belt, and thus wouldn't push people. I don't think it'd work outdoors, since you can't get the x,y loc of the party to check what floor they're standing on, and can't use the terrain script method either. Quote
Understated Ur-Drakon Celtic Minstrel Posted December 17, 2007 Author Posted December 17, 2007 Or I could use my original method - the SDF - if I simply wanted to disable all belts in the town. By the way, what's the maximum number of creatures in a town? And the max num of items? Edit: There's no way to iterate through all items in the town like you can do with creatures, is there? Edit: It's telling me there is "syntax error [statement" (ALint) or "Bad term in expression" (Avernum) on line 39. That's the "south" line in the INIT_STATE: Code: variables;short xTarget,yTarget,willPush,i,j;// Constantsshort north,east,south,west,nw,ne,se,sw;body;beginstate INIT_STATE; // Set the constants nw = 0; ne = 0; se = 0; sw = 0; north = 474; east = 476 south = 477; west = 475; set_ter_script_mode(ME,3);break; This makes no sense at all. Quote
Unflappable Drayk John S Posted December 17, 2007 Posted December 17, 2007 The "east" line is missing a semicolon. Maybe an SDF could be used to chart whether a belt has moved a player yet, with one for each player (6). Set them to a number after moving a player, and reset them every turn. If you want the belt to stop you can set all the SDFs to the inactive value. Will monsters also need to walk on the belt? Quote
Well-Actually War Trall Niemand Posted December 17, 2007 Posted December 17, 2007 The maximum is 120 creatures, I think, and something like 144 items, but move_item_on_spot is probably your best bet for items. Quote
Well-Actually War Trall Ishad Nha Posted December 17, 2007 Posted December 17, 2007 Looking at the 3D source file Global.h around line 65 gives all of the limits, this agrees with Editor help file. In particular, you can only place eighty monsters, the other 34 slots are reserved for summonings. Edit: as it so happens the Blazing Blades produced good conveyor belt graphics. Quote
Well-Actually War Trall Niemand Posted December 17, 2007 Posted December 17, 2007 80 placed creatures + 34 summoned + 6 party members = 120 charcters in the town. Quote
Understated Ur-Drakon Celtic Minstrel Posted December 17, 2007 Author Posted December 17, 2007 Quote: Originally written by Calphrexo:The "east" line is missing a semicolon. Whoa – how'd I miss that? Quote: Originally written by Calphrexo:Maybe an SDF could be used to chart whether a belt has moved a player yet, with one for each player (6). Set them to a number after moving a player, and reset them every turn. If you want the belt to stop you can set all the SDFs to the inactive value.Will monsters also need to walk on the belt? Actually, for the characters I'm going to check each character in turn to see if they are on a belt, so that monsters/NPCs can be affected by them - provided they aren't blocked. Quote: Originally written by Ishad Nha:Edit: as it so happens the Blazing Blades produced good conveyor belt graphics. I've seen the graphic you mean (based on the original Exile graphics), but I had already made my own at that time. However, I will likely switch at some point as mine is really bad. Quote: Originally written by Niemand:The maximum is 120 creatures, I think, and something like 144 items, but move_item_on_spot is probably your best bet for items.Originally written by Niemand:80 placed creatures + 34 summoned + 6 party members = 120 charcters in the town. Thanks. I was assuming 250, but clearly I was wrong.Now I just have to figure out a way to ensure a specific pile of items is only pushed once per turn... The easiest way would be to work backwards along the chain, but that would require different code for each town that uses conveyors. I'll do it if I can't think of a better way, though... I have a suspicion that this is actually the only way it could work.Edit: Well, it's improved, but now for some reason it moves about ten spaces at a time, and I can't figure out why. Here's the functional code: Code: i = 0;//print_str("Checking conveyors...");while(i<120){ // What's the maximum number of creatures in a town? xTarget = char_loc_x(i); yTarget = char_loc_y(i); if(i == 0){ print_named_str(i,"considered"); print_nums(xTarget,yTarget,get_terrain(xTarget, yTarget)); } if ((get_terrain(xTarget, yTarget) == north && north > 0) || (get_terrain(xTarget, yTarget) == ne && ne > 0) || (get_terrain(xTarget, yTarget) == nw && nw > 0)) yTarget = yTarget - 1; else if ((get_terrain(xTarget, yTarget) == south && south > 0) || (get_terrain(xTarget, yTarget) == se && se > 0) || (get_terrain(xTarget, yTarget) == sw && sw > 0)) yTarget = yTarget + 1; if ((get_terrain(xTarget, yTarget) == east && east > 0) || (get_terrain(xTarget, yTarget) == ne && ne > 0) || (get_terrain(xTarget, yTarget) == se && se > 0)) xTarget = xTarget + 1; else if ((get_terrain(xTarget, yTarget) == west && west > 0) || (get_terrain(xTarget, yTarget) == sw && sw > 0) || (get_terrain(xTarget, yTarget) == nw && nw > 0)) xTarget = xTarget - 1; if(i == 0)print_nums(xTarget,yTarget,0); if (xTarget != char_loc_x(i) || yTarget != char_loc_y(i)){ willPush = 1; // If hasted, the character may not be pushed. if (get_char_status(i,3) > get_ran(1,1,100)) willPush = 0; // If flying or hovering feet, the character will not be pushed. if (get_char_status(i,25) > 0 || get_char_status(i,27) > 0) willPush = 0; if (willPush == 1) { print_named_str(i," is pushed!"); relocate_character(i,xTarget,yTarget); force_instant_terrain_redraw(); } } i = i + 1;} The debug commands are only run (displayed) once for character 0, yet he moves about ten spaces at a time. Quote
Well-Actually War Trall Niemand Posted December 18, 2007 Posted December 18, 2007 Quote: The easiest way would be to work backwards along the chain, but that would require different code for each town that uses conveyors. About a year ago I worked on this for some time, and I concluded that a unique script for every town was the only practical way. One major reason is that even if you make sure that you only move each character once, how you you correctly handle things that are next to each other on the conveyor, or when one goes off the end, stops, and the others can't move forward? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.