[Guided Release] PvP script explained menu

User Tag List

Results 1 to 4 of 4
  1. #1
    TheSpidey's Avatar Elite User
    Reputation
    365
    Join Date
    Jan 2008
    Posts
    2,200
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Guided Release] PvP script explained

    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    
    //This struct will help us store the info we need for each player.
    struct kill_info
    {
    	kill_info()
    	{
    		streak = 0;
    		lguid = 0;
    	}
    
    	~kill_info() {}
    
    	uint16 streak; //Stores how many kills we have in a row
    	uint32 lguid; //Stores the last player killed guid to prevent abuse
    };
    
    static map<uint32, kill_info> kills;
    
    void onPVP(Player * pPlayer, Player * pVictim)
    {
            //We don't want this script to affect GMs.
    	if(pPlayer->GetSession()->HasGMPermissions() || pVictim->GetSession()->HasGMPermissions())
    		return;
    
            //We're storing the guids for easy access later
            //They're our indexes of the 'kills' map.
    	uint32 p = pPlayer->GetGUIDLow();
    	uint32 v = pVictim->GetGUIDLow();
    
    	char msg[256] = ""; //This will store our message to the world
    	if(p == v) //If the player's guid is the same as the victim guid
    	{
    		sprintf(msg, "%s just commited suicide! Pathetic!", pPlayer->GetName());
    		sWorld.SendWorldWideScreenText(msg);
    		kills[v].streak = 0;
    		return;
    	}
    
            //if we have a restricted no-pvp zone, define it here:
    	if(pPlayer->GetMapId() == 169 && pVictim->GetMapId() == 169) //In this case it's Emerald Forest
    	{
                    //Time to do nasty stuff
    		pPlayer->Reset_Spells();
    		pPlayer->Reset_Talents();
    		pPlayer->Reset_ToLevel1();
    		pPlayer->EventTeleport(1, 16226.2, 16403.3, -63);
    		pPlayer->BroadcastMessage("You were sent to jail for killing in the mall.");
    		char msg[1024];
    		snprintf(msg, 1024, "|cffff0000 %s the noob got kicked for fighting in the mall.", pPlayer->GetName());
    		sWorld.SendWorldText(msg);
    		pPlayer->Kick(60000);
    		return;
    	}
    
            //Now let's check if the player killed the same guy twice. If so, give him nothing
    	if(kills[p].lguid == v)
    		return;
    
    	kills[p].streak++;
    
            //Now it's time to run checks like, if the victim had X kills in a row, do this and that.
            //I'm not including this, think up your own stuff ;)
    
            //In the end we set the player's lguid to the current victim, and reset the victim's streak. Don't put this before the checks, for obvious reasons.
    	kills[p].lguid = v;
    	kills[v].streak = 0;
    
            //This snippet changes the scale of the player. More kills = bigger scale. On my 
            //servers the more kills you have in a row, the more marks you're worth
            //So this is a good way to see pinatas ;)
    	if(pPlayer->getRace == RACE_TAUREN) //Taurens start at 1.3 scale
    		pPlayer->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.3+((kills[p].streak-1)*0.2)); //Tricky line! We take the streak - 1 (so only double kills and up would count), and multiply by 0.2. So 5 kills are 1.3 + 0.8
    	else
    		pPlayer->SetFloatValue(OBJECT_FIELD_SCALE_X, 1+((kills[p].streak-1)*0.2)); //Same here, just the base scale is 1
    
    } //Don't forget me!
    
    
    //And of course we need to set it up now
    void SetupPVP(ScriptMgr * mgr)
    {
           //We register the onPVP function to the ON_KILL hook, so every time a player kills another player, the function gets called.
    	mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, &onPVP);
    }
    Now all you need to do is add the appropriate lines in setup.h and setup.cpp and compile

    Edit: Ouch this looks like a huge wall of code. I'll explode it later to smaller bits
    Last edited by TheSpidey; 12-27-2008 at 06:44 PM.

    [Guided Release] PvP script explained
  2. #2
    Spectre90's Avatar Contributor
    Reputation
    92
    Join Date
    Jan 2008
    Posts
    77
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice work, I love how you removed that one part to make the leechers think for themselves ^^

  3. #3
    Risap's Avatar Member
    Reputation
    1
    Join Date
    Dec 2007
    Posts
    15
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    xD looks like a nice script i whish i new how to compile :'(

  4. #4
    TheSpidey's Avatar Elite User
    Reputation
    365
    Join Date
    Jan 2008
    Posts
    2,200
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Spectre90 View Post
    Nice work, I love how you removed that one part to make the leechers think for themselves ^^
    Yep, this isn't for leechers, this is mainly for people who want to learn how to make scripts, and give back to the community eventually.

Similar Threads

  1. [GUIDE/RELEASE] How to make multiple realms on 1 server!
    By latruwski in forum World of Warcraft Emulator Servers
    Replies: 6
    Last Post: 11-14-2007, 02:16 PM
  2. A Very quick Guide on pvp for Warriors (simple)
    By edestron in forum World of Warcraft Guides
    Replies: 12
    Last Post: 02-14-2007, 07:16 PM
  3. TUU's Guide to PvP Warriors--Feedback please!
    By Örpheus in forum World of Warcraft Guides
    Replies: 8
    Last Post: 07-10-2006, 02:41 PM
  4. TUU's Guide to PvP Shamans--READ DISCLAIMER
    By Örpheus in forum World of Warcraft Guides
    Replies: 3
    Last Post: 07-08-2006, 10:09 PM
  5. TUU's Guide To PvP Rogues
    By Örpheus in forum World of Warcraft Guides
    Replies: 0
    Last Post: 07-04-2006, 10:56 PM
All times are GMT -5. The time now is 10:10 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search