Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-05-2009, 06:26 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
PutNPC to DBNPC communication

How would that be done? I tried having the putNPCs findNPC the DBNPC, but I don't think they're quite reaching...could someone provide a code sample? I mean, I could probably get the desired results with server strings, but eww...

putNPC:
on created, send the DBNPC some sorta ID.
on hit or whatever, right before destroying itself, let the DBNPC know

DBNPC:
When a request comes in from a player's weapon let's say, should be able to find and manipulate the putNPCs in its list no matter where they are. Like, the player says "NPC #6587, move to the right", and it should despite the DBNPC and the player being in different levels from the putNPC.

Or am I going about my ultimate goal in the silliest way possible, and the server side of a weapon can Easily search all NPCs on the server, compile a list, and tell them what to do? :-P
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #2  
Old 04-05-2009, 06:56 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Well, in the DBNPC you can store the classes object. And manipulate it from there...

Like, in the class, you could have.
PHP Code:
function onCreated()
  
findNPC("npc_name").testvariable this
and in the dbnpc have
PHP Code:
function onManipulateClass()
{
  
with(this.testvariable)
    
this.chat "[test]";

__________________

Reply With Quote
  #3  
Old 04-05-2009, 07:23 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Hmm, and npc_name is the dbNPC's name? I'll have to give that a try.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #4  
Old 04-05-2009, 08:13 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
If you're trying to do what I think you're trying to do, I would probably do this:

In the class that is being joined via putnpc's
PHP Code:
//Store the NPC's name along with some way to indentify it in a database
function onCreated() {
  (@ 
"DBNPC_NAME").(@ this.level.name "_" this.id) = this.name;

In a weapon:
PHP Code:
function getNPCNPC_LEVELNPC_ID ) {
  
//Get the NPC's name
  
temp.npcname = (@ "DBNPC_NAME").(@ NPC_LEVEL "_" NPC_ID);
  
  
//Get the actual NPC object
  
temp.npc findNPCnpcname );

  
//Bam
  
npc.DoServerSideStuff();

Reply With Quote
  #5  
Old 04-05-2009, 10:04 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Goodness! While elucidating, Jazz's solution works quite well as it stands; I think I have enough code now to lump together some sort of "Find all NPCs in the database, show an arrow pointing to the closest such NPC, tell that NPC to run the "stand still" script" code...
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #6  
Old 04-05-2009, 06:09 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
I did, in fact, write an example implementation of this a while ago on the wiki: http://wiki.graal.net/index.php/Crea..._Communication
Reply With Quote
  #7  
Old 04-05-2009, 08:33 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
You do not need to use findnpc or the (@ "var") syntax if the NPC or weapon name is standard.

Here is my implementation for the class, just showing how the NPC is registered:
PHP Code:
function onCreated() {
  
dbnpc_name.register(this);

In the dbnpc:
PHP Code:
public function register(npcobj) {
  
this.(@ "n" npcobj.id) = npcobj;

I think it is better to be using functions in this case.
__________________
Reply With Quote
  #8  
Old 04-05-2009, 10:05 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Huh. I tried using functions in the first place and they didn't seem to findNPC each other...
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #9  
Old 04-05-2009, 11:49 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tyhm View Post
Huh. I tried using functions in the first place and they didn't seem to findNPC each other...
I don't know what you mean by "didn't seem to findNPC each other."
__________________
Reply With Quote
  #10  
Old 04-06-2009, 02:23 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
I mean I used to have it set up such that
the putnpc
function oncreated(){
//etc
ZombieControl.addMob(this);
//etc
}

ZombieControl
public function addMob(param1){
this.mobs.add(param1);
}

Maybe I didn't have it as a public function, maybe that was the whole problem. Pretty sure I did, but I've been wrong before. ;
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #11  
Old 04-06-2009, 09:45 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Hrm... a mob? Maybe you don't actually need a database and to just trigger the other monsters in the mob, if that makes any sense?
Reply With Quote
  #12  
Old 04-06-2009, 11:21 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
The mob's just one NPC that displays multiple items in its area, and the trouble with triggering is telling NPCs in other levels what to do.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #13  
Old 04-06-2009, 07:39 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Hmm you could just do something like this in the class script

HTML Code:
//NPC.addMember(this); to call it
public function addMember(id) {
  this.moblist.add(id);
}

public function onCallMob() {
  for (temp.npc: this.moblist) temp.npc.trigger("YourTrigger", "");
}

public function onYourTrigger() {
  //Hell Yeah!
}
Reply With Quote
  #14  
Old 04-06-2009, 09:39 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tyhm View Post
I mean I used to have it set up such that
the putnpc
function oncreated(){
//etc
ZombieControl.addMob(this);
//etc
}

ZombieControl
public function addMob(param1){
this.mobs.add(param1);
}

Maybe I didn't have it as a public function, maybe that was the whole problem. Pretty sure I did, but I've been wrong before. ;
That looks fine to me, also make sure you check if it is already in the list.
__________________
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 07:26 PM.


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