PDA

View Full Version : Tower Defense-Styled Event (incomplete)


Shin Noir
10-16-2009, 05:06 PM
This is old code of mine when I first started up EQEMU questing, but instead of it potentially getting deleted or lost in limbo of other projects, I figured I'd post it for others to see. Originally written on 7/12/09.

It isn't complete. It needed a few tweaks to properly get working
The general idea was, you talked to Derron_Coldmist in Crystal Caverns and he would give you a task to defend him. He also started an event where orcs would begin roaming to him, intent on killing him. If he died, you failed the task. Each time an orc died during this event, he would give you a bounty point that allowed you to spawn archers to help assist in fending off the attacks.
So essentially:
Derron_Coldmist - your life
Archers: your towers
Orcs: Creeps

I didn't know how qglobals worked back then, so I was using just temp vars.
Here's the code. Originally built on crystal\Derron_Coldmist.pl
sub EVENT_SAY {
if ($text=~/hail/i) {
#quest::say("Yes, hello");
#quest::spawn2(999144, 0, 0, 184.5, -55.6, -376.7, 86.5);
quest::spawn2(999144, 0, 0, 219.1, -53.7, -376.7, 130.1);
quest::say("$orcslays killed");
}
if ($text=~/archer/i) {
if (!defined($entity_list->GetMobByNpcTypeID(999145))) {
$tmpname = 999145;
quest::spawn2($tmpname, 0, 0, 200.4, -226.7, -382.7, 27.3);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #1 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999146))) {
$tmpname = 999146;
quest::spawn2($tmpname, 0, 0, 221.8, -227.5, -382.7, 0.0);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #2 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999147))) {
$tmpname = 999147;
quest::spawn2($tmpname, 0, 0, 198.8, -246.5, -382.7, 19.6);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #3 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999148))) {
$tmpname = 999148;
quest::spawn2($tmpname, 0, 0, 210.1, -245.2, -380.2, 8.8);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #4 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999149))) {
$tmpname = 999149;
quest::spawn2($tmpname, 0, 0, 220.7, -246.5, -382.7, 254.8);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #5 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999150))) {
$tmpname = 999150;
quest::spawn2($tmpname, 0, 0, 192.9, -259.9, -382.7, 18.6);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #6 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999151))) {
$tmpname = 999151;
quest::spawn2($tmpname, 0, 0, 215.2, -263.6, -382.7, 1.9);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #7 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999152))) {
$tmpname = 999152;
quest::spawn2($tmpname, 0, 0, 203.1, -299.6, -382.7, 7.0);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #8 reporting for duty!"); #back row guy.
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999153))) {
$tmpname = 999153;
quest::spawn2($tmpname, 0, 0, 191.3, -279.4, -382.7, 15.1);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #9 reporting for duty!");
}
elsif (!defined($entity_list->GetMobByNpcTypeID(999154))) {
$tmpname = 999154;
quest::spawn2($tmpname, 0, 0, 214.3, -275.6, -382.7, 0.0);
$entity_list->GetMobByNpcTypeID($tmpname)->Stun(2.0); #They're stunned for 2 secs.
$entity_list->GetMobByNpcTypeID($tmpname)->Say("Archer #10 reporting for duty!");
}
else {
quest::say("You have already the maximum amount of guards.");
}
}

}

sub EVENT_SIGNAL {
#quest::ze(15, "Orc Dead Rec'd.");
if (!defined($orcslays)) {
$orcslays = 0;
}
$orcslays++;
$orcmoney++;
quest::say("$orcslays orcs have been killed!");
}

Then you had crystal/a_Ry-Gorr_invader.pl
# # 999144 a_Ry`Gorr_invader used on Derron Coldmists's custom quest.

sub EVENT_SPAWN {
#quest::attacknpctype(
quest::moveto(206, -321, -383);
#
#sethate
}
sub EVENT_SLAY {
quest::moveto(206, -321, -383);
}
sub EVENT_NPC_SLAY {
quest::moveto(206, -321, -383);
}
sub EVENT_COMBAT {
if ($combat_state==0) {
quest::moveto(206, -321, -383);
}

}
sub EVENT_DEATH {
quest::signal(121024);
}

Sadly I don't have these mobs anymore, but they wouldn't be hard to recreate.

ChaosSlayerZ
10-16-2009, 06:39 PM
did you had an actual "archer" that would shout a bow?

Shin Noir
10-16-2009, 06:46 PM
I don't think archers were supported back in July.. I ran into a lot of issues with it. ;) Haha.
Are they even supported now? (ranged attack mobs)

bbgunz
10-17-2009, 10:09 PM
Shin Noir, your a source of inspiration!.

Id love to see something like this finished.

I cant speak for the majority, but im newb at coding or i'd do it myself. Alot of people waiting on these sort of pvp/ctf/tf developments which are typically created on private servers but never released.

Shin Noir
10-23-2009, 07:15 AM
fine fine.
Here's a more complete version. Needs quite a few tweaking here or there, but it is working on my test box. Got to clean up some random junk, trying to make it easy to plug into other situations.. Not sure I'll mess around with this more later or not. But, Enjoy~

Yeah, I need to use some qglobals and not rely on local vars so much since they can be pretty icky, but for all intent and purposes this seems to work decently well!

