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-31-2007, 09:48 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Send params to putnpc2?

I'm creating a projectile using putnpc2 but I want to send some data to it. It cant read from player.attr.

Is there any way to send some parameters to an NPC created using putnpc2 with a joined class?

Thanks
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #2  
Old 01-31-2007, 09:54 PM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
I doubt its the most efficient, but you could always pass them to a DB NPC and use

this.variable = FindNPC("NPC").variable;

or set them to a temporary server variable?
__________________
Reply With Quote
  #3  
Old 01-31-2007, 09:59 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
but how do i identify the npc when using findnpc?

There could be more than one instance of the projectile class.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #4  
Old 01-31-2007, 10:02 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
when the npc was created, make it save the npc id it was :o ( (npccount - 1) I think?), then use the npc id :]
__________________
Reply With Quote
  #5  
Old 01-31-2007, 10:09 PM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by JkWhoSaysNi View Post
but how do i identify the npc when using findnpc?

There could be more than one instance of the projectile class.
Well this is what i mean for example

PHP Code:
function onActionServerside() {
 
FindNPC("Params").power clientr.power;
}
//#CLIENTSIDE
function onWeaponFired() {
 
triggerserver("gui"this.name"power");
 
putnpc2...

Then in the class you have something like

PHP Code:
function onCreated() {
 
this.power FindNPC("Params").power;

Hope thats what you were asking anyways and im not making it needlessly complex.
__________________
Reply With Quote
  #6  
Old 01-31-2007, 10:12 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
You mean..

HTML Code:
with (putnpc2(x, y, "join someclass;"))
{
  this.something = somevar;
  this.somefunc();
}
or
HTML Code:
temp.npc putnpc2(x, y, "join someclass;");
  temp.npc.something = somevar;
  temp.npc.somefunc();
Reply With Quote
  #7  
Old 01-31-2007, 10:13 PM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
NPC Code:

thiso.param = "rawrs";
with (npcs[npcs.size()-1]) {
this.string = thiso.param;
}


or so
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #8  
Old 01-31-2007, 10:13 PM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
Quote:
Originally Posted by Riot View Post
You mean..

HTML Code:
with (putnpc2(x, y, "join someclass;"))
{
  this.something = somevar;
  this.somefunc();
}
or
HTML Code:
temp.npc putnpc2(x, y, "join someclass;");
  temp.npc.something = somevar;
  temp.npc.somefunc();
with (putnpc2) works?
"join(\"someclass\");"
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #9  
Old 01-31-2007, 10:15 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 hotrian View Post
"join(\"someclass\");"
It should be "this.join(\"someclass\");", but what is the point in overcomplicating it when "join someclass;" is clearer in the case of putnpc2()?
__________________
Skyld
Reply With Quote
  #10  
Old 01-31-2007, 10:16 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally Posted by hotrian View Post
with (putnpc2) works?
"join(\"someclass\");"
putnpc2 returns the object of the NPC. And I prefer to just use the old join as it looks better than "join(\"someclass\");".
Reply With Quote
  #11  
Old 01-31-2007, 10:16 PM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
Quote:
Originally Posted by Skyld View Post
It should be "this.join(\"someclass\");", but what is the point in overcomplicating it when "join someclass;" is clearer in the case of putnpc2()?
why this., doesnt it already assume? Or is it instead joining the script to the script that called it or so?

@Riot
Yea? I didn't know you could pull the object of a putnpc2
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #12  
Old 01-31-2007, 10:17 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 hotrian View Post
why this., doesnt it already assume? Or is it instead joining the script to the script that called it or so?
Because you should specify the object you're working with for clarity, and I guess easier later editing.
__________________
Skyld
Reply With Quote
  #13  
Old 01-31-2007, 10:17 PM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
Quote:
Originally Posted by Skyld View Post
Because you should specify the object you're working with for clarity, and I guess easier later editing.
But doesn't it already know..? Its always worked for me without it XD
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #14  
Old 01-31-2007, 10:18 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 hotrian View Post
But doesn't it already know..? Its always worked for me without it XD
It will work, yes, but like I said, you should be clear on what you're working with, for at least clarity and consistency.
__________________
Skyld
Reply With Quote
  #15  
Old 01-31-2007, 10:26 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
ok, I found a better way.


looks messy, but works and should be more efficient than findnpc()

PHP Code:
putnpc2(player.x,player.y,"join(\"test_projectile2\"); this.value=" this.value ";"); 
edit: I didn't see Skyld's posts.
__________________

Coming soon (Hopefully:P)
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:04 AM.


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