PDA

View Full Version : C++ Portal



StickyIcky
25-07-08, 01:44 PM
Made by WigSplitta

In this tutorial I will show you how to make a portal in C++.
I will be using a portal that goes to Orgrimmar for an example
Well first of all we need to start the clean .cpp file with this:

#include "StdAfx.h"
#include "Setup.h"
#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#pragma warning(disable:4018) // warning C4018: '<' : signed/unsigned mismatch
#endif

#define GAME_OBJECT_ID 20000000 //Your Portal GO ID

Then you want to add this a few lines down from that:

class tele_Org: public GameObjectAIScript // Org portal

Then add:

{
public:
tele_Org(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
void OnActivate(Player * pPlayer)
{
pPlayer->SafeTeleport(0, 0, 2066.594727, 284.810089, 97.031319, 1); //Map Id, 0, X, Y, Z, O
}
static GameObjectAIScript *Create(GameObject * GO) { return new tele_Org(GO); }
};
GameObjectAIScript * create_goGAME_OBJECT_ID(GameObject * GO) { return new tele_Org(GO); }

Then you will have to make a game object in your database for it.
Then change #define GAME_OBJECT_ID 20000000 to whatever the GO ID is.

It should now look like:

#include "StdAfx.h"
#include "Setup.h"
#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#pragma warning(disable:4018) // warning C4018: '<' : signed/unsigned mismatch
#endif

#define GAME_OBJECT_ID 20000000 //Your Portal GO ID

class tele_Org: public GameObjectAIScript // Org portal
{
public:
tele_Org(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
void OnActivate(Player * pPlayer)
{
pPlayer->SafeTeleport(0, 0, 2066.594727, 284.810089, 97.031319, 1); //Map Id, 0, X, Y, Z, O
}
static GameObjectAIScript *Create(GameObject * GO) { return new tele_Org(GO); }
};
GameObjectAIScript * create_goGAME_OBJECT_ID(GameObject * GO) { return new tele_Org(GO); }

Synthetic
31-08-08, 09:08 AM
Nice script, works.. but why dont u make portals in lua? c++ portals require alot more work.

Synthetic
31-08-08, 09:24 AM
Oh, i now realise u dont know lua ;) My bad.

StickyIcky
31-08-08, 10:58 PM
I don't know LUA one bit...thats why =P

Boxxy
31-08-08, 11:38 PM
Very nice script but even without any lua skills creating lua portals is bolth easyer and more usfull(you dont have to complie it every core change XD).

StickyIcky
31-08-08, 11:41 PM
Idc...I will eventually learn LUA but im not going to go out of my way to learn it when C++ is better...even tho LUA is faster...and easier to use cuz u dont need to compile it everytime...but idk really i just like it better