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 02-08-2005, 03:21 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
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)
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #2  
Old 02-08-2005, 04:00 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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...?
Reply With Quote
  #3  
Old 02-08-2005, 04:02 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
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?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #4  
Old 02-08-2005, 04:04 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
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?
__________________
Who has time for life these days?
Reply With Quote
  #5  
Old 02-08-2005, 04:07 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
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.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #6  
Old 02-08-2005, 05:18 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
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 )
__________________
Who has time for life these days?
Reply With Quote
  #7  
Old 02-08-2005, 05:21 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
I will try using this method and tell you ifd it works, thanks for your help.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #8  
Old 02-08-2005, 05:26 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
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.
__________________
Who has time for life these days?
Reply With Quote
  #9  
Old 02-08-2005, 10:25 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
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.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!

Last edited by falco10291029; 02-09-2005 at 01:03 AM..
Reply With Quote
  #10  
Old 02-08-2005, 10:53 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #11  
Old 02-08-2005, 11:31 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
I tried both, neihter worked.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #12  
Old 02-08-2005, 11:47 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by falco10291029
I tried both, neihter worked.
how are you obtaining 'client.id'?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #13  
Old 02-08-2005, 11:54 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
I already made sure that part works, don't worry about it.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #14  
Old 02-09-2005, 12:03 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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.
Reply With Quote
  #15  
Old 02-09-2005, 01:04 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
I did, the problem is that the callnpc isnt getting picked up by the monster.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #16  
Old 02-09-2005, 05:18 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by falco10291029
I did, the problem is that the callnpc isnt getting picked up by the monster.
This would probably then mean that you're not getting the proper NPC. I think it's more intelligent to do the selection in a weapon. Also I think it's helpful to do a this.npctype string on class NPCs so you know exactly what it is via the script. That way you could check if (strequals(#s(this.npctype)),monster)) and know it's a monster.
For debugging, that's a crucial part man x.x I'd suggest trying with (npc[client.id]) sendtonc accessing the monster!: And if you do the this.npctype I said also send that, perhaps your'e not on the right NPC (as I said prior). What server is this on and I might swing by?
__________________
Who has time for life these days?
Reply With Quote
  #17  
Old 02-09-2005, 06:17 AM
Alexander Alexander is offline
Registered User
Join Date: Apr 2003
Location: California
Posts: 246
Alexander is on a distinguished road
Send a message via AIM to Alexander
Clientside ID of a NPC does not always equal the serverside ID of a NPC.

Also why not just trigger the npc directly from clientside?
Reply With Quote
  #18  
Old 02-09-2005, 10:05 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Dont you need callnpc servewrside if dealing with a serverside npc?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!

Last edited by falco10291029; 02-09-2005 at 10:38 PM..
Reply With Quote
  #19  
Old 02-09-2005, 10:51 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Found the problem, cant fix it:


NPC Code:

this.npc=strtofloat(#p(1));
callnpc this.npc,move,#p(2),#p(3);


That part, where it sends the command to the npc, which should recieve it with:

NPC Code:

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


But it doesnt make any acknowledgement that it was told to move.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #20  
Old 02-09-2005, 11:31 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
> Clientside ID of a NPC does not always equal the serverside ID of a NPC.
> Also why not just trigger the npc directly from clientside?
Reply With Quote
  #21  
Old 02-10-2005, 12:23 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Is there any way to convert a clientside id to a serverside one?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #22  
Old 02-10-2005, 02:02 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by falco10291029
Is there any way to convert a clientside id to a serverside one?
Well there are different solutions:

1. You trigger on the position of the npc you want to move, then the npc directly gets the trigger and you don't need to code anything complicated (triggeraction monsterx,monstery,test,...; -> if (actiontest) ...)

2. You send the ID of the npc (not the index), and on the serverside you are searching for the npc with the right id - this works because the ID is actually the same, except when the npc is not existing on the serverside, e.g. if it only has clientside script
for (i=0; i<npcscount; i++) if (npcs[i].id==monsterid) callnpc i,test,...;
Reply With Quote
  #23  
Old 02-10-2005, 03:23 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
I'll try the second one.


EDIT: It works, thank you so much! And also thanks PS for giving me tha targeting system when you came on last night.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!

Last edited by falco10291029; 02-10-2005 at 04:01 AM..
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 09:27 PM.


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