HerculesWS / Hercules

Hercules is a collaborative software development project revolving around the creation of a robust massively multiplayer online role playing game (MMORPG) server package. Written in C, the program is very versatile and provides NPCs, warps and modifications. The project is jointly managed by a group of volunteers located around the world as well as a tremendous community providing QA and support. Hercules is a continuation of the original Athena project.
http://herc.ws
GNU General Public License v3.0
896 stars 754 forks source link

Monsters Summoned by Script Cannot Get boss_monster status #1839

Open bWolfie opened 7 years ago

bWolfie commented 7 years ago

Issue Prelude

Description

Boss monsters, such as the lhz_dun03/04 ones, that are summoned through scripts can never attain the same setting as monsters spawn through the boss_monster NPC definition.

Why make this change?

It will allow people to take advantage of the Tombstone system for script-spawned monsters.

New Behavior

There should be an optional parameter or a new script command bossmonster for summoning these monsters, with the appropriate respawn delays able to be set for tombstones.

Branch(es):

Helianthella commented 7 years ago

try this:

.@mobGID = monster("place", 60, 100, "Poring", PORING, 1); // <= change location here
.@mode = getunitdata(.@mobGID, UDT_MODE); // get the mode of the spawned monster
.@mode |= 0x20; // append MD_BOSS to the mode
setunitdata(.@mobGID, UDT_MODE, .@mode); // set the new mode on the spawned monster

In theory you should be able to use this for any mode in enum e_mode

Helianthella commented 7 years ago

@MishimaHaruna imho we should expose those MD_ mode flags constants to the script engine

bWolfie commented 7 years ago

Thanks for input @mekolat sadly it didn't work, as 0x20 is already appended on my monster. MVP Tombstones are actually spawned using md->spawn->state.boss data rather than md->status.mode&MD_BOSS, because that data is unique to the NPC definition of boss_monster.

I tried creating a plugin which could create custom tombstones, but it didn't work.

BUILDIN(mvptomb)
{
    struct map_session_data *sd = NULL;
    struct mob_data *md;

    if (!script_hasdata(st, 2) && ! script_hasdata(st, 3))
        return false;

    sd = map->id2sd(script_getnum(st, 2));
    md = map->id2md(script_getnum(st, 3));

    if (sd == NULL || md == NULL)
        return false;

    if (map->list[md->bl.m].flag.notomb != 1)
        mob->mvptomb_create(md, sd ? sd->status.name : NULL, time(NULL));
    return true;
}

where you md scriptnum3 will be mobGID.

Also something funny, getunitdata is returning false at end of funciton, so always giving a debug message.

MishimaHaruna commented 6 years ago

@EyesOfAHawk do you have a suggestion on how to make those tombstones disappear when the monster is spawned the next time, if we implement this?

guilherme-gm commented 6 years ago

@MishimaHaruna what if we leave the tomb removal to the script too? Like:

//...
OnSpawn:
   if (.myTomb)
       delmvptomb(.myTomb);
  monster ... "OnMyMvpDie";
  end;

OnMyMvpDie:
  .myTomb = mvptomb(playerName, mobName);
  end;
//...

but mvptombs stores a md instead of the mob name, so this might need to be changed

Emistry commented 5 years ago

I believe the main reason to enable npc script to spawn a monster with boss_monster are because of the usage of convex mirror item, that used to track the location of MVP monster.

Perhaps we could consider a new script command that spawn monster that has md->spawn->state.boss. auto respawn are optional. Might as well consider a separate script command to handle create/destroy for Tombstone.

Tombstone for LHZ bosses, its possible to be done even at current stage, just the location might differ since we can't get the exact coordinate of the monster when it died. and it is ugly way to do it. (md data no longer available when the mob died and trigger OnNPCKillEvent, need to find a way to store the md data for this case.) Image of Yaktocat