ArcEmu: A Lot Of If's In One Case - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

A Lot Of If's In One Case

#1 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2014 - 03:59 PM

Hey there,

my C++ book didnt tell me everything. For example I have try to work with cases, but it looks very bad....
void OnCreatureDeath(Creature* pCreature, Unit* pUnit)
	{
		switch (pCreature->GetEntry())
		{
			//Need check if killed set state 2
			case CN_LORD_MARROWGAR: //really ugly I know... maybe someone can make a suggestion
			{
				GameObject* pMarrowIceDoor1 = GetGameObjectByGuid(mMarrowIceDoor1_GUID);
				if (pMarrowIceDoor1 != NULL && pMarrowIceDoor1->GetState() != 2)
					pMarrowIceDoor1->SetState(2);

				GameObject* pMarrowIceDoor2 = GetGameObjectByGuid(mMarrowIceDoor2_GUID);
				if (pMarrowIceDoor2 != NULL && pMarrowIceDoor2->GetState() != 2)
					pMarrowIceDoor2->SetState(2);

				GameObject* pMarrowDoor = GetGameObjectByGuid(mMarrowDoor_GUID);
				if (pMarrowDoor != NULL && pMarrowDoor->GetState() != 2)
					pMarrowDoor->SetState(2);
			}break;
			case CN_LADY_DEATHWHISPER:
			case CN_VALITHRIA_DREAMWALKER:
			case CN_COLDFLAME:
			default:
				break;
		}
		return;
	}


	uint32 mMarrowIceDoor1_GUID;
	uint32 mMarrowIceDoor2_GUID;
	uint32 mMarrowDoor_GUID;


Any idea how to make the following part nice and beatutiful?
//Need check if killed set state 2
			case CN_LORD_MARROWGAR: //really ugly I know... maybe someone can make a suggestion
			{
				GameObject* pMarrowIceDoor1 = GetGameObjectByGuid(mMarrowIceDoor1_GUID);
				if (pMarrowIceDoor1 != NULL && pMarrowIceDoor1->GetState() != 2)
					pMarrowIceDoor1->SetState(2);

				GameObject* pMarrowIceDoor2 = GetGameObjectByGuid(mMarrowIceDoor2_GUID);
				if (pMarrowIceDoor2 != NULL && pMarrowIceDoor2->GetState() != 2)
					pMarrowIceDoor2->SetState(2);

				GameObject* pMarrowDoor = GetGameObjectByGuid(mMarrowDoor_GUID);
				if (pMarrowDoor != NULL && pMarrowDoor->GetState() != 2)
					pMarrowDoor->SetState(2);
			}break;


I'd appreciate an example.

Best regard
Tulba
0

#2 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 12 August 2014 - 04:57 PM

What did your book not tell you exactly?

Your if statements look just fine.
However you could just use arrays instead of typing the same thing over and over again.
Also maybe you shouldn't use "magic numbers". For example to set states. There's an enum for those...
"The demand for free goods is infinite."
0

#3 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2014 - 05:15 PM

Hey,

It looked wrong, but is working.

What are "magic numbers"? Okay you mean i have to use for example "GAMEOBJECT_STATE_ALTERNATIVE_OPEN" instead of "2". :-) I get it ;-)

To open and close an GO, it has to be in visible range? The last door is outside my visible range and i think this is the reason why it is not statet?
Any suggestion to this? I tried:
GameObject* pMarrowDoor = FindClosestGameObjectOnMap(GO_MARROWGAR_DOOR, Doors[2].x, Doors[2].y, Doors[2].z);

But its just do it, if it was loaded by the player...
0

#4 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 12 August 2014 - 05:23 PM

I don't exactly understand your problem, it must be the language barrier.
Either way, no a GO doesn't have to be in range to be changed.
"The demand for free goods is infinite."
0

#5 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2014 - 05:47 PM

maybe I'm too tired :-)

