Jump to content
  • 0

set CELL_PK


Scofield

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.03
  • Content Count:  265
  • Reputation:   11
  • Joined:  01/11/13
  • Last Seen:  

want to activate pvp only in a specific area of the map, I made these changes more still not work, do not be activating pvp. I wonder if there's something wrong.

 

SRC

  

//battle.c
    
    
    //find this
    
    
    int battle_check_target( struct block_list *src, struct block_list *target,int flag)
    
    
    //add this before it
    
    
    bool cell_pk_check(struct block_list *t_bl, struct block_list *s_bl, int m)
    
    
    {
    
    
            if(t_bl->type == BL_PC && map[m].cell[s_bl->x+s_bl->y*map[m].xs].pk == true && map[m].cell[t_bl->x+t_bl->y*map[m].xs].pk == true)
    
    
            {
    
    
                    if(status_get_party_id(t_bl)==status_get_party_id(s_bl))
    
    
                            if(map[m].flag.pvp_noparty)
    
    
                                    return true;
    
    
                            else
    
    
                                    return false;
    
    
                    if(status_get_guild_id(t_bl)==status_get_guild_id(s_bl))
    
    
                            if(map[m].flag.pvp_noguild && map[m].flag.gvg)
    
    
                                    return true;
    
    
                            else
    
    
                                    return false;
    
    
                    return true;
    
    
            }
    
    
            return false;
    
    
    }
    
    
     
    
    
    //+++++++++++++++++++++++++++++++++//
    
    
     
    
    
    //find this
    
    
    else if(( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.p
    
    
    //use this to replace
    
    
    else if(( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg&& map_flag_gvg(m))))||( cell_pk_check(t_bl, s_bl, m) == true ))
    
    
     
    
    
    //+++++++++++++++++++++++++++++++++//
    
    
     
    
    
    //map.c
    
    
    void map_setcell(int m, int x, int y, cell_t cell, bool flag)
    
    
    {
    
    
            int j;
    
    
            if( m < 0 || m >= map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
    
    
                    return;
    
    
            j = x + y*map[m].xs;   
    
    
            switch( cell ) {
    
    
                    case CELL_WALKABLE:      map[m].cell[j].walkable = flag;      break;
    
    
                    case CELL_SHOOTABLE:     map[m].cell[j].shootable = flag;     break;
    
    
                    case CELL_WATER:         map[m].cell[j].water = flag;         break;
    
    
                    case CELL_NPC:           map[m].cell[j].npc = flag;           break;
    
    
                    case CELL_BASILICA:      map[m].cell[j].basilica = flag;      break;
    
    
                    case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break;
    
    
                    case CELL_NOVENDING:     map[m].cell[j].novending = flag;     break;
    
    
                    case CELL_NOCHAT:        map[m].cell[j].nochat = flag;        break;
    
    
                   
    
    
                    case CELL_PK:   map[m].cell[j].pk = flag;       break;//<---add this
    
    
                   
    
    
                    default:
    
    
                            ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell);
    
    
                            break;
    
    
            }
    
    
    }
    
    
     
    
    
    //+++++++++++++++++++++++++++++++++//
    
    
     
    
    
    //map.h
    
    
    typedef enum {
    
    
            CELL_WALKABLE,
    
    
            CELL_SHOOTABLE,
    
    
            CELL_WATER,
    
    
            CELL_NPC,
    
    
            CELL_BASILICA,
    
    
            CELL_LANDPROTECTOR,
    
    
            CELL_NOVENDING,
    
    
            CELL_NOCHAT,
    
    
            CELL_PK,//<---add this
    
    
    } cell_t;
    
    
     
    
    
    //+++++++++++++++++++++++++++++++++//
    
    
     
    
    
    struct mapcell
    
    
    {
    
    
            // terrain flags
    
    
            unsigned char
    
    
                    walkable : 1,
    
    
                    shootable : 1,
    
    
                    water : 1;
    
    
     
    
    
            // dynamic flags
    
    
            unsigned char
    
    
                    npc : 1,
    
    
                    basilica : 1,
    
    
                    landprotector : 1,
    
    
                    novending : 1,
    
    
                    nochat : 1,
    
    
                    pk      :       1;//<---add this
    
    
     
    
    
    //+++++++++++++++++++++++++++++++++//
    
    
     
    
    
    //db\const.txt
    
    
    cell_walkable   0
    
    
    cell_shootable  1
    
    
    cell_water      2
    
    
    cell_npc        3
    
    
    cell_basilica   4
    
    
    cell_landprotector      5
    
    
    cell_novending  6
    
    
    cell_nochat     7
    
    
    cell_pk 8//<---add this
    
    
     
    
    
    //+++++++++++++++++++++++++++++++++//
    
    
   

 

 

script

-    script    SetPvPCells    -1,{
    end;
    
    OnInit:
    //setcell "prontera",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
    //A1
    setcell "prontera",133,192,142,170,cell_pk,1;
    setcell "prontera",126,185,134,178,cell_pk,1;
    setcell "prontera",141,185,149,178,cell_pk,1;
Edited by cumbe11
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  7
  • Reputation:   2
  • Joined:  11/06/13
  • Last Seen:  

The relevant source block in battle.c:

 

                                else if( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) )
                                {
                                        if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) )
                                                return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else.
                                        else
                                                return 0; // You can't target anything out of your duel
                                }

If the only thing you replaced is

else if( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) )

into
else if(( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg&& map_flag_gvg(m))))||( cell_pk_check(t_bl, s_bl, m) == true ))

Then it's no wonder that it's not working.

 

Look at the line right below:

if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) )

That translates to "If the target is a player AND targets duel_group matches mine"

 

I would say just make a extra if / else, like so:

 

                case BL_PC:
                {
                        struct map_session_data *sd = BL_CAST(BL_PC, s_bl);
                        if( s_bl != t_bl )
                        {
                                if( sd->state.killer )
                                {
                                        state |= BCT_ENEMY; // Can kill anything
                                        strip_enemy = 0;
                                }
                                else if( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) )
                                {
                                        if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) )
                                                return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else.
                                        else
                                                return 0; // You can't target anything out of your duel
                                }
                                else if( cell_pk_check(t_bl, s_bl, m) == true )
                                {
                                       return (BCT_ENEMY&flag)?1:-1;
                                }
                        }
                        if( map_flag_gvg(m) && !sd->status.guild_id && t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->class_ == MOBID_EMPERIUM )
                                return 0; //If you don't belong to a guild, can't target emperium.
                        if( t_bl->type != BL_PC )
                                state |= BCT_ENEMY; //Natural enemy.
                        break;
                }
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.03
  • Content Count:  265
  • Reputation:   11
  • Joined:  01/11/13
  • Last Seen:  

I did exactly as you said and it did not work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...