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 03-16-2005, 01:16 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Question Small question

Okay, I'm doing a huge revamp on Graal and combining it with an RPG. I believe it would be sort of like Graal Kingdoms, as it has stats and things... anywho, the movement speed of the player is derived from a 'Speed' stat using the following formula:

spd = 0.5 + ((Speed - 20)/100)

A quick note if anyone cares: the max Speed you can have is 100.
spd is how many tiles a character moves every 0.05 seconds. Using this and a bunch of code from premade NPCs using a lot of vecx and vecy and all that other crap, I completely recreated the movement system of Graal (yes, I know I did it the hard way, but it allows for more flexibility, I suppose). Now, all that is well and good, but I have two questions.

1) Because this project isn't even CLOSE to being finished, I have made a prototype level that allows you to change your speed by typing 'setspeed #'. Now, all this is fine and dandy, and perhaps it's been a bit too long since I last scripted, but how do you set a variable to a string? Namely, speed = #t(1);.

2) This is not going to be needed for a while, but how would I be able to script a weapon that hits multiple areas that are close together, but does not hurt the target multiple times? This idea came from a sword scenario: in reality, a person does not have to be directly in front of you to be hit; they could be at the very beginning or end of the swing (to the near left or right) and still be hit, and so you see my need for multiple areas of damage dealing.

Whew, that took a while... ideas and answers welcome.

Ciao
__________________
Reply With Quote
  #2  
Old 03-16-2005, 03:03 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Idrox0
how do you set a variable to a string? Namely, speed = #t(1);
If you're using the old scripting engine then you'll need to use setstring ('setstring nameofstring,newvalue;'). The new GScript makes things a little easier; the code that you gave would work.

Quote:
This is not going to be needed for a while, but how would I be able to script a weapon that hits multiple areas that are close together, but does not hurt the target multiple times?
Well, as a starter - and you may already know this - damage scripts are the kind of thing that should take place on the server. So if it's an immediate thing then you should send a trigger. If it's the result of a projectile then you can just receive the default notification. Stefan made a tutorial on this kind of thing that you might find useful: http://forums.graalonline.com/forums...ad.php?t=50809

In either case, you'll probably want to use the 'getnearestplayers' function to get a list of players near to the damage area and then iterate through them all to determine which should be affected. I've never used the function personally, but it's included in the tutorial I linked and it seems fairly simple.
__________________
Reply With Quote
  #3  
Old 03-17-2005, 01:57 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
I keep hearing about a new GScript engine, aka GScript 2... what is everyone talking about?
__________________
Reply With Quote
  #4  
Old 03-17-2005, 02:08 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Idrox0
I keep hearing about a new GScript engine, aka GScript 2... what is everyone talking about?
It's the engine that's being introduced with Graal v3. The new GScript is a lot friendlier and more intuitive - especially if you already use C-like languages. It also opens up some nice options like public functions, function arguments, etc.

It is also somewhat fluffy, but I can excuse that.
__________________
Reply With Quote
  #5  
Old 03-17-2005, 02:21 AM
Luigi203 Luigi203 is offline
Hamma Time
Luigi203's Avatar
Join Date: Mar 2003
Location: North East PA
Posts: 285
Luigi203 is on a distinguished road
Send a message via AIM to Luigi203
Quote:
Originally Posted by Idrox0
how do you set a variable to a string? Namely, speed = #t(1);.
strtofloat()
__________________


CAUTION
Reply With Quote
  #6  
Old 03-17-2005, 03:04 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Luigi203
strtofloat()
Do not give bad advice, please. There are rules about that kind of thing.
__________________
Reply With Quote
  #7  
Old 03-17-2005, 03:34 PM
Luigi203 Luigi203 is offline
Hamma Time
Luigi203's Avatar
Join Date: Mar 2003
Location: North East PA
Posts: 285
Luigi203 is on a distinguished road
Send a message via AIM to Luigi203
How is that bad advice, he CAN search for it in the commands rtf. If i explain him the whole thing then:
Quote:
Originally Posted by Kaimetsu Whining
The rules prohibit you from giving so much information.
__________________


CAUTION
Reply With Quote
  #8  
Old 03-17-2005, 04:02 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Luigi203
How is that bad advice, he CAN search for it in the commands rtf. If i explain him the whole thing then:
The problem isn't your terseness. Rather, it's the content of your message.

However, I must admit at this point that I'm no longer sure what the original poster was asking. Accordingly to my original interpretation, strtofloat would have no applicability (which is why I objected). But I accept that his words were ambiguous, and that either version is viable.

I still think that ambiguity could have been tackled if you'd gone into more depth, but I'm not blaming you any more.
__________________

Last edited by Darlene159; 03-18-2005 at 01:22 AM.. Reason: no need for name calling
Reply With Quote
  #9  