The last "if" does not seem to take effect.
When I go to the door, I can see how it just closes.
And I dont know why.

Raid_IceCrownCitadel.h
/*
 * ArcScripts for ArcEmu MMORPG Server
 * Copyright (C) 2009- 2014 ArcEmu Team <http://www.arcemu.org/>
 * Copyright (C) 2008-2009 Sun++ Team <http://www.sunscripting.com/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/////////////////ICC GOs managed by script//////////////////////

enum IceCrownCitadelGOs{
	GO_MARROWGAR_ICEWALL_1 = 201911,
	GO_MARROWGAR_ICEWALL_2 = 201910,
	GO_MARROWGAR_DOOR = 201563
};

static Location Doors[] =
{
	{ -407.35f, 2147.88f, 42.85f, 0 },	     //IceWall1
	{ -412.97f, 2285.24f, 42.01f, 0 },       //IceWall2
	{ -520.44f, 2211.47f, 63.14f, 0 },       //Door behinde ice
};


// IceCrown Teleporter
void SetupICC(ScriptMgr* mgr);


Raid_IceCrownCitadel.cpp
/*
 * ArcEmu MMORPG Server
 * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
 * Copyright (C) 2008-2014 <http://www.ArcEmu.org/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "Setup.h"
#include "Raid_IceCrownCitadel.h"

#define MAP_ICECROWNCITADEL 631
////////////////////////////////////////////////////////
//ICC zone: 4812
//Prepared creature entry:
//
#define CN_LORD_MARROWGAR           36612
#define CN_COLDFLAME                36672
#define CN_LADY_DEATHWHISPER        36855
//#define CN_DEATHBRINGER_SAURFANG    37813
//#define CN_FESTERGUT                36626
//#define CN_ROTFACE                  36627
//#define CN_PROFESSOR_PUTRICIDE      36678
//#define CN_PRINCE_VALANAR           37970
//#define CN_BLOOD_QUEEN_LANATHEL     37955
#define CN_VALITHRIA_DREAMWALKER    36789
//#define CN_SINDRAGOSA               36853
//#define CN_THE_LICHKING             36597
//
//ToDo: start boss scripts
////////////////////////////////////////////////////////
//Event: GunshipBattle
//
//Affects:
//Available teleports. If GunshipBattle done -> Teleportlocation 4 available.
//
//Devnotes:
//Far away from implementing this :(
///////////////////////////////////////////////////////


///////////////////////////////////////////////////////
//IceCrownCitadel Instance

class IceCrownCitadelScript : public MoonInstanceScript
{
public:
	MOONSCRIPT_INSTANCE_FACTORY_FUNCTION(IceCrownCitadelScript, MoonInstanceScript);

	IceCrownCitadelScript(MapMgr* pMapMgr) : MoonInstanceScript(pMapMgr) 
	{
		mMarrowIceDoor1_GUID = 0;
		mMarrowIceDoor2_GUID = 0;
		mMarrowDoor_GUID = 0;
	}
	
	void OnGameObjectPushToWorld(GameObject* pGameObject)
	{
		switch (pGameObject->GetEntry())
		{
		case GO_MARROWGAR_ICEWALL_1:    mMarrowIceDoor1_GUID = pGameObject->GetGUID(); break;
		case GO_MARROWGAR_ICEWALL_2:    mMarrowIceDoor2_GUID = pGameObject->GetGUID(); break;
		case GO_MARROWGAR_DOOR:         mMarrowDoor_GUID = pGameObject->GetGUID(); break;
		}
	}
	/*bool NPCData
	Creature.h looks good to realize teleport intrusion
	CREATURE_STATE_ALIVE = 0,			// no special death state
    CREATURE_STATE_APPEAR_DEAD = 1,		// these creatures are actually alive but appears as dead for client
    CREATURE_STATE_DEAD = 2				// these creatures are dead*/
	void OnCreatureDeath(Creature* pCreature, Unit* pUnit)
	{
		switch (pCreature->GetEntry())
		{
			//Need check if killed set state 2
			case CN_LORD_MARROWGAR:
			{
				GameObject* pMarrowIceDoor1 = FindClosestGameObjectOnMap(GO_MARROWGAR_ICEWALL_1, Doors[0].x, Doors[0].y, Doors[0].z);
				if (pMarrowIceDoor1 != NULL)
					pMarrowIceDoor1->SetState(GAMEOBJECT_STATE_OPEN);

				GameObject* pMarrowIceDoor2 = FindClosestGameObjectOnMap(GO_MARROWGAR_ICEWALL_2, Doors[1].x, Doors[1].y, Doors[1].z);
				if (pMarrowIceDoor2 != NULL)
					pMarrowIceDoor2->SetState(GAMEOBJECT_STATE_OPEN);

				GameObject* pMarrowDoor = FindClosestGameObjectOnMap(GO_MARROWGAR_DOOR, Doors[2].x, Doors[2].y, Doors[2].z);
				if (pMarrowDoor != NULL)
					pMarrowDoor->SetState(GAMEOBJECT_STATE_OPEN);

				MorrowgarIsDead = true;
			}break;
			case CN_LADY_DEATHWHISPER:
			case CN_VALITHRIA_DREAMWALKER:
			case CN_COLDFLAME:
			default:
				break;
		}
		return;
	}
