Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
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
  #2  
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:35 PM.


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