PDA

View Full Version : Bounty Hunter



StickyIcky
25-07-08, 01:39 AM
Created By lilNate22

WARNING this script is tested, and works fine on my hope pc (running winxp) HOWEVER on my WS 2003 SE it crashes server, im still wondering why

Bounty Inserter

/*/Bounty Hunter NPC ftw *****ES
By:AcDB Aka LilNate22 visit ac-db.info for more
*/

#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#endif


//Start of Script
class SCRIPT_DECL HunterNPC : public GossipScript
{
public:
void GossipHello(Object * pObject, Player* Plr , bool AutoSend);
void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void HunterNPC::GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
if(Plr->CombatStatus.IsInCombat()){
Plr->BroadcastMessage("You are in combat!");
return;
}
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 30013, Plr);
Menu->AddItem(1, "I want to hire an Assasin for 100g to kill some one!",1,1);
Menu->AddItem(2, "I want to put a bounty on some one for 50g!", 2,1);




if(AutoSend)
Menu->SendTo(Plr);
}
//Defining Cases
void HunterNPC::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
uint32 plrid;

switch(IntId)
{
case 1: //Service Center
{
uint32 price = 1000000;
uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
if(currentgold>=price)
{
int32 newgold = currentgold - price;
Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold);
QueryResult*namecheck=WorldDatabase.Query("select `guid` from `characters` where `name`='%s';",Code);
if(namecheck){
plrid=namecheck->Fetch()[0].GetUInt32();
WorldDatabase.Query("replace into `assasin` (`hunted`,`GUID`) Values ('1','%u');",plrid);
}

delete namecheck;
}
else
Plr->BroadcastMessage("You Dont Have enough gold!");
Plr->Gossip_Complete();
}break;

case 2: //bounty
{
uint32 price = 1000000/2;
uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
if(currentgold>=price)
{
int32 newgold = currentgold - price;
Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold);
QueryResult*namecheck=WorldDatabase.Query("select `guid` from `characters` where `name`='%s';",Code);
if(namecheck)
{
plrid=namecheck->Fetch()[0].GetUInt32();
WorldDatabase.Query("replace into bountyhunts (`name`, `plrid`) VALUES ('%s','%u');",Code,plrid);
}
}

Plr->Gossip_Complete();



}break;







}
};

void HunterNPC::GossipEnd(Object * pObject, Player* Plr)

{
GossipScript::GossipEnd(pObject, Plr);
}

void SetupHunterNPC(ScriptMgr * mgr)

{
GossipScript * gs = (GossipScript*) new HunterNPC();
mgr->register_gossip_script(30015, gs);

}

Bounty Informant

/* Scripted By LilNate22 of AC-DB
**** you leeching queers+haters
*/
#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#endif


//Start of Script
class SCRIPT_DECL BHNPC : public GossipScript
{
public:
void GossipHello(Object * pObject, Player* Plr , bool AutoSend);
void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void BHNPC::GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
if(Plr->CombatStatus.IsInCombat()){
Plr->BroadcastMessage("You are in combat!");
return;
}
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 30013, Plr);
QueryResult*bountyresult=WorldDatabase.Query("select `name` from `bountyhunts`;");
if( bountyresult )
{
int x=bountyresult->GetRowCount();
/*if(x==1)
{
const char *name=result->Fetch()[0].GetString();
Menu->AddItem->(1,name,1);
return;
}*/
if(x!=1){
do
{
const char * name =bountyresult->Fetch()[0].GetString();
Menu->AddItem(1,name,1);

} while (bountyresult->NextRow());
}
else{
const char * name =bountyresult->Fetch()[0].GetString();
Menu->AddItem(1,name,1);
}



delete bountyresult;
}
else
{
Plr->BroadcastMessage("There are no Bounties");
}



if(AutoSend)
Menu->SendTo(Plr);
}
//Defining Cases
void BHNPC::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
uint32 plrid;

switch(IntId)
{
case 1:
Plr->BroadcastMessage("Go kill that Basterd!");
Plr->Gossip_Complete();
}








};

void BHNPC::GossipEnd(Object * pObject, Player* Plr)

{
GossipScript::GossipEnd(pObject, Plr);
}

void SetupBHNPC(ScriptMgr * mgr)

{
GossipScript * gs = (GossipScript*) new BHNPC();
mgr->register_gossip_script(30017, gs);
}

Bounty PvP

/*/Bounty Hunter NPC ftw *****ES
By:AcDB Aka LilNate22 visit ac-db.info for more
*/


#include "StdAfx.h"
#include "Setup.h"