public:
	bool MorrowgarIsDead;

protected:
	uint32 mMarrowIceDoor1_GUID;
	uint32 mMarrowIceDoor2_GUID;
	uint32 mMarrowDoor_GUID;

};

// IceCrown Teleporter
static float ICCTeleCoords[6][5] =
{	// Maybe moving this to a clean mysql table with all teleports in it... maybe as spell or event?
	{ 631, -17.856115f, 2211.640137f, 30.115812f, 0.0f },     //1   Teleport to Light's Hammer 
	{ 631, -503.632599f, 2211.219971f, 62.823246f, 0.0f },    //2   Teleport to Oratory of The Damned
	{ 631, -615.098267f, 2211.509766f, 199.973083f, 0.0f },   //3   Teleport to Rampart of Skulls 
	{ 631, -549.151001f, 2211.463967f, 539.290222f, 0.0f },   //4   Teleport to Deathbringer's Rise 
	{ 631, 4356.780273f, 2863.636230f, 349.337982f, 0.0f },   //5   Teleport to the Upper Spire.
	{ 631, 4453.248535f, 2769.325684f, 349.347473f, 0.0f }    //6   Teleport to Sindragosa's Lair
};

class ICCTeleporterAI : public GameObjectAIScript
{
public:

	ICCTeleporterAI(GameObject* go) : GameObjectAIScript(go){}

	~ICCTeleporterAI() {}

	static GameObjectAIScript* Create(GameObject* go) { return new ICCTeleporterAI(go); }

	void OnActivate(Player* player)
	{
		GossipMenu* menu = NULL;
		objmgr.CreateGossipMenuForPlayer(&menu, _gameobject->GetGUID(), 1/*Its not one need to be checked*/, player);

		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Light's Hammer.", 0);

		// need to be checked, if npc is death...
		// CN_LORD_MARROWGAR killed?
		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Oratory of The Damned.", 1);
		// CN_LADY_DEATHWHISPER  killed?
		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Rampart of Skulls.", 2);
		// Who has to be killed?
		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Deathbringer's Rise.", 3);
		// Who has to be killed?
		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to the Upper Spire.", 4);
		// CN_VALITHRIA_DREAMWALKER killed?
		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Sindragosa's Lair.", 5);

		menu->SendTo(player);
	}
};

class ICCTeleporterGossip : public GossipScript
{
public:
	ICCTeleporterGossip() : GossipScript(){}

