PDA

View Full Version : Code for zone control pvp


caravellex
01-20-2018, 10:54 AM
So I have an idea, and I know generally how to connect it via quest commands, but no idea how to get the syntax correct.

The core of the idea is that when a certain pvp team captures a control point (this can be a zone or a particular camp, like the commonlands orc tents.)
They gain ownership over the point and npcs.

To do this I was thinking you have a quest that changes the faction of the npcs in the zone or area to that if the team. The quest is triggered by killing the "boss" of the camp. Doing this sets the global quest flag for your team as "owner", depops the old npcs and repops them with the updated faction.

If anyone had a little time and wanted to help show me what that would look like I'd be really grateful!

Lane
01-21-2018, 01:07 AM
I would put something like this in the NPC's .pl file.

For killer_Id, it would change based on your database. For me, my GM is 82,289 so anything 82,290 and higher is a regular player. I'm sure there's a better way to code this, but I'm a novice.

The GM Say will also broadcast the name of who's taken over the orcs. I think the code below is in red. Could easily change it to yellow or whatever.

For faction... it couldn’t be a part of the code below. I’m not sure how to do a quest::faction to $killer... if you add quest::faction to below it won’t work because below is triggered on death, so the killer wouldn’t get the faction hit. maybe have to edit the player.pl to somehow register killing = faction.

sub EVENT_DEATH_COMPLETE
{
$entity_list -->GetClientByID($killer_id) ;
if($killer_id > 82,290) {
quest::gmsay("$entity_list->GetClientByID($killer_id)->GetName() . " has taken over the orcs in the Commonlands! ", 335, 1, 0, 250);
quest::spawn(npc_type_id, grid, guildwarset, x, y, z) # Spawn 'npc_type_id' on 'grid' with 'guildwarset' (use 0) at 'x', 'y', and 'z);
}
}


Another idea I had would to be to use the code above, edit the database to make all players KOS to the NPC faction, also change the DB value to give maximum faction on kill. Then you could add a sub EVENT_ENTER_ZONE to the player.pl that calls for quest::faction to go completely negative. This way when the player dies or zones and re-enters the zone, they would be KOS again.

This would require the player to kill the NPC to get a maximum faction hit and it would be the player who is allied to try and stop you from killing it.

The only downside I see to the above approach is what if players sit in the zone or hide after killing NPC, then all players kill NPC and are max faction? Shrug just some thoughts. Good luck and let me know if you figure out how to give faction on kill with quest::faction. I’m designing a custom PvP server as well and I just gave in and do a ground spawn on player kill for a turn in for faction.

Lane
01-21-2018, 01:09 AM
I was thinking and another way to do this would require more database work than Perl. If you have a port in NPC that allows you to be ported to Commons with Team 1 or Team 2, you could make custom NPC versions in the database.

An example would be...

Quest NPC has a if text = “Good Team”

Quest::movepc (to zone to Commons)
Quest::faction (to X amount corresponding to the NPC values you want for good or evil team NPCs.)

Then having a Perl event on the NPC that says if $killer = guild good team ... quest::spawn good team version of mobs... and vise versa. Anyway, there’s a ton of ways to do this so some more information about your server set up would allow people to help you more :)

caravellex
01-21-2018, 03:54 AM
I would put something like this in the NPC's .pl file.

For killer_Id, it would change based on your database. For me, my GM is 82,289 so anything 82,290 and higher is a regular player. I'm sure there's a better way to code this, but I'm a novice.

The GM Say will also broadcast the name of who's taken over the orcs. I think the code below is in red. Could easily change it to yellow or whatever.

For faction... it couldn’t be a part of the code below. I’m not sure how to do a quest::faction to $killer... if you add quest::faction to below it won’t work because below is triggered on death, so the killer wouldn’t get the faction hit. maybe have to edit the player.pl to somehow register killing = faction.

sub EVENT_DEATH_COMPLETE
{
$entity_list -->GetClientByID($killer_id) ;
if($killer_id > 82,290) {
quest::gmsay("$entity_list->GetClientByID($killer_id)->GetName() . " has taken over the orcs in the Commonlands! ", 335, 1, 0, 250);
quest::spawn(npc_type_id, grid, guildwarset, x, y, z) # Spawn 'npc_type_id' on 'grid' with 'guildwarset' (use 0) at 'x', 'y', and 'z);
}
}


Another idea I had would to be to use the code above, edit the database to make all players KOS to the NPC faction, also change the DB value to give maximum faction on kill. Then you could add a sub EVENT_ENTER_ZONE to the player.pl that calls for quest::faction to go completely negative. This way when the player dies or zones and re-enters the zone, they would be KOS again.

This would require the player to kill the NPC to get a maximum faction hit and it would be the player who is allied to try and stop you from killing it.

The only downside I see to the above approach is what if players sit in the zone or hide after killing NPC, then all players kill NPC and are max faction? Shrug just some thoughts. Good luck and let me know if you figure out how to give faction on kill with quest::faction. I’m designing a custom PvP server as well and I just gave in and do a ground spawn on player kill for a turn in for faction.

Ohhhh yeah great point - not replacing the mobs at all but instead changing the faction for the team losing control of the npc would be the best way to do it.
Orrrr - if it was a race/diety pvp system. You make the quest change the database value for the faction entry -2000 for losing team classes and races, +2000 for winning team. That's way easier ty!