Jump to content
  • 0

Monster helper


Yukaiii

Question


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  110
  • Reputation:   9
  • Joined:  11/20/13
  • Last Seen:  

Quote

// . Description: .
// . Change from dead monster reborn to help for some . .
// . minutes. . .
// . A percentage is 5% and can be changed.
// . a permanent variable is generated with the time of .
// . 'validity' of the monster, so only the char already has .
// . a monstrous helper, he won't get another one and that one.
// . 'expiration' time is 5 minutes + rand(120) being .
// . so a time between 5 and 7 minutes - monster level, .
// . that is, the higher the level of the monstrous, the less.
// . 'expiration' time it will have.
// . Not valid for MvP/Boss, monsters that don't attack. .
// . and they don't move and they are WoE monsters               .
// .----------------------------------------------------------.
-    script    Mob Helper    -1,{

    OnNPCKillEvent:
        if(rand(0,10000) > 500) end;                                                                //5% para conseguir
        if(mkTimed && gettimetick(2) <= mkTimed) end;                                                //Checa tempo
        set @MobMode, getmonsterinfo(killedrid,MOB_MODE);
        if(!(@MobMode & 1)) end;                                                                    //Mob não se move
        if(!(@MobMode & 128)) end;                                                                    //Mob não ataca
        if(@MobMode & 32) end;                                                                        //Mob MvP/Boss
        set @WoE[0],1288|1285|1830|1949|1950|1286|1287|1899|1829;                                    //WoE IDs
        for(set @n,0; @n < getarraysize(@WoE); set @n,@n+1){ if(@WoE[@n] == killedrid){ end; } }    //WoE
        
        set @nTime, (300+rand(0,120))-getmonsterinfo(killedrid,1);
        summon "Ajudante "+getmonsterinfo(killedrid,0), killedrid, @nTime;
        set mkTimed, gettimetick(2)+@nTime+rand(0,60);
        message strcharinfo(0),"["+getmonsterinfo(killedrid,0)+"] Hello "+strcharinfo(0)+" I will help you for a few minutes!";
    end;

}

What's up guys!!
Guys, could anyone help me with this script?
it simply does not present any errors in the emulator.
It shows the message that mob will appear to help and but it doesn't appear, could anyone tell me how I can fix this?

 

 

Dimension-RO 19_03_2024 12_00_32.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  662
  • Reputation:   671
  • Joined:  11/12/12
  • Last Seen:  

Hmm, you'd definitely want to add more checks on this, but here:

-	script	Mob Helper	-1,{
OnNPCKillEvent:
	// Fixed improper usage of rand for "chance"
	if (500 < rand(10000)) end;
	if (mkTimed && gettimetick(2) <= mkTimed) end;
	// Don't use "set" anymore, that's way outdated.
	// Using getmonsterinfo isn't a bad idea, but it's somewhat useless/broken now. You'd have to expand on it in the source to make it useful.
	getunitdata(killedgid, .@mobdata);
	// There's no reason to use player variables in this case, the variable has no purpose outside of the NPC block code. Therefore it should be a NPC variable.
	.@MobMode = .@mobdata[UMOB_MODE];
	.@MobClass = .@mobdata[UMOB_CLASS];
	if (!(.@MobMode & MD_CANMOVE)) end;
	if (!(.@MobMode & MD_CANATTACK)) end;
	// MD_BOSS/32 isn't a thing anymore either, so that code won't work.
	if (.@MobClass == CLASS_BOSS) end;
	// Too much wrong with these lines.
	//set @WoE[0],1288|1285|1830|1949|1950|1286|1287|1899|1829;                                    //WoE IDs
	//for(set @n,0; @n < getarraysize(@WoE); set @n,@n+1){ if(@WoE[@n] == killedrid){ end; } }    //WoE
	// You probably meant to use "setarray", and you also probably to use commas instead of separators: setarray @woe, 1288, 1285, ..;
	// Either way, that's inefficient considering this code runs on all killed monsters. Honestly I'd do the whole thing via the source instead since running a script everytime you kill a monster is overkill. Anyhow, use a dictionary seach:
	if (.badMob[killedrid]) end;
	.@nTime = (300 + rand(0, 120)) - getmonsterinfo(killedrid, MOB_LV);
	// The main reason why your script didn't work: "summon" uses miliseconds, not seconds.
	.@nTime *= 1000; // s to ms
	summon "Ajudante " + getmonsterinfo(killedrid, MOB_NAME), killedrid, .@nTime;
	mkTimed = gettimetick(2) + .@nTime + rand(0, 60);
	message strcharinfo(0), "[" + getmonsterinfo(killedrid, MOB_NAME) + "] Hello " + strcharinfo(0) + " I will help you for a few minutes!";
	end;
OnInit:
	// Define bad mobs here
	.badMob[1288] = 1;
	.badMob[1285] = 1;
	.badMob[1830] = 1;
	.badMob[1949] = 1;
	.badMob[1950] = 1;
	.badMob[1286] = 1;
	.badMob[1287] = 1;
	.badMob[1899] = 1;
	.badMob[1829] = 1;
	end;
}

 

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  110
  • Reputation:   9
  • Joined:  11/20/13
  • Last Seen:  