#Written by Shin Noir, with intent of being used on /crystal/Derron_Coldmist.pl
sub EVENT_SAY {
$towerid = 121026; #Guard Evercold
#tower location spawn points.
$dname = "defender";
$aname = "orc";
@towerx = ( 200.4, 221.8, 198.8, 210.1, 220.7, 192.9, 215.2, 203.1, 191.3, 214.3);
@towery = (-226.7, -227.5, -246.5, -245.2, -246.5, -259.9, -263.6, -299.6, -279.4 -275.6);
@towerz = (-382.7, -382.7, -382.7, -380.2, -382.7, -382.7, -382.7, -382.7, -382.7, -382.7);
@towerh = ( 27.3, 0, 19.6, 8.8, 254.8, 18.6, 1.9, 7.0, 15.1, 0);
@creeploc = (229.3, -73.7, -376.7, 131.8); #This could be split up like tower is.
if (!defined $bounty) { $bounty = 0; }
if (!defined $killcount) { $killcount = 0; }
$wavedelay = 5; #seconds between each wave.
$towercost = 3; #How many creeps does it cost to buy a tower?
if ($text=~/hail/i) {
if (!defined $wave) {
quest::say("Are you [ready] to begin?");
} else {
quest::say("It has already begun.");
}
}
if ($text=~/ready/i) {
if (!defined $wave) {
$bounty = 0; #Reset Bounty
$wave = 1; #Reset Wave
$killcount = 0;
@tower = {0,0,0,0,0,0,0,0,0,0 }; #reset defenders.
quest::say("I hear them incoming...");
quest::settimer(1, $wavedelay); #Set timer for initial wave, delay 5 secs.
} else {
quest::say("It has already begun.");
}
}
if ($text=~/bounty/i) {
if (!defined $wave) {
quest::say("You haven't started yet.");
} else {
quest::say("Your current bounty is $bounty, with $killcount total kills.")
}
}
if ($text=~/left/i) {
quest::say("I would guess there's about ".scalar @creeps." left..");
}
if ($text=~/$dname/i) {
#Figure out who goes next!
#this is a routine where I essentially have an array, @tower, that stors each tower mob.
#It goes through each tower, seeing if they're still alive, and if not, replaces their
#spot with fresh tower.
if ($bounty > $towercost) {
for ($i = 1; $i < 11; $i++) {
if (!defined($tower[$i]) || !defined( $entity_list->GetMobID($tower[$i]))) {
$tower[$i] = quest::spawn2($towerid, 0, 0, $towerx[$i-1], $towery[$i-1], $towerz[$i-1], $towerh[$i-1]);
quest::say("Tower #$i reporting!"); #$tower[$i]
$entity_list->GetMobID($tower[$i])->Stun(2.0); #Stun new tower for 2 seconds.
$bounty = $bounty - $towercost;
return;
}
}
quest::say("No spots available.");
return;
} else {
quest::say("You need at least $towercost bounty points to buy a $dname, you only have $bounty.");
}
}
}

sub EVENT_TIMER {
#116024: Scout, 116007: Centurion, 116172: Legionarre, 116011: Elite
@creepid = (116024, 116024, 116007, 116007, 116172, 116172, 116011, 116011);
@creepamt = (1, 3, 2, 4, 1, 3, 1, 3);
if ($timer eq "1") { #Initial Message.
if (!defined $wavedelay) { #sanity check
quest::stoptimer(1);
quest::say("Event ended prematurely (GM Intervention?)");
return;
}
quest::say("They're here! (Wave $wave)");
quest::settimer(2, 2); #2 second delay until upkeep check
quest::stoptimer(1); #kill this timer.

if (!defined(@creeploc)) { my @creeploc = (200.4, -226.7, -382.7, 27.3); } #This could be split up like tower is.
undef(@creeps);
if (!defined $creepamt[$wave-1]) { #end of creeps!
quest::say("You have won! You ended up with $bounty bounty and $killcount total kills!");
$bounty = 0; #Reset Bounty
undef($wave); #Reset Wave
$bounty = 0;
$killcount = 0;
quest::stoptimer(1);
}
for ($i =0; $i < $creepamt[$wave-1]; $i++) {
#quest::say("$creepid");
$creeps[$i] = quest::spawn2($creepid[$wave-1], 0, 0, $creeploc[0], $creeploc[1], $creeploc[2], $creeploc[3]); #Keep their entity ID.
$entity_list->GetMobID($creeps[$i])->Stun(int(rand(5)));
$entity_list->GetMobID($creeps[$i])->AddToHateList($npc, 1,0); #make them hate Derron.
}
quest::say("Looks to be about ".$creepamt[$wave-1]." ".$entity_list->GetMobID($creeps[0])->GetCleanName. (($creepamt[$wave-1]>1) ? "s" : ""));
}
if ($timer eq "2") { #Upkeep
if (!defined $wavedelay) { #sanity check
quest::stoptimer(2);
quest::say("Event ended prematurely (GM Intervention?)");
return;
}
#quest::say(scalar @creeps);
my $oldbounty = 0;
for ($i = 0; $i < scalar @creeps; $i++) { #Creep check!
if (defined $creeps[$i]) { #I find this a silly check but scalar size is wierd.
if (!defined $entity_list->GetMobID($creeps[$i])) {
delete $creeps[$i]; #Clean up dead mobs.
$bounty++;
$oldbounty++;
$killcount++;
}
}
}
if ($oldbounty) {
#quest::say("You killed an $aname, putting your total to $bounty!");
}
#quest::say(scalar @creeps);
if (scalar @creeps < 1) { #no more creeps
quest::stoptimer(2); #kill this timer
$wave = $wave+1; #Next wave!
quest::settimer(1, $wavedelay); #delay until next wave
quest::say("You have finished off the wave! You have $bounty unspent bounty points. $wavedelay seconds until the next attack...");
}
}
}

sub EVENT_SIGNAL {
#quest::ze(15, "Orc Dead Rec'd.");
if (!defined($orcslays)) {
$orcslays = 0;
}
$orcslays++;
$orcmoney++;
quest::say("$orcslays orcs have been killed!");
}

bbgunz
10-29-2009, 07:20 PM
legend !

can't wait to give this a shot