1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Guest, PO has ceased our separate tiering and adopted Smogon tiers for SM. More information and updates here.

    Dismiss Notice

Code questions

Discussion in 'Development General' started by Zakharov, Oct 4, 2011.

  1. Zakharov

    Zakharov New Member

    Joined:
    Oct 2, 2011
    Messages:
    11
    Likes Received:
    0
    I want to modify the behavior of some moves, but I can't find the code to modify. If any of you can help, that would be great. The moves are:

    - Chip Away (I want to copy this functionality to some other moves)
    - Dragon Rage
    - Hurricane (Might be named WindStorm? I can't find anything for either, but I can modify Thunder and Blizzard just fine).

    I've done a search in /src for the names of all these moves. I only get results for Dragon Rage, but that gives me
    "turn(b,s)["CustomDamage"] = turn(b,s)["DragonRage_Arg"];"
    and no references anywhere to what DragonRage_Arg is.
     
  2. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    What exactly do you want to change?
    The easiest way is to do it with scripts, you can alter move power, accuracy, priority and PP, see the docs.
    If this is not enough, you can modify most things in the database, it's located in /bin/db/moves/ and its subfolders.
    In those files each line represents a move, line number - move id (actually id+1, but that doesn't matter).
    As an example: To find Draco Meteor's id we check moves.txt, DM is at the line 435, so by modifying 435's line in other files we can alter DM's behavior. Say, by replacing 2 with 1 in /5G/damage_class.txt we can make it Physical, by changing 0 to -50 in /5G/recoil.txt, we can make it cause 50% recoil, etc... Some properties like caused effects are a bit tricky, but can also be changed.
     
  3. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    MoveName_Arg is a value from the file move_special_effects.txt after specifying the class.

    In this case, the file contains
    30-40 for dragon rage
    and
    30-20 for sonicboom

    Code (c++):
    1.  
    2.         std::string s = specialEffectS.toStdString();
    3.  
    4.         int specialEffect = atoi(s.c_str());
    5.  
    6.         /* if the effect is invalid or not yet implemented then no need to go further */
    7.         if (!mechanics.contains(specialEffect)) {
    8.             break;
    9.         }
    10.  
    11.         MoveMechanics &m = mechanics[specialEffect];
    12.         QString &n = names[specialEffect];
    13.  
    14.         QHash<QString, MoveMechanics::function>::iterator i;
    15.  
    16.         size_t pos = s.find('-');
    17.         if (pos != std::string::npos) {
    18.             MM::turn(b,source)[n+"_Arg"] = specialEffectS.mid(pos+1);
    19.         }
    20.  
     
    Last edited: Oct 4, 2011
  4. Zakharov

    Zakharov New Member

    Joined:
    Oct 2, 2011
    Messages:
    11
    Likes Received:
    0
    Ah, thanks for that, that answers my questions about Dragon Rage and Hurricane. I still can't find anything about Chip Away, though.

    EDIT: I think Chip Away is named Trickery, so that solves that problem.
    EDIT2: No, Trickery is Foul Play.
     
    Last edited: Oct 4, 2011
  5. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Unfortunately, ChipAway is hardcoded. (It's referred as PaymentPlan in the source)

    Only way to duplicate it's information is to modify C++ source.

    battle.cpp:
    Code (c++):
    1.  
    2.         //Unaware
    3.         if (attacker != player && attacked == player) {
    4.             if (hasWorkingAbility(attacker, Ability::Unaware) && (stat == SpDefense || stat == Defense || stat == Evasion)) {
    5.                 boost = 0;
    6.             }
    7.             else if ((tmove(attacker).attack == Move::PaymentPlan
    8.                       || tmove(attacker).attack == Move::SacredSword)&& (stat == SpDefense || stat == Defense)) {
    9.                 boost = 0;
    10.             }
    11.         } else if (attacker == player && attacked != player && hasWorkingAbility(attacked, Ability::Unaware) &&
    12.                    (stat == SpAttack || stat == Attack || stat == Accuracy)) {
    13.             boost = 0;
    14.         }
    15.  
     
  6. Zakharov

    Zakharov New Member

    Joined:
    Oct 2, 2011
    Messages:
    11
    Likes Received:
    0
    Modifying the source is fine, I've done that for a few moves already. The only tricky part is figuring out what parts of the source to modify. Thanks for your help with that.
     
  7. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Well yeah, I posted the part, you can probably figure out ^_^
     
  8. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
  9. Zakharov

    Zakharov New Member

    Joined:
    Oct 2, 2011
    Messages:
    11
    Likes Received:
    0
    That's not an issue for me; one part of my mod is removing all evasion.