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 11-13-2006, 02:06 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
Joint Project 1: Baddies - trouble with clientside/serverside/GS2 Conversion

I'm trying to assemble a really basic Baddy script over on the Playerworld Main board so everyone will have access to the same sorts of tools we all had back when the world was clientside (but with the added advantage that this time, we can script the baddies to shoot fireballs out of their ears or whatever else we want to modify them to do)-
Point is, I've made a bunch of baddy scripts, but I keep running into a handfull of problems.
1) I don't actually remember how the late GS1 scripts worked - the really efficient Move, Shoot, etc. I jury-rigged a Shoot command for the extant swampsoldier, but I'm getting the standard issue problems - won't shoot over walls, not sure I have the power right (was it -1 for Go Forever, or am I firing them backwards?) Is there a specific place that still lists these in the old NewFeatures2002.txt style?
2) The original Swampsoldier used putleaps0,x,y in its "script" - which is now a clientside-only command, I guess...anyway, I put a ganiscript in to emulate that and it never does anything. Not sure why. Anyone else run into this?
3) Is there a Simple way of saying "Hit by a #1 arrow" short of shootarrow? It'd work fine for the swampsoldier, but shootball (last check) doesn't offer a direction so much as a target.

I'm way outta my depth here, so I'd appreciate any help I can get. Everyone's free to do what they like with the finished product, I'd just prefer if all the intermediate work on it was public domain so we don't have a different Basic Baddy Gani for every server, etc. And yes, I'm fully cognizant that every server has a different name for how they handle damage, movement, etc...I hope to, in the final version, have a series of constants or function calls to make it as easy as possible to graft it into whichever system is necessary.
__________________
"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

Last edited by Tyhm; 11-13-2006 at 02:39 AM..
Reply With Quote
  #2  
Old 11-13-2006, 09:09 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Tyhm View Post
1) I don't actually remember how the late GS1 scripts worked - the really efficient Move, Shoot, etc. I jury-rigged a Shoot command for the extant swampsoldier, but I'm getting the standard issue problems - won't shoot over walls, not sure I have the power right (was it -1 for Go Forever, or am I firing them backwards?) Is there a specific place that still lists these in the old NewFeatures2002.txt style?
Yes, -1 is untill it hits something. I can't remember how to prevent that though. I'll look through Era's script's later on and see if I can find out for you.

Quote:
Originally Posted by Tyhm View Post
2) The original Swampsoldier used putleaps0,x,y in its "script" - which is now a clientside-only command, I guess...anyway, I put a ganiscript in to emulate that and it never does anything. Not sure why. Anyone else run into this?
Have you tried using an attribute?
HTML Code:
this.attr[1] = "the gani for the putleaps effect"; 
Quote:
Originally Posted by Tyhm View Post
3) Is there a Simple way of saying "Hit by a #1 arrow" short of shootarrow? It'd work fine for the swampsoldier, but shootball (last check) doesn't offer a direction so much as a target.
Ah, I don't think that there is a function to detect the arrow hit [default].
__________________
Reply With Quote
  #3  
Old 11-13-2006, 10:02 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
Quote:
Originally Posted by xAndrewx View Post
Have you tried using an attribute?
HTML Code:
this.attr[1] = "the gani for the putleaps effect"; 
I would, but I'm not certain there IS a putleaps gani. If there is one then yeah, I'll just have it call that gani, save me a lot of time...
You know, Massokre would know, I'll ask him. I'm sure he came across this when he was rescripting Classic's Carrying-And-Throwing script.

Quote:
Originally Posted by xAndrewx View Post
Ah, I don't think that there is a function to detect the arrow hit [default].
Ah well, easy enough to script a system to handle that.

Had another thought:
Would it be more efficient for the system NPC to detect when a player's touching a baddy than to have each baddy running a constant loop to detect when they touch a player? 'cuz right now, that's the only reason the Frog's got a constant timeout loop...otherwise it could show the rustle, wait 1 second, show the frog, wait 2 seconds, show the rustle, wait 1 second, hide and move, wait, repeat...and when I get scripts moving by the Move command, same story there...
__________________
"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 11-13-2006, 09:25 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Tyhm View Post
I would, but I'm not certain there IS a putleaps gani. If there is one then yeah, I'll just have it call that gani, save me a lot of time...
You know, Massokre would know, I'll ask him. I'm sure he came across this when he was rescripting Classic's Carrying-And-Throwing script.



