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-18-2008, 06:25 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Rescripting default baddies

Well, I think every classic server would benefit from the default baddies being rescripted in GS2... so I thought I would discuss some here.
My main curiosity is whether they should be serverside or clientside. I'll post my opinions about both:

serverside:
- Baddies will be able to be taken down with others
- baddies will be, of course, 'synced' for all players. If you see a baddy there, so will everyone else.
- can be used for 'multi-player' dungeons, where it takes more than one player to beat it. On the clientside... this can be done, but everyone will be doing their own thing when it comes to killing the baddies.
- Jumpy movement. Since there is a min 0.1 timeout on serverside, movement wouldn't be as smooth.
- Biggest factor: because it's on the serverside, lagging will have a big effect on how the baddy operates. If you lag, the experience can be easily ruined as things like attacks and such are delayed from server to client.

clientside:
- one person won't be able to clear the way for others
- usages will be much more 'one-player' type of feel.
- no walking through a whole dungeon without encountering a baddy because someone else killed them
- smoother movement, of course!
- you will be the only target. Could easily be scripted to chase other players, but since it's on the clientside... other players won't be seeing the same thing you are so it won't make sense.
- fast response. Even if you're lagging, since the baddy is operating on the clientside you won't notice any negative sideeffects(except for serverside things like drops).

I've also had an idea of syncing clientside and serverside info on movement/position so I could get the benefit of clientside and serverside... but since you can only send data to the clientside through attr's... I don't think that worked.
Anyways, I think getting these done will help a lot, and I'm willing to collaborate ideas with anyone here to get them done. I don't care about getting the details done, I can get the middle-stuff done... I'm more worried about creating a baddy that takes the best of both worlds, though feel free to discuss anything else about them. If you want me to post my details about what I've learned with baddies since I've been studying them, just post so and I will.
Reply With Quote
  #2  
Old 01-18-2008, 06:54 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
I am not really a scripter or anything but I get the basics.

From what your saying it sounds like the serverside has more pluses, it just seems like the player would have to not lag. And the majority of graal players don't lag so I would go with serverside.

Serverside +1
Reply With Quote
  #3  
Old 01-18-2008, 07:28 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by MrAnonymous_P2P View Post
And the majority of graal players don't lag...
Noooot really...

