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
  #31  
Old 01-25-2005, 07:37 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Projectshifter
I'm going to have to side with Stefan now in the assumption that it is something else with your script. I got on UN and tried it and it works fine. if (created) in the new NPC is called after the 1st NPC (the one that created the new one) finishes it's loop or so. It set the strings and worked fine with if (created). You could do something like this if it's perhaps not adding them
NPC Code:

oldnpcscount = npcscount;
while (npcscount == oldnpcscount)
create();
with(npcs[npcscount-1])
blah;

function create()
putnpc2 x,y,{blah;}


This way it would ensure it really adds the NPC before continuing, and if it doesn't add it, it will try to add it again.
Not to burst your bubble, but the placement of your while is not very good.
Reply With Quote
  #32  
Old 01-25-2005, 08:05 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Slash-P2P
I agree (kind of) but I still don't see anything about bashing in "Show off your best NPCs or ask the experts"
Nor do I see anything about answering questions or helping to solve problems. Should we be banned from doing that also?

You really should think about your arguments before you use them.
__________________
Reply With Quote
  #33  
Old 01-25-2005, 08:16 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by Lance
Not to burst your bubble, but the placement of your while is not very good.
I disagree, as it checks to make sure if it's created, not that it sets the things. If what he said is true, then it's not adding the NPCs (as stefan said), and it basically replaces Stefan's if (npcscount > oldnpcscount) by continually trying to add it if it fails. Perhaps I've been doing java too much lately, but I think it is in a fine place? But I'm open to other opinions
__________________
Who has time for life these days?
Reply With Quote
  #34  
Old 01-25-2005, 08:57 AM
TB3 TB3 is offline
Registered User
TB3's Avatar
Join Date: May 2001
Location: US of A State of VA
Posts: 658
TB3 is on a distinguished road
Send a message via Yahoo to TB3
Quote:
Originally Posted by Projectshifter
I'm going to have to side with Stefan now in the assumption that it is something else with your script. I got on UN and tried it and it works fine. if (created) in the new NPC is called after the 1st NPC (the one that created the new one) finishes it's loop or so. It set the strings and worked fine with if (created). You could do something like this if it's perhaps not adding them
NPC Code:

oldnpcscount = npcscount;
while (npcscount == oldnpcscount)
create();
with(npcs[npcscount-1])
blah;

function create()
putnpc2 x,y,{blah;}


This way it would ensure it really adds the NPC before continuing, and if it doesn't add it, it will try to add it again.
The problem was not that the npc was not being added (or my script), it was that the newly added npc was not having its strings set. And as I said stefans code
NPC Code:

oldnpcscount = npcscount;
putnpc2 ...
if (npcscount>oldnpcscount) with (npcs[oldnpcsount]) { ... }


Did not work at first , he came on to the server and removed the
if (npcscount>oldnpcscount)
And then it worked ( thats when he posted "works for me" )

The real problem is that after the putnpc2 the npcscount was increasing (on very small occasions) do some local npcs loading into memory a bit farther than it should , before the with() took place, even though it was directly following the putnpc2 command. Thus the wrong npc was getting the strings set. So the new way
PHP Code:
  oldnpcscount npcscount;
  
putnpc2 x,y,{
    
join baddy;
  };
  
with(npcs[oldnpcscount]) {
    
//code....
  

Works fine now. These problems however don't seem to occur in regular maps / levels just in gmaps for some reason. (As I have yet to have a problem with the npcs in regular levels)
__________________

To the sun of your age, I arise
Reply With Quote
  #35  
Old 01-25-2005, 09:13 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by TB3
The real problem is that after the putnpc2 the npcscount was increasing (on very small occasions) do some local npcs loading into memory a bit farther than it should , before the with() took place, even though it was directly following the putnpc2 command. Thus the wrong npc was getting the strings set. So the new way
That is rather odd, but makes sense as to why it wouldn't work. Seems strange though that it wouldn't be adding the # properly or what-not. I'm tired, but glad you figured it out.
__________________
Who has time for life these days?
Reply With Quote
  #36  
Old 01-25-2005, 09:17 AM
TB3 TB3 is offline
Registered User
TB3's Avatar
Join Date: May 2001
Location: US of A State of VA
Posts: 658
TB3 is on a distinguished road
Send a message via Yahoo to TB3
Quote:
Originally Posted by Projectshifter
That is rather odd, but makes sense as to why it wouldn't work. Seems strange though that it wouldn't be adding the # properly or what-not. I'm tired, but glad you figured it out.
Yes it is , I'm still a bit unsure what to think of it still lolz
And thanks for trying to help
If I find anything else out or the script bugs anymore I'll post again
Im gone to bed l8 l8 and i have get up in 2.75 hours cooolege
__________________

To the sun of your age, I arise

Last edited by TB3; 01-25-2005 at 09:52 AM..
Reply With Quote
  #37  
Old 01-25-2005, 04:57 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
The most important thing is that you are accessing npcscount before adding the npc, because accessing npcscount is causing the local npcs to be loaded, all local npcs in a radius of 1 level.
Most of the time the local npcs are already loaded, because several script commands have the side effect of the npcs being loaded, but in special cases it can happen that you are adding an npc into an area where there is no player and no npc activity. Before adding the npc the local npcs of the current level are loaded (radius 0), but not of the surrounding levels, may be I should change that.
It might sound simple, but I must keep care to not cause a chain reaction, e.g. a local npc putting an npc, the surrounding levels are loaded, the local npcs of the surrounding levels are putting new npcs, at the end the whole gmap is loaded into memory. With putnpc2 it should not be a problem though since I don't expect local npcs to use that command when they are loaded.

Ok will make putnpc2 load all surrounding levels before adding the new npc, then it should work better.
Reply With Quote
  #38  
Old 01-25-2005, 07:16 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by ZeroTrack
because functions are clientside
oh my...
__________________
Do it with a DON!
Reply With Quote
  #39  
Old 01-25-2005, 08:05 PM
Sildae Sildae is offline
Elven sorceress!
Sildae's Avatar
Join Date: Dec 2001
Location: Lothlòrien
Posts: 159
Sildae is on a distinguished road
Quote:
Originally Posted by Projectshifter
it's not adding the NPCs (as stefan said)
Stefan said that npcscount might be not indexOfTheNewNPC+1, but +n, for n > 1.

Quote:
perhaps I've been doing java too much lately, but I think it is in a fine place? But I'm open to other opinions
My opinion is that if you read indexOfTheNewNPC as an acceptable variable name, you have indeed beein doing java too much.
__________________
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man."
-- George Bernard Shaw
Reply With Quote
  #40  
Old 01-25-2005, 10:43 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
In new scripting you can just do
with (putnpc2(x,y,"script")) { ... }
Reply With Quote
  #41  
Old 01-25-2005, 10:48 PM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
Quote:
Originally Posted by Kaimetsu
Nor do I see anything about answering questions or helping to solve problems.
Then continue not to help people
Reply With Quote
  #42  
Old 01-26-2005, 10:29 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Slash-P2P
Then continue not to help people
Do you always change the subject when somebody points out a flaw in your logic?
__________________
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 05:25 PM.


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