Jump to content
  • 0

help NPC invoking an MVP with modified stats via setunitdata


deafity

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.01
  • Content Count:  6
  • Reputation:   0
  • Joined:  08/19/24
  • Last Seen:  

Hello,
I would like to create an NPC that invokes MVPs using their ID, but I would like the invoked monster to be dynamically modified (HP, ATK, etc.) without having to modify the whole mob_db.yml.
I've seen that you can use setunitdata for this, but I'm not sure of the right way to use it in this context.
Could someone please help me?
Many thanks to the rAthena team for your hard work and invaluable help!

 

 

 


mes "[MVP Invoker]";
mes "Dis-moi l'ID du MVP que tu veux invoquer.";
input .@mvp_id;
if ( getmonsterinfo(.@mvp_id, MOB_NAME) == "" ) {
    mes "Cet ID ne correspond à aucun monstre.";
    close;

mes "[MVP Invoker]";
mes "Dis-moi l'ID du MVP que tu veux invoquer.";
input .@mvp_id;
if ( getmonsterinfo(.@mvp_id, MOB_NAME) == "" ) {
    mes "Cet ID ne correspond à aucun monstre.";
    close;

}

mes "Veux-tu vraiment invoquer " + getmonsterinfo(.@mvp_id, MOB_NAME) + " pour 1 000 000 Zeny ?";
if ( select("Oui:Non") == 2 ) {
    mes "Très bien, une autre fois peut-être.";
    close;

}

if ( Zeny < 1000000 ) {
    mes "Tu n'as pas assez de Zeny. Il te faut 1 000 000 Z.";
    close;

}

Zeny -= 1000000;

// Invoquer le monstre et modifier ses stats dans le même contexte (PAS via callfunc)
.@mob_gid = monster("db_room", 106, 62, getmonsterinfo(.@mvp_id, MOB_NAME), .@mvp_id, 1);

sleep 500; // Laisse le temps au monstre d'apparaître

if (.@mob_gid > 0) {
    setunitdata(.@mob_gid, UDT_HP, 20000000);
    setunitdata(.@mob_gid, UDT_MAXHP, 20000000);
    setunitdata(.@mob_gid, UDT_ATK1, 10000);
    setunitdata(.@mob_gid, UDT_ATK2, 15000);
    setunitdata(.@mob_gid, UDT_DEF, 200);
    setunitdata(.@mob_gid, UDT_MDEF, 200);
    setunitdata(.@mob_gid, UDT_AGI, 150);
    setunitdata(.@mob_gid, UDT_STR, 200);
    setunitdata(.@mob_gid, UDT_VIT, 200);
    setunitdata(.@mob_gid, UDT_INT, 150);

}

mes "Le MVP a été invoqué et ses statistiques ont été ajustées pour être vraiment puissantes !";
close;

 

Edited by deafity
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  222
  • Reputation:   95
  • Joined:  06/02/12
  • Last Seen:  

Hello,
getmonsterinfo will return "null" if you requested a invalid monster's name.

getmonsterinfo(.@mvp_id, MOB_NAME) == "null"

 

monster sets an array with the game ID of the spawned monster(s). Array is stored in $@mobid[].

.@mob_gid = $@mobid[0];

 

setunitdata monster parameters are UMOB_.

	    setunitdata(.@mob_gid, UMOB_HP, 20000000);
	    setunitdata(.@mob_gid, UMOB_MAXHP, 20000000);
	    setunitdata(.@mob_gid, UMOB_ATKMIN, 10000);
	    setunitdata(.@mob_gid, UMOB_ATKMAX, 15000);
	    setunitdata(.@mob_gid, UMOB_DEF, 200);
	    setunitdata(.@mob_gid, UMOB_MDEF, 200);
	    setunitdata(.@mob_gid, UMOB_AGI, 150);
	    setunitdata(.@mob_gid, UMOB_STR, 200);
	    setunitdata(.@mob_gid, UMOB_VIT, 200);
	    setunitdata(.@mob_gid, UMOB_INT, 150);
	    setunitdata(.@mob_gid, UMOB_HIT, 600);
	    setunitdata(.@mob_gid, UMOB_FLEE, 500);

Parameters (indexes) for monsters
 

Use sleep2 instead of sleep. sleep will not keep the rid (to display the mes text), while sleep2 does.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.01
  • Content Count:  6
  • Reputation:   0
  • Joined:  08/19/24
  • Last Seen:  

Hello everyone,

I just wanted to take a moment to warmly thank the rAthena community for all the invaluable help you provide every day.

Thanks to your clear answers, your sharing of scripts and your technical explanations, I've been able to make considerable progress on my project. Whether it's documentation, scripting tips or optimization suggestions, you are truly an invaluable resource for all Ragnarok Online enthusiasts.

Thank you to all those who take the time to reply, correct, test or even just encourage. You bring this community to life and make development so much more enjoyable!

All the best to everyone, and see you soon on the forum!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...