Ah well, easy enough to script a system to handle that.

Had another thought:
Would it be more efficient for the system NPC to detect when a player's touching a baddy than to have each baddy running a constant loop to detect when they touch a player? 'cuz right now, that's the only reason the Frog's got a constant timeout loop...otherwise it could show the rustle, wait 1 second, show the frog, wait 2 seconds, show the rustle, wait 1 second, hide and move, wait, repeat...and when I get scripts moving by the Move command, same story there...
I redid lift/carry... couldn't do throw. Anything concerning projectiles are still on Master Storm's code.

There's no way to turn off wall checking.

Also, there's no efficient way to check for a player contacting a baddy. Even if you use playertouchsme, it will check an area in front of the player, and that can get very ugly with opposite boots. It's a bit strange. I think Stefan's reasoning for this is to make the player seem like they didn't lag that sign or level link.

A long time ago, I suggested to Stefan that he add an event handler playerEntersArea, that would trigger when the player's area and the area of an NPC intersected. I also had a multitude of applications for such an event handler other than just baddies.

serverside-protected spars
nopkareas (restricted to the area of the NPC)
nopauseareas
etc.

However, with most of these other applications, you'd want to know when the player leaves the area of an NPC as well, which would be another event handler: playerLeavesArea.

This idea would parallel playerenters and playerleaves for levels, except with NPCs detecting the players. It's not necessary for the NPCs to keep track of all players in a level, etc, however, because the script could keep track of it if you needed that kind of implementation.

Unfortunately, I don't believe Stefan's interested in adding such a feature. Couldn't hurt to ask though.
Reply With Quote
  #5  
Old 11-13-2006, 09:38 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
There's a way to put it in a system NPC...as long as it's in a timeout loop anyway, it's trivial and primarily client-lag to have it send playerentersarea(playerid) to any NPCs it's entered the area of, assuming said NPCs have a detectable size.

But yes, it'd be a wonderful feature if Stefan were to add it.

In the meantime, I suppose I'll have to keep the baddies scripted with a .05 timeout loop on the off chance players are walking backwards or being pushed by conveyer belts, winds, or strong currents...
I suppose it might be possible to just script anything that moves a player unduly to launch playertouchsme() at anything the player's pushed into...a bit of an overhead on that, but with joins, why not?
__________________
"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 11-13-2006, 10:59 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
If you don't mind using a circle for area detection use
PHP Code:
temp.distance = ((player.this.x)^+ (player.this.y)^2)^0.5
Use a timeout to check when the var gets to a certain number.

