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 09-06-2002, 05:19 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Vecx and Vecy

Someone mind explaining these two things too me in plain english? I know that vec stands for Vector, and I think vectors = speed+direction, but thats where my knowlege ends on this subject ;P
Reply With Quote
  #2  
Old 09-06-2002, 05:35 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
posted a while back.

NPC Code:

dir vecx vecy
0 0 -1
1 -1 0
2 0 1
3 1 0



Quote:
commands.rtf
vecx( dir ) vertical movement vector (0,-1,0,1)
vecy( dir ) horizontal movement vector (-1,0,1,0)
I'm no expert at this, but I would think that if the player was facing down:


vecx(playerdir) //<-- that would equal the tile the player was standing on. (numeral direction for down: 2)

Numeral Directions:
0 Up
1 Left
2 Down
3 Right


Hope it helps.
Reply With Quote
  #3  
Old 09-06-2002, 05:54 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Err sort of, I still dont quite understand it, thanks though.
Reply With Quote
  #4  
Old 09-06-2002, 06:03 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by haunter
Err sort of, I still dont quite understand it, thanks though.
What don't you understand about it?
Reply With Quote
  #5  
Old 09-06-2002, 06:54 AM
Knuckles Knuckles is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 580
Knuckles is on a distinguished road
Send a message via AIM to Knuckles
I didn't really understand it at first either.. And it's kinda hard to explain.. Let's see...

*Steals Tarankusu's list*
NPC Code:

dir vecx vecy
0 0 -1
1 -1 0
2 0 1
3 1 0



*explains list ferther*
vecx(playerdir) // the best usage for it.
vecx={0,-1,0,1} // like if playerdir {0,1,2,3}
vecy={-1,0,1,0} // like if playerdir {0,1,2,3}
if playerdir = 0, the VECY would = -1
if playerdir = 1, the VECX would = -1
if playerdir = 2, the VECY would = 1
if playerdir = 3, the VECX would = 1

playery=playery+vecy(playerdir)
if he was faceing up, the playerdir would = 0, so it would add -1 to his playery, AKA playery-=1 //in other words.. move him up


playerx=playerx+vecx(playerdir)
if he was facing left, the playerdir would = 1, so it would add -1 to his playerx, AKA playerx-=1 //in other words.. move him left

and so on and so forth... >;/ get it?
__________________
Knuckles
"They say 60% of the time, it works everytime!"
Reply With Quote
  #6  
Old 09-06-2002, 08:08 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
So vecx and vecy are for moving the player?
Reply With Quote
  #7  
Old 09-06-2002, 08:12 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by haunter
So vecx and vecy are for moving the player?
not always.
you can also use them for detecting tiles infront of the players dir.
EXAMPLE:
NPC Code:

hitobjects 2,playerx+1.5+vecx(playerdir)*2,playery+2+vecy(pla yerdir)*2;

Reply With Quote
  #8  
Old 09-06-2002, 08:14 AM
Knuckles Knuckles is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 580
Knuckles is on a distinguished road
Send a message via AIM to Knuckles
No, but MOST SCRIPTERS when there new.. they use it for movement...

NPC Code:

if (playerenters || timeout) {
moveplayer();
timeout=0.05;
}
function moveplayer() {
for (i=0;i<4;i++) {
if (keydown(i)) {
playerdir=i;
playerx=playerx+vecx(i);
playery=playery+vecy(i);
}
}

__________________
Knuckles
"They say 60% of the time, it works everytime!"
Reply With Quote
  #9  
Old 09-06-2002, 08:18 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Quote:
Originally posted by Torankusu
not always.
you can also use them for detecting tiles infront of the players dir.
EXAMPLE:
NPC Code:

hitobjects 2,playerx+1.5+vecx(playerdir)*2,playery+2+vecy(pla yerdir)*2;

Yes, that is the kind of thing I want to know, for using with a triggeraction, to detect a player in front of you. Can you explain why the playerx has the +1.5+vecx(playerdir)*2 and the playery has +2+vecy(playerdir)*2 , please?
Reply With Quote
  #10  
Old 09-06-2002, 08:22 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by haunter

Yes, that is the kind of thing I want to know, for using with a triggeraction, to detect a player in front of you. Can you explain why the playerx has the +1.5+vecx(playerdir)*2 and the playery has +2+vecy(playerdir)*2 , please?
ask screen_name.

I'm not sure about the playery+2 / playerx+1.5 myself. I tried taking it out, but it didn't work. It doesn't move the player or anything though.
Reply With Quote
  #11  
Old 09-06-2002, 08:24 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Hmmm... Is there like a guide or something, in plain english for scripting @_@;?
Reply With Quote
  #12  
Old 09-06-2002, 08:41 AM
Knuckles Knuckles is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 580
Knuckles is on a distinguished road
Send a message via AIM to Knuckles
// Delete's post...

I posted a explination.. but explaining.. didn't make it sound right... hehe, i kinda confused myself >;O.. good idea < ask screen_name...
__________________
Knuckles
"They say 60% of the time, it works everytime!"
Reply With Quote
  #13  
Old 09-06-2002, 08:44 AM
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 Torankusu

NPC Code:

hitobjects 2,playerx+1.5+vecx(playerdir)*2,playery+2+vecy(pla yerdir)*2;

Is for hitting stuff in front of the player... use your imagination
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #14  
Old 09-06-2002, 09:00 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Quote:
Originally posted by Knuckles
// Delete's post...

I posted a explination.. but explaining.. didn't make it sound right... hehe, i kinda confused myself >;O.. good idea < ask screen_name...
Hmm alright, thanks for your help.

By the way, I was playing around with triggeraction and I can't get it to work,

NPC Code:


if (created) {
showcharacter;
}
if (playerchats&&strequals(#c,Test)) {
triggeraction x,y,test,;
}
if (actiontest) {
setcharprop #c,Test_kekeke;
}



Should that work, or am I just really dumb?
Reply With Quote
  #15  
Old 09-06-2002, 09:53 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by haunter


Hmm alright, thanks for your help.

By the way, I was playing around with triggeraction and I can't get it to work,

NPC Code:


if (created) {
showcharacter;
}
if (playerchats&&strequals(#c,Test)) {
triggeraction x,y,test,;
}
if (actiontest) {
setcharprop #c,Test_kekeke;
}



Should that work, or am I just really dumb?
What's the need for that?
Reply With Quote
  #16  
Old 09-07-2002, 07:29 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Quote:
Originally posted by Torankusu

What's the need for that?
Testing triggeraction ;P
Reply With Quote
  #17  
Old 09-07-2002, 07:33 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by haunter


Testing triggeraction ;P
well, you need a //#CLIENTSIDE
and the actiontest goes above the clientsided part.
Reply With Quote
  #18  
Old 09-07-2002, 11:19 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Quote:
Originally posted by Torankusu
well, you need a //#CLIENTSIDE
and the actiontest goes above the clientsided part.
I was testing offline ;O does that still matter?
Reply With Quote
  #19  
Old 09-07-2002, 11:50 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by haunter


I was testing offline ;O does that still matter?
i don't think triggering actions works offline...
Reply With Quote
  #20  
Old 09-07-2002, 11:56 AM
bigkow44 bigkow44 is offline
Registered User
bigkow44's Avatar
Join Date: Dec 2001
Location: Inside my head.
Posts: 610
bigkow44 is on a distinguished road
Quote:
Originally posted by haunter


Hmm alright, thanks for your help.

By the way, I was playing around with triggeraction and I can't get it to work,

NPC Code:


if (created) {
showcharacter;
}
if (playerchats&&strequals(#c,Test)) {
triggeraction x,y,test,;
}
if (actiontest) {
setcharprop #c,Test_kekeke;
}



Should that work, or am I just really dumb?
You use the (actiontest) or whatever in a different NPC usually...If its the same NPC you do a function

Also if it is a separate NPC and the separate one has an image, the triggeraction must be on the image. kind of like opening an NPC, your mouse has to be on its image or that blank NPC outline
__________________
Reply With Quote
  #21  
Old 09-08-2002, 03:17 AM
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 Torankusu
i don't think triggering actions works offline...
It does.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #22  
Old 09-08-2002, 03:24 AM
KuJi2002 KuJi2002 is offline
Banned
Join Date: Jul 2002
Location: NYC
Posts: 144
KuJi2002 is on a distinguished road
Send a message via AIM to KuJi2002 Send a message via Yahoo to KuJi2002
How do u work the mouse thingy anyway?
if (mousex==playerx) {
or something?
Reply With Quote
  #23  
Old 09-08-2002, 08:20 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Quote:
Originally posted by KuJi2002
How do u work the mouse thingy anyway?
if (mousex==playerx) {
or something?
open newfeatures2001.txt (or 2002 i forget which one) in notepad, press Ctrl+f and search for the word "mouse" and you should find how to use all of the new mouse, that's how I found out
Reply With Quote
  #24  
Old 09-08-2002, 08:24 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by Dach

It does.
I've never gotten serverside actions to be triggered offline...


And for the mousex questionaire,
I'm not too sure either.

I've tried it all different ways.
Reply With Quote
  #25  
Old 09-08-2002, 10:27 PM
Goboom Goboom is offline
Pixel Monkey
Goboom's Avatar
Join Date: Dec 2001
Location: Michigan
Posts: 1,702
Goboom is on a distinguished road
Send a message via ICQ to Goboom Send a message via AIM to Goboom Send a message via MSN to Goboom Send a message via Yahoo to Goboom
Quote:
Originally posted by haunter


Hmm alright, thanks for your help.

By the way, I was playing around with triggeraction and I can't get it to work,

NPC Code:


if (created) {
showcharacter;
}
if (playerchats&&strequals(#c,Test)) {
triggeraction x,y,test,;
}
if (actiontest) {
setcharprop #c,Test_kekeke;
}



Should that work, or am I just really dumb?
...read this....it was in new features...
- New script command: triggeraction targetx,targety,action,params;
This is one of the commands that give you like 50% more scripting
power than before. It is like a combination of hitobjects and
callnpc, but better. With 'triggeraction' you invoke an event
to the object on positon (targetx,targety). If the object is
an npc, then the npc script is called with the flag
'action<action>' set, when the object is a player then the
weapon scripts of the that player are called with the
'action<action>' flag set.
'params' can be one or more parameters, divided by commas;
the called script can read the paramters by accessing the
message code #p(paramindex).
Because this is hard to explain with words, here some
little examples:

- trigger player weapons
You can easily do a weapon which freezes the other
player:

if (playertouchsme) toweapons Freezing-Weapon;
if (weaponfired) {
triggeraction playerx+1.5+vecx(playerdir)*2,
playery+2+vecy(playerdir)*2,freeze,;
}
if (actionfreeze) {
freezeplayer 3;
setplayerprop #c,FREEZED;
}

Both players must have this weapon for making it
working. Then use it on the other player, and he will
be freezed, because a 'freeze' action is sent to him
and his weapon script, called with flag 'actionfreeze',
will freeze him. You can also move the if (actionfreeze) ...
into an system npc so the weapon can be used on all
players.
Other nice things you could do with triggering actions
on players: a stealing weapon which lets the other player
loose gralats (if (actionsteal) lay2 greenrupee,... );
complex attacking weapons that use your own hitpoint
system instead of the default hearts thing

- trigger npcs

Until now npcs can only react to 'playertouchsme' and
'washit', other things are very hard to do (e.g. the
mining on Graal2001 was made by checking periodically
what animation the player has and before which stone the
player stands). You could do callnpc, but this works only
client-side and you needed to pass parameters with
flags.
Using 'triggeraction' you can make those things much easier.
The mining axe could have the script
if (weaponfired) {
setani jaxe,hammergold0.png;
triggeraction playerx+1.5+vecx(playerdir)*2,
playery+2+vecy(playerdir)*2,mining,#v(axepower);
}
If you now use the weapon on a stone, the stone npc could
check this so:
if (actionmining) {
axepower = strtofloat(#p(0));
this.power -= axepower;
if (this.power<=0) {
setstring uncraftedgold,#v(strtofloat(#s(uncraftedgold))+1);
hide;
}
}
With this thing you can also easily do switches which are
activated with the hammer, or torch lamps which are turned on
by using a torch on it.
__________________
Reply With Quote
  #26  
Old 09-09-2002, 02:37 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
I DID read that, and to me there is nothing wrong with what i coded.
Reply With Quote
  #27  
Old 09-10-2002, 11:23 PM
R0b1n-NPC R0b1n-NPC is offline
Registered User
Join Date: Sep 2002
Posts: 397
R0b1n-NPC is on a distinguished road
x+1.5
y+1.5

I find triggeraction woorks better when in the middle of the npc/player.
__________________
- R0bin
Reply With Quote
  #28  
Old 09-11-2002, 03:32 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
I doubt this is possible, but can you use a call for a function via CLIENTSIDE and have the function DEFINED serverside?
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #29  
Old 09-11-2002, 03:58 AM
Graal2001_NAT Graal2001_NAT is offline
Registered User
Join Date: Sep 2002
Posts: 241
Graal2001_NAT is on a distinguished road
Quote:
Originally posted by emortylone
I doubt this is possible, but can you use a call for a function via CLIENTSIDE and have the function DEFINED serverside?
---Shifter
probaby not
__________________
GONE, BAI
Reply With Quote
  #30  
Old 09-11-2002, 07:42 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Figured as much. Never tried it, lolz.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
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:03 PM.


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