10 hours ago, Tokei said:

Hmm, you'd definitely want to add more checks on this, but here:

-	script	Mob Helper	-1,{
OnNPCKillEvent:
	// Fixed improper usage of rand for "chance"
	if (500 < rand(10000)) end;
	if (mkTimed && gettimetick(2) <= mkTimed) end;
	// Don't use "set" anymore, that's way outdated.
	// Using getmonsterinfo isn't a bad idea, but it's somewhat useless/broken now. You'd have to expand on it in the source to make it useful.
	getunitdata(killedgid, .@mobdata);
	// There's no reason to use player variables in this case, the variable has no purpose outside of the NPC block code. Therefore it should be a NPC variable.
	.@MobMode = .@mobdata[UMOB_MODE];
	.@MobClass = .@mobdata[UMOB_CLASS];
	if (!(.@MobMode & MD_CANMOVE)) end;
	if (!(.@MobMode & MD_CANATTACK)) end;
	// MD_BOSS/32 isn't a thing anymore either, so that code won't work.
	if (.@MobClass == CLASS_BOSS) end;
	// Too much wrong with these lines.
	//set @WoE[0],1288|1285|1830|1949|1950|1286|1287|1899|1829;                                    //WoE IDs
	//for(set @n,0; @n < getarraysize(@WoE); set @n,@n+1){ if(@WoE[@n] == killedrid){ end; } }    //WoE
	// You probably meant to use "setarray", and you also probably to use commas instead of separators: setarray @woe, 1288, 1285, ..;
	// Either way, that's inefficient considering this code runs on all killed monsters. Honestly I'd do the whole thing via the source instead since running a script everytime you kill a monster is overkill. Anyhow, use a dictionary seach:
	if (.badMob[killedrid]) end;
	.@nTime = (300 + rand(0, 120)) - getmonsterinfo(killedrid, MOB_LV);
	// The main reason why your script didn't work: "summon" uses miliseconds, not seconds.
	.@nTime *= 1000; // s to ms
	summon "Ajudante " + getmonsterinfo(killedrid, MOB_NAME), killedrid, .@nTime;
	mkTimed = gettimetick(2) + .@nTime + rand(0, 60);
	message strcharinfo(0), "[" + getmonsterinfo(killedrid, MOB_NAME) + "] Hello " + strcharinfo(0) + " I will help you for a few minutes!";
	end;
OnInit:
	// Define bad mobs here
	.badMob[1288] = 1;
	.badMob[1285] = 1;
	.badMob[1830] = 1;
	.badMob[1949] = 1;
	.badMob[1950] = 1;
	.badMob[1286] = 1;
	.badMob[1287] = 1;
	.badMob[1899] = 1;
	.badMob[1829] = 1;
	end;
}

 

Thank you very much friend!!

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...