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 09-14-2010, 01:39 AM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
Npc |Server - Clientside| Communication

Hey guys!

I'm just making a baddysystem. So I'm wondering how you communicate between Clientside and Serverside in an npc class. To make a bit more understandable:

Baddy Class ( if the baddy gets hit)
PHP Code:
function onActionhurt()
{
if (
this.npchp params[0])
{
this.npchp -= params[0];
this.chat this.npchp;
}
else
{
this.npchp this.npchpmax;
this.chat this.npchp;
"-xpcalculator".Actionxp(this.npclevel);
}

Aight, so basicly what im doin is, whenever the baddy dies, it calls the public function "Actionxp" of the weapon "-xpcalculator". So everything works fine, if the baddy class is //#CLIENTSIDE. The problem is i dont want my baddies clientside, so my aim is to remove the //#CLIENTSIDE but if i do it he cant find the public function "Actionxp" anymore. Hope you got me and hope you got any resolutions for that

So far...
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #2  
Old 09-14-2010, 01:49 AM
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
Move the "Actionxp" function to the serverside portion of the -xpcalculator script. You should be doing things like that on serverside anyway.
__________________
Reply With Quote
  #3  
Old 09-14-2010, 01:57 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
When you're developing an EXP system you should have all those functions in a player-joined class. Here have some bare-bones for one.

class: playerfunctions
PHP Code:
public function getEXP() {
  return 
clientr.stat.exp;
}

public function 
getLevel() {
  return 
clientr.stat.level;
}

public function 
addEXP(amount) {
  
clientr.stat.exp += amount;
  
checkEXP();
}

public function 
setEXP(amount) {
  
clientr.stat.exp amount;
}

public function 
checkEXP() {
  if (
getEXP() > EXPRequired()) {
    
levelUP();
  }
}

public function 
getEXPRequired() {
  
// Add a custom formula here.
  
return 10000;
}

public function 
levelUP() {
  
setEXP(0);
  
clientr.stat.level++;
  
clientr.stat.expneeded getEXPRequired();

then in your Control-NPC:

PHP Code:
function onActionPlayerOnline() {
  
player.join("playerfunctions");

then in other scripts when you know the attacker or what not

PHP Code:
function onBaddyKilled(killedby) {
  
findplayer(killedby).addEXP(100);

__________________
Quote:
Reply With Quote
  #4  
Old 09-14-2010, 02:00 AM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
aight i see, simple as that.

Thanks =)
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #5  
Old 09-14-2010, 09:05 AM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
Okay, yet another problem:

I surfed about 1hour in the forums now, but still can't find any good resolution. So for my baddyclass script i need Serverside > Clientside communication ( local npcs that joins baddyclass) . I found out that you can use attr[] , tried it but it seems i can only set them once and then cant change them anymore...
then i read that triggerAction would work from Serverside to Clientside aswell , well i tried it and nope unfortunately it doesnt seem to work.
At this point i just doubled everything like what i wrote clientside i wrote serverside aswell so it works in both purposes but this cant obviously be the best solution for it.

Hope you got any good ideas
__________________
You cannot Prevent and Prepare for War at the same Time.

Last edited by Deathborn123; 09-14-2010 at 11:01 AM..
Reply With Quote
  #6  
Old 09-14-2010, 11:46 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
Look up Inverns Clientside <-> Serverside thread in the code gallery, should be helpful, but what your could do, is if you start client side in a class use triggerserver(); to a weapon, then trigger down to the client (triggerclient() in that weapon then call the function from the class. Or vice versa if starting serverside
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #7  
Old 09-14-2010, 01:02 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
What do you need to do on the client in your baddy script? Chances are it can be done better on the server.
__________________
Reply With Quote
  #8  
Old 09-15-2010, 04:19 PM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
Yea the Problem is i need things like The hitdetection for the npc clientside aswell as dead animation and stuff
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #9  
Old 09-15-2010, 11:01 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 Deathborn123 View Post
Yea the Problem is i need things like The hitdetection for the npc clientside aswell as dead animation and stuff
Why?
__________________
Reply With Quote
  #10  
Old 09-16-2010, 10:29 PM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
How would you do an ani Serverside? And the hitdetection though, im doin it via triggeraction and as you will know, it'll bug out if more than one levelnpc is in the level.

thats why i'm doin it clientside, if you have any other suggestions your welcome
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #11  
Old 09-16-2010, 11:12 PM
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
All the same commands (setcharani) and the triggeraction will hit both the client-side and server-side functions provided there's a set shape or character for it to hit.
__________________
Quote:
Reply With Quote
  #12  
Old 09-17-2010, 04:05 PM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
Triggeraction wont work cause im triggering via this.x and this.y which wont work if the baddy is walking :o
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #13  
Old 09-17-2010, 05:57 PM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
aight. so i just made everything work Clientside now. Its all fine except i thought i could easily just use an public image id (<200) and then everything would be perfect; every player would see the same healthstatus of the baddy but unfortunately im wrong :/

any help?
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #14  
Old 09-18-2010, 12:50 AM
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
Maybe try something like this.


Quote:
Originally Posted by cbk1994 View Post
You can also do

PHP Code:
function onCreated() {
  
this.level.tapThis this;
}

function 
onPow() {
  
this.chat "ouch!";
}

//#CLIENTSIDE
function onPlayerChats() {
  
triggerServer("npc""TriggerControl""Trigger"this.level.name"tapThis""Pow");

and then in an NPC TriggerControl

PHP Code:
function onActionTrigger(levelNamenpcNamecommand) {
  
findLevel(levelName).(@ npcName).trigger(command);

Though you'd want to add some security features. Usually something like this is preferable since you never know if a trigger will be received when using x/y.
__________________
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 04:24 AM.


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