Issue information

Issue ID
#3567
Status
Working as Intended
Severity
None
Started
Hercules Elf Bot
Sep 8, 2009 19:08
Last Post
Hercules Elf Bot
Aug 13, 2012 4:39
Confirmation
N/A

Hercules Elf Bot - Sep 8, 2009 19:08

Originally posted by [b]Ivion[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=3567

Tested with: eAthena both SQL and TXT SVN (r14047)
Compiled with: Microsoft Visual Studio

When you place a doevent command after the OnAgitBreak label of the agit_template.txt script, the doevent command doesn't get executed.
See the following code I'm using:

I added the doevent command after the OnAgitBreak label:
QUOTE
// The Emperium has been broken.
OnAgitBreak:
announce "Test 1.",bc_all;
doevent "test::OnEmp1";

set .@GID,getcharid(2);
// Show and log error if an unguilded player breaks the Emperium. (Should NEVER happen)
if (.@GID <= 0) {
set .@notice$,"Character "+strcharinfo(0)+" ("+getcharid(0)+") broke the Emperium in Castle: "+strnpcinfo(2)+" while guildless. No data will be saved and Emperium respawned.";
logmes .@notice$; debugmes .@notice$;
donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
end;
}
// Adjust Economy Invest Level for Castle
set .@Economy,GetCastleData(strnpcinfo(2),2) - 5;
if (.@Economy < 0) set .@Economy, 0;
SetCastleData strnpcinfo(2), 2, .@Economy;
// Adjust Defense Invest Level for Castle
set .@Defence,GetCastleData(strnpcinfo(2),3) - 5;
if (.@Defence < 0) set .@Defence, 0;
SetCastleData strnpcinfo(2), 3, .@Defence;

// Set new Castle Occupant
SetCastleData strnpcinfo(2),1, .@GID;

// Announce that the Emperium is destroyed, and respawn all but new castle-occupants.
mapannounce strnpcinfo(2),"The emperium has been destroyed.",bc_map,"0x00CCFF";
MapRespawnGuildID strnpcinfo(2),.@GID,2;

// Refresh castle data, disable Kafra and reset Invest information.
GetCastleData strnpcinfo(2),0,strnpcinfo(0)+"::OnRecvCastle";
disablenpc "Kafra Staff#"+strnpcinfo(2);
for( set .@i, 4; .@i <= 9; set .@i, .@i+1 ) {
SetCastleData strnpcinfo(2), .@i, 0;
}
// Erase Guardian Database information if the new owners do not have Guardian Research.
if( getgdskilllv(.@GID,10002) == 0 ) {
for( set .@i, 10; .@i <= 17; set .@i, .@i+1 ) {
SetCastleData strnpcinfo(2), .@i, 0;
}
}
// Respawn the Emperium, and display new owners.
sleep 500; // Slow down script execution slightly.
if( agitcheck() )
donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
sleep getbattleflag("gvg_eliminate_time");
announce "The [" + getcastlename(strnpcinfo(2)) + "] castle has been conquered by the [" + getguildName(.@GID) + "] guild.",bc_all;
end;


Then, in another script I put the following code:
QUOTE
- script test -1,{

OnEmp1:
announce "Test 2.",bc_all;
end;
}


If you kill the Emperium in a castle that didn't have an owner previously, everythink works perfectly.
But if you kill the emperium in a castle that had an owner previously, then the "Test 1" announce is displayed, but the "Test 2" announce isn't displayed, because the OnEmp1 event never gets executed.

This post has been edited by Ivion: Sep 8 2009, 12:12 PM

Hercules Elf Bot - Dec 20, 2011 5:14

Originally posted by [b]Ind[/b]
it should show a 'npc_event:' queue error in the map server, though, i'm poised to set it to working as intended, confirmed so other devs give input

Hercules Elf Bot - Aug 13, 2012 4:39

Originally posted by [b]Euphy[/b]
I updated the documentation for 'doevent' in [rev=16358]. It will execute on the attached player after the current script ends, which is why it works for your first case - but on your second case, a 'sleep' command drops the attached RID, resulting in the 'doevent' label not being called.

Agree with Ind, this is working as intended because 'donpcevent' and 'doevent' serve rightfully different purposes.