	void OnSelectOption(Object* object, Player* player, uint32 Id, const char* enteredcode)
	{
		Arcemu::Gossip::Menu::Complete(player);

		if(Id >= 6) //if menuitem bigger or 6 then somethin went completly wrong...
			return;
		else
			player->SafeTeleport(ICCTeleCoords[Id][0], player->GetInstanceID(), ICCTeleCoords[Id][1], ICCTeleCoords[Id][2], ICCTeleCoords[Id][3], ICCTeleCoords[Id][4]);
	}
};

void SetupICC(ScriptMgr* mgr)
{
	//Bosses
	mgr->register_instance_script(MAP_ICECROWNCITADEL, &IceCrownCitadelScript::Create);
	//Teleporters
	mgr->register_gameobject_script(202242, &ICCTeleporterAI::Create);
	mgr->register_go_gossip_script(202242, new ICCTeleporterGossip());

	mgr->register_gameobject_script(202243, &ICCTeleporterAI::Create);
	mgr->register_go_gossip_script(202243, new ICCTeleporterGossip());

	mgr->register_gameobject_script(202244, &ICCTeleporterAI::Create);
	mgr->register_go_gossip_script(202244, new ICCTeleporterGossip());

	mgr->register_gameobject_script(202245, &ICCTeleporterAI::Create);
	mgr->register_go_gossip_script(202245, new ICCTeleporterGossip());

	mgr->register_gameobject_script(202246, &ICCTeleporterAI::Create);
	mgr->register_go_gossip_script(202246, new ICCTeleporterGossip());
};

0

#6 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 12 August 2014 - 06:02 PM

Maybe it's a wrong GO or it just works different.
If you are right next to it and set it open then it shows open in the game too?
"The demand for free goods is infinite."
0

#7 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2014 - 06:10 PM

Quote

Maybe it's a wrong GO or it just works different.
If you are right next to it and set it open then it shows open in the game too?


Yes, so I thought, that it could be due to the player visibility.

I have merged all GO commits from your branch (thats the reason, why my PR is so big)... perhaps this could be the reason? (But it could not be... the other doors works fine).
0

#8 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 12 August 2014 - 06:40 PM

View PostTulba, on 12 August 2014 - 06:10 PM, said:

Yes, so I thought, that it could be due to the player visibility.

I have merged all GO commits from your branch (thats the reason, why my PR is so big)... perhaps this could be the reason? (But it could not be... the other doors works fine).

Why on Earth would you merge that branch?!
It wasn't merged into the main branch because it was not done FFS...
You shouldn't be touching things that you don't understand...
"The demand for free goods is infinite."
0

#9 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2014 - 06:53 PM

View Postdfighter, on 12 August 2014 - 06:40 PM, said:

Why on Earth would you merge that branch?!
It wasn't merged into the main branch because it was not done FFS...
You shouldn't be touching things that you don't understand...


not yet ready... for four years ... touching things that you don't understand <- no comment!
It is an open issue in Milestone 3 and every merge conflict was commented. But thats not the point of this thread!
0

#10 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 12 August 2014 - 07:01 PM

View PostTulba, on 12 August 2014 - 06:53 PM, said:

not yet ready... for four years ... touching things that you don't understand <- no comment!
It is an open issue in Milestone 3 and every merge conflict was commented. But thats not the point of this thread!

It may not be the point of the thread, but you did something very very stupid. ( not to mention that instead of using the git merge command you merged by hand )
Merge conflicts aren't supposed to be commented, they are supposed to be RESOLVED.
So what if it's been there for four years?
I don't even see how time has anything to do with this... The passage of time alone doesn't affect the completeness of some code.

As for not touching something you don't understand. Why don't you comment it?
Arcemu is a quite complex software, you can't make ANY changes without understanding the consequences.
Especially such HUGE ones, especially when you are just learning C++ :D
"The demand for free goods is infinite."
0

#11 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2014 - 07:14 PM

What is your problem? Besides the fact that you already do not have time to do something.

Quote

Merge conflicts aren't supposed to be commented, they are supposed to be RESOLVED.

