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
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 01:39 AM.


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