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
  #31  
Old 08-23-2003, 03:48 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Ah, yes, in that case you are correct. I tend to favour separation of event checks from normal conditional statements, but that's just a stylistic thing. Wouldn't affect efficiency.
__________________
Reply With Quote
  #32  
Old 08-23-2003, 11:52 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
NPC Code:

//#CLIENTSIDE
if (timeout||playerenters) {
if (playerscount=>5) {
//Stuff here
}
timeout=0.05;
}


Also note if you have showcharacter NPCS (the ones which stefan put in.. that have heads, bodies and stuff counts as players to, so if you got lets say 2 of them, change the 5 to 7.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #33  
Old 08-23-2003, 12:31 PM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
//#CLIENTSIDE
if ((playerenters && strequals(#L,levelname.nw)) || timeout){
for(i=0; i<playerscount; i++{
stuff here :o
}
timeout=0.05;
}
Isnt that one way?
I dont think it is.. not sure tho :o..
__________________
"Freedom is best I tell thee
of all things to be won
then never live within the bond
of slavery my son".


Reply With Quote
  #34  
Old 08-23-2003, 02:09 PM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
Snake, no need for the level thing, playerscount is the players in the level, allplayers is players in the server.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #35  
Old 08-23-2003, 03:31 PM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
I see, Thanks for mensioning
__________________
"Freedom is best I tell thee
of all things to be won
then never live within the bond
of slavery my son".


Reply With Quote
  #36  
Old 08-23-2003, 06:46 PM
KainDaMan KainDaMan is offline
Registered User
Join Date: Jul 2003
Location: Virginia,USA
Posts: 51
KainDaMan is on a distinguished road
Send a message via AIM to KainDaMan
the npc character's problem can be solved like this
NPC Code:

for (i=0; i<playerscount; i++) {
if (players[i].id>=0) {
this.players++;
}
}


of course the "this.players" variable would have to be reset to zero before called. and the variable "this.players" everytime would equal to the amount of "real players" in the room.
__________________
---Kain Morbid
Reply With Quote
  #37  
Old 08-24-2003, 03:04 AM
protagonist protagonist is offline
Banned
protagonist's Avatar
Join Date: May 2003
Location: CAW
Posts: 5,586
protagonist is on a distinguished road
Send a message via AIM to protagonist Send a message via MSN to protagonist
Quote:
Originally posted by Tseng


Um, the first 'check' is when the action is called, so that happens regardless. The second 'check', be it on another line or in the same if ( ) statement, will be executed regardless; efficiency is not something you can debate with this.

Very easily? I don't go around putting '&& otherflag==true' for every check I add, but it is arguably easier to type two ampersands than 'if ( ) { }'. That does not make it better, but you are incorrect in saying it's easier.
It seems bluntly obvious that it is in the interest of readability to seperate your conditional checks.
Reply With Quote
  #38  
Old 08-24-2003, 06:31 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by protagonist


It seems bluntly obvious that it is in the interest of readability to seperate your conditional checks.
What part of 'stylistic choice' don't you understand? Readability is subjective.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #39  
Old 08-24-2003, 07:23 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
I prefer Tsengs way actually, because if you ask me its alot easier to see all the checks at once instead of making new brackets for each one

just so you know it's not jut Tseng whose crazy
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #40  
Old 08-24-2003, 07:27 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by Dach
I prefer Tsengs way actually, because if you ask me its alot easier to see all the checks at once instead of making new brackets for each one

just so you know it's not jut Tseng whose crazy
Well, you can liken it to reading. Different cultures have come up with different ways to read books. Some go left to right, then up to down; others go right to left, up to down; others just go straight down, right to left; still others go in other ways. Can you argue that our style of reading is better than the Japanese, or Hebrew?

Stylistic. choice.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #41  
Old 08-24-2003, 07:56 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
It depends. The name of the game is implicit intentions; personally I don't like searching through endless conditions to understand what somebody is doing. If the conditions are related then yeah, fine, but otherwise it's stupid.
__________________
Reply With Quote
  #42  
Old 08-24-2003, 08:37 AM
TB3 TB3 is offline
Registered User
TB3's Avatar
Join Date: May 2001
Location: US of A State of VA
Posts: 658
TB3 is on a distinguished road
Send a message via Yahoo to TB3
I didnt read all the way to the third page but.....

In order for more people to be in the room playerenters will have to be triggered.... *DUH* you dont need a timeout loop to lag the server any or little just a simple
NPC Code:


if(created) {
this.minplayers=5;
}
if(playerenters) {
if(playerscount>=this.minplayers){
blah();
}
}



THat would be sufficient right or did i miss something?


[edit]
NPC Code:


if(created) {
this.minplayers=5;
this.mode=0;
this.check=0;
}
if(playerenters||playerleaves) {
this.mode=(playerscount>=this.minplayers? 1 : playerscount<this.minplayers? 0 );
if(this.mode!==this.check) {
door();
}

}

function door() {
this.check=this.mode
if(this.mode=1) {//Opening
blah;
}
if(this.mode=0) {//Closing
blah;
}
}



THeres a more complex edit it should work *goez to zleep im tired*
__________________

To the sun of your age, I arise

Last edited by TB3; 08-24-2003 at 08:52 AM..
Reply With Quote
  #43  
Old 08-24-2003, 09:12 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by Kaimetsu
It depends. The name of the game is implicit intentions; personally I don't like searching through endless conditions to understand what somebody is doing. If the conditions are related then yeah, fine, but otherwise it's stupid.
if (playerchats && strequals(#c,give me pie)) {
//Some cool pie-giving coding
}

I've been arguing related the whole time.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #44  
Old 08-24-2003, 10:15 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by Tseng
I've been arguing related the whole time.
Indeed, but I'm not addressing just you
__________________
Reply With Quote
  #45  
Old 08-24-2003, 11:46 AM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
Quote:
Originally posted by TB3

NPC Code:


if(created) {
this.minplayers=5;
this.mode=0;
this.check=0;
}
if(playerenters||playerleaves) {
this.mode=(playerscount>=this.minplayers? 1 : playerscount<this.minplayers? 0 );
if(this.mode!==this.check) {
door();
}

}

function door() {
this.check=this.mode
if(this.mode=1) {//Opening
blah;
}
if(this.mode=0) {//Closing
blah;
}
}



THeres a more complex edit it should work *goez to zleep im tired*
I'm sorry but, why does your script question it self?...
__________________
"Freedom is best I tell thee
of all things to be won
then never live within the bond
of slavery my son".


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 01:14 PM.


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