[Server Scripting] Script changes for next update

Discussion in 'Server and Client Scripting' started by coyotte508, Feb 19, 2012.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Next update, version 2.0, will have several changes.

    Including the possibility to use several teams on server. So that means that a team parameter will be added at the beginning for all functions pertaining to a team (including the gen() function).

    The battleStarted() event will have two additional parameters too at the end, one describing the team slot of each player.

    There will be some period of alpha testing anyway (at least 1 week), so you'll be able to test your scripts before the next version is released!

    (here is a changelog: http://pastebin.com/gvPVfdry )
     
    Last edited: Jul 7, 2012
  2. [ƦЄ]Blade

    [ƦЄ]Blade Not sure.

    Joined:
    Mar 6, 2011
    Messages:
    75
    Likes Received:
    0
    Sounds cool. Can't wait!
     
  3. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    inb4 EVERYTHING BREAKS :3
     
  4. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    U did it on purpose! :(

    We'll test stuff before release. :')
     
  5. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    You wish.
     
  6. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    If people doesn't help it'll take lot of time. >_> We're just 2 now...........................<insertmorepoints>
     
  7. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Test stuff? Too mainstream!
     
  8. Blitzamirin

    Blitzamirin Waluigi! Number one!

    Joined:
    Nov 25, 2011
    Messages:
    1,806
    Likes Received:
    276
    PO Trainer Name:
    Blitz
    This sounds like a nice addition. Hope it works.

    And of course, testing should be involved before hand. Doesn't mean devs will test them first, though ;)
     
  9. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    I already did! :lies:
     
  10. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    How will sys.hasLegalTeamForTier behave? Will it have team index parameter as well and will check only that particular team, or will it try to find suiting team?
    I also suggest functions to change active team, get amount of teams and events for changeActiveTeam and teamAdded(Deleted).
     
  11. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    no work has been done on sys.hasLegalTeamForTier. It will probably return an array of the teams legal for the tier. Like [0,3,4]. (1, 4th and 5th teams of the user). sys.isTeamLegalForTier(player, team, tier) will probably need to be added also.

    There's no concept of active team on server. You have several teams, you can challenge with any, answer a challenge with any in the correct tier, or find battle with all the teams you want together.

    About team changes: There are two possible ways to make a team change, either replace all the teams or one team only. This will be translated into event. (Notice that the server supports both, the client is too lazy atm to check if only a team changed. Maybe a Team menu in the client will allow to do that without going through the teambuilder).
     
  12. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    Ah, I got it all wrong. I thought it's implemented this way: Client has several teams, Server knows nothing about them, it only gets active team when a battle starts.

    Anyway, what I'm concerned about is scripted metagames, where players use teams created by server (RPG, Factory, etc...), not theyr own. The concept of having several teams may break everything since users might be able to select their own team instead of the one they should use, so I hope there will be away to limit amount of teams per user (by stopping teamAdded event, or by configuring the server).

    Also some kind of team identifier, say xml representation hash, might be usefull.
     
  13. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Well, after a teamchange event just reset a player's teams to what the stored team is (using the functions to change the team), or before a battle begins.
     
  14. Darklight

    Darklight Nothing is True

    Joined:
    Jan 8, 2011
    Messages:
    1,195
    Likes Received:
    1
    Woah, It looks so good, Oh yeah and btw, Testing if for nubs, Real men break things :3
     
  15. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
  16. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Ignore the sys.additionalChannels() it was removed.
     
  17. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Update is coming in a few days, as soon as I have all the data for the subgens.
     
  18. DipDip

    DipDip New Member

    Joined:
    May 1, 2012
    Messages:
    15
    Likes Received:
    0
    What to put in pokeSlot?


    [*]Changed sys.teamPoke(playerId, teamNum, pokeSlot) to support multiple teams.
     
  19. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    A number between 0-5 representing the party number.
    e.g. if you have a team of Salamence, Garchomp, Kyurem
    Then 0 would give the id of Salamence, 1 would give Garchomp etc
     
  20. DipDip

    DipDip New Member

    Joined:
    May 1, 2012
    Messages:
    15
    Likes Received:
    0
    Is that so?
    sys.teamPoke(src, i, 4);
     
  21. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    Why battleEnded and battleMatchup do not have a parameter that returns each player's team, just like battleStarted?

    Great job! I'm sure this new Pokémon Online will be amazing.
     
  22. MindFreak

    MindFreak Member

    Joined:
    Jun 23, 2012
    Messages:
    32
    Likes Received:
    0
    the scripts of old PO doesn't work very good>_>
     
  23. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    Try this
    PHP:
    1. afterBattleEnded: function(winner, loser, result, battleid,team1,team2)
    And
    PHP:
    1. beforeBattleMatchup : function(src,dest,clauses,rated,team1,team2)
    I use my own script to get the data from the teams in the afterBattleEnded event.

    PHP:
    1. var teamlist = "\n Winner " + sys.name(winner) + ":";
    2.         for(x=0; x<=5; x++)
    3.         {
    4.             var teammon = sys.teamPoke(winner,team1,x);
    5.             teamlist = teamlist + sys.pokemon(teammon);
    6.             if (x!=5)
    7.             {
    8.                 teamlist = teamlist + ",";
    9.             }
    10.         }
    11.         teamlist = teamlist + " vs Loser: " + sys.name(loser) + ":";
    12.         for (y=0; y<=5; y++)
    13.         {
    14.             var teammon = sys.teamPoke(loser,team2, y);
    15.             teamlist = teamlist + sys.pokemon(teammon);
    16.             if (y!=5)
    17.             {
    18.                 teamlist = teamlist + ",";
    19.             }
    20.         }
    21. sys.appendToFile("battleresults.txt", teamlist);
     
  24. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    I already tried to get it, but it always returned undefined.
    Maybe this is already fixed, I was using 2.0.0.1b version then lol

    I'll update this and I'll check if this works. Thanks!
     
  25. Abry

    Abry Member

    Joined:
    Dec 3, 2010
    Messages:
    64
    Likes Received:
    0
    When you challenge someone, you have to choose a team to use. And that's right. Then your opponent receive the Battle Challenge Window and can choose a Team.

    What's the parameter to prevent battle starting if the two teams chosen are not in the same tier?

    Let's say, I'm OU, I challenge someone that has a OU team AND a Uber Team. I Choose my OU, then he choose his Uber Team. But I wanted to battle him in OU, so what?
     
  26. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    beforeBattleStarted(src, dest, clauses, rated, mode, battleid, src_team, dest_team)

    You can use sys.tier(player, team) to compare
     
  27. Abry

    Abry Member

    Joined:
    Dec 3, 2010
    Messages:
    64
    Likes Received:
    0
    Is that enough to avoid the beginning of the match? After clicking on "Accept", isn't it unstoppable?
     
  28. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    No it isn't unstoppable at that point. The order goes beforeBattleStarted, battleSetup, afterBattleStarted. The challenges happen before the beforeBattleStarted event. When you call something in the before event, it allows you to stop the event by using sys.stopEvent.
     
  29. Abry

    Abry Member

    Joined:
    Dec 3, 2010
    Messages:
    64
    Likes Received:
    0
    Yes ok, but how to block beforeBattleStarted if the check on the team tiers of the two players involved is not the same as the tournament we ran? It seems it lacks of a parameter that specify the Tier of the teams used in the future battle; a sort of additional step inbetween Challenge and beforeBattleStarted...
     
  30. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    You could use beforeChallengeIssued if you really want to.

    PHP:
    1. beforeChallengeIssued : function (src, dest, clauses, rated, mode,team1,team2)
    2. {
    3. if(sys.tier(src, team1)!=sys.tier(dest,team2))
    4. {
    5. sys.sendMessage(src, "You may only face players in your tier.", chan);
    6. sys.stopEvent();
    7. }
    8. }
    9. ,
    10.  
     
  31. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    beforeChallengeIssued has two additional parameters: srcTeam and destTier.

    So you just have to check that sys.tier(src, srcTeam) == tourTier and destTier == tourTier.

    When you challenge someone, you choose a tier in his challenge window - if you challenge him in OU, he can only answer in OU, not in ubers - as well as the team you're using.
     
  32. Abry

    Abry Member

    Joined:
    Dec 3, 2010
    Messages:
    64
    Likes Received:
    0
    Didn't read about that parameters in the changelog sry.
     
  33. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    The changelog is missing the changes for timers:
    quickCall was added. It is like delayedCall but accepts milliseconds instead of seconds as second parameter.
    intervalTimer was added. It accepts a string as first parameter and milliseconds as second. It evaluates the string every xxx ms.
    intervalCall was added. It is like intervalTimer but the first parameter accepts a function.
    callLater, callQuickly, delayedCall, quickCall, intervalTimer, intervalCall: returns an id associated with the timer (can be stored in a number variable, array, or object)
    stopTimer stops a timer with the first parameter (the id). Returns true if a timer could be found and stopped. False otherwise.
     
  34. Tallgeese

    Tallgeese New Member

    Joined:
    Jul 31, 2012
    Messages:
    6
    Likes Received:
    0
    Unfortunately, this is not true in my testing. Is it supposed to be stoppable?

    Calling sys.stopEvent() in a beforeBattleStarted function on 2.0 gives a warning in the main server window that you are using it on an unstoppable event. I just tried it to enforce ability bans.

    Is there another way to check the abilities on a challenged person's team before battle starts for challenges? In 1.0, since there was just one team it was simple to do with beforeChallengeIssued, but you can't check their team with that now because they have not picked one yet.
     
  35. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Wasn't sure where to mention this, but that pastebin doesn't seem to list the new tempBan functions.

    sys.dbTempBanTime(name) return's how long name is banned for in seconds
    sys.tempBan(name, minutes) bans name for minutes.
     
  36. Tallgeese

    Tallgeese New Member

    Joined:
    Jul 31, 2012
    Messages:
    6
    Likes Received:
    0
    I do not know if you are still using this, but it looks as if afterBattleEnded is not set up to transmit the teams used. As a result, your code only returns the team in the user's first slot. Unless I am misreading the source, beforeBattleMatchup is not set for it either.
     
    Last edited: Aug 2, 2012
  37. Maxima304

    Maxima304 New Member

    Joined:
    Aug 12, 2012
    Messages:
    14
    Likes Received:
    0
    Hy When We click On Ur link This msg appears
    Oops! Google Chrome could not connect to pastebin.com
     
  38. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    pastebin was probably down for maintenance. it's back up.
     
  39. Manectric-Rang

    Manectric-Rang Unown-Ç ftw

    Joined:
    Mar 21, 2012
    Messages:
    60
    Likes Received:
    0
    I installed the last version and those functions still return undefined for me...
     
  40. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Which functions did you try (exact case)?