Graal Forums

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

ownerofbabylon 07-23-2001 08:34 AM

Creatures
 
I am making a creature that follows the player around and I was experimenting with setimgpart and stuff. I know Merlin wont help if u dont have some of it done so here is what i did.

// NPC made by Lord Helmut (LAT)
if(playerenters){
setimgpart bomy.png,98,52,40,43;
}
if (playerdir==left) {
setimgpart bomy.png,48,99,48,43;
}
if (playerdir==right{
setimgpart bomy.png,140,98,44,44;
}

I was playing around and seeing how this stuff worked and i got the right thing for setimgpart and i was happy. But I want it so it watches a player and when they walk left it turns left and stays behind them. So like if a player x = 30 then this x is like 2 less. How would I make it work so it constantly did somthing? Because I want this to follow the player and each time there x increases the creatures increases by the same amount.

I used a bomy as a example but this is not the real one. It was just for experimenting.

Merlin 07-23-2001 08:53 AM

if (Created) {
tokenize x;
tokenize y;
timeout=.5;}
if (playerx=playerx&&timeout) {x=playerx-2;
timeout=.5;
}
if (playery=playery&&timeout) {y=y-1;}

Well actualy I have no idea but that may work.

ownerofbabylon 07-23-2001 09:14 AM

i see tokenize alot but dont understand it. What is that used for?

General 07-23-2001 12:17 PM

tokenize is useless in that script, he is a newbie scripter...
a better one would be

x=playerx+vecx(playerdir)*3;
y=playery+vecy(playerdir)*3;

ownerofbabylon 07-23-2001 01:33 PM

ooooo

so thats all i gotta put??

BTW, what does vecx and vecy do???

LiquidIce00 07-24-2001 07:02 AM

vecx and vecy is weird but it works.
erm ill try to explain what it does and how it does..
what it does is ..
it returns a -1 or a 0 or a 1 . depending on the playerdir. and its used to move things ''forward'' or backwards or whatever..
if you do
playerx+=vecx(playerdir);
playery+=vecy(playerdir);
it will move the player 1 spot forward. (the way hes facing)
how it does is simple..
ill tell you in english
if playerdir is 0 (up) vecx returns 0 and vecy -1
if playerdir is 1 (left) vecx returns -1 and vecy 0
if playerdir is 2 (down) vecx returns 0 and vecy 1
if playerdir is 3 (left) vecx returns 1 and vecy 0

its also usefull for triggeraction
triggeraction playerx+1.5+(vecx(playerdir)*2),
playery+2+(vecy(playerdir)*2),blabla;

=)

ownerofbabylon 07-28-2001 11:36 PM

Quote:

Originally posted by LiquidIce00
vecx and vecy is weird but it works.
erm ill try to explain what it does and how it does..
what it does is ..
it returns a -1 or a 0 or a 1 . depending on the playerdir. and its used to move things ''forward'' or backwards or whatever..
if you do
playerx+=vecx(playerdir);
playery+=vecy(playerdir);
it will move the player 1 spot forward. (the way hes facing)
how it does is simple..
ill tell you in english
if playerdir is 0 (up) vecx returns 0 and vecy -1
if playerdir is 1 (left) vecx returns -1 and vecy 0
if playerdir is 2 (down) vecx returns 0 and vecy 1
if playerdir is 3 (left) vecx returns 1 and vecy 0

its also usefull for triggeraction
triggeraction playerx+1.5+(vecx(playerdir)*2),
playery+2+(vecy(playerdir)*2),blabla;

=)

Thanks man. Now I understand how to use Vec better. I still dont quit get triggeraction but i may learn if I keep playing with it. Thanks again =D


All times are GMT +2. The time now is 05:50 AM.

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