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 08-21-2003, 03:36 PM
bashjgovers bashjgovers is offline
Registered User
Join Date: Aug 2003
Posts: 31
bashjgovers is on a distinguished road
players in room

hey i wanna make a event house where the people dont need ET to play events. I wanna make the doors will open automatic when there are enough players in the room. Can anyone help me with this?
Reply With Quote
  #2  
Old 08-21-2003, 03:48 PM
Neoreno Neoreno is offline
Cerebrate
Neoreno's Avatar
Join Date: Aug 2001
Location: England
Posts: 1,663
Neoreno is on a distinguished road
Send a message via AIM to Neoreno
Use a for loop and the playercount variable.
__________________

Quote:
Exitus Acta Probat: The Outcome Justifies the Deed.
Reply With Quote
  #3  
Old 08-21-2003, 04:28 PM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
Wasnt there a command like
if (playerscount == 2){..}
Bla, But i'd listen to kiirar, the loop is the best direction to go
__________________
"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
  #4  
Old 08-21-2003, 04:44 PM
Knuckles Knuckles is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 580
Knuckles is on a distinguished road
Send a message via AIM to Knuckles
Quote:
Originally posted by Snakeandy7
Wasnt there a command like
if (playerscount == 2){..}
Bla, But i'd listen to kiirar, the loop is the best direction to go
...That's close to what Kirrar's saying.
Quote:
Use a for loop and the playercount variable.
And you mean a timeout loop?
__________________
Knuckles
"They say 60% of the time, it works everytime!"
Reply With Quote
  #5  
Old 08-21-2003, 05:00 PM
Neoreno Neoreno is offline
Cerebrate
Neoreno's Avatar
Join Date: Aug 2001
Location: England
Posts: 1,663
Neoreno is on a distinguished road
Send a message via AIM to Neoreno
No. I mean a for loop.


Edit: I re-read what they wanted, a timeout loop would be more useful in this case.
__________________

Quote:
Exitus Acta Probat: The Outcome Justifies the Deed.

Last edited by Neoreno; 08-21-2003 at 06:12 PM..
Reply With Quote
  #6  
Old 08-21-2003, 06:27 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
ok... i'm no scripting genius, heck, i can barelly make a door

but wouldn't it look like this?
NPC Code:

timeout=0.5;

if (timeout && playercount>5){
do something;
timeout=0.5;
}



but I don't know, i've never used player count, and heck, i suck at scripting..
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #7  
Old 08-21-2003, 06:32 PM
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 marcoR
ok... i'm no scripting genius, heck, i can barelly make a door

but wouldn't it look like this?
NPC Code:

timeout=0.5;

if (timeout && playercount>5){
do something;
timeout=0.5;
}



but I don't know, i've never used player count, and heck, i suck at scripting..
Don't declare flags/variables etc. outside of code blocks. In addition, do not have an event check and a conditional check in the same if (statement). I suggest defining timeout in playerenters.
Reply With Quote
  #8  
Old 08-21-2003, 06:33 PM
Neoreno Neoreno is offline
Cerebrate
Neoreno's Avatar
Join Date: Aug 2001
Location: England
Posts: 1,663
Neoreno is on a distinguished road
Send a message via AIM to Neoreno
Well. The timeout is too infrequent. A timeout of 0.05 would do.
The variable is playerscount I believe. Not to mention it doesn't conform to KSI-GS standards.
__________________

Quote:
Exitus Acta Probat: The Outcome Justifies the Deed.
Reply With Quote
  #9  
Old 08-21-2003, 06:38 PM
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


In addition, do not have an event check and a conditional check in the same if (statement).
The logic behind this is...?
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #10  
Old 08-21-2003, 06:40 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
not the standards!? NO!!! *cuts hand off* it was an example, sheesh, and what's wrong with doing that? (give me a good reason and i'll never do it again)

[edit]
sorry about the timeout I always do that.. I don't even know why, I meant 0.05 tho.
[/edit]
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #11  
Old 08-21-2003, 06:50 PM
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


The logic behind this is...?

It is neater. Read KSI-GS standards thread.
Reply With Quote
  #12  
Old 08-21-2003, 06:58 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
meh, I guess I'll fall to the wrain of kai...

so would it be like this?

NPC Code:


timeout=0.05;

if (timeout){
if(playerscount>5){
do something, please!;
}
timeout=0.05;
}



atleast that's how I understood it...
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #13  
Old 08-21-2003, 06:59 PM
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 marcoR
meh, I guess I'll fall to the wrain of kai...

so would it be like this?

NPC Code:


timeout=0.05;

if (timeout){
if(playerscount>5){
do something, please!;
}
timeout=0.05;
}



atleast that's how I understood it...
You should still need to define timeout in a code block.
Reply With Quote
  #14  
Old 08-21-2003, 07:00 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
than like this!?

NPC Code:


if (created){
timeout=0.05;
}

if (timeout){
if(playerscount>5){
do something, please!;
}
timeout=0.05;
}




!?
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #15  
Old 08-21-2003, 07:27 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by marcoR
than like this!?

NPC Code:


if (created){
timeout=0.05;
}

if (timeout){
if(playerscount>5){
do something, please!;
}
timeout=0.05;
}




