Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-16-2006, 10:14 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Setting variables when a player enters a level

Alright.. I have a ladder NPC.
When the player enters the level, I want each ladder to tell the player where it is. A system handles climbing, based on this information.

When the player enters the level, it adds the ladder's ID to one array (ladders) and it adds the ladder's area to another array (ladder#).

When the player enters, the system clears the ladders, so old ladder placements aren't carried into the level.


However, the ladder ID array is randomly being erased. I'm guessing it's by the clearing of ladders when the player enters.
I tried making it set the ladder ID array after .5 seconds, but it still doesn't work.
The ladders array just randomly clears itself; if I update the level or relog, it works. However, like I said, after a while it clears itself for no reason.

Any ideas?
Reply With Quote
  #2  
Old 04-16-2006, 11:44 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Try using a level. variable so you don't have to clear it when they enter a new level?
Reply With Quote
  #3  
Old 04-17-2006, 12:05 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by Riot
Try using a level. variable so you don't have to clear it when they enter a new level?
I think I tried that, but I'll try again.
Reply With Quote
  #4  
Old 04-17-2006, 12:09 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Yeah, it doesn't work at all as level.
Reply With Quote
  #5  
Old 04-19-2006, 02:50 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Try making the ladders NPCs, and then having the system detect the NPCs.

ex.
ladder
PHP Code:
function onCreated() {
  
setshape(1,16*width,16*height);
  
this.isLadder true;
}

-----
system NPC function for testing ladders
function testLadder() {
  
temp.tnpcs findareanpcs(x,y,w,h);
  for (
i=0i<temp.tnpcs.size(); i++)
    if (
temp.tnpcs[i].isladder)
      return 
true;
  return 
false;

Reply With Quote
  #6  
Old 04-19-2006, 02:27 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
To access level. variables clientside, you have to set them clientside.
This would probably be your best method of doing this, something like:

PHP Code:
//#CLIENTSIDE
if(created) {
  
level.ladders.add({ this.xthis.ywhateverelse });

__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 04-19-2006, 05:12 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by ApothiX
To access level. variables clientside, you have to set them clientside.
This would probably be your best method of doing this, something like:

PHP Code:
//#CLIENTSIDE
if(created) {
  
level.ladders.add({ this.xthis.ywhateverelse });

It treats them the same as un-prefix'd variables.

I can't really make the system detect them, because the player could be on a gmap with 1000s of NPCs.
You know how laggy that is. :P
Reply With Quote
  #8  
Old 04-19-2006, 06:59 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Yen
It treats them the same as un-prefix'd variables.

I can't really make the system detect them, because the player could be on a gmap with 1000s of NPCs.
You know how laggy that is. :P
Well, that's what was a problem with my movement system, and then stefan made findareanpcs(x,y,w,h) work for weapons so that I could detect NPCs. It's probably one of the most useful functions that stefan has made.
findareanpcs(x,y,w,h) returns an array of npc objects on x,y,w,h. Therefore you don't have to cycle through thousands of NPCs. He's been talking about doing a findareaplayers function, that will also be quite helpful.
Reply With Quote
  #9  
Old 04-19-2006, 11:45 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Do you know if PlayerEnters is called when the player enters a new section of the gmap?
Reply With Quote
  #10  
Old 04-20-2006, 05:30 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
I generally treat the gmap as if it were one level, though I'm sure it does in some senses, just not trustworthy senses.
Reply With Quote
  #11  
Old 04-20-2006, 02:14 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Yen
Do you know if PlayerEnters is called when the player enters a new section of the gmap?
It is. Clientside it doesn't show the level being the gmap, it shows the individual sections.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #12  
Old 04-20-2006, 07:44 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by ApothiX
It is. Clientside it doesn't show the level being the gmap, it shows the individual sections.
yes, but I believe it may call the playerenters event on multiple levels.
Reply With Quote
  #13  
Old 04-20-2006, 07:50 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by jake13jake
yes, but I believe it may call the playerenters event on multiple levels.
I will reiterate what Okiesmokie said.

The clientside does not see the GMAP as one giant level, like the serverside does. Therefore, function onPlayerEnters() will be called clientside as you enter each level in the GMAP, not on every level as you enter the GMAP.
__________________
Skyld
Reply With Quote
  #14  
Old 04-20-2006, 07:53 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Skyld
I will reiterate what Okiesmokie said.

The clientside does not see the GMAP as one giant level, like the serverside does. Therefore, function onPlayerEnters() will be called clientside as you enter each level in the GMAP, not on every level as you enter the GMAP.
No, I mean for every level that is visible, but I haven't tested it in a long time.
Reply With Quote
  #15  
Old 04-20-2006, 08:24 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by Skyld
I will reiterate what Okiesmokie said.

The clientside does not see the GMAP as one giant level, like the serverside does. Therefore, function onPlayerEnters() will be called clientside as you enter each level in the GMAP, not on every level as you enter the GMAP.
This creates a problem.

Ganis will fix it, though! YAY GANI!
Reply With Quote
  #16  
Old 04-24-2006, 02:30 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
No, I mean for every level that is visible, but I haven't tested it in a long time.
.. read what both me and Skyld said, and then reply <_<
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 04:56 PM.


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