And you should try out both!
If you're intending to make this public use than that's the obvious choice. The courteous choice, rather, since it would accommodate servers that might want either one, but since this an act of free will you don't HAVE to go through all that work.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #4  
Old 01-18-2008, 07:32 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
Do clientside, just make it so when you kill a baddy it dies on other player's clients too. Its not hard.
Quote:
Originally Posted by DustyPorViva
but since you can only send data to the clientside through attr's...
When an npc is created on clientside it would have an ID variable which you can use to locate it from any client. Thats how you go from serverside to clientside.
PHP Code:
// Script in the NPC
public function sendserverkill(omitleveln) {
  for (
temp.iallplayers) {
    if (
i.account == omit || i.level.name != leveln)
      continue;
    
with (iSystem.clientfunction2(null"npcfunction"this.id"onServerKill");
  }
}
//#CLIENTSIDE
function onServerKill() {
  
// When the kill message is received from server.
}
function 
sendserverkill() {
  
System.serverfunction2(null"npcfunction"this.levelthis.id"sendserverkill"player.accountthis.level);

It is using this class:
PHP Code:
// Serverside to Clientside Function
public function clientfunction(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
temp.out 0;

  
triggerclient("gui"this.name"clientfunction"fobjfnamep0p1p2p3p4p5p6p7p8p9);
  
waitfor(this"ClientFunctionEnd"5);
  
temp.out thiso.cfreturn;
  
thiso.cfreturn null;
  return 
temp.out;
}
public function 
clientfunction2(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
triggerclient("gui"this.name"clientfunction2"fobjfnamep0p1p2p3p4p5p6p7p8p9);
}
public function 
npcfunction(p0p1p2p3p4p5p6p7p8p9) {
  
temp.obj findlevel(p0);
  for (
temp.iobj.npcs) {
    if (
i.id == p1) {
      
i.(@ p2)(p3p4p5p6p7p8p9);
      break;
    }
  }
}
function 
onActionServerSide() {
  if (
params[0] == "end") {
    
thiso.cfreturn params[1];
    
trigger("ClientFunctionEnd"null);
  }
  else if (
params[0] == "serverfunction") {    
    if (
params[1] != null)
      
triggerclient("gui"this.name"end"makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
    else 
      
triggerclient("gui"this.name"end"makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
  }
  else if (
params[0] == "serverfunction2") {
    if (
params[1] != null)
      
makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
    else 
      
makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
  }
}
//#CLIENTSIDE
function onActionClientSide() {
  if (
params[0] == "end") {
    
thiso.sfreturn params[1];
    
trigger("ServerFunctionEnd"null);
  }
  else if (
params[0] == "clientfunction") {    
    if (
params[1] != null)
      
triggerserver("gui"this.name"end"makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
    else 
      
triggerserver("gui"this.name"end"makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
  }
  else if (
params[0] == "clientfunction2") {
    if (
params[1] != null)
      
makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
    else 
      
makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
  }
}
public function 
npcfunction(p0p1p2p3p4p5p6p7p8p9) {
  
findnpcbyid(p0).(@ p1)(p2p3p4p5p6p7p8p9);
}
public function 
serverfunction(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
temp.out 0;
  
  
triggerserver("gui"this.name"serverfunction"fobjfnamep0p1p2p3p4p5p6p7p8p9);
  
waitfor(this"ServerFunctionEnd"5);
  
out thiso.sfreturn;
  
thiso.sfreturn null;
  return 
out;
}
public function 
serverfunction2(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
triggerserver("gui"this.name"serverfunction2"fobjfnamep0p1p2p3p4p5p6p7p8p9);

For some reason, clientside level objects don't have anything in their npcs variable, only on serverside.

You could also make your own system for keeping track of baddy objects by ID on clientside and serverside.
__________________

Last edited by Inverness; 01-18-2008 at 09:12 AM..
Reply With Quote
  #5  
Old 01-18-2008, 05:15 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by DustyPorViva View Post
Well, I think every classic server would benefit from the default baddies being rescripted in GS2... so I thought I would discuss some here.
My main curiosity is whether they should be serverside or clientside. I'll post my opinions about both:

serverside:
- Jumpy movement. Since there is a min 0.1 timeout on serverside, movement wouldn't be as smooth.
Depending on how you use the move() function, it doesn't have to be jumpy at all.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #6  
Old 01-18-2008, 05:37 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I have tried and tried and tried move(), while not 'jumpy' in the same sense, it flies all over the place at times when there is any delay on the serverside; since it will continue to move in the last known direction it was heading, then suddenly update and appear at it's more updated location. If anyone can give me an example script of using move() correctly serverside, I'd appreciate it!
Reply With Quote
  #7  
Old 01-18-2008, 05:41 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by DustyPorViva View Post
I have tried and tried and tried move(), while not 'jumpy' in the same sense, it flies all over the place at times when there is any delay on the serverside; since it will continue to move in the last known direction it was heading, then suddenly update and appear at it's more updated location. If anyone can give me an example script of using move() correctly serverside, I'd appreciate it!
You should calculate it's next move before it even starts moving, that way once it finishes the move function it doesn't have to calculate it and have those weird bugs. Calculate it based on the destination x and y, and where you want it to go from there, then do the first move function, repeat, and do the other move function, repeat, etc. Basically all of the calculations should be delayed by 1 move function.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #8  
Old 01-18-2008, 07:16 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I have tried that, but honestly I don't have much experience with move() so I doubt I was doing it properly...
Reply With Quote
  #9  
Old 01-20-2008, 04:14 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
I really do think we should be able to have quicker timeouts. Just restrict the amount of data that can be processed in quicker timeouts. But quite honestly, I've done serverside baddies before, and the .1 timeout limit really doesn't make it look choppy at all.

But yeah, I still say you should do both. ;(
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
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:43 PM.


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