R> Map|Mob of the Week Event

Just a fast test and :

// forgot ;set .equiprobability, 1set .map_job_exp_multiplier, 200

Code:
// forgot bracketset $@specialmap$, getd(".maps_" + .@randarray + "$["+ .@randpos +"]";
Code:
// .mobs_X type integer not stringset .@randpos, rand(0, getarraysize(getd(".mobs_" + .@randarray + "$")) - 1);set $@specialmob, getd(".mobs_" + .@randarray + "$["+ .@randpos +"]"); // This black magic is supposed to draw a random mob from the poolset $@specialmob, getd(".mobs_" + .@i + "$["+ .@draw +"]");
Code:
// display the mob IDif ($@specialmob) announce $@specialmob + " has a x" + .mob_base_exp_multiplier/100 + "." + .mob_base_exp_multiplier0 + " base exp and a x" + .mob_job_exp_multiplier/100 + "." + .mob_job_exp_multiplier0 + " job exp multiplier for the weekend!",bc_self;
Code:
// must be under OnMon0000: or the config is deleted right after be loaddonpcevent strnpcinfo(3)+"::OnDelConfig"; //This way we save memory for the week at the cost of a bit of process
Code:
// @set .@jobexp, getmonsterinfo($@specialmob,4)*(.@mob_job_exp_multiplier - 100)/getbattleflag("quest_exp_rate");
Also when both map + mob of the week enabled that give a strange multiplicator... dunno why

 
Last edited by a moderator:
And this, ladies and gentlemen, is what happens when I haven't a console near me for testing or detecting basic errors in npcs. This also justifies what I say about testing them before using and feeding me back with errors.

Sorry for these errors, I'll try to fix them as soon as I get back to my pc (I'm on my smartphone right now).

 
I'm a bit rusty on scripting as you can see. This script has passed in Hercules Console checking of errors.

Try this one:

http://upaste.me/9fca5983bac12e78

@Capuche: loading config OnMon0000, using it and then unloading that from memory is intentional and works; also strange rate from mobs and map at once is intended: if a mob of the week is in a map of the week, you get a total base_mobexp * server_rate * (map_bonus + mob_bonus).

@general public: Still not thoroughly tested so errors/bugs may still be there, it just passed console parsing.

 
SQL Based: WeeklyEvent.txt (Haven't tested but hope to work)

To Add a Map: PM "NPC:mobmapoftheweek" with "ADDMAP#mapname"

To Add a Mob: PM "NPC:mobmapoftheweek" with "ADDMOB#mobid"

To remove a Map: PM "NPC:mobmapoftheweek" with "DELMAP#mapname"

To remove a Mob: PM "NPC:mobmapoftheweek" with "DELMOB#mobid"

Or use directly sql.

 

Attachments

Also don't know if it works, but I'll suggest small improvements for your script here and there:

Line 25: add a map check before:

if (@whispervar0$ == "ADDMAP") { if (getmapusers(@whispervar2$) < 0) dispbottom "Not adding. Invalid map."; else query_sql "INSERT INTO `map_mob_week` (`mapname`) VALUES ('"+@whispervar1$+"')"; // If map proven to exist no need to escape}

Line 28: better check if monster exists with getmonsterinfo() or strmobinfo(). I'll use getmonsterinfo since it returns -1 on invalid mob_id:

else if (@whispervar0$ == "ADDMOB") { if (getmonsterinfo(atoi(@whispervar1$),1) != -1){query_sql "INSERT INTO `map_mob_week` (`mobid`) VALUES ("+atoi(@whispervar1$)+")";} else{dispbottom "Cannot Add, Invalid ID";}}
Same checks for deleting mob and/or maps.

In line 85 there's a debug line I forgot to remove and not much more. And thanks for the idea of ordering query results by rand(), didn't think about it!

 
@jaBote

I was little sleepy and forgot to put checks
default_smile.png


Here's the Fixed version:

WeeklyEvent.txt

To Add a Map: PM "NPC:mobmapoftheweek" with "ADDMAP#mapname"

To Add a Mob: PM "NPC:mobmapoftheweek" with "ADDMOB#mobid"

To remove a Map: PM "NPC:mobmapoftheweek" with "DELMAP#mapname"

To remove a Mob: PM "NPC:mobmapoftheweek" with "DELMOB#mobid"

 

Attachments

Back
Top