Jump to content
  • 0

help NPC invoking an MVP with modified stats via setunitdata


Question

Posted (edited)

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

2 answers to this question

Recommended Posts

  • 0
Posted

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.

  • 0
Posted

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!

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...