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 01-24-2005, 12:39 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
with(npcs[npcscount-1]) Priority ?

Ok I'm having a few problems it's a bit hard to understand / explain.

I have a spawner npc i will dumb it down as the whole code isn't needed. Here is an example..

Spawner NPC:
PHP Code:
function spawn() {
  
setstring this.type,Undead;
  
putnpc2 x,y,{
  
join temporary;
  
join baddy;
  };
  
with(npcs[npcscount-1]) {
    
setstring this.type,#s(thiso.type);
    
setstring this.owner,Baddy;
  }

Class baddy
PHP Code:
//Baddies script 
Class temporary
PHP Code:
if (createdsendtonc Type#s(this.type); 
The problem is about 1/20 times the this.type string is blank (and other strings set in with() ). I'm guessing that maybe the if (created) either loads before the with(npcs[npcscount-1]) sets the string or that with(npcs[npcscount-1]) gets an incorrect npc?

Any help , Ideas?
__________________

To the sun of your age, I arise
Reply With Quote
  #2  
Old 01-24-2005, 01:57 AM
Sildae Sildae is offline
Elven sorceress!
Sildae's Avatar
Join Date: Dec 2001
Location: Lothlòrien
Posts: 159
Sildae is on a distinguished road
I am very sure that Stefan uses this pattern himself a lot, so I do not see how it could not work.
__________________
"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
  #3  
Old 01-24-2005, 02:02 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 Sildae
I am very sure that Stefan uses this pattern himself a lot, so I do not see how it could not work.
Yeah, thats also why its not making sense to me O_o
__________________

To the sun of your age, I arise
Reply With Quote
  #4  
Old 01-24-2005, 02:52 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
dont use function , to do that in must be serverside, instead of calling the function triggeraction to serverside and put everything in that function in serverside

PHP Code:
if(actionserverside){
  if(
strequals(#p(0),baddy)){
    
putnpc2 xy,y,{
        
join temporary;
        
join baddy
    
};
    
with(npcs[npcscount-1]){
    
setstring this.type,#s(thiso.type);
    
setstring this.owner,Baddy
    }
  }
}

//#CLIENTSIDE
 // 0,0 was used not know weather it was a weapon or local npc
 
if(createdtriggeraction 0,0,serverside,Baddy Placer,baddy
__________________

Reply With Quote
  #5  
Old 01-24-2005, 03:03 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 ZeroTrack
dont use function , to do that in must be serverside, instead of calling the function triggeraction to serverside and put everything in that function in serverside

PHP Code:
if(actionserverside){
  if(
strequals(#p(0),baddy)){
    
putnpc2 xy,y,{
        
join temporary;
        
join baddy
    
};
    
with(npcs[npcscount-1]){
    
setstring this.type,#s(thiso.type);
    
setstring this.owner,Baddy
    }
  }
}

//#CLIENTSIDE
 // 0,0 was used not know weather it was a weapon or local npc
 
if(createdtriggeraction 0,0,serverside,Baddy Placer,baddy

It's not clientside it is all serverside.
There is no client activity involved other than...
The only flags used are (created) (playerenters) and (timeout) and vars used , playercount in the level, timeout.

It isn't in a function inside the actual NPC, the script is inside of a timeout , and doesn't use any functions or triggeractions.

The function above was an example rather than showing
if (playerenters||timeout) {} and going through the trouble of adding timeout = ect.... because the problem was not / is not located there it is rather the fact that with(npcs[npcscount-1]){ is not working ahead of the (created) of the newly placed npc.... (everything else i said above)

However I don't see how it being a function has anything to do with it ??
__________________

To the sun of your age, I arise
Reply With Quote
  #6  
Old 01-24-2005, 03:05 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
Quote:
Originally Posted by TB3
Its not clientside it is all serverside, there is no client activity involved other than the playercount in the level. It isn't in a function inside the actual NPC it is inside of a timeout , and doesn't use any functions or triggeractions.

However I don't see how it being a function has anything to do with it ??
uhh it doesn't the way you posted it led me to believe that because functions are clientside and you used a function, next time post correctly
__________________

Reply With Quote
  #7  
Old 01-24-2005, 03:12 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 ZeroTrack
uhh it doesn't the way you posted it led me to believe that because functions are clientside and you used a function, next time post correctly
The way I posted it does not contain //#CLIENTSIDE anywhere.
Functions are not clientside they are serversided and clientsided
__________________

To the sun of your age, I arise
Reply With Quote
  #8  
Old 01-24-2005, 04:16 AM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
How did you think he was using putnpc2 and with() clientside?

Not only is that not possible in general, if you had read his post (key step) you would see that it's completely impossible that this script is clientside.

Come on, I thought you knew how to script.
__________________

Reply With Quote
  #9  
Old 01-24-2005, 04:22 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by ZeroTrack
because functions are clientside
You call yourself a scripter?

Edit:
I would do this
PHP Code:
function spawn() { 
  
setstring this.type,Undead
  
putnpc2 x,y,{ 
  
join temporary
  
join baddy
  }; 
  
with(npcs[npcscount-1]) { 
    
setstring this.type,#s(thiso.type); 
    
setstring this.owner,Baddy
    
callnpc -1,typeset;
  } 


//class
if(typesetsendtonc Type#s(this.type); 
Reply With Quote
  #10  
Old 01-24-2005, 04:42 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 Python523
You call yourself a scripter?

Edit:
I would do this
PHP Code:
function spawn() { 
  
setstring this.type,Undead
  
putnpc2 x,y,{ 
  
join temporary
  
join baddy
  }; 
  
with(npcs[npcscount-1]) { 
    
setstring this.type,#s(thiso.type); 
    
setstring this.owner,Baddy
    
callnpc -1,typeset;
  } 


//class
if(typesetsendtonc Type#s(this.type); 
K i may try that out , however with the way the baddy is scripted together i would have to say put a this.active=1; inside of that typeset and also a if (this.active==1) {}
around everything else in the script , because if its created priority messes up might its playerenters also since it would be called at the same time (after created) ?

[edit]
I will try this l8r if no one else posts a solution, however if the problem is that it is getting the wrong npc (IE.. 2 npcs being spawned at same time) then it still wouldnt fix : (
The problem runs a bit deeper as the baddies are logged into a database and are removed after death / or on invalidity , being they are invalid when being placed they do not remove the correct string set by the placing npc. Thus the spawn npc gets stuck thinking there are more baddies than there realy is in the room and new ones dont spawn.
[/edit]
__________________

To the sun of your age, I arise
Reply With Quote
  #11  
Old 01-24-2005, 04:57 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 ZeroTrack
uhh it doesn't the way you posted it led me to believe that because functions are clientside and you used a function, next time post correctly
Uh. Functions work both serverside and clientside, man. Also, how does one 'post correctly'? I'm not totally sure what you mean by that directive, but I think you just violated it.
Reply With Quote
  #12  
Old 01-24-2005, 04:59 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Are you sure you have a string nameed thiso.type?
From what you posted, it looks like you misspelled it.
Reply With Quote
  #13  
Old 01-24-2005, 05:02 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 Tolnaftate2004
Are you sure you have a string nameed thiso.type?
From what you posted, it looks like you misspelled it.
o_O thiso.type is getting the flag from the original npc that is using with().
So im setting this.type in the new npc from the this.type of the old npc that way.
Excerpt From Dach Commands.rtf:
this.flag flags that only exist on server-side and belong to the npc, and are stored when the npc is a database npc
thiso.flag refer to the this. flags of the executing npc when you use the with () command: with (getnpc(npc2)) setstring thiso.temp,this.temp; will copy 'this.temp' from npc2 to the current npc
__________________

To the sun of your age, I arise
Reply With Quote
  #14  
Old 01-24-2005, 07:25 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
Im doing some extensive testing with the bug now that there are not many people on. Im using timevar2 and ids to show me the exact time that created is called and the exact time that int is called. So now If only one of them is called then I know for sure that its not getting the correct npc in the with()

[edit]
I have found the problem. I set it to send to nc; everytime both created and call npc was called ; the id of the npc.
If both were not called and only one was called it auto removed showing the this.type ect....
This is what i got after about 50 npcs lolz XD.
NPC Code:

Double Int - ID : 100098
Double Int - ID : 100653
[Invalid Baddy]: Name: from spawner | Debug: | Actual: 211/565 mal.gmap | ID: 100654
Double Int - ID : 100940
Double Int - ID : 100062



What this means is that in baddy 100654 only created was called and the callnpc -1 wasn't nor the strings set.
Meaning that with(npcs[npcscount-1]) was not getting the correct npc!
[/edit]

[edit2]
Ran another test adding to a variable on each call created & callnpc and every so many baddies one screws up and with() gets the wrong npc apparently as no strings are set and the call isnt made ....
[/edit2]
Thus..... WTF DO I DO???? HELP? Stefan ? Eh someone ?
__________________

To the sun of your age, I arise

Last edited by TB3; 01-24-2005 at 08:00 AM..
Reply With Quote
  #15  
Old 01-24-2005, 08:10 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
I'm with Jagen. Don't use if (created) because it is created before strings are set using the with() statement. It would only work because it's run really quickly but in theory it shouldn't. The callnpcs then it needed. When I do this I do not use the if (created) I use like if (started) and callnpc -1,started type thing so it will call a new statement after it sets the variables.
Also please note that is the pattern "Stefan uses" I believe. I do not think he would be unable to code his own engine properly
__________________
Who has time for life these days?
Reply With Quote
  #16  
Old 01-24-2005, 08:14 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 with Jagen. Don't use if (created) because it is created before strings are set using the with() statement. It would only work because it's run really quickly but in theory it shouldn't. The callnpcs then it needed. When I do this I do not use the if (created) I use like if (started) and callnpc -1,started type thing so it will call a new statement after it sets the variables.
Also please note that is the pattern "Stefan uses" I believe. I do not think he would be unable to code his own engine properly
I did use that but it was not calling the npc, thats why I'm so confused. if (created) was the only thing being called .

The callnpc was being called most of the time but after so many npcs it misses one or 2 randomly. 1 or 2 npcs every few minutes = alot after a few hours : (
__________________

To the sun of your age, I arise
Reply With Quote
  #17  
Old 01-24-2005, 08:30 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
I did use that but it was not calling the npc, thats why I'm so confused. if (created) was the only thing being called .

The callnpc was being called most of the time but after so many npcs it misses one or 2 randomly. 1 or 2 npcs every few minutes = alot after a few hours : (
Perhaps you have a bug in another part of your script? I've found small errors in things I've made that just make it miss a few cycles because it stalls at some points then when the action happens the next time it puts it back in the loop. Perhaps you should have it do a sendtonc message and have it make like 50 and just see if it does loop it each time or if it just won't hit the process instead due to another error?
__________________
Who has time for life these days?
Reply With Quote
  #18  
Old 01-24-2005, 02: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
Global staff please stop posting BAD script!

The original script is perfectly fine, but shouldn't be bugged.
The current script is not interrupted, so of course the if (created) should see all variables set. A "callnpc" is completely nonsense.
The only reason for the spawn function not working would be if you call it from a bad place, e.g. "with (anothernpc) { spawn(); }" because then "setstring this.type,Undead;" would not set thiso.type. Eventually replace it with
"setstring thiso.type,Undead;". Check in the script that is putting the npc if the string is actually set.
Reply With Quote
  #19  
Old 01-24-2005, 03:21 PM
Sern Sern is offline
Banned
Join Date: Jan 2005
Location: LongIsland, NY
Posts: 2
Sern is on a distinguished road
Send a message via AIM to Sern
it would be nice if gobals didnt try to bash everyone who didnt know the excat syntax for every little thing, i never bothered trying functions serverside cause i just figured that it wouldnt be , oh god sue me , hence why i asked him to post correctly , gobals are supposed to be elitests there supposed to be professional and help people, no offence to ProjectShifter cause hes the only gst i ever see going around helping people on forums and on servers, thanks for being true PS
Reply With Quote
  #20  
Old 01-24-2005, 03:43 PM
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 Sern
it would be nice if gobals didnt try to bash everyone who didnt know the excat syntax for every little thing, i never bothered trying functions serverside cause i just figured that it wouldnt be
So if you've never done something, you automatically assume that it is impossible?

Being wrong (however spectacularly) wasn't your biggest sin here. If people are criticising you then it is mostly because:
  1. You pushed your false beliefs on other people
  2. You scolded another person for correcting you

Nobody expects you to be perfect. Nobody even expects you to be good. It is your belligerence and overconfidence that makes you a target, not your lack of skill.
__________________
Reply With Quote
  #21  
Old 01-24-2005, 04:30 PM
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
Unhappy

Quote:
Originally Posted by Stefan
Global staff please stop posting BAD script!

The original script is perfectly fine, but shouldn't be bugged.
The current script is not interrupted, so of course the if (created) should see all variables set. A "callnpc" is completely nonsense.
The only reason for the spawn function not working would be if you call it from a bad place, e.g. "with (anothernpc) { spawn(); }" because then "setstring this.type,Undead;" would not set thiso.type. Eventually replace it with
"setstring thiso.type,Undead;". Check in the script that is putting the npc if the string is actually set.
Yes the string is actualy set in the previous npc, it also sets a debug string with its x , y , level, and params used in the spawns calcualtion that is also missing in those npcs that get bugged.

If the string is blank in the "Spawning" npc whether it is the type or the spawnid (which is a string also set (that is missing in those few bugged npcs) with xylevelname) an error message is sent to RC. Which luckily the only one to have that problem was the one I intentionaly made to check if the error check worked.

Example Taken from Baddy that errored / removed itself because it was missing its strings : [Invalid Baddy]: Name: from spawner | Debug: | Actual: 214/161 mal_dungeon5.gmap |ID:100278|Active:1
The name is the type which doesnt get set same as the debug message which is blank, the other stuff is the npcs base attributes.
Its strings do not get set and it automaticaly removes itself reporting its error.

with() seems to be getting an incorrect npc and setting its strings thats the only explanation that seems fit. No clue why or how. Stefan if you wish to see the spawning npc it is class : system_spawn
But it isn't that much more to the npc other than a few randomish timers based on player count and some calculations for baddy spawn. ect....
__________________

To the sun of your age, I arise
Reply With Quote
  #22  
Old 01-24-2005, 10:24 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
Nobody expects you to be perfect. Nobody even expects you to be good. It is your belligerence and overconfidence that makes you a target, not your lack of skill.
I agree (kind of) but I still don't see anything about bashing in "Show off your best NPCs or ask the experts". Do you?
Reply With Quote
  #23  
Old 01-25-2005, 12:00 AM
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
Quote:
Originally Posted by TB3
with() seems to be getting an incorrect npc and setting its strings thats the only explanation that seems fit.
The perfect implementation would include getting npcscount before adding the new npc, because the level might not be in memory and adding the npc might swap in some new local npcs (accessing npcscount is one of the acitivities which is loading the level into memory). Can you try this :
NPC Code:

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


I have never had problems with the npcs[npcscount-1] yet though, so it must be a special case
Reply With Quote
  #24  
Old 01-25-2005, 12:01 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 Stefan
Global staff please stop posting BAD script!

The original script is perfectly fine, but shouldn't be bugged.
The current script is not interrupted, so of course the if (created) should see all variables set. A "callnpc" is completely nonsense.
The only reason for the spawn function not working would be if you call it from a bad place, e.g. "with (anothernpc) { spawn(); }" because then "setstring this.type,Undead;" would not set thiso.type. Eventually replace it with
"setstring thiso.type,Undead;". Check in the script that is putting the npc if the string is actually set.
I realize this is your engine, so you know how it should work, we're just speaking from experience of what we have used and what has worked best in the past. Generally there are some errors in doing functions and transfering variables if you try to do it all with the putnpc2 command. For some reason it just doesn't like setting variables without going back and setting them, and then it doesn't make plausible sense if you create the object (it SHOULD run if (created) at that point) and then add strings and expect it to be effected and read by the if (created)? Without knowing the logistics behind the engine I can say that it makes little sense even if it runs at an incredible speed, it just logically doesn't add up.
__________________
Who has time for life these days?
Reply With Quote
  #25  
Old 01-25-2005, 12:03 AM
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
Quote:
Originally Posted by Projectshifter
I realize this is your engine, so you know how it should work, we're just speaking from experience of what we have used and what has worked best in the past. Generally there are some errors in doing functions and transfering variables if you try to do it all with the putnpc2 command. For some reason it just doesn't like setting variables without going back and setting them, and then it doesn't make plausible sense if you create the object (it SHOULD run if (created) at that point) and then add strings and expect it to be effected and read by the if (created)? Without knowing the logistics behind the engine I can say that it makes little sense even if it runs at an incredible speed, it just logically doesn't add up.
It would still be better to first test before saying wrong things x-x
Reply With Quote
  #26  
Old 01-25-2005, 12:14 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 Stefan
It would still be better to first test before saying wrong things x-x
Arg "wrong thigns" assumes it doesn't work, although it does =/ I am on playerworlds everyday. I have tested this before, but we'll finish this on debug.
__________________
Who has time for life these days?
Reply With Quote
  #27  
Old 01-25-2005, 12:18 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 Stefan
oldnpcscount = npcscount;
putnpc2 ...
if (npcscount>oldnpcscount) with (npcs[oldnpcsount]) { ... }
Im going to try this now , however the bug only happened about 40-50+ npcs or so so it may take a half hour dunno.
[EDIT]
O_O HOLY CHRIST THAT SCREWED EVERYTHING UP o_o .
It put baddies down with no strings everytime that way O_O
[/edit]
__________________

To the sun of your age, I arise

Last edited by TB3; 01-25-2005 at 12:30 AM..
Reply With Quote
  #28  
Old 01-25-2005, 12:47 AM
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
Quote:
Originally Posted by TB3
Im going to try this now , however the bug only happened about 40-50+ npcs or so so it may take a half hour dunno.
[EDIT]
O_O HOLY CHRIST THAT SCREWED EVERYTHING UP o_o .
It put baddies down with no strings everytime that way O_O
[/edit]
Works fine for me
Reply With Quote
  #29  
Old 01-25-2005, 01:46 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 Stefan
Works fine for me

Psssttt thats because you took out the
if (npcscount>oldnpcscount)
and did it XD

Btw thanks I'll report any other findings XD
__________________

To the sun of your age, I arise
Reply With Quote
  #30  
Old 01-25-2005, 07:32 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
Psssttt thats because you took out the
if (npcscount>oldnpcscount)
and did it XD

Btw thanks I'll report any other findings XD
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.
__________________
Who has time for life these days?
Reply With Quote
  #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
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 08:55 PM.


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