Skip to content

Commit

Permalink
Terranite Cave Ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
wushin committed May 12, 2016
1 parent 9141902 commit d1e1173
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions world/map/npc/012-4/_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ map: 012-4
npc: npc/012-4/_mobs.txt
npc: npc/012-4/_nodes.txt
npc: npc/012-4/_warps.txt
npc: npc/012-4/cave_ownership.txt
npc: npc/012-4/mapflags.txt
npc: npc/012-4/pvpflag.txt
130 changes: 130 additions & 0 deletions world/map/npc/012-4/cave_ownership.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Author: Wushin
// Terranite Cave Ownership
012-4,478,180,0|script|Barclay|355
{
mes "[Barclay]";
mes "\"\"";
end;
}
// 10x10 area timers that are started by players
-|script|TCO|32767
{
explode .n, strnpcinfo(0), "#";
if (getcharid(1) == 0) goto L_NeedParty;
if (get(.TCO[.n[1]], "TCO") == getcharid(1)) goto L_Owned;
if (.cancel) goto L_ReCharge;
if (.focusing) end; // a party is currently focusing on this totem
if (gettimetick(2) - .protected < 4) goto L_Protect; // a party is currently protecting this totem
set .focusing, getcharid(1);
message strcharinfo(0), "The stone begins to glow";
set .cnt, gettimetick(2);
set .cancel, 0;
addnpctimer 1000, strnpcinfo(0)+"::OnFocus"; // make glow
addnpctimer get(.length, "TCO") * 1000, strnpcinfo(0)+"::OnFocusDone";
end;

L_Owned:
message strcharinfo(0), "The stone glows in your presense";
end;

L_ReCharge:
message strcharinfo(0), "The stone needs to recharge.";
end;

L_NeedParty:
message strcharinfo(0), "You need to be in a party.";
end;

L_Protect:
message strcharinfo(0), "This monolith is currently being protected.";
end;

OnFocus:
if (!.focusing) end;
if (.cancel) goto L_CancelEffect;
specialeffect 11;
areatimer 0, strnpcinfo(3), getnpcx()-10, getnpcy()-10, getnpcx()+10, getnpcy()+10, 1000, strnpcinfo(0)+"::OnPulse";
if (gettimetick(2) - .cnt > 3) goto L_Missing;
addnpctimer 1000, strnpcinfo(0)+"::OnFocus";
end;

L_CancelEffect:
specialeffect 26;
addnpctimer 1000, strnpcinfo(0)+"::OnFocus";
end;

L_Missing:
set .cancel, 1;
specialeffect 30;
end;

OnPulse:
if (isdead()) end;
if (.focusing != getcharid(1) || .cancel) end; // someone else clicked it
if (isin(strnpcinfo(3), getnpcx()-10, getnpcy()-10, getnpcx()+10, getnpcy()+10) < 1) end;
misceffect 8, strcharinfo(0);
set .cnt, gettimetick(2);
end;

OnProtect:
if (.focusing || .cancel) end; // another party claimed this totem while it wasn't protected
if (gettimetick(2) - .protected < 4) specialeffect 21;
areatimer 0, strnpcinfo(3), getnpcx()-10, getnpcy()-10, getnpcx()+10, getnpcy()+10, 1000, strnpcinfo(0)+"::OnProtectCheck";
addnpctimer 1000, strnpcinfo(0)+"::OnProtect";
end;

OnProtectCheck:
if (isdead()) end;
if (get(.TCO[.n[1]], "TCO") != getcharid(1)) end;
if (isin(strnpcinfo(3), getnpcx()-10, getnpcy()-10, getnpcx()+10, getnpcy()+10) < 1) end;
misceffect 8, strcharinfo(0);
set .protect, gettimetick(2);
end;

OnFocusDone:
if (!.focusing) end;
if (.cancel) goto L_Cancel;
specialeffect 40;
set .protected, gettimetick(2); // the totem can not be taken while party members protect it
addnpctimer 1000, strnpcinfo(0)+"::OnProtect"; // protection
set .TCO[.n[1]], .focusing, "TCO";
set .focusing, 0;
set .cancel, 0;
end;

L_Cancel:
specialeffect 33;
set .focusing, 0;
set .cancel, 0;
end;

OnInit:
setarray .TCO[0], 0; // init the array => TODO check if necessary
set .length, 20;
setarray .@mono, 481, 348, 124, 32, 44,
115, 38, 48, 48, 177;
set .s, getarraysize(.@mono) / 2;
goto L_Loop;

L_Loop:
if (puppet("012-4", .@mono[.@x], .@mono[.@x+.s], "Fey Anomaly#"+.@x, 204) < 1) mapexit;
set .@x, .@x + 1;
if (.@x < .s) goto L_Loop;
end;
}
function|script|CaveOwnershipBonus
{
setarray .@prizes, 640, 4001, 4002, 4003, 4004, 4005, 4006, 4007;
goto L_Loop;

L_Loop:
if ($@TCO$[.@loop] == strcharinfo(1))
set .@cnt, (.@cnt + 1);
set .@loop, (.@loop + 1);
if (.@loop < getarraysize($@TCO$))
goto L_Loop;
if (rand(100) > (91 - .@cnt))
getitem .@prizes[rand(getarraysize(.@prizes))], 1;
getexp ((BaseLevel / 10) * (.@cnt * (BaseLevel / 10))), 0;
return;
}
2 changes: 2 additions & 0 deletions world/map/npc/functions/mob_points.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function|script|MobPoints
if (MPQUEST == 1)
set Mobpt, Mobpt + @points[@mobID - 1002];

callfunc "CaveOwnershipBonus";

callfunc "ValonCount";
if (((QL_VALON >= 2) && (QL_VALON < 6)) && (@mobID == $@ValonMob[@valon_mob]))
goto L_ValonMobKill;
Expand Down

0 comments on commit d1e1173

Please sign in to comment.