Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-28-2004, 07:54 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Unhappy NPC Troubles :(

Hello all

I am trying to make a pair of staff boots where i can set the speed but when i try to test them it turns them on but my speed does not increase nor can i walk on and through obstacles. Check it out and help pls
Quote:
NPC Scriptundefined

// NPC made by Jerret
//#CLIENTSIDE

if (weaponfired) {
if (this.inuse=0) {
this.inuse=1;
timeout = 0.05;
setplayerprop #c,Boots On
} else {
this.inuse=0;
timeout = 0;
setplayerprop #c,Boots Off
}
}
if (this.inuse==1 && timeout) {
if (keydown(0)) playery -= strtofloat(this.bootspeed);
if (keydown(1)) playerx -= strtofloat(this.bootspeed);
if (keydown(2)) playery += strtofloat(this.bootspeed);
if (keydown(3)) playerx += strtofloat(this.bootspeed);
timeout = 0.05
}
if (timeout) {timeout = 0.05}
if (playerchats) {
tokenize #c;
if (tokenscount==3){
if (strequals(#t(0),/boots)&&strequals(#t(1),speed)) {
this.bootspeed = strtofloat(#t(2))
}
}
}
if (playerchats) {
if (strequals(#c,/boots on)) {
this.inuse==1;
timeout=.05;
}
if (strequals(#c,/boots off)) {
this.inuse==0;
}}
Reply With Quote
  #2  
Old 12-28-2004, 08:21 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
get rid of the strtofloat() around the this.bootspeed, it's a variable, not a string.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #3  
Old 12-28-2004, 08:40 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
frist of yes get rid of those strtofloats, second get rid of that pointless timeout , thrid u need to set the var first , nothing is setting the var when the script is active, with all the corrections is should look like this
PHP Code:
//#CLIENTSIDE
if (weaponfired) {
  if (
this.inuse=0) {
    
this.inuse=1;
    
timeout 0.05;
    
this.bootspeed=1;
    
setplayerprop #c,Boots On;
  
} else {
    
this.inuse=0;
    
setplayerprop #c,Boots Off;
  
}
}
if (
this.inuse==&& timeout) {
  if (
keydown(0)) playery -= this.bootspeed;
  if (
keydown(1)) playerx -= this.bootspeed;
  if (
keydown(2)) playery += this.bootspeed;
  if (
keydown(3)) playerx += this.bootspeed;
  
timeout 0.05;
}
if (
playerchats) {
  
tokenize #c;
  
if (tokenscount==3){
    if (
strequals(#t(0),/boots)&&strequals(#t(1),speed)) {
      
this.bootspeed strtofloat(#t(2));
    
}
  }
}
if (
playerchats) {
  if (
strequals(#c,/boots on)) {
    
this.inuse==1;
    
timeout=.05;
  }
  if (
strequals(#c,/boots off)) {
    
this.inuse==0;
  }

__________________

Reply With Quote
  #4  
Old 12-28-2004, 08:49 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Thank you
Reply With Quote
  #5  
Old 12-28-2004, 09:42 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
KSI-GS!
__________________
Reply With Quote
  #6  
Old 01-01-2005, 02:39 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
This is a slightly more complex way to do that. It shows a lot more techniques of manupilating strings/variables. Either way works just fine.

NPC Code:

//#CLIENTSIDE
if (created) this.speed = 0.5;
if (weaponfired) {
this.inuse = ( this.inuse + 1 ) % 2;
tokenize Off On;
setplayerprop #c,Boots #t(this.inuse);
timeout = 0.05;
}
if (timeout && this.inuse == 1){
this.x = (keydown(3) - keydown(1));
this.y = (keydown(2) - keydown(0));
playerx += this.x * this.speed;
playery += this.y * this.speed;
timeout = 0.05;
}
if (playerchats){
if (strequals(#e(0,6,#c),/boots)){
tokenize #c;
setstring this.list,off,on;
if (strtofloat(#t(1)) > 0){
this.speed = strtofloat(#t(1));
} else if (lindexof(#t(1),this.list) > -1){
this.inuse = lindexof(#t(1),this.list);
timeout = 0.05;
}
}
}

Reply With Quote
  #7  
Old 01-04-2005, 10:49 PM
Sildae Sildae is offline
Elven sorceress!
Sildae's Avatar
Join Date: Dec 2001
Location: Lothlòrien
Posts: 159
Sildae is on a distinguished road
I am not really good with gscript, and I have not used it for years, so I have a few questions. I have made a few changes to your code, could you explain to me why you did not write it that way?
Quote:
Originally Posted by Velox Cruentus
NPC Code:

//#CLIENTSIDE
if (created)
this.speed = 0.5;

if (weaponfired) {
timeout = 0.05 - timeout;
tokenize Off On;
setplayerprop #c,Boots #t(timeout * 20);
}

if (timeout) {
for (direction = 0; direction < 4; direction ++) {
playerx += keydown(direction) * vecx(direction) * this.speed;
playery += keydown(direction) * vecy(direction) * this.speed;
}
timeout = 0.05;
}

if (playerchats) {
if (startswith(/boots, #c)) {
newSpeed = strtofloat(#e(7,-1,#c));
if (newSpeed > 0) {
this.speed = newSpeed;
} else {
index = indexof(#e(7,-1,#c), off on);
if (index in {0, 4})
timeout = 0.05 * (index / 4);
}

}
}

__________________
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man."
-- George Bernard Shaw
Reply With Quote
  #8  
Old 01-04-2005, 10:56 PM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
your version of his script appears to be just as good

I would have used vecx and vecy myself, if I was making this. His version of that part seems to be more efficient though.

I would say the biggest difference between the way you coded it, and the way he coded it, is that when I read his, I can understand what each line does easier. It took me a little longer to understand why you used certain things the way you did.

Edit: many things edited in this post
__________________


Last edited by Evil_Trunks; 01-04-2005 at 11:10 PM..
Reply With Quote
  #9  
Old 01-05-2005, 01:30 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
Well, first off, it's a lot more effiecient:
PHP Code:
this.= (keydown(3) - keydown(1));
this.= (keydown(2) - keydown(0));
playerx += this.this.speed;
playery += this.this.speed
PHP Code:
for (direction 0direction 4direction ++) {
  
playerx += keydown(direction) * vecx(direction) * this.speed;
  
playery += keydown(direction) * vecy(direction) * this.speed;

Basically here, you're saying "Go by there! Then by here! ... ...", where they can cancel out... 5 right + 5 left = 0 movement. Thus, if you press the right and left movement, you would't move at all... It would prevent calculating one side, then calculating the next.

Other then that, the rest doesn't change much at all...Other then you declared a variable where I didn't. And I used tokenize. Differant ways to proceed.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:08 PM.


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