// TMW-2 Script. // Author: // Jesusalva // Description: // Homunculus HP and MP healing, based on Reid's work // // Variables: // @heal // Amount in % of max HP to heal. Can exceed 100% // @delay // How long it takes to heal the @heal amount // // Vitality increases heal value. If "item" is set, it'll be deleted later // HomunHeal(heal, delay{, item=None}) function script HomunHeal { .@heal=getarg(0); .@delay=getarg(1); .@item=getarg(2, 0); // Do you have a Homunculus? if (!gethominfo(0)) { dispbottom l("You do not own an Homunculus."); return; } // Is the homunculus active? if (homstatus() != 0) { dispbottom l("Your homunculus is sleeping! Wake them up!"); return; } // Do we even have a valid GID? if (gethomunid() < 1) { Exception("Homunculus has no Game ID!", RB_DEBUGMES|RB_DISPBOTTOM|RB_ISFATAL); return; } // Retrieve the Homunculus status, each 5 vit gives 1% bonus .@vit = getunitdata(gethomunid(), UDT_VIT) / 5; .@mhp = getunitdata(gethomunid(), UDT_MAXHP); // Calculate healing value in % .@min=.@heal * ( 75 + .@vit) / 100; .@max=.@heal * (100 + .@vit) / 100; // Make these abstract % in absolute values .@min=max(1, .@mhp*.@min/100); .@max=max(3, .@mhp*.@max/100); // Calculate how much it'll heal @val1 = rand2(.@min, .@max); // Update val1 to be the healing per tick @val1 = (@val1 / .@delay) + 1; // Decide the healing bonus type. We have four types: S, L, G and M // By default, we use 'S' .@skill = SC_S_LIFEPOTION; // Put the delay in ms .@delay *= 1000; // If an item was specified, delete it here if (.@item) delitem .@item, 1; // Debug information if ($@GM_OVERRIDE) debugmes("Skill %d GID %d Ticks %d Value %d", .@skill, gethomunid(), .@delay, @val1); // Apply the effect and finish sc_end(.@skill, gethomunid()); sc_start2(.@skill, .@delay, @val1, 1, 10000, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE, gethomunid()); return @val1; }