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 03-13-2006, 03:29 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
"hooking" functions?

Hi,

is there a way to "hook" functions?
like to modify them or put own code on them?
or to fully rewrite them?
__________________
Reply With Quote
  #2  
Old 03-13-2006, 07:42 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
What exactly are you trying to do?
__________________
Who has time for life these days?
Reply With Quote
  #3  
Old 03-13-2006, 08:42 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Basically changing functions
or Events
like onPlayerTouchsMe
or like changing the gui controls to use other template setup or stretch/dont stretch images etc xD or to make own syntaxhighlightning at the guitext ctrls
__________________
Reply With Quote
  #4  
Old 03-13-2006, 10:09 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
The way you format your posts makes it hard for me to understand what you are talking about.

I am under the impression that you want to override built-in functions/events? I am pretty sure that you can't. What you can do, though, is script your own.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 03-13-2006, 10:26 PM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
He wants to rescript default events/functions.
__________________
Liek omigosh.

Reply With Quote
  #6  
Old 03-13-2006, 11:02 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Ajira got it xD
or simply add something to them
__________________
Reply With Quote
  #7  
Old 03-14-2006, 01:14 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
As far as I know you can't override the default functions, but you can always make your own. If you mold your server properly then you can have certain NPCs handle certain events instead of having 45973497534 NPCs that could be combined for efficiency and editability (and yes, it is a word, I just made it up so get over it).
__________________
Who has time for life these days?
Reply With Quote
  #8  
Old 03-14-2006, 04:15 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Yeah you can make your own but that means fully redoing the function instead of changing it X_x
__________________
Reply With Quote
  #9  
