Hello! It's been exciting to play Ragnarok again!
I think I've found where in the code we have to alter. I do not have any C++ background, but here's the thing about clone so far I understood. My reference is the old version of 3Ceam's which has a perfectly working battle sage-mode slaveclone.
1. Slaveclone is a mob treated as a pet (without its info etc), but attacking & giving us exp like homunculus. All wrapped under a BL_MOB category. Therefore, we need to change the ASPD etc. The problem is that with altering this in hardcoded, Rune Knight seems okay, but a simple low level Mage will be strangely a strong melee attacker. Details on attachment.
2. So, to imitate the routine/procedure that rathena has made on the code, I duplicate mob_clone_spawn ---> mob_clone_spawn2, with necessary addition in its *.hpp . Why? it's because I also added another @clonea atcommand, by "clone-A" means assistant. I found that by changing the flag & master status (true/false), there is my @clonemp (marine sphere PVP) as regular PC char. Plus, @clonepe as PVPevil. Consequently, I add another conf point as a replacement for mob_skill_rate (clone_skill_rate). In simple word: Actually I want a Mage slaveclone for my Swordsman account mwahahaha
3. ai_mob functions are awesome! (but maybe being overkill, since some ineffective routine done by peak Biolab mobs, idk why cmiiw)
4. I thought by playing with mobs' state (MSS_BERSERK, etc) will change the skill for slaveclone. It doesn't.
5. Finally, less/more, files I edited are: mob, battle, unit (cpp & hpp). Also, atcommand_def & atcommand (inc). And for-import battle_conf (txt), groups.conf .
6. Here's the main thing I change (after 2 weeks of skimming the code lol) (mob.cpp) :
.....
if (!bl) continue;
md->skill_idx = i; //assign the filtered skill that's chosen
map_freeblock_lock(); //lock the new target for your skill
if (!battle_check_range(&md->bl, bl, skill_get_range2(&md->bl, ms.skill_id, ms.skill_lv, true)) || !unit_skilluse_id2(&md->bl, bl->id, ms.skill_id, ms.skill_lv, ms.casttime, ms.cancel)) { //validity and executable check (but still doesnt execute?) map_freeblock_unlock(); //bcs un-executable, release our lock continue; //and just skip this block //at this point i still dont understand why skill still doesnt work. So I forcefully add another default thing to do below } } unit_skilluse_id2(&md->bl, bl->id, ms.skill_id, ms.skill_lv, ms.casttime, ms.cancel); //yes it's here
....
also:
.... status->aspd_rate = 1000; //meaning a -10% acceleration from that quick humunculus' aspd
status->adelay = 1000; //interval delay
status->amotion = 1000; //animation (?)
status->dmotion = 1000; // idk
.... maybe with other status->xyz if you want
7. For further development (maybe!) : a) differentiate the stat alteration, so it looks okay or approximates the master. b) Does slaveclone imitate 100% the master's leveling? IDK. c) I still dont know how to change slaveclone's name to be admin_1 omg i dont get how c++ concatenate strings lol, so teach me!
8. Because this is a repeatedly routine, crash might happen. For example, debugger wants us to fix this on status.cpp: status = md->base_status;
memcpy(status, &md->db->status, sizeof(struct status_data));
9. Lastly, the "valve' to be opened as we want the slaveclone to auto skill is (mob.cpp) :
if (!battle_config.mob_skill_rate || md->ud.skilltimer != INVALID_TIMER || !md->db->maxskill || status_has_mode(&md->status,MD_NOCAST_SKILL))
return 0;
I "opened" to be:
if (!battle_config.mob_skill_rate || md->ud.skilltimer != -1 || !md->db->maxskill)
return 0;
So that (maybe) the MD_NOCAST_SKILL status doesn't exit this particular line
Check this out on my github.
https://github.com/amharfm/rathena