void onPVPBounty(Player*hunter, Player*bounty)
{


QueryResult*victimcheck=WorldDatabase.Query("select `name` from `bountyhunts` where `plrid`='%u';",bounty->GetGUID());
bool bountycheck=false;
if(victimcheck)
bountycheck=true;

if(bountycheck==true)
{
hunter->BroadcastMessage("Target...|CFFFF66FF Assasinated |r");
QueryResult*clearbounty=WorldDatabase.Query("Delete from `bountyhunts` WHERE `plrid`='%u';",bounty->GetGUID());
ItemPrototype *proto = ItemPrototypeStorage.LookupEntry(94);
SlotResult slotresult;
slotresult = hunter->GetItemInterface()->FindFreeInventorySlot(proto);
//hunter->BroadcastMessage("|CFFFF00FF Greater PvP Token|r Recieved");
if(!slotresult.Result)
{
hunter->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
hunter->BroadcastMessage("Bag Full!");
}
else
{
Item *itm = objmgr.CreateItem(94, hunter);
itm->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
hunter->GetItemInterface()->SafeAddItem(itm,slotresult.ContainerSlot, slotresult.Slot);
//hunter->GetItemInterface()->SafeAddItem(itm,slotresult.ContainerSlot, slotresult.Slot);


}
delete victimcheck;
delete clearbounty;

}
}





void SetupBountyPVP(ScriptMgr * mgr)
{
//GossipScript * gs = (GossipScript*) new BountyNPC();
/* Teleporter List */
//mgr->register_gossip_script(100001, gs); // Nega
mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, onPVPBounty);
}


Assasin-this is safe

/* Assasin System
Created by: Ac-Db (lilnate22) so suck it you ****s from *******
License: GNuGPLv3
Additional: leave credits or die::::Dedicated to Kristen
*/
#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#endif



void AssasinSystem (Player* plr){

char checking[200];
int faction=plr->GetTeam();
int killerfaction;
CreatureSpawn * sp = new CreatureSpawn;
sprintf(checking,"SELECT `hunted` FROM `assasin` WHERE `GUID`='%i';", plr->GetGUID());
QueryResult*check=WorldDatabase.Query(checking);
uint32 hunt=0;

if(!check)
{return;}

//Not sure if i need to do this 2x...prolly not...but to be safe...

else//the player is hunted
{
if(check)
{
Field*hunted=check->Fetch();
hunt=hunted[0].GetUInt32();

}
}//else::if!check bracket

//We need the opposite of the players faction
if (faction==0)
{killerfaction=2;}
else
{killerfaction=1;}
/////////////////////////////////////////////
if(hunt>0)
{
uint32 entry=123455;
plr->BroadcastMessage("Theres an |CFF33CC33 Assasin after you|r!");
plr->PlaySoundToSet(10178);
CreatureInfo * info = CreatureNameStorage.LookupEntry(123455);
info->GenerateModelId(&sp->displayid);
sp->entry = entry;
sp->form = 0;
sp->id = objmgr.GenerateCreatureSpawnID();
sp->movetype = 0;
sp->x = plr->GetPositionX();
sp->y = plr->GetPositionY();
sp->z = plr->GetPositionZ();
sp->o = plr->GetOrientation();
sp->emote_state =0;
sp->flags = 0;
sp->factionid = killerfaction;
sp->bytes=0;
sp->bytes2=0;
//sp->respawnNpcLink = 0;
sp->stand_state = 0;
sp->channel_spell=sp->channel_target_creature=sp->channel_target_go=0;


Creature * p = plr->GetMapMgr()->CreateCreature(entry);
ASSERT(p);
p->Load(sp, (uint32)NULL, NULL);
p->PushToWorld(plr->GetMapMgr());

uint32 x = plr->GetMapMgr()->GetPosX(plr->GetPositionX());
uint32 y = plr->GetMapMgr()->GetPosY(plr->GetPositionY());

// Add spawn to map
/*plr->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(
x,
y)->CreatureSpawns.push_back(sp);*/
}
}
void Assasin(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_ENTER_WORLD, AssasinSystem);
}


Assasin Unit - also safe

#include "StdAfx.h"
#include "Setup.h"

#define PvP_Guard 123455

class PvPGuard : public CreatureAIScript
{

public:
ADD_CREATURE_FACTORY_FUNCTION(PvPGuard);

PvPGuard(Creature* pCreature) : CreatureAIScript(pCreature)
{
}

void OnTargetDied(Unit *mTarget)
{
if(mTarget->IsPlayer())
{
//random code to do something when the mob kills a player?
QueryResult*reseting=WorldDatabase.Query("delete from `assasin` WHERE `GUID`='%u';",mTarget->GetGUID());
_unit->Despawn(1,0);
}
}

};


void SetupPvPGuards(ScriptMgr * mgr)
{
mgr->register_creature_script(PvP_Guard, &PvPGuard::Create);
}

brock106
29-07-08, 02:06 PM
Thank you for the source

Boxxy
04-08-08, 02:20 AM
wo i havent seen this in forever i remember how cool it was to have a bounty placed on you and people hunting you lol +rep

Edit: need to spread teh rep cookies