Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Bug Report
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 08-26-2014, 12:06 AM
samich samich is offline
Registered User
samich's Avatar
Join Date: Jan 2007
Posts: 59
samich will become famous soon enough
Send a message via MSN to samich
NPC Setlevel2 problem

So I have a problem where setlevel2 is not acting appropriately.

Example: So imagine I'm building an hotel with 30 floors/levels that will all be 100% similar. The stairs will be on the north and south of the room, with NPC's as level warps. If the north and south npcs - that use selevel2 to change floors - are on the same x axis location, then it will enter the script of the next floor's npc to go to the next level, etc. In a split second, you go from floor 1 to floor 30.

The problem: Npcs using setlevel2 to transfer a player to another level which contains an npc with a setlevel2 call also, will send the player to that call's location as well IF they have the same x location; the y location is not important.

If you want to see an example, log onto my server - Aqua (Going to be renamed to Vivitron), and I will show you a hotel system I'm working on.
__________________
[Graal Related Business]

Last edited by samich; 08-26-2014 at 05:02 PM..
Reply With Quote
  #2  
Old 08-27-2014, 03:27 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
post some script(s) please.
don't really feel like logging onto a private server after aforementioned security flaws, and not really looking forward to hunting down some hotel system...

Just based on the description, you need to compensate for the direction the player is traveling in, because it seems you are probably warping him either:
1.) Directly on top of the next NPC, causing the player to touch the NPC event to occur, and warp him appropriately, or
2.) You are warping him too few tiles apart from the NPC and he is still traveling causing him to touch the NPC promptly after he warps.

A video here might help.

Also, is there any particular reason you are using NPCs to set the level here?
If this is some form of an elevator system, don't you think you could integrate it into a grab system you develop? ( onActionGrab() )
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #3  
Old 08-27-2014, 03:33 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
sounds like a never-ending chain of onPlayerTouchsMe events, although its hard to tell given the lack of script or screenshots the problem could also involve needing to change the players direction

if you script the touch event on Clientside then trigger to Serverside on the npc to handle warping, that should definitely prevent this
__________________
This signature has been deleted by Darlene159.

Last edited by Jakov_the_Jakovasaur; 08-27-2014 at 03:53 PM..
Reply With Quote
  #4  
Old 08-27-2014, 05:49 PM
samich samich is offline
Registered User
samich's Avatar
Join Date: Jan 2007
Posts: 59
samich will become famous soon enough
Send a message via MSN to samich
The reason they are NPC's is because they are copyLevel generated floors. It is an automated playerhouse-esque system, and I needed to dynamically set the level to go to next, as regular level links wouldn't work dynamically like that.

NPC Code:

function onCreated() {
setimg("vivitron_hotel-halfdoor.png");
// Get the next level up's floor number
this.floor = int(this.level.name.substring(12, -1).tokenize(".")[0]) + 1;
setshape(1, 32, 16);
dontblock();
drawunderplayer();
}

function onPlayerTouchsMe() {
if(!levelexists("hotel_floor_" @ this.floor @ ".nw")) return;
setlevel2("hotel_floor_" @ this.floor @ ".nw", player.x, 33.5);
}



Here is a video (disregard floors 1,2 and possibly 3, as they are made in a way that works, but is not the way I want the levels to look like): http://youtu.be/w6vKyZ8Pa_I

At around 18-20 seconds I demonstrate how moving slowly, the setlevel2 transition works just fine, but anytime before that, weird things happen, such as some images not loading (due to such immediate level switching, I'm assuming).
__________________
[Graal Related Business]
Reply With Quote
  #5  
Old 08-27-2014, 05:55 PM
samich samich is offline
Registered User
samich's Avatar
Join Date: Jan 2007
Posts: 59
samich will become famous soon enough
Send a message via MSN to samich
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
sounds like a never-ending chain of onPlayerTouchsMe events, although its hard to tell given the lack of script or screenshots the problem could also involve needing to change the players direction

if you script the touch event on Clientside then trigger to Serverside on the npc to handle warping, that should definitely prevent this

I think I'll try something like that. Hopefully the playertouchsme chain won't happen after taking time to chat with the npc server, and add a bit more precision by relying on clientside checking.

And I apologize for the initial post having no resources to review. In the middle of a house move and I didn't have internet for a bit.
__________________
[Graal Related Business]
Reply With Quote
  #6  
Old 08-27-2014, 07:17 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
On delteria when we generate levels we change the links via script
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #7  
Old 08-27-2014, 07:21 PM
samich samich is offline
Registered User
samich's Avatar
Join Date: Jan 2007
Posts: 59
samich will become famous soon enough
Send a message via MSN to samich
You can change level links via script? How would you go about doing that, if you don't mind me asking? I haven't done much level manipulation via script.
__________________
[Graal Related Business]
Reply With Quote
  #8  
Old 08-27-2014, 09:54 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by samich View Post
You can change level links via script? How would you go about doing that, if you don't mind me asking? I haven't done much level manipulation via script.
You have like a template level. You always load that one file as a text (using loadLines() or whatever you want to use) and have the script look for a certain warp you want to manipulate (lets say the format is 'LINK 30 30 some_level.nw' ; I'm not too sure didn't check it). After you've found that / them, you simply alter the Level name like:

PHP Code:
temp.newlevel "new_level.nw";
temp.line yourFoundLINKLocationInsideTheFile.tokenize();
//          LINK             x                y                levelname
temp.line temp.line[0SPC temp.line[1SPC temp.line[2SPC temp.newlevel 
and save those edited lines via saveLines() as a new level. Make sure to keep your level template unedited - it's a template

TBH I've never really tried editing the links directly like that, but that's the way that I can think of right now. Probably would end up changing it all again
__________________
MEEP!
Reply With Quote
  #9  
Old 08-31-2014, 11:41 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Quote:
Originally Posted by callimuc View Post
You have like a template level. You always load that one file as a text (using loadLines() or whatever you want to use) and have the script look for a certain warp you want to manipulate (lets say the format is 'LINK 30 30 some_level.nw' ; I'm not too sure didn't check it). After you've found that / them, you simply alter the Level name like:

PHP Code:
temp.newlevel "new_level.nw";
temp.line yourFoundLINKLocationInsideTheFile.tokenize();
//          LINK             x                y                levelname
temp.line temp.line[0SPC temp.line[1SPC temp.line[2SPC temp.newlevel 
and save those edited lines via saveLines() as a new level. Make sure to keep your level template unedited - it's a template

TBH I've never really tried editing the links directly like that, but that's the way that I can think of right now. Probably would end up changing it all again
Like Callimuc said, here is a piece that might help from Instance System from Novo. A tad was changed by me below.

We actually find the links using a identifiable name such as original. All our instance levels are levelname-original.nw.
to get the copy_id, we calculate each instance created (Ex: this.copy_counter.(@temp.id) ++;//temp.id would be the instance type)
PHP Code:
  temp.original_level levelname-original.nw;
  
temp.lines.loadlines("levels/instance/"temp.original_level);
  
temp.newlines = new[0];
  for (
temp.linetemp.lines) {
    
temp.original_pos temp.line.pos("original");
    while (
temp.original_pos != -1) {
      
temp.line temp.line.substring(0temp.original_pos) @ temp.copy_id temp.line.substring(temp.original_pos strlen("original") - 2);
      
temp.original_pos temp.line.pos("original");
    }
    
temp.newlines.add(temp.line);
  } 

And what this does is it copys the x and y coordinates of your original level, and renames the copied level as well as the links.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
Reply


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


All times are GMT +2. The time now is 03:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.