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 04-23-2009, 07:04 AM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
triggerserver/client

Why don't these two functions work in NPCs too?
I find it kinda dumb that you have to do: triggeraction(this.x, this.y...)
:o
Reply With Quote
  #2  
Old 04-23-2009, 09:58 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
They do work.

PHP Code:
findPlayer("cbk1994").triggerclient("gui""-System""blueDeath"); 
You can never trigger serverside from serverside; use this instead.
PHP Code:
(@ "-System").trigger("onActionServerSide""meow"); 
__________________
Reply With Quote
  #3  
Old 04-23-2009, 10:05 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
They do work.

PHP Code:
findPlayer("cbk1994").triggerclient("gui""-System""blueDeath"); 
You can never trigger serverside from serverside; use this instead.
PHP Code:
(@ "-System").trigger("onActionServerSide""meow"); 
Well, he wants to use them to trigger the serverside/clientside in an NPC using another or the same NPC. Which does not work.
__________________
Reply With Quote
  #4  
Old 04-23-2009, 10:14 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Crow View Post
Well, he wants to use them to trigger the serverside/clientside in an NPC using another or the same NPC. Which does not work.
From a level NPC or a DB NPC?

EDIT: I think I get it ... yeah, I agree, it would be cool if there was a way to do this easily.
__________________
Reply With Quote
  #5  
Old 04-23-2009, 10:50 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 Crow View Post
Well, he wants to use them to trigger the serverside/clientside in an NPC using another or the same NPC. Which does not work.
Well it's possible if you have a weapon between the two npcs. From client to server you'd need to send the npc's level name and ID, and from server to client only the npc's ID; this is so the npc object can be located.
__________________
Reply With Quote
  #6  
Old 04-23-2009, 10:54 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
You can trigger npcs, you just need to know the (serverside) name of the npc: triggerserver("npc", npcname, eventname, params..)
Reply With Quote
  #7  
Old 04-23-2009, 11:29 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stefan View Post
You can trigger npcs, you just need to know the (serverside) name of the npc: triggerserver("npc", npcname, eventname, params..)
I don't think this works with local level NPCs.
__________________
Reply With Quote
  #8  
Old 04-24-2009, 02:18 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
I don't think this works with local level NPCs.
Pretty sure it does not. Level NPCs all have "unknown" as their name I think.
__________________
Reply With Quote
  #9  
Old 04-25-2009, 05:42 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well if the this.name isn't that same on the clientside you could store their .name in an attr and do..