Then do it... I thought its not finished yet, and no one on earth know what you have done.

It's my problem and not yours!

In my script, nothing is wrong? Have you tested it? I think not.

And I repeat, this has nothing to do with the topic! :D :D
0

#12 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 12 August 2014 - 07:35 PM

View PostTulba, on 12 August 2014 - 07:14 PM, said:

What is your problem? Besides the fact that you already do not have time to do something.

Then do it... I thought its not finished yet, and no one on earth know what you have done.

It's my problem and not yours!

In my script, nothing is wrong? Have you tested it? I think not.

And I repeat, this has nothing to do with the topic! :D :D

It's my problem too if you open up pull requests which contain merged code...

Also I don't have to test each and every code snippet to be able to tell if they are OK or not...
Lots of code you can just "run" in your head...
"The demand for free goods is infinite."
0

#13 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 13 August 2014 - 02:32 PM

View Postdfighter, on 12 August 2014 - 07:35 PM, said:

It's my problem too if you open up pull requests which contain merged code...

Also I don't have to test each and every code snippet to be able to tell if they are OK or not...
Lots of code you can just "run" in your head...


I can't say anything more to this discussion.
The problem with the last door is a fact, and if you don't have time to check it it's meaningless to talk about.

I wish you a good night, I have to go to bed...

So, back to Topic.

I have these cases: in my class:
class IceCrownCitadelScript : public MoonInstanceScript
{
friend class ICCTeleporterAI; // Friendship forever ;-)
...
void OnCreatureDeath(Creature* pCreature, Unit* pUnit)
	{
		switch (pCreature->GetEntry())
		{
			//Need check if killed set state 2
			case CN_LORD_MARROWGAR:
			{
				GameObject* pMarrowIceDoor1 = FindClosestGameObjectOnMap(GO_MARROWGAR_ICEWALL_1, Doors[0].x, Doors[0].y, Doors[0].z);
				if (pMarrowIceDoor1 != NULL)
					pMarrowIceDoor1->SetState(GAMEOBJECT_STATE_OPEN);

				GameObject* pMarrowIceDoor2 = FindClosestGameObjectOnMap(GO_MARROWGAR_ICEWALL_2, Doors[1].x, Doors[1].y, Doors[1].z);
				if (pMarrowIceDoor2 != NULL)
					pMarrowIceDoor2->SetState(GAMEOBJECT_STATE_OPEN);

				GameObject* pMarrowDoor = FindClosestGameObjectOnMap(GO_MARROWGAR_DOOR, Doors[2].x, Doors[2].y, Doors[2].z);
				if (pMarrowDoor != NULL)
					pMarrowDoor->SetState(GAMEOBJECT_STATE_OPEN);

				SetInstanceData(Data_EncounterState, CN_LORD_MARROWGAR, State_Finished);

			}break;

			case CN_LADY_DEATHWHISPER:
				SetInstanceData(Data_EncounterState, CN_LADY_DEATHWHISPER, State_Finished);
				break;

			case CN_VALITHRIA_DREAMWALKER:
				SetInstanceData(Data_EncounterState, CN_VALITHRIA_DREAMWALKER, State_Finished);
				break;

			case CN_COLDFLAME:
				SetInstanceData(Data_EncounterState, CN_COLDFLAME, State_Finished);
				break;

			default:
				break;
		}
		return;
	}


Now I want to check in the Teleporter, if the npc is death (EncounterState = State_Finished)
class ICCTeleporterAI : public GameObjectAIScript
void OnActivate(Player* player)
	{
		GossipMenu* menu = NULL;
		objmgr.CreateGossipMenuForPlayer(&menu, _gameobject->GetGUID(), 1/*Its not one need to be checked*/, player);
		menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Light's Hammer.", 0);

		//Check if boss is dead, then add the menu item
		//if(GetInstanceData(mMarrowgarGUID) = State_Finished)
			menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Oratory of The Damned.", 1);

		//if(GetInstanceData(mDeathwhisperGUID) = State_Finished)
			menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Rampart of Skulls.", 2);

		// GunshipBattle has to be finished...
		//menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Deathbringer's Rise.", 3);

		//if(GetInstanceData(mDreamwalkerGUID) = State_Finished)
			menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to the Upper Spire.", 4);

		//if(GetInstanceData(mColdflameGUID) = State_Finished)
			menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to Sindragosa's Lair.", 5);

		menu->SendTo(player);
	}


Any suggestion for the "if" before printing the menu item?
maybe I've misinterpreted "SetInstanceData"
0

#14 User is offline   lexythelord 

