order clone attack

Tio Akima

New member
Messages
349
Points
0
Age
36
Discord
TioAkima#0636
Github
Tio Akima
Emulator
hi, i made a skill to send the clone generated by the player to attack a target. (order to attack a target).
I did a custom function, where I return the clone ID on the map.
And so, give him an order.
But, I do not know if it is correct to go this way, or if there is any other necessary procedure

case CLONE_ATTACK:
{
int c = 0;
int clone_id = 0;
int maxcount = 1;

map->foreachinmap(skill->check_condition_clone, sd->bl.m, BL_MOB, sd->bl.id, &c , &clone_id ); // clone search on the map

//ShowWarning("clone_id: %d\n", clone_id); //debug

if( c < maxcount ) { //if no clones are found
clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0);
map->freeblock_unlock();
return 0;
}
struct block_list* mbl = map->id2bl(clone_id); //takes the clone id and converts it to a bl
struct unit_data *ud = unit->bl2ud(mbl); //take the bl and convert it to a unit

//nullpo_ret(mbl);
//nullpo_ret(ud);

if(ud){
unit->set_target(ud, bl->id); //set a target
unit->attack(mbl, bl->id, ud->state.attack_continue); // Execute normal attack

}
}


suggestions?

@EDIT: Solved

 
Last edited by a moderator:
Back
Top