Issue information

Issue ID
#2605
Status
Duplicate
Severity
None
Started
Hercules Elf Bot
Dec 29, 2008 12:21
Last Post
Hercules Elf Bot
Dec 29, 2008 12:21
Confirmation
N/A

Hercules Elf Bot - Dec 29, 2008 12:21

Originally posted by [b]Ai4rei[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2605

setbattleflag/getbattleflag currently don't ajdust settings like it's done in battle_adjust_conf after battle config reading.
CODE
    battle_config.monster_max_aspd = 2000 - battle_config.monster_max_aspd*10;
    battle_config.max_aspd = 2000 - battle_config.max_aspd*10;
    battle_config.max_walk_speed = 100*DEFAULT_WALK_SPEED/battle_config.max_walk_speed;    
    battle_config.max_cart_weight *= 10;

Thus issuing setbattleflag("max_aspd", 195); won't work as expected. Suggested fix:
CODE
BUILDIN_FUNC(setbattleflag)
{
    const char *flag, *value;

    flag = script_getstr(st,2);
    value = script_getstr(st,3);

    if (battle_set_value(flag, value) == 0)
        ShowWarning("buildin_setbattleflag: unknown battle_config flag '%s'\n",flag);
    else
        ShowInfo("buildin_setbattleflag: battle_config flag '%s' is now set to '%s'.\n",flag,value);

    if(!strcmpi(flag, "monster_max_aspd")
    {
        battle_config.monster_max_aspd = 2000-battle_config.monster_max_aspd*10;
    }
    else if(!strcmpi(flag, "max_aspd"))
    {
        battle_config.max_aspd = 2000-battle_config.max_aspd*10;
    }
    else if(!strcmpi(flag, "max_walk_speed"))
    {
        battle_config.max_walk_speed = 100*DEFAULT_WALK_SPEED/battle_config.max_walk_speed;
    }
    else if(!strcmpi(flag, "max_cart_weight"))
    {
        battle_config.max_cart_weight *= 10;
    }

    if(battle_config.max_def > 100 && !battle_config.weapon_defense_type)     // added by [Skotlex]
        battle_config.max_def = 100;

    if(battle_config.min_hitrate > battle_config.max_hitrate)
        battle_config.min_hitrate = battle_config.max_hitrate;

    if(battle_config.pet_max_atk1 > battle_config.pet_max_atk2)    //Skotlex
        battle_config.pet_max_atk1 = battle_config.pet_max_atk2;

    return 0;
}

BUILDIN_FUNC(getbattleflag)
{
    const char *flag;
    int value;
    flag = script_getstr(st,2);
    value = battle_get_value(flag);

    if(!strcmpi(flag, "monster_max_aspd") || !strcmpi(flag, "max_aspd"))
    {
        value = (2000-value)/10;
    }
    else if(!strcmpi(flag, "max_walk_speed"))
    {
        value = 100*DEFAULT_WALK_SPEED/value;
    }
    else if(!strcmpi(flag, "max_cart_weight"))
    {
        value /= 10;
    }

    script_pushint(st, value);
    return 0;
}


#Edit1: Fixed calculations in setbattleflag being done on string...
#Edit2: Added missing adjustments to setbattleflag.

This post has been edited by Ai4rei: Jan 5 2009, 12:07 AM