Old 03-14-2006, 04:18 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by projectigi
Yeah you can make your own but that means fully redoing the function instead of changing it X_x
I fail to see the problem Sure Graal has some built in functions, but you have a lot more control and understanding of the systems if you rewrite majority of it from scratch (plus it's more fun lol).
__________________
Who has time for life these days?
Reply With Quote
  #10  
Old 03-14-2006, 04:22 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Projectshifter, have you ever used the GUI controls in Graal?
Reply With Quote
  #11  
Old 03-14-2006, 04:36 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by Rick
Projectshifter, have you ever used the GUI controls in Graal?
Many a time. Personally I don't like them, but it's mostly because I was using them when the new engine was in its infancy and it wasn't supported by any client other than the one that basically the GST and Stefan had, so it wasn't worth writing a lot of stuff in it. I wrote a nice RC equivalent program with it. But yes, I have used the GUI controls in Graal and until graalv4 becomes mandatory, I don't think they should be used.
__________________
Who has time for life these days?
Reply With Quote
  #12  
Old 03-14-2006, 04:47 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Well look at GuiControls
they are nice but u cant change the template(well you cant change positioning/use/size of it XD
__________________
Reply With Quote
  #13  
Old 03-14-2006, 04:52 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by projectigi
Well look at GuiControls
they are nice but u cant change the template(well you cant change positioning/use/size of it XD
? I remember back when we were testing it when Stefan first designed it you could change the template and the scheme and positioning?
__________________
Who has time for life these days?
Reply With Quote
  #14  
Old 03-14-2006, 05:06 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Hmm, using catchevent() would probably be the closest thing you could do to 'hooking functions'
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #15  
Old 03-14-2006, 05:09 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
AFAIK you can change the image it uses and by that changing its style but i dont know of changing the template it uses o_o like having an other order of the elements on the image etc or adding new things
__________________
Reply With Quote
  #16  
Old 03-15-2006, 08:50 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
playertouchsme is the strangest event handler in the sense that you can't modify it. There are several instances in which you might want to, but you just can't.

You can most easily control certain clientside events if you can disable them (consider disableweapons). However, you can't control all serverside events quite as efficiently. I'm pretty sure you could tell an NPC not to recognize an event and use the trigger function to call it whenever you needed it, but it would be hard to mimick serverside with the lack of a timeout (especially for playertouchsme).

I'm hoping Stefan will release at least one more event handler, being similar to playertouchsme, for the player overlapping or bordering the NPC. Playertouchsme doesn't do that specifically, but there are a lot of places it could be used if you simply wanted a script to be based on a field and use the npc's x,y,width,height to define that field. Perhaps damage fields, or even any coordinate dependent zones that activate some other script functionality. Damage fields would be what I would immediately use this for, but the concept can certainly cover other aspects of things as well. I would probably think the best implementation would be something like:
onPlayerEntersMyShape() and onPlayerLeavesMyShape(). It would be comparable to having onPlayerEnters() and onPlayerLeaves(), but the player only enters a part of the level that's defined by an NPC's x,y,w,h... or leaves a part of the level that's defined by an NPC's x,y,w,h. It would make sense to call the onPlayerLeavesMyShape() for the NPC the player has not left the shape of before the player leaves the level. I ought to post this in my other thread about playertouchsme.

It would certainly help a bit to have such functionality.
Reply With Quote
  #17  
Old 03-15-2006, 10:27 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Quote:
Originally Posted by projectigi
AFAIK you can change the image it uses and by that changing its style but i dont know of changing the template it uses o_o like having an other order of the elements on the image etc or adding new things
What do you mean by template? Profiles are 100% customizable.
Reply With Quote
  #18  
Old 03-15-2006, 11:38 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
with template i mean the order of the elements on the bitmap it uses
__________________
Reply With Quote
  #19  
Old 03-17-2006, 12:46 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by jake13jake
I would probably think the best implementation would be something like:
onPlayerEntersMyShape() and onPlayerLeavesMyShape(). It would be comparable to having onPlayerEnters() and onPlayerLeaves(), but the player only enters a part of the level that's defined by an NPC's x,y,w,h... or leaves a part of the level that's defined by an NPC's x,y,w,h. It would make sense to call the onPlayerLeavesMyShape() for the NPC the player has not left the shape of before the player leaves the level. I ought to post this in my other thread about playertouchsme.

It would certainly help a bit to have such functionality.
I don't see the use of it being added in all seriousness. If you really want that functionality you could do it with a while() loop or so if you were so compelled using a combination of npc.x/y/width/height and player coords. Sadly the few times that I've used while() loops in conjunction with coord and keydown checks (with simple commands) seemed to make Graal unstable and often times crash. Sad day.
__________________
Who has time for life these days?
Reply With Quote
  #20  
Old 03-17-2006, 02:45 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 Projectshifter
I don't see the use of it being added in all seriousness. If you really want that functionality you could do it with a while() loop or so if you were so compelled using a combination of npc.x/y/width/height and player coords. Sadly the few times that I've used while() loops in conjunction with coord and keydown checks (with simple commands) seemed to make Graal unstable and often times crash. Sad day.
AS SERVERSIDE EVENTS.....

There would be no way to create that functionality serverside without crashing the NPC server.

If you don't see the use of it being added, it's your sad day.

Here's one scenario: say we have a sparring area within a level. You want to lock the sparring area when two players are in the arena and warp anyone else out.

What you would never be able to script as effectively without this event handler:
PHP Code:
function onCreated() {
  
setshape(1,widthofspar*16,heightofspar*16);
}

function 
onPlayerEntersMyShape() {
  
this.myPlayers.add(player); //keep of track of all players in area

  //two players per spar
  
if (this.myPlayers.size() == 2) {
    
//to keep the spar civil
    
lockArena();
    
healPlayers();
    
initializeSpar();
  } else if (
this.myPlayers.size() > 2) {
    
//keep extra people from getting into the sparring area
    
kickFromSpar(player);
  }
}

function 
onPlayerLeavesMyShape() {
  
this.myPlayers.remove(player); //keep track of players in area
  
if (this.myPlayers.size() < 2)
    
unlockArena();

They can be used in any similar script. The "playertouchsme" event handler would be similar to "PlayerEntersMyShape", but it wouldn't be the same functionality because the player doesn't have to be touching the NPC to touch it. In addition, a "PlayerLeavesMyShape" would help to more easily keep track of who's in the area. That would bring a lot of functionality upon itself. Sparring, guild wars, special areas on a gmap, nopk zones, pk-specific zones... It would be like having "playerenters" and "playerleaves" but on a sub-level scale that offers a huge amount of flexibility. It could also be used in damage systems (which I'm all ready to do).
Reply With Quote
  #21  
Old 03-18-2006, 04:18 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
In the past, we've used x's and y's or setshape, but yeah, I would like this. It would also have to be modify...able. You would have to be able to control the area around it. Maybe even an option of using radius, so you can have a circle. (in my oppinion, this would be an exelent addition, i'm tired of sine, cosine, a^2 and so on).
Reply With Quote
  #22  
Old 03-18-2006, 09:47 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Generally this is done with a trigger and/or a timeout. I'm comprehending what you're saying you want, and why you seem to think you need it, I just really don't see it being that big of a deal and something that cannot be accomplished in other ways just fine.
__________________
Who has time for life these days?
Reply With Quote
  #23  
Old 03-18-2006, 10:37 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 excaliber7388
In the past, we've used x's and y's or setshape, but yeah, I would like this. It would also have to be modify...able. You would have to be able to control the area around it. Maybe even an option of using radius, so you can have a circle. (in my oppinion, this would be an exelent addition, i'm tired of sine, cosine, a^2 and so on).
Well, this is why it would be awesome to have a setshape mode for circles/ellipses. (I suggested that a while ago too when I was building my damage system).

Quote:
Originally Posted by Projectshifter
Generally this is done with a trigger and/or a timeout. I'm comprehending what you're saying you want, and why you seem to think you need it, I just really don't see it being that big of a deal and something that cannot be accomplished in other ways just fine.
It would certainly be much more secure for the server to detect it than the client (because the clientside scripts are run by the client and not the server, therefore, the player could potentially modify the client... blahblahblah... In essence, what would be the purpose of a serverside hit detection system if the detection was being done clientside). In regards to scripts that interact with many players, the scripting should be serverside. If a script is a show script or a script that you want to interact solely with the client player rather than all server players, it should be scripted clientside.

Last edited by jake13jake; 03-18-2006 at 10:56 PM..
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 02:27 PM.


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