PHP Code:
function onCreated() {
  
attr[3] = this.name;
}
//#CLIENTSIDE
function onDamageNPC(baddy) {
  
triggerserver("npc"baddy.attr[3], "damage"9999);

Of course you'll need some sort of targetting system to use the damage npc function.
__________________
Quote:
Reply With Quote
  #10  
Old 04-25-2009, 09:39 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
Instead of doing the above you'd rather just use triggeraction...
Reply With Quote
  #11  
Old 04-25-2009, 10:09 AM
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
This is demonstrating how you would have an npc call a weapon function to trigger an event on its serverside or clientside.

This is the weapon script.
PHP Code:
public function npctriggerclient(npcidevtnameparams...) {
  
triggerclient("gui"this.name"ntc"npcidevtnameparams...);
}
public function 
npctriggerclientother(accnpcidevtnameparams...) {
  
with (findplayer(acc)) {
    
triggerclient("gui"this.name"ntc"npcidevtnameparams...);
  }
}
function 
onActionServerside() {
  
temp.0;

  if (
params[0] == "nts") {
    for (
ifindlevel(params[1]).npcs) {
      if (
i.id == params[2]) {
        
i.trigger(params[3], params[...]);
        break;
      }
    }
  }
}
//#CLIENTSIDE
function onActionClientside() {
  if (
params[0] == "ntc") {
    
findnpcbyid(params[1]).trigger(params[2], params[...]);
  }
}
public function 
npctriggerserver(npclvlnpcidevtnameparams...) {
  
triggerserver("gui"this.name"nts"npclvlnpcidevtnameparams...);

Considering how npc ids are local to the level, I don't think the server to client part would work the same. In that case you would need to manually assign a unique name for the npc, since findlevel() does not appear to exist on clientside.

In the npc in it's created you would do something like:
PHP Code:
(@ "localnpc" extractfilebase(this.level.name) @ this.id) = this
A class could be used for that. And would probably be better to be using a global TStaticVar to put those vars on:
PHP Code:
// In the system weapon on created:
if (player.objectmap.type() != 2)
  
player.objectmap = new TStaticVar("ObjectMap"); 
Then we do:
PHP Code:
// In a local npc on created:
ObjectMap.(@ "localnpc" extractfilebase(this.level.name) @ this.id) = this
Though in the end it would be easier to have an Interop weapon or so and have npcs register with it when they're created and it will have functions for triggering the npc's other side and stuff.
Quote:
Originally Posted by [email protected] View Post
Instead of doing the above you'd rather just use triggeraction...
First post.
__________________

Last edited by Inverness; 04-25-2009 at 10:29 AM..
Reply With Quote
  #12  
Old 04-25-2009, 10:21 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
Oh- I see what you're trying to do.
Makes sense- interesting solution @ Inverness
Reply With Quote
  #13  
Old 04-25-2009, 11:28 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Inverness View Post
This is demonstrating how you would have an npc call a weapon function to trigger an event on its serverside or clientside.

This is the weapon script.
PHP Code:
public function npctriggerclient(npcidevtnameparams...) {
  
triggerclient("gui"this.name"ntc"npcidevtnameparams...);
}
public function 
npctriggerclientother(accnpcidevtnameparams...) {
  
with (findplayer(acc)) {
    
triggerclient("gui"this.name"ntc"npcidevtnameparams...);
  }
}
function 
onActionServerside() {
  
temp.0;

  if (
params[0] == "nts") {
    for (
ifindlevel(params[1]).npcs) {
      if (
i.id == params[2]) {
        
i.trigger(params[3], params[...]);
        break;
      }
    }
  }
}
//#CLIENTSIDE
function onActionClientside() {
  if (
params[0] == "ntc") {
    
findnpcbyid(params[1]).trigger(params[2], params[...]);
  }
}
public function 
npctriggerserver(npclvlnpcidevtnameparams...) {
  
triggerserver("gui"this.name"nts"npclvlnpcidevtnameparams...);

Considering how npc ids are local to the level, I don't think the server to client part would work the same. In that case you would need to manually assign a unique name for the npc, since findlevel() does not appear to exist on clientside.

In the npc in it's created you would do something like:
PHP Code:
(@ "localnpc" extractfilebase(this.level.name) @ this.id) = this
A class could be used for that. And would probably be better to be using a global TStaticVar to put those vars on:
PHP Code:
// In the system weapon on created:
if (player.objectmap.type() != 2)
  
player.objectmap = new TStaticVar("ObjectMap"); 
Then we do:
PHP Code:
// In a local npc on created:
ObjectMap.(@ "localnpc" extractfilebase(this.level.name) @ this.id) = this
Though in the end it would be easier to have an Interop weapon or so and have npcs register with it when they're created and it will have functions for triggering the npc's other side and stuff.
First post.
I actually like this solution.
I just don't see why Stefan can't make triggerserver/client work in every NPC just as easy as it works in the Weapons.
Why is the Serverside name not the Clientside Name?
Kinda confusing, isn't it?
Reply With Quote
  #14  
Old 04-25-2009, 09:59 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 Pelikano View Post
Why is the Serverside name not the Clientside Name?
Kinda confusing, isn't it?
What do you mean? Local npcs do not have names, they're identified by their ID in relation to the level they're in.
__________________
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 09:19 AM.


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