PDA

View Full Version : [C++ Script] Bounty Hunter


Myerz
04-18-2009, 06:47 AM
http://i378.photobucket.com/albums/oo226/InfernosInfinite/Myerz-Logo.png

Bounty Inserter





#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



#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


By:AcD

*/





#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);

}

Myerz
04-18-2009, 06:47 AM
Assasin

/* Assasin System

Created by: Ac-Db so suck it you ****s from mmowned

License: GNuGPLv3

*/

#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

#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);

}

** Credits **
mmopro

skreem
04-18-2009, 09:12 AM
I love these bounty script

Charlie9809S
04-18-2009, 01:09 PM
Got the SQL for it?

Gnome
04-18-2009, 03:09 PM
What is this?

Sdyess
04-18-2009, 04:22 PM
Its a C++ script. You talk to the NPC, place gold on the death of a character, and then that character has to keep himself from dying. Then The Bounty Informant is updated with latest placed bounty, and anyone is free to kill the character with the bounty placed on him for the gold.

slade1000
04-18-2009, 05:54 PM
lol this is kick ass nice

ogchaos
04-26-2009, 08:21 AM
Nice script, But how the hell would you compile that?

QQrofl
04-26-2009, 08:26 AM
To go the tutorial section there will be tutorials on how to compile "extrascripts"

This has been released on mmop** and Mmowned.

I got it to work 100% it is a very awesome script, thanks for sharing.

ogchaos
04-26-2009, 10:18 AM
Ok thanks Qqrofl

birdofdeath
05-01-2009, 01:02 PM
this is great TY
BTW, i had to change one of the deffinitions "byte" i had to make "byte1" i think


Thanks again LOVE IT!!!

tekkeryole
05-02-2009, 11:39 AM
I knew I had the SQL for this somewhere, so I dug around and here you guys go, I hope this helps anybody. If I remember right - you need to thouroughly go through the scripts and make sure they are reading out of the right realm / login db function call.



// Use this query to create necessary table for use with this script.
/*

CREATE TABLE `bountyhunter` (
`id` int(11) NOT NULL auto_increment,
`client` int(11) NOT NULL,
`target` int(11) NOT NULL,
`bounty` int(11) NOT NULL,
`start` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`finish` timestamp NOT NULL default '0000-00-00 00:00:00',
`contractor` int(11) NOT NULL default '0',
`level` int(11) NOT NULL default '0',
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ;


INSERT INTO `creature_names` (`entry`, `name`, `subname`, `mouseFlags`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`) VALUES
(30089, 'Bounty Informant', '', 0, 0, 8, 0, 0, 0, NULL, 19314, 19315, 0, 0, 1, 1, 1, NULL);

INSERT INTO `creature_proto` (`entry`, `minlevel`, `maxlevel`, `faction`, `minhealth`, `maxhealth`, `mana`, `scale`, `npcflags`, `attacktime`, `mindamage`, `maxdamage`, `rangedattacktime`, `rangedmindamage`, `rangedmaxdamage`, `mountdisplayid`, `equipmodel1`, `equipinfo1`, `equipslot1`, `equipmodel2`, `equipinfo2`, `equipslot2`, `equipmodel3`, `equipinfo3`, `equipslot3`, `respawntime`, `armor`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `combat_reach`, `bounding_radius`, `auras`, `boss`, `money`, `invisibility_type`, `death_state`, `walk_speed`, `run_speed`, `fly_speed`, `extra_a9_flags`) VALUES
(30089, 255, 255, 35, 999999999, 999999999, 0, 1, 1, 2, 100000, 200000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9000, 100000, 100, 100, 100, 100, 100, 100, 1, 1, '0', 1, 0, 0, 0, 2.5, 8, 14, 0);


INSERT INTO `creature_names` (`entry`, `name`, `subname`, `mouseFlags`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`) VALUES
(30070, 'Bob Sagget', '', 0, 0, 8, 0, 0, 0, NULL, 21665, 0, 0, 0, 1, 1, 1, NULL);

INSERT INTO `creature_proto` (`entry`, `minlevel`, `maxlevel`, `faction`, `minhealth`, `maxhealth`, `mana`, `scale`, `npcflags`, `attacktime`, `mindamage`, `maxdamage`, `rangedattacktime`, `rangedmindamage`, `rangedmaxdamage`, `mountdisplayid`, `equipmodel1`, `equipinfo1`, `equipslot1`, `equipmodel2`, `equipinfo2`, `equipslot2`, `equipmodel3`, `equipinfo3`, `equipslot3`, `respawntime`, `armor`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `combat_reach`, `bounding_radius`, `auras`, `boss`, `money`, `invisibility_type`, `death_state`, `walk_speed`, `run_speed`, `fly_speed`, `extra_a9_flags`) VALUES
(30070, 255, 255, 35, 999999999, 999999999, 0, 1, 1, 2, 100000, 200000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9000, 100000, 100, 100, 100, 100, 100, 100, 1, 1, '0', 1, 0, 0, 0, 2.5, 8, 14, 0);
*/



As for the PHP Script that goes with it, give me a minute, I'll give you guys our refined version in a min...


Ok, I edited the scripts a bit, they should be working decently enough without error, Demo Site is up, test the scripts however you wish.

Bounty Status (http://tekkertronyc.servegame.org/staff/bh_status.php)
##EDIT##

Here is the download link for the site tools -
tekkertronyc.servegame.org/downloads/BOUNTY_SITE_TOOLS.rar (tekkertronyc.servegame.org/downloads/BOUNTY_SITE_TOOLS.rar)

Icerobert
05-05-2009, 06:20 PM
well to your script are still missing the assasin mysql table and it have a very big bug, the problem is that it searc for the bountyhunter and assasin table in the world db not in the char db.

atte

Icerobert

tekkeryole
05-05-2009, 08:26 PM
Thats why I was saying to go over the C++ scrpt to ensure its communicating with the right DB. If you look over the C++ bounty scripts you will notice some are pointing into the acct DB and some is pointing to the world DB function.

Icerobert
05-05-2009, 08:31 PM
plz repair it soon T_T

Cele
05-05-2009, 09:11 PM
I don't think he plans on editing it, just go through the script and you will be able to find the issues fairly quickly.

Icerobert
05-06-2009, 01:08 AM
the problem is that i dont have the sql tables

tekkeryole
05-06-2009, 08:36 AM
if you look over the C++ scripts, you CAN peice together a working DB structure, you just find out the name of the table, and create the necessary columns, most likely it will list those in the order they need to be in. If you know your MYSQL function calls in C++, then shouldn't be a problem.

Terrorblade
05-06-2009, 12:34 PM
i say make the people who are doing the bounties have a ffa flag lol

ogchaos
05-06-2009, 01:25 PM
Someone please post a "Fully" working SQL for this script or this script is pointless.

tekkeryole
05-06-2009, 11:14 PM
Someone please post a "Fully" working SQL for this script or this script is pointless.

OMFG. I already posted the only known SQL for this4 year old script TWICE, once in a download Link and and in a code Box Above. Learn To Read all posts on a Topic. Then learn you C++ Functions and how they interact with MYSQL. VS 2008 automatiocally has support for this bro, so check the MYSQL folder in your VS 2008 directory, check out the function calls, and peice together your own DB structure. Its not that hard.

fullmetalalki
05-06-2009, 11:27 PM
awesome script, im gonna love using this :D

Coreyduffel
05-07-2009, 12:57 AM
What does it do?