Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   vecx,vecy? (https://forums.graalonline.com/forums/showthread.php?t=25041)

happyme 03-04-2002 09:47 AM

vecx,vecy?
 
what does
vecx,vecy
do??
ive read the definition but i still dont get it, would some redefine it for me?

screen_name 03-04-2002 10:50 AM

its just variables for player movement

Saga2001 03-04-2002 12:52 PM

Quote:

Originally posted by Kaimetsu
Tables!

NPC Code:

Input vecx vecy
0 0 -1
1 -1 0
2 0 1
3 1 0


yay, tables!

you input vecx(playerdir) and it returns stuff as in this table^!

happyme 03-04-2002 08:37 PM

eh
 
i dont get it.... can someone give me an example?

screen_name 03-04-2002 09:28 PM

use this


NPC Code:

if (playerenters) {
message #v(vecy(playerdir));
}


TDO2000 03-05-2002 12:08 AM

It was added to make random player movement easier...
you know there are 4 dirs a player can have

0 up
1 left
2 down
3 right

so now u watch the table:
NPC Code:

Dir value for vecx value for vecy
0 0 -1
1 -1 0
2 0 1
3 1 0



so if you have the player looking up and u want him to move in this direction you need to substract a value from the players y-Position but the players X-Position has to be the same value so you don't have to add or substract something from the value

ok lets say players x pos is 32 and the players y pos is 25 and he is looking up

playerx+=vecx(playerdir); //nothing will happen to the players x-value
playery+=vecy(playerdir); // oh wonder there is 1 substracted from players y-value and he has gone upwards :)

so one simple in-use-example (some Staff-Boots)
NPC Code:

if (playertouchsme) toweapons StaffBoots;
// Activating the weapon
if (weaponfired) {
if (this.active==1) this.active=0;
else {
this.active=1;
timeout=.05;
}
}

if (timeout) {
if (this.active==1) {
//now there comes our movement part
for (i=0;i<4;i++) {
if (keydown(i)) {
playerx+=vecx(i);
playery+=vecy(i);
}
}
timeout=.05;
}
}



the for loop is just used to get an easier use for a keydow routine wit less code i is always the value of the dir your char is looking at so while pressing a key your charackter gets faster and he can walk over walls...

Saga2001 03-05-2002 12:15 AM

Quote:

Originally posted by TDO2000
It was added to make random player movement easier......
Ihat is the most i have ever heard anyone ever say about vecx vecy, good work. :p.

happyme 03-05-2002 03:46 AM

thxs
 
thanks
screen_name and TDO2000

neomaximus2k 03-05-2002 05:24 AM

Re: thxs
 
Quote:

Originally posted by happyme
thanks
screen_name and TDO2000

yeah thanks everyone i knew about it just wasn't sure :D


All times are GMT +2. The time now is 04:15 AM.

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