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 01-16-2011, 07:40 AM
MattKan MattKan is offline
the KattMan
Join Date: Aug 2010
Location: United States
Posts: 1,325
MattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to behold
Send a message via AIM to MattKan
Events: Teams?

I've taken up event development, and have managed to make a few things. Currently, I'm at a loss at making teams for team events.

I need to split up the players in the room into 2 equal (random) groups, each group with a different guild name.

I figure I'll need to use a randomizer, but I've never really done that before. And I'll need to apply it to all players in the room, which I have trouble doing ()

So if you guys could help me, that'd be great.

And if you could help me with the script pointing out what the more complicated parts mean, that'd be great. My goal is to learn, not to copy.
__________________
Quote:
Originally Posted by Satoru Iwata
On the other hand, free-to-play games, if unbalanced, could result in some consumers paying extremely large amounts of money, and we can certainly not expect to build a good relationship with our consumers in this fashion. In order to have a favorable long-term relationship, we would like to offer free-to-play games that are balanced and reasonable.
Quote:
Originally Posted by Unximad
Eurocenter Games remains attached to the values of indies game developer and to the service our playerbase community.
Reply With Quote
  #2  
Old 01-16-2011, 08:26 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Something simple is looping through all the players in the level and in each loop assign a team, then switch a flag, and go to the next.

PHP Code:
function AssignTeams() {
  
team 1;
  for (
player object players in the level) {
    
player guild team;
    
team = (team==1); //(arg ? true : false)
  
}

__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 01-16-2011 at 09:24 AM..
Reply With Quote
  #3  
Old 01-16-2011, 08:35 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
The easiest way is to use modulus (the % sign, think of it as "remainder" of division)

PHP Code:
temp.teams = {"Red Team""Blue Team"}; // array of teams
temp.0;

for (
temp.pl players) { // loop through the players
  
if (pl.guild == "Events Team") {
    continue; 
// if they have an ET tag, skip them
  
}
  
  
pl.guild teams[teams.size()];
  
++;

To add/remove teams just add them to the list at the top.

edit:


Quote:
Originally Posted by Switch View Post
PHP Code:
  team 1
You should always prefix your variables unless you intend for them to be global.
Quote:
PHP Code:
  for (player players in the level) { 
Uhm...what?
Quote:
PHP Code:
    player.guild team
Never use player as a variable name except to refer to the active player; it's reserved.
Quote:
PHP Code:
team = (team=1); //(arg ? true : false) 
Use == for comparison, like so:
PHP Code:
team = (team == 1); 
__________________

Last edited by cbk1994; 01-16-2011 at 08:55 AM..
Reply With Quote
  #4  
Old 01-16-2011, 09:05 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
missing the point
I was outlining it for him, not actually making it.

Quote:
Originally Posted by MattKan View Post
My goal is to learn, not to copy.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #5  
Old 01-16-2011, 09:06 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
I was outlining it for him, not actually making it.
So you mixed instructions with GScript inside a PHP tag, and you're wondering why I "missed the point"?

This line, for example:
PHP Code:
team = (team=1); //(arg ? true : false) 
The code part of the line (before the comment) looks like actual code, and the comment looks like you're explaining that code. I don't believe it would be unreasonable to assume a person new to GScript could reach the conclusion I did and become confused when it doesn't work.

I hope you don't take this as me picking on you for helping others, of course . I'm just trying to help you give assistance in a way that's less confusing.
__________________
Reply With Quote
  #6  
Old 01-16-2011, 09:24 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
So you mixed instructions with GScript inside a PHP tag, and you're wondering why I "missed the point"?

This line, for example:
PHP Code:
team = (team=1); //(arg ? true : false) 
The code part of the line (before the comment) looks like actual code, and the comment looks like you're explaining that code. I don't believe it would be unreasonable to assume a person new to GScript could reach the conclusion I did and become confused when it doesn't work.

I hope you don't take this as me picking on you for helping others, of course . I'm just trying to help you give assistance in a way that's less confusing.
True, didn't even notice that. It's so late.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #7  
Old 01-16-2011, 05:22 PM
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
Modulus is so not fun enough.

Randomizing with Sortvalue

PHP Code:
// Loop through each player in the level
for (temp.plplayers) {
  
// Make sure they aren't part of the ET
  
if (temp.pl.guild != "Events Team") {
    
// Add Player to Temp Players Array
    
temp.plyrs.add(temp.pl);
    
// Assign the Player a Random Sortvalue
    
temp.plyrs[temp.plyrs.size()-1].sortvalue random(0100);
  }
}
// Sort the Array by Value
temp.plyrs.sortbyvalue("sortvalue""float"false);
// Split the Array Appropriately and Assign Guild Tags
for (temp.pltemp.plyrs) {
  
// Your other code here

It's not really necessary to use a randomizer since the order of the players array isn't exactly public knowledge but for a queuing system it might be something to prevent players from stacking teams.
__________________
Quote:
Reply With Quote
  #8  
Old 01-16-2011, 06:56 PM
MattKan MattKan is offline
the KattMan
Join Date: Aug 2010
Location: United States
Posts: 1,325
MattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to behold
Send a message via AIM to MattKan
I wanted to do something where when player join the event and enter the level, they would be put on a team like this:

First person would go to Team 1, Second person would go to Team 2, Third Person would go to Team 1, and so on.

I tried using server flags to make it so that if a player logged in when
PHP Code:
server.eventname=
it would add the player to Team 1 and make
PHP Code:
server.eventname=
And then if they entered while
PHP Code:
server.eventname=
It would set the player to team 1 and reset:
PHP Code:
server.eventname=
That didn't work, and there probably is a better way. Thanks for all your advice on the first post, I will need those sometime soon, but for now I'm making an event where I want the players to be assigned teams alternatively as they enter. So, yeah, if you could help me again, lol
__________________
Quote:
Originally Posted by Satoru Iwata
On the other hand, free-to-play games, if unbalanced, could result in some consumers paying extremely large amounts of money, and we can certainly not expect to build a good relationship with our consumers in this fashion. In order to have a favorable long-term relationship, we would like to offer free-to-play games that are balanced and reasonable.
Quote:
Originally Posted by Unximad
Eurocenter Games remains attached to the values of indies game developer and to the service our playerbase community.
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 04:29 AM.


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