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 07-18-2002, 06:54 AM
IAMNOTAFREAK IAMNOTAFREAK is offline
Registered User
Join Date: May 2002
Location: IBM Stellar Sphere
Posts: 118
IAMNOTAFREAK is on a distinguished road
Send a message via ICQ to IAMNOTAFREAK Send a message via AIM to IAMNOTAFREAK
help with onwall

NPC Code:

if (created) {toweapons walking;}
if (playerenters){this.m=.1;this.oldx = playerx;this.oldy = playery;}
if (isweapon||timeout){this.mx=0;this.my=0;this.ok=1;
this.dir=10*this.my+this.mx;this.rx=1;this.ry=1;
if (playerx<this.oldx) {this.mx=this.m;}
if (playery<this.oldy) {this.my=this.m;}
if (playerx>this.oldx) {this.mx=-1*this.m;}
if (playery>this.oldy) {this.my=-1*this.m;}
if (this.mx<0) {this.rx=4-1;}
if (this.mx>0) {this.rx=-1.5-1;}
for (i=1;i<=2;i+=.25; ) {this.rx+=.25;
for (this.ry=1;this.ry<=2.5;this.ry+=.5) {
if (onwall(playerx+this.rx+this.mx,playery+this.ry)) {this.ok=0;}}}
if (this.ok==1) {playerx-=this.mx;}
if (this.my<0) {this.ry=4.5-1.5;}
if (this.my>0) {this.ry=-1-1.5;}
for (i=1;i<=3;i+=.25; ) {this.ry+=.25;
for (this.rx=.75;this.rx<=2.5;this.rx+=.5) {
if (onwall(playerx+this.rx,playery+this.ry+this.my)) {this.ok=0;}}}
if (this.ok==1) {playery-=this.my;}
this.oldx = playerx;
this.oldy = playery;
timeout=.05;
}



the scripts works fine, i just need some help with the onwall for playerdir 1 (to the left)
__________________
Crimson


Nocturne...it's coming.
Reply With Quote
  #2  
Old 07-18-2002, 07:50 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
no offense but the format is like unreadable, format your scripts like this
if(stuff){
commands here;
}
Reply With Quote
  #3  
Old 07-18-2002, 08:24 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
Everyone has their own preference in formating. If you wanna be anal retentative (sp?) it should acually be like

NPC Code:

if(this)
{
commands;
if(this)
{
commands;
}
}



I acualy like this way more, since you can see the acual code blocks. but it is faster to type it in one line. Which is how most people do it. Duno why I posted this. But their are many ways to format. I'm more concerned with his lack of commenting. Commenting will help you and everyone else emmensly (sp?). Telling yourself and other what you are doing in the code, what the variables do and stuff. So comming back to your code weeks/months later, doesn't confuse you.
__________________

subliminal message: 1+1=3
Reply With Quote
  #4  
Old 07-18-2002, 08:36 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
i use to formatlike that, but I changed when my friends wanted me to use the other way for some reason, don't know why, as long as its not like all on one line I try not to complain too much
Reply With Quote
  #5  
Old 07-18-2002, 09:25 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
My format.

NPC Code:


if (playerenters) {
do this stuff;
do that stuff;
if (this == that) {
do this stuff too;
} else {
do this stuff instead;
}
}



omg wow my screen just flashed blue
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #6  
Old 07-18-2002, 10:30 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
that code was pretty unreadable Xx

dont include every command on one line please

but you could use onwall2 if going to use NPC Server



- to you CheeTos
__________________
[signature]insert here[/signature]
Reply With Quote
  #7  
Old 07-19-2002, 11:40 AM
IAMNOTAFREAK IAMNOTAFREAK is offline
Registered User
Join Date: May 2002
Location: IBM Stellar Sphere
Posts: 118
IAMNOTAFREAK is on a distinguished road
Send a message via ICQ to IAMNOTAFREAK Send a message via AIM to IAMNOTAFREAK
any experienced scripter would be able to read that with no problem...or maybe im just special

anyway, here:
NPC Code:

if (created) {
toweapons walking;
}
if (playerenters){
this.m=.1;
this.oldx = playerx;
this.oldy = playery;
}
if (isweapon||timeout){
this.mx=0;
this.my=0;
this.ok=1;
this.dir=10*this.my+this.mx;
this.rx=1;this.ry=1;
if (playerx<this.oldx) {
this.mx=this.m;
}
if (playery<this.oldy) {
this.my=this.m;
}
if (playerx>this.oldx) {
this.mx=-1*this.m;
}
if (playery>this.oldy) {
this.my=-1*this.m;
}
if (this.mx<0) {
this.rx=4-1;
}
if (this.mx>0) {
this.rx=-1.5-1;
}
for (i=1;i<=2;i+=.25; ) {
this.rx+=.25;
for (this.ry=1;this.ry<=2.5;this.ry+=.5) {
if (onwall(playerx+this.rx+this.mx,playery+this.ry)) {
this.ok=0;
}
}
}
if (this.ok==1) {
playerx-=this.mx;
}
if (this.my<0) {
this.ry=4.5-1.5;
}
if (this.my>0) {
this.ry=-1-1.5;
}
for (i=1;i<=3;i+=.25; ) {
this.ry+=.25;
for (this.rx=.75;this.rx<=2.5;this.rx+=.5) {
if (onwall(playerx+this.rx,playery+this.ry+this.my)) {
this.ok=0;
}
}
}
if (this.ok==1) {
playery-=this.my;
}
this.oldx = playerx;
this.oldy = playery;
timeout=.05;
}



there, gosh that's so much longer...
well, anyway, here, now it's readable, please help, all i need is some help with onwall, not too much to ask...i'm just no good with it...
and, by the way, it's not for an npc server, but how do you use onwall2, for future reference...
__________________
Crimson


Nocturne...it's coming.
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 07:30 PM.


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