!?
Yes.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #16  
Old 08-21-2003, 09:12 PM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
Lol, finally he got it, still chance for you zero.
Anywho you could of done
if (playerenters || timeout){
}
lol, Anywho
__________________
"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
  #17  
Old 08-21-2003, 09:22 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
I knew how to make it work, I just didn't know how to do it propperly.
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #18  
Old 08-21-2003, 09:37 PM
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 marcoR
I knew how to make it work, I just didn't know how to do it propperly.
You got there in the end
__________________
"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
  #19  
Old 08-21-2003, 11:01 PM
Riot-Starter Riot-Starter is offline
Registered User
Join Date: Aug 2001
Location: Central Florida, USA
Posts: 79
Riot-Starter is on a distinguished road
Send a message via AIM to Riot-Starter
Just a side note:
playerscount includes NPCs when used clientside.
Reply With Quote
  #20  
Old 08-21-2003, 11:06 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by Riot-Starter
Just a side note:
playerscount includes NPCs when used clientside.
only showcharacter ones I believe, unless that was changed
Reply With Quote
  #21  
Old 08-21-2003, 11:20 PM
Riot-Starter Riot-Starter is offline
Registered User
Join Date: Aug 2001
Location: Central Florida, USA
Posts: 79
Riot-Starter is on a distinguished road
Send a message via AIM to Riot-Starter
Quote:
Originally posted by Python523


only showcharacter ones I believe, unless that was changed
I think it is only showcharacters, I just remember problems with gralats causing spar room doors to stay closed.
Although there is an easy fix to determine whether it’s an NPC or player.
Reply With Quote
  #22  
Old 08-21-2003, 11:38 PM
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 is neater. Read KSI-GS standards thread.
Neater? Subjective. I find it neater to have a balance of lines and lengths. You find it neater to have one check per line. When they are related (as they are in this case), I find it unnecessary to split it up. Perhaps I should paste the first line of the first if check in the hpfunctions subroutine on graal2001, and ask if those shouldn't be split up.

One line of two related checks (an event and a condition) and splitting them up one to each line is the same code - so you can't really argue efficiency or optimization, but only a stylistic choice.

(Additionally, the standards thread does not mention putting an event and a condition on separate lines.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----

Last edited by Tseng; 08-21-2003 at 11:51 PM..
Reply With Quote
  #23  
Old 08-21-2003, 11:40 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
I'm not a script head, so.. these rules would not be worth remembering, nor practicing.
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #24  
Old 08-22-2003, 12:51 PM
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


Neater? Subjective. I find it neater to have a balance of lines and lengths. You find it neater to have one check per line. When they are related (as they are in this case), I find it unnecessary to split it up. Perhaps I should paste the first line of the first if check in the hpfunctions subroutine on graal2001, and ask if those shouldn't be split up.

One line of two related checks (an event and a condition) and splitting them up one to each line is the same code - so you can't really argue efficiency or optimization, but only a stylistic choice.

(Additionally, the standards thread does not mention putting an event and a condition on separate lines.
I also find it more efficient to have one check per line in MOST cases. It adds flexibility to a script. You can add in additional commands and statements very easily as compared to having multiple checks in your if statement.
Reply With Quote
  #25  
Old 08-22-2003, 07:52 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by Riot-Starter

I think it is only showcharacters, I just remember problems with gralats causing spar room doors to stay closed.
Although there is an easy fix to determine whether it’s an NPC or player.
Yep,also these new gralats are showcharacters =p
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #26  
Old 08-22-2003, 10:41 PM
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
Quote:
Originally posted by protagonist


I also find it more efficient to have one check per line in MOST cases
that's not more efficient, it's just your style. dang, that word is getting thrown around to often nowadays
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #27  
Old 08-22-2003, 11:14 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
you can solve the problem of it counting npc characters by doing a for statement that includes the playerscount and a check if players[i].id>=0; as -1 = npc character. then if it's true add to a variable. this, however, would require resetting the string every time the event is called. I would go right out and post the script, but I fear it is against the rules of the NPC Scripting Forums
__________________
---Kain Morbid
Reply With Quote
  #28  
Old 08-23-2003, 01:04 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


I also find it more efficient to have one check per line in MOST cases. It adds flexibility to a script. You can add in additional commands and statements very easily as compared to having multiple checks in your if statement.
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.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #29  
Old 08-23-2003, 01:18 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 on Graal's inner workings. If you're using a literal compiler/interpreter that doesn't make a distinction between & and && then it's more efficient to split up the checks - if you combine them then it'll happily evaluate the whole condition without stopping to check if it's already invalidated itself.
__________________
Reply With Quote
  #30  
Old 08-23-2003, 03:46 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 on Graal's inner workings. If you're using a literal compiler/interpreter that doesn't make a distinction between & and && then it's more efficient to split up the checks - if you combine them then it'll happily evaluate the whole condition without stopping to check if it's already invalidated itself.
Well, I think I said it before, but I am only talking about an:

if (event && flag=true) {

compared to:

if (event) {
if (flag==true) {

type situation - if the event occurs, how could it invalidate itself in either?

Or, are you talking about if the event doesn't occur at all? That's the only way I can think that it could be invalidated...
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #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
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 09:49 PM.


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