viewing paste Unknown #7619 | C

Posted on the
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
bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
    struct homun_data *hd;
    int i = 0;
 
    nullpo_retr(false, sd);
 
    Assert((sd->status.hom_id == 0 || sd->hd == 0) || sd->hd->master == sd);
 
    i = homun->db_search(hom->class_,HOMUNCULUS_CLASS);
    if(i < 0) {
        ShowError("homunculus_create: unknown class [%d] for homunculus '%s', requesting deletion.\n", hom->class_, hom->name);
        sd->status.hom_id = 0;
        intif->homunculus_requestdelete(hom->hom_id);
        return false;
    }
    sd->hd = hd = (struct homun_data*)aCalloc(1,sizeof(struct homun_data));
    hd->bl.type = BL_HOM;
    hd->bl.id = npc->get_new_npc_id();
 
    hd->master = sd;
    hd->homunculusDB = &homun->db[i];
    memcpy(&hd->homunculus, hom, sizeof(struct s_homunculus));
    hd->exp_next = homun->exptable[hd->homunculus.level - 1];
 
    iStatus->set_viewdata(&hd->bl, hd->homunculus.class_);
    iStatus->change_init(&hd->bl);
    unit->dataset(&hd->bl);
    hd->ud.dir = sd->ud.dir;
 
    // Find a random valid pos around the player
    hd->bl.m = sd->bl.m;
    hd->bl.x = sd->bl.x;
    hd->bl.y = sd->bl.y;
    unit->calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
    hd->bl.x = hd->ud.to_x;
    hd->bl.y = hd->ud.to_y;
 
    iMap->addiddb(&hd->bl);
    status_calc_homunculus(hd,1);
 
    hd->hungry_timer = INVALID_TIMER;
    return true;
}
 
Viewed 633 times, submitted by Guest.