Old 03-17-2005, 04:07 PM
Luigi203 Luigi203 is offline
Hamma Time
Luigi203's Avatar
Join Date: Mar 2003
Location: North East PA
Posts: 285
Luigi203 is on a distinguished road
Send a message via AIM to Luigi203
speed = #t(1); > test > Error: Expected format var, var[i], obj[i].attr, function(a), function(a,b)
speed = strtofloat(#t(1)); > test > Error: (none)
__________________


CAUTION
Reply With Quote
  #10  
Old 03-18-2005, 12:58 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Actually... Luigi was he who saved me from my demise... it has simply been so long that I forgot about strtofloat()... Kaimetsu, how do I 'upgrade' to this new GScript? I know I have not already, because the x = string; did not work. But I now have another problem...
Excuse the crude ASCII (and the sets of X's), but see the following diagram:
O = player X = blocking tile

O

XXX
XXX
XXX

If my player were to go down continuously, running into the blocking tiles, and then (while pressing down) hit left or right, the ganis would mess up, because it is constantly checking the onwall (which is hitting the blocking tiles) and setting the gani to idle, whereas there is no blocking tile to the left or right, so it sets it to walk, and so because it constantly switches between idle and walk, it looks like it is frozen in the first frame of walk. So... know how to fix that? Should I post my code?
__________________
Reply With Quote
  #11  
Old 03-18-2005, 01:40 AM
Luigi203 Luigi203 is offline
Hamma Time
Luigi203's Avatar
Join Date: Mar 2003
Location: North East PA
Posts: 285
Luigi203 is on a distinguished road
Send a message via AIM to Luigi203
I dont know what your script looks like, post your onwall detection, but if you're using playerdir in a vecx and vecy to check for the onwall, that might be messing it up. Try using the for loop in a timeout to check for the keys 0-3 being pressed, and use that same var from the for command as the index of all vectors.
__________________


CAUTION
Reply With Quote
  #12  
Old 03-18-2005, 01:42 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Idrox0
Kaimetsu, how do I 'upgrade' to this new GScript?
You'd need to talk to Stefan in order to get it enabled on your server.

Quote:
because it constantly switches between idle and walk, it looks like it is frozen in the first frame of walk. So... know how to fix that?
Well, just don't use multiple references to setani.
__________________
Reply With Quote
  #13  
Old 03-19-2005, 07:04 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Sweetness! Somehow, I fixed the code... maybe it's because I just put in a for loop... anyway, I have yet another problem (you can download my script at the bottom of this post for reference).
This problem was actually there before, I just wasn't thinking about it.
See the diagram again...

O

XXX
XXX
XXX

If my character was in the middle row (not the left one) and hit the obstacle, all is well, but then, if I slowly edge to the left (while still going down) I will walk through the leftmost coloumn of blocking tiles. However, this only happens when going these directions: Down-left, Up-left, Right-up, Left-up. See my attached script for reference.

Another thing... does offline mode emulate serverside and clientside scripting? I do not own or work for a server, and I probably won't any time in the near future, so I don't have any way of testing such things.
Attached Files
File Type: txt movement.txt (696 Bytes, 183 views)
__________________

Last edited by Idrox0; 03-19-2005 at 07:17 AM.. Reason: Additional Question
Reply With Quote
  #14  
Old 03-21-2005, 09:48 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Idrox0
Another thing... does offline mode emulate serverside and clientside scripting? I do not own or work for a server, and I probably won't any time in the near future, so I don't have any way of testing such things.

Offline Mode = No NPC-Server.
Reply With Quote
  #15  
Old 03-21-2005, 09:49 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Quote:
Originally Posted by Idrox0
If my character was in the middle row (not the left one) and hit the obstacle, all is well, but then, if I slowly edge to the left (while still going down) I will walk through the leftmost coloumn of blocking tiles. However, this only happens when going these directions: Down-left, Up-left, Right-up, Left-up. See my attached script for reference.
I'm gonna have to open photoshop for this..
First off, your node creation is rather odd. This little graphic will show you what you're script does to find the nodes, red being the x,y of player and the blues being the newx/newy then the testx/testy (what I'm refering to as nodes):

Just find the center of the player then add the vecx/vecy stuff to that. (center of feet is playerx+1.5 playery+2, center of player graphic is playerx+1.5,playery+1.5)
This will pretty much accomodate the corner-jumping problem you're having.

Quote:
Another thing... does offline mode emulate serverside and clientside scripting? I do not own or work for a server, and I probably won't any time in the near future, so I don't have any way of testing such things.
Offline has clientside only.
I don't work for any servers yet I have access to a couple of servers just to test stuff. Point being, you can get limited RC access to some servers to learn scripting. (there is a "Graal Test Server" that should work out for you, it's enabled for the new engine, but it's backwards combatible so you don't have to worry about that if you don't want to)
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
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:56 AM.


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