Could/should also be able to do
PHP Code:
if (player.x in |this.xthis.this.width|)
{
  if (
player.y in |this.ythis.this.height|)
  {
  
//Hit detection =o
  
}

Reply With Quote
  #7  
Old 11-13-2006, 11:14 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
Well, naturally, it's just a matter of knowing the shape and dimensions of the NPCs in question. I'd figure the rectangle would be good enough...
__________________
"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
  #8  
Old 11-15-2006, 02:14 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Tyhm View Post
There's a way to put it in a system NPC...as long as it's in a timeout loop anyway, it's trivial and primarily client-lag to have it send playerentersarea(playerid) to any NPCs it's entered the area of, assuming said NPCs have a detectable size.

But yes, it'd be a wonderful feature if Stefan were to add it.

In the meantime, I suppose I'll have to keep the baddies scripted with a .05 timeout loop on the off chance players are walking backwards or being pushed by conveyer belts, winds, or strong currents...
I suppose it might be possible to just script anything that moves a player unduly to launch playertouchsme() at anything the player's pushed into...a bit of an overhead on that, but with joins, why not?
Actually, that would make the server lag more in other ways. Most of the lag that players experience actually has to do more with I/O than whether something is scripted as efficiently as possible on the server.

A good idea for baddies, is that when their script is created, to make an array level.baddies, and have the baddies each add themselves (as an object) to that array both serverside and clientside. That way, you could more easily detect the baddy's presence clientside and then trigger the server. That would pretty much be a less efficient version of clientside hit detection.
Reply With Quote
  #9  
Old 11-15-2006, 07:43 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
:-/ Don't like it. Then you ask the player to detect every few seconds whether they've collided with any element of level.baddies.
__________________
"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
  #10  
Old 11-15-2006, 08:29 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Tyhm View Post
:-/ Don't like it. Then you ask the player to detect every few seconds whether they've collided with any element of level.baddies.
No, instead of constantly telling the client to send data packets to the server, you're letting everything happen on the client and only sending data to the server when it needs to. Most overhead comes from client-server interaction. As traffic to the server will increase for every player on the server, the server will take more time to take in all of the data, and therefore also take longer to process and respond. It's also good practice to use bitflags instead of typical bools to reduce traffic.
Reply With Quote
  #11  
Old 11-15-2006, 09:48 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
...having no idea what you just said, I'm going to assume you're right about this. Bitflag...different from boolean...reduces traffic...to less than one bit...
You put a lot of faith in the player honestly telling the server when a baddy's collided with them, but I suppose one must these days. Any playertouchsme solution would require much the same thing.

I still say playertouchsme should be manually fired when the player's forced to move by room-based (or goofy-boots-based) script...won't help with the baddies catching the player, but it'd be a start.

Hmm, the player's running a timeout loop, the server's running an occasional "Oh yeah and all the frogs on the server jump" every seven seconds or so...I'd think the client knows where even the serverside Frogs are so it can animate them, thus the client would be fully capable of saying "Yeah, I'm on top of a frog right now - what? They're attacking? Damn, sucks to be me."

But perhaps I oversimplify. It's been a long day.
__________________
"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

Last edited by Tyhm; 11-15-2006 at 10:35 AM..
Reply With Quote
  #12  
Old 11-16-2006, 02:17 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Tyhm View Post
...having no idea what you just said, I'm going to assume you're right about this. Bitflag...different from boolean...reduces traffic...to less than one bit...
You put a lot of faith in the player honestly telling the server when a baddy's collided with them, but I suppose one must these days. Any playertouchsme solution would require much the same thing.

I still say playertouchsme should be manually fired when the player's forced to move by room-based (or goofy-boots-based) script...won't help with the baddies catching the player, but it'd be a start.

Hmm, the player's running a timeout loop, the server's running an occasional "Oh yeah and all the frogs on the server jump" every seven seconds or so...I'd think the client knows where even the serverside Frogs are so it can animate them, thus the client would be fully capable of saying "Yeah, I'm on top of a frog right now - what? They're attacking? Damn, sucks to be me."

But perhaps I oversimplify. It's been a long day.
Serverside damage is like putting a swear filter on.
Instead of having a swear filter, we could just record words that *could* be deemed offensive.
Instead of having serverside damage, we could detect inconsistencies in damage responses.
Reply With Quote
  #13  
Old 11-16-2006, 02:54 AM
Tyrial Tyrial is offline
The Shiznic
Join Date: Dec 2001
Location: Sweden > Stockholm
Posts: 2,411
Tyrial is an unknown quantity at this point
Okay, this isn't even GScript so don't laugh..
(Don't know what it is.. just some random theory.)

Can't you do like this?

NPC Code:


Class: Baddies.
timeout = 0.05;
if (timeout)
{

-- Stolen --
if (player.x in |this.x, this.x + this.width|)
{
if (player.y in |this.y, this.y + this.height|)
{
//Hit detection =o
}
}
-- /Stolen --

timeout = 0.05;
}



then in the baddie script do like "join baddies;" ?
__________________
-Mher Avetian
Reply With Quote
  #14  
Old 11-16-2006, 08:20 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Twas why i posted those sample codes. Depends on whats the order of preference for baddies in the end. Movement can be handled serverside while detection is clientside.. it won't lag when you get hit but may look odd to other people =S.
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 11:15 PM.


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