Hey guys, I wanted to make it so that an NPC in my custom city will do the .advanceallskills ___ thing to the players, so I was wondering if that's even possible, and if it is, how to do it. It's just so that the GMs have one less thing to do.
Hey guys, I wanted to make it so that an NPC in my custom city will do the .advanceallskills ___ thing to the players, so I was wondering if that's even possible, and if it is, how to do it. It's just so that the GMs have one less thing to do.
C++ scripting.
As all GM commands are built up using C++, there must be some way to make this with c++ =P
I need my friendly neighborhood Spidey
I'll message him and ask him, thanks for helping me narrow it down though Illuminati!
Can you show or explain how you did it so I might have a shot at making my own?
Along with that, can I make a object port someone when they click it, but I want the object to do .start, so it always sends them back to their starting location?
you can find the commands and how they work in level0.cpp, level1.cpp, level2.cpp, and level3.cpp in src/ascent-world
Okay, but then how do I translate that over to an NPC or a gameobject? Sorry that I'm new to LUA/C++.
well you can edit a npc gossip script (somthing like a warp npc) or jsut make a gameobject script. you can search for either, get the source and edit the case
Without a knowledge of C++ and how it works, its highly unlikely you could script this mate, sorry.
no its not highly unlikely, he just needed some help, unfortunately im busy atm and cant assist him. its not like if you dont know all of C++ that you wont be able to do anything.
Okay, I understand what I need to do with the LUA script (or I have a fairly good idea of it) from reading up and practicing by making a few boss scrpits and gossip scripts. I went searching through the level stuff and found the .start command from there.
From that info, what would I put into my script, which from Spidey's tutorial on GameObject scripts would look similar too:bool ChatHandler::HandleStartCommand(const char* args, WorldSession *m_session)
{
std::string race;
uint32 raceid = 0;
Player *m_plyr = getSelectedChar(m_session, false);
if (m_plyr && args && strlen(args) < 2)
{
raceid = m_plyr->getRace();
switch (raceid)
{
case 1:
race = "human";
break;
case 2:
race = "orc";
break;
case 3:
race = "dwarf";
break;
case 4:
race = "nightelf";
break;
case 5:
race = "undead";
break;
case 6:
race = "tauren";
break;
case 7:
race = "gnome";
break;
case 8:
race = "troll";
break;
case 10:
race = "bloodelf";
break;
case 11:
race = "draenei";
break;
default:
return false;
break;
}
}
else if (m_plyr && args && strlen(args) > 2)
{
race = args;
ASCENT_TOLOWER(race);
// Teleport to specific race
if(race == "human")
raceid = 1;
else if(race == "orc")
raceid = 2;
else if(race == "dwarf")
raceid = 3;
else if(race == "nightelf")
raceid = 4;
else if(race == "undead")
raceid = 5;
else if(race == "tauren")
raceid = 6;
else if(race == "gnome")
raceid = 7;
else if(race == "troll")
raceid = 8;
else if(race == "bloodelf")
raceid = 10;
else if(race == "draenei")
raceid = 11;
else
{
RedSystemMessage(m_session, "Invalid start location! Valid locations are: human, dwarf, gnome, nightelf, draenei, orc, troll, tauren, undead, bloodelf");
return true;
}
}
else
{
return false;
}
// Try to find a class that works
PlayerCreateInfo *info = NULL;
for(uint32 i=1;i<11;i++)
{
info = objmgr.GetPlayerCreateInfo(raceid, i);
if(info != NULL) break;
}
if(info == NULL)
{
RedSystemMessage(m_session, "Internal error: Could not find create info.");
return false;
}
GreenSystemMessage(m_session, "Telporting %s to %s starting location.", m_plyr->GetName(), race.c_str());
m_session->GetPlayer()->SafeTeleport(info->mapId, 0, LocationVector(info->positionX, info->positionY, info->positionZ));
return true;
}
EDIT: Actually, refrain from answering, I think I understand this, it kinda looks similar to Java in some ways (with the boolean and the if ___ else ___). Let me try this myself and I'll see if I can do it.#include "StdAfx.h"
#include "Setup.h"
class GONAME : public GameObjectAIScript
{
public:
GONAME(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new GONAME(GO); }
void OnActivate(Player * pPlayer)
{
//do stuff here
}
};
void SetupGONAME(ScriptMgr * mgr)
{
mgr->register_gameobject_script(ENTRY, &GONAME::Create);
}
Last edited by guitargod218; 05-28-2008 at 04:38 PM.
Here's a hint - C&P the code from .advanceallskills to //do stuff here![]()
Thanks, my friendly neighborhood Spidey, I'll try it out later once I get back from dinner.
Okay, I input my C++ script into my scripts folder, but nothing happens when I click on it. The name of the object is "Globe of Translocation" (Crappy name , I know), and here is the script:
Does it not work because in the script it's Globe_of_Translocation instead of GlobeofTranslocation?#include "StdAfx.h"
#include "Setup.h"
class Globe_of_Translocation : public GameObjectAIScript
{
public:
Globe_of_Translocation(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new Globe_of_Translocation(GO); }
void OnActivate(Player * pPlayer)
{
bool ChatHandler::HandleStartCommand(const char* args, WorldSession *m_session)
{
std::string race;
uint32 raceid = 0;
Player *m_plyr = getSelectedChar(m_session, false);
if (m_plyr && args && strlen(args) < 2)
{
raceid = m_plyr->getRace();
switch (raceid)
{
case 1:
race = "human";
break;
case 2:
race = "orc";
break;
case 3:
race = "dwarf";
break;
case 4:
race = "nightelf";
break;
case 5:
race = "undead";
break;
case 6:
race = "tauren";
break;
case 7:
race = "gnome";
break;
case 8:
race = "troll";
break;
case 10:
race = "bloodelf";
break;
case 11:
race = "draenei";
break;
default:
return false;
break;
}
}
else if (m_plyr && args && strlen(args) > 2)
{
race = args;
ASCENT_TOLOWER(race);
// Teleport to specific race
if(race == "human")
raceid = 1;
else if(race == "orc")
raceid = 2;
else if(race == "dwarf")
raceid = 3;
else if(race == "nightelf")
raceid = 4;
else if(race == "undead")
raceid = 5;
else if(race == "tauren")
raceid = 6;
else if(race == "gnome")
raceid = 7;
else if(race == "troll")
raceid = 8;
else if(race == "bloodelf")
raceid = 10;
else if(race == "draenei")
raceid = 11;
else
{
RedSystemMessage(m_session, "Invalid start location! Valid locations are: human, dwarf, gnome, nightelf, draenei, orc, troll, tauren, undead, bloodelf");
return true;
}
}
else
{
return false;
}
// Try to find a class that works
PlayerCreateInfo *info = NULL;
for(uint32 i=1;i<11;i++)
{
info = objmgr.GetPlayerCreateInfo(raceid, i);
if(info != NULL) break;
}
if(info == NULL)
{
RedSystemMessage(m_session, "Internal error: Could not find create info.");
return false;
}
GreenSystemMessage(m_session, "Telporting %s to %s starting location.", m_plyr->GetName(), race.c_str());
m_session->GetPlayer()->SafeTeleport(info->mapId, 0, LocationVector(info->positionX, info->positionY, info->positionZ));
return true;
}
}
};
void SetupGlobe_of_Translocation(ScriptMgr * mgr)
{
mgr->register_gameobject_script(910000, &Globe_of_Translocation::Create);
}
EDIT: Oh yeah, I made the object a 10 (goober) in my database, is that what it should be?
Last edited by guitargod218; 05-28-2008 at 07:13 PM.
I suggest you read some C++ tutorials.