Graal Forums

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

falco10291029 02-08-2005 03:21 AM

mouse coords
 
NPC Code:

with (getplayer(#s(this.player))) {
thiso.x=mousex;
thiso.y=mousey;
}


this should transefer player mouse x and y coordinates to the npc's values thos.x and this.y right? If not what am I doing wrong? (if needbe I can post more of the script)

Lance 02-08-2005 04:00 AM

Quote:

Originally Posted by falco10291029
NPC Code:

with (getplayer(#s(this.player))) {
thiso.x=mousex;
thiso.y=mousey;
}


this should transefer player mouse x and y coordinates to the npc's values thos.x and this.y right? If not what am I doing wrong? (if needbe I can post more of the script)

They are clientside variables, and you are trying to access them serverside...?

falco10291029 02-08-2005 04:02 AM

Well is there anyway i can access them with a serverside script without trying to somehow get the client to constantly send them as new variables?

Projectshifter 02-08-2005 04:04 AM

Quote:

Originally Posted by falco10291029
NPC Code:

with (getplayer(#s(this.player))) {
thiso.x=mousex;
thiso.y=mousey;
}


this should transefer player mouse x and y coordinates to the npc's values thos.x and this.y right? If not what am I doing wrong? (if needbe I can post more of the script)

I get the impression you haven't even tried this... "this should..." "if not what am I doing wrong?" Try it next time before hand. And I believe they are purely clientside vars, in which case you'd either need to do a constant triggeraction (ewww...) or set client.strings and read from them constantly (ewww...) What are you trying to do and perhaps we could suggest another method?

falco10291029 02-08-2005 04:07 AM

I did try it, of course, I read the rules. By it should i mean it doesnt but it should and by iof not what am i doign wrong i mean if im wrong assuming this should what is the proper method? But anyway, what i am trying to do is have a summoned monster move to and when close enough attack that coordinate. I couldnty use a triggeractrion or client.string since it's a putnpc2 class npc that gets summoned, so yes any help would be appreciated.

Projectshifter 02-08-2005 05:18 AM

Quote:

Originally Posted by falco10291029
I did try it, of course, I read the rules. By it should i mean it doesnt but it should and by iof not what am i doign wrong i mean if im wrong assuming this should what is the proper method? But anyway, what i am trying to do is have a summoned monster move to and when close enough attack that coordinate. I couldnty use a triggeractrion or client.string since it's a putnpc2 class npc that gets summoned, so yes any help would be appreciated.

You're talking about some type of monster control I assume? You'll want to have a special weapon set aside for administrating them. Will want to select that monster, and store its id (we'll use the string monsterid for this purpose)
NPC Code:

if (actionserverside){
if (strequals(#p(0),move))
callnpcs strtofloat(#p(1)),move,#p(2),#p(3);
//this will trigger an if (move) statement with the coordinates (triggers the monster)
}

//#CLIENTSIDE
if (mousedown && leftmousebutton && monsterid != -1)
//You'll need to do a monsterid selection system, and set -1 to mean not a monster
triggeraction 0,0,serverside,weaponName,move,#v(monsterid),#v(mo usex),#v(mousey);



That would be the best way to go about it in my opinion. It is best to keep as much of the monster code in the actual monster class, rather than spread it out (Makes it easier for editing and just overall purposes). If you have any other questions ask away (within reason and after evaluating what you're asking ;))

falco10291029 02-08-2005 05:21 AM

I will try using this method and tell you ifd it works, thanks for your help.

Projectshifter 02-08-2005 05:26 AM

Quote:

Originally Posted by falco10291029
I will try using this method and tell you ifd it works, thanks for your help.

No problems. At least you're being more open-minded than some others :) As long as you're willing to learn, there will always be people willing to teach and help you out when you run into problems.

falco10291029 02-08-2005 10:25 PM

hmm, doesnt seem to be working, through debug maneuvers the problem seems to be that the monster isnt recieving the flag....

NPC Code:

if (move) {
unset move;
this.x=strtofloat(#p(0));
this.y=strtofloat(#p(1));
}


which is called from the script:
NPC Code:

if (actionserverside) {
callnpcs strtofloat(#p(0)),move,#p(2),#p(3);
}
//#CLIENTSIDE
//note this isnt the full script, I cut only the client and serverside parts that are used here.

if (mousedown&&leftmousebutton&&strlen(#s(client.id)) >0) {
setplayerprop#c, #s(client.id);
triggeraction 0,0,serverside,subclass/summon mold,#s(client.id),#v(mousex),#v(mousey),move;


};



I believe this is what you said to do, I haven't ever used callnpc before though, so i wouldn't know.

ApothiX 02-08-2005 10:53 PM

Quote:

Originally Posted by falco10291029
hmm, doesnt seem to be working, through debug maneuvers the problem seems to be that the monster isnt recieving the flag....

NPC Code:

if (actionserverside) {
callnpcs strtofloat(#p(0)),move,#p(2),#p(3);
}


Try changing 'callnpcs' to callnpc

falco10291029 02-08-2005 11:31 PM

I tried both, neihter worked.

ApothiX 02-08-2005 11:47 PM

Quote:

Originally Posted by falco10291029
I tried both, neihter worked.

how are you obtaining 'client.id'?

falco10291029 02-08-2005 11:54 PM

I already made sure that part works, don't worry about it.

Lance 02-09-2005 12:03 AM

Quote:

Originally Posted by falco10291029
hmm, doesnt seem to be working, through debug maneuvers the problem seems to be that the monster isnt recieving the flag....

NPC Code:

if (move) {unset move;this.x=strtofloat(#p(0));this.y=strtofloat(#p (1));}


which is called from the script:
NPC Code:

if (actionserverside) {
callnpcs strtofloat(#p(0)),move,#p(2),#p(3);
}
//#CLIENTSIDE
//note this isnt the full script, I cut only the client and serverside parts that are used here.

if (mousedown&&leftmousebutton&&strlen(#s(client.id)) >0) {
setplayerprop#c, #s(client.id);
triggeraction 0,0,serverside,subclass/summon mold,#s(client.id),#v(mousex),#v(mousey),move;


};



I believe this is what you said to do, I haven't ever used callnpc before though, so i wouldn't know.

Please make an effort to make your code readable. Refer to KSI-GS, please.

Anyway, follow the debug process, dude. Figure out exactly which part of your code is not working, and then post it.

falco10291029 02-09-2005 01:04 AM

I did, the problem is that the callnpc isnt getting picked up by the monster.


All times are GMT +2. The time now is 09:22 AM.

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