Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Small question (https://forums.graalonline.com/forums/showthread.php?t=58096)

Idrox0 03-16-2005 01:16 AM

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

Kaimetsu 03-16-2005 03:03 AM

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.

Idrox0 03-17-2005 01:57 AM

I keep hearing about a new GScript engine, aka GScript 2... what is everyone talking about?

Kaimetsu 03-17-2005 02:08 AM

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.

Luigi203 03-17-2005 02:21 AM

Quote:

Originally Posted by Idrox0
how do you set a variable to a string? Namely, speed = #t(1);.

strtofloat()

Kaimetsu 03-17-2005 03:04 AM

Quote:

Originally Posted by Luigi203
strtofloat()

Do not give bad advice, please. There are rules about that kind of thing.

Luigi203 03-17-2005 03:34 PM

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.


Kaimetsu 03-17-2005 04:02 PM

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.

Luigi203 03-17-2005 04:07 PM

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)

Idrox0 03-18-2005 12:58 AM

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?

Luigi203 03-18-2005 01:40 AM

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.

Kaimetsu 03-18-2005 01:42 AM

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.

Idrox0 03-19-2005 07:04 AM

1 Attachment(s)
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.

Gambet 03-21-2005 09:48 PM

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.

Dach 03-21-2005 09:49 PM

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):
http://members.aol.com/michaelangelo36/Graphic.jpg
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)


All times are GMT +2. The time now is 08:22 PM.

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