viewing paste topic/4856- antagonism.c | C

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../map/pc.h"
#include "../map/guild.h"
#include "../map/battle.h"
#include "../common/HPMi.h"
 
#include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)
 
HPExport struct hplugin_info pinfo = {
    "antagonism",   // Plugin name
    SERVER_TYPE_MAP,// Which server types this plugin works with?
    "0.1",          // Plugin version
    HPM_VERSION,    // HPM Version (don't change, macro is automatically updated)
};
 
int battle_check_target_antagonism( int retVal, struct block_list *src, struct block_list *target,int flag ) {
 
    if ( retVal != -1 )
        return retVal;
    else {
        struct block_list *s_bl = src, *t_bl = target;
 
        if( (t_bl = battle->get_master(target)) == NULL )
            t_bl = target;
        if( (s_bl = battle->get_master(src)) == NULL )
            s_bl = src;
    
        if ( s_bl->type == BL_PC && t_bl->type == BL_PC ) {
            TBL_PC *sd = BL_CAST( BL_PC, s_bl );
            if ( guild->check_alliance( sd->status.guild_id, ((TBL_PC*)t_bl)->status.guild_id, 1 ) && !map->list[sd->bl.m].flag.town && !map->list[sd->bl.m].flag.nowarpto )
                return 1;
        }
    }
    return -1;
}
 
HPExport void plugin_init (void) {
    battle = GET_SYMBOL("battle");
    guild = GET_SYMBOL("guild");
    map = GET_SYMBOL("map");
 
    addHookPost("battle->check_target", battle_check_target_antagonism);
}
Viewed 1523 times, submitted by AnnieRuru.