  • Member
  • Pip
  • Group: Members
  • Posts: 40
  • Joined: 23-December 10
  • Gender:Male

Posted 13 August 2014 - 02:36 PM

What about putting the if before printing the menu items?
0

#15 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 13 August 2014 - 02:41 PM

All I can suggest is what I've already suggested.
Use arrays.
"The demand for free goods is infinite."
0

#16 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 13 August 2014 - 02:59 PM

View Postdfighter, on 13 August 2014 - 02:41 PM, said:

All I can suggest is what I've already suggested.
Use arrays.


More I did not expect from you.
thanks anyway
0

#17 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 13 August 2014 - 03:12 PM

View PostTulba, on 13 August 2014 - 02:59 PM, said:

More I did not expect from you.
thanks anyway

Don't be so sour.
What kind of suggestions would you be happy with?
"The demand for free goods is infinite."
0

#18 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 13 August 2014 - 03:19 PM

View Postlexythelord, on 13 August 2014 - 02:36 PM, said:

What about putting the if before printing the menu items?


//if(GetInstanceData(mDreamwalkerGUID) = State_Finished)
                        menu->AddItem(Arcemu::Gossip::ICON_CHAT, "Teleport to the Upper Spire.", 4);


I try it (sorry its commented...)
GetInstanceData is not a member of class ICCTeleportAI

Here the code from Instance_Base.h
// Data get / set - idea taken from ScriptDev2
		virtual void				SetInstanceData(uint32 pType, uint32 pIndex, uint32 pData);
		virtual uint32				GetInstanceData(uint32 pType, uint32 pIndex);


And from Instance_Base.cpp
uint32 MoonInstanceScript::GetInstanceData(uint32 pType, uint32 pIndex)
{
	return 0;
};


Thats why I asked, if i missinterpreted this...

View Postdfighter, on 13 August 2014 - 03:12 PM, said:

Don't be so sour.
What kind of suggestions would you be happy with?


I'm sorry. It takes a lot of time to get a helpful answer with a short example.

A short example like:

took this in code in the IceCrownCitadelScript, and this in the teleporter.
Short and easy not for everything, just one case and one menu item. And I will be the luckiest person on earth ;-)
0

#19 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 13 August 2014 - 03:24 PM

View PostTulba, on 13 August 2014 - 03:19 PM, said:

Thats why I asked, if i missinterpreted this...

Based on that code snippet, the method takes two arguments and you are arbitrarily passing it a GUID as a signgle argument.
So no wonder it doesn't work.

View PostTulba, on 13 August 2014 - 03:19 PM, said:

I'm sorry. It takes a lot of time to get a helpful answer with a short example.

A short example like:

took this in code in the IceCrownCitadelScript, and this in the teleporter.
Short and easy not for everything, just one case and one menu item. And I will be the luckiest person on earth ;-)

Sorry, but I don't understand what you are trying to tell me. ( English )
"The demand for free goods is infinite."
0

#20 User is offline   Tulba 

  • Member
  • Pip
  • Group: Members
  • Posts: 29
  • Joined: 21-November 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 13 August 2014 - 03:42 PM

Quote

What kind of suggestions would you be happy with?


A suggestion with examples like:

Quote

Put this in your class:
code suggestion


Put this in the case:
code suggestion


And at least, this to the menu:

code suggestion


0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users