Help on instance script

utofaery

New member
Messages
101
Points
0
prontera,150,180,5 script Instance Challenger 4_M_EINMINER,{
mes ( " Big sun Big day ! " ) ;
dispbottom ( " #GRRoomDelay :: " + #GRRoomDelay ) ;
switch ( select(
"~ Create Instance",
"~ Exit.",
"~ Clear Instance"
)){
case 3:
instance_destroy( );//.@instance );
close;
case 1:
.@mapname$ = "1@dth1";
#GRHunt = 0;
if( #GRRoomDelay > gettimetick(2) ) {
.last = #GRRoomDelay - gettimetick(2);
.@min = .last % ( 24 * 3600 ) % 3600 / (60);
mes "Wait for ^FF0000"+.@min+" Minutes^000000.";
close;
}

.@instance = instance_create( .@Zone4$, getcharid( 3 ), IOT_CHAR);
if( .@instance < 0 ) {
dispbottom "Instance Failed.";
close;
}
dispbottom "" + .@mapname$ + "- Attempting to create Farm Instance.";
if( instance_attachmap("1@dth1",.@instance) == "" ) {
instance_destroy( .@instance );
dispbottom "Failed to instance 1@dth1";
end;
}

dispbottom "" + .@Zone4$ + " attempt successful on Instance attach!";
instance_set_timeout( 3600, 300, .@instance );
instance_init( .@instance );
instance_attach .@instance;
'cid = getcharid(0);
'aid = getcharid(3);
FarmIns_cooldown = gettimetick(2) + 3600; // 1 hour cooldown
warp instance_mapname("1@dth1",.@instance),166,130;
end;
case 2:
close;
end;
}
close;
}

//=====================================================
/*

[Farm Zone] Gold Room
Information/How-To Setup:

'GRRate - The rate at which they obtain Gold, which is in %. So 50 = 50%.
.GRDelayMin - Controls Time Limit of Re-entering: 1 = 1 Minute, 2 = 2 Minute, etc.
.MaxGRLimit - Max amount of Gold they can Farm until instance is complete, if they don't reach max amount they just complete the instance.
'MOB1ID/MOB2ID - Select the ID of the monster you want.
'MOB1AM/MOB2AM - Select the Amount of designated Monsters you want to spawn.
NOTE: Don't make the .MaxGRLimit exceed the total amount of monsters you selected to spawn. Otherwise, they will never reach the Max Limit.
All other variables do not touch, especially the Count, and the Start. ('Farm_Count and 'Farm_Start)


*/
//=====================================================
1@dth1,28,23,1 script IxGR#Ins FAKE_NPC,{

OnInstanceInit:
.GRDelayMin = (1/10);
.MaxGRLimit = 1000;
'GRRate = 5;
'MOB1ID = 1002;
'MOB2ID = 1113;
'MOB1AM = 40;
'MOB2AM = 35;
'MobTOTAL = 'MOB1AM+'MOB2AM;

'Farm_Count = 0;
'Farm_Start = 0;

if (!'Farm_Start) {
donpcevent instance_npcname("IxGR#Ins")+"::OnGRFarmStart";
'Farm_Start++;
end;
}
OnGRFarmStart:
//instance_announce -1,"[Farming Instance] Enjoy farming some Gold!",bc_map;
monster instance_mapname("1@dth1"),0,0,"[ Farm Zone ] Gold Holder",'MOB1ID,'MOB1AM,instance_npcname("IxGR#Ins")+"::OnFarmGR";
monster instance_mapname("1@dth1"),0,0,"[ Farm Zone ] Gold Guest",'MOB2ID,'MOB2AM,instance_npcname("IxGR#Ins")+"::OnFarmGR";
end;
OnFarmGR:
'dMon = killedrid;
if ( #GRHunt >= .MaxGRLimit )
{
dispbottom "[ Farm Zone ] : You are trying to abuse Farm Zone! Prematurely ending.";
sleep2 500;
#GRRoomDelay = gettimetick(2) + ( .GRDelayMin * 60 );
#GRHunt = 0;
warp "prontera",150,185;
instance_destroy();
end;
}

monster instance_mapname("1@dth1"),0,0,"[ Farm Zone ] Gold Holder",'dMon,'MOB1AM,instance_npcname("IxGR#Ins")+"::OnFarmGR";

if ( rand(100) < 'GRRate ) {
#GRHunt++;
'Farm_Count++;
dispbottom "[ Farm Zone ] : Farmed "+#GRHunt+" / "+.MaxGRLimit+" Gold.";
if( #GRHunt >= .MaxGRLimit ) {
getitem 969, 1;
message strcharinfo(0),"Limit Reach , you may join again later.";
sleep2 500;
#GRRoomDelay = gettimetick(2) + ( .GRDelayMin * 60 );
warp "prontera",150,150;
instance_destroy();
end;
}
getitem 969, 1;
dispbottom ( " Current farm Count :: " + 'Farm_Count + " Hunted Gold Count :: " + #GRHunt ) ;
donpcevent instance_npcname("IxGR#Ins")+"::OnGRFarmCount";
} else {
'Farm_Count++;
dispbottom ( " Current farm Count :: " + 'Farm_Count + " Hunted Gold Count :: " + #GRHunt ) ;
donpcevent instance_npcname("IxGR#Ins")+"::OnGRFarmCount";
end;
}
end;
OnGRFarmCount:
if ('Farm_Count >= 'MobTOTAL) { // modified >> .MaxGRLimit <<

if( attachrid('aid) )
if( getcharid(0) == 'cid ) {
instance_announce -1,"[Farming Instance] Farming instance Completed.",bc_map;
#GRRoomDelay = gettimetick(2) + ( .GRDelayMin * 60 );
sleep2 5000;
instance_destroy();
end;
}
else
end;
}
}


1.

I was borrowing instance script ( Forgot where I collected this script from but it's from herc.ws)

but it's always randomly terminate by this line:

dispbottom "[ Farm Zone ] : You are trying to abuse Farm Zone! Prematurely ending.";

or some time randomly terminate.

2.

the script is suppose to let you player to kill 1000 mobs with repeated spawning of dead mobs but it's working randomly because of random termination of instance.

 
.GRDelayMin = (1/10);
.MaxGRLimit = 1000;
'GRRate = 5;
'MOB1ID = 1002;
'MOB2ID = 1113;
'MOB1AM = 40;
'MOB2AM = 35;
'MobTOTAL = 'MOB1AM+'MOB2AM;


as you can see, .GRDelayMin and .MaxGRLimit is npc variable
in this script, means even you have reach the hunt limit, it still generate the instance,
that's why you get the weird instance behavior

you should stop generate the instance when player already hunt enough gold

 
.GRDelayMin = (1/10);
.MaxGRLimit = 1000;
'GRRate = 5;
'MOB1ID = 1002;
'MOB2ID = 1113;
'MOB1AM = 40;
'MOB2AM = 35;
'MobTOTAL = 'MOB1AM+'MOB2AM;


as you can see, .GRDelayMin and .MaxGRLimit is npc variable
in this script, means even you have reach the hunt limit, it still generate the instance,
that's why you get the weird instance behavior

you should stop generate the instance when player already hunt enough gold
1.  ok what should be changed to fix that??

should I change that variable to instance variable??

or should it be player temporary variable??  whenever player starts the instance by talking to the npc?

this instance script need to chew upon to understand.

2.  The cases is that in that particular instance it runs till killed monster 75 or 77 then it terminates or randomly terminate.

 
I just mostly copy paste from my blog
https://annieruru.blogspot.com/2019/01/compare-instance-script-between-rathena.html

prontera,150,180,5 script Instance Challenger 4_M_EINMINER,{
mes " Big sun Big day ! ";
next;
if ( select( "~ Create Instance", "~ Clear Instance" ) == 2 ) {
if ( has_instance2("guild_vs2") >= 0 )
instance_destroy( has_instance2("guild_vs2") );
close;
}
if ( has_instance2("guild_vs2") >= 0 ) {
warp has_instance("guild_vs2"), 49,49;
end;
}
if ( #gold_room_delay + 30 > gettimetick(2) ) { // deny for 30 seconds
mesf "please wait %d seconds", #gold_room_delay + 30 - gettimetick(2);
close;
}
if ( ( .@ins = instance_create( "Gold Room", getcharid(CHAR_ID_ACCOUNT), IOT_CHAR ) ) < 0 ) {
mes "error : "+ .@ins;
close;
}
if ( !getstrlen( instance_attachmap( "guild_vs2", .@ins, true, .@ins +"INST" ) ) ) {
mes "error : 5";
instance_destroy .@ins;
close;
}
instance_set_timeout 3600, 300, .@ins; // 1 hour to farm
instance_init .@ins;
warp has_instance("guild_vs2"), 49,49;
#gold_room_delay = gettimetick(2);
end;
}

guild_vs2,0,0,0 script gold_room FAKE_NPC,{
OnInstanceInit:
monster instance_mapname("guild_vs2"), 0,0, "--ja--", PORING, 30, instance_npcname( strnpcinfo(NPC_NAME) )+"::OnMobDead"; // spawn 30 poring
end;
OnMobDead:
monster instance_mapname("guild_vs2"), 0,0, "--ja--", PORING, 1, instance_npcname( strnpcinfo(NPC_NAME) )+"::OnMobDead"; // everytime player make a kill, just respawn it
getitem Gold, 1; // gain this item
end;
}


and I seriously hope you read the script_commands.txt before you make your next posts
how to change the value, its all inside the documentations

 
Last edited by a moderator:
Back
Top