ArcEmu: A Door - 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
  • This topic is locked

A Door Can I pull it off?

#21 User is offline   Ceres 

  • Member
  • Pip
  • Group: Members
  • Posts: 44
  • Joined: 26-May 10
  • Gender:Male

Posted 29 December 2010 - 06:07 AM

(not that it worked or anything. Gonna ask him to re-script with a invisible NPC that will open it. *sigh*)
Posted Image
0

#22 User is offline   jackpoz 

  • ArcEmu Lemon Priest
  • PipPipPipPipPipPipPipPip
  • Group: Developers
  • Posts: 2,153
  • Joined: 19-June 08
  • Gender:Male
  • Location:Italy
  • Server OS:Windows

Posted 29 December 2010 - 07:57 AM

View PostSaintJamesApostle, on 28 December 2010 - 04:07 AM, said:

The pink teleporters in the DK starting zone check each second if there's a player near and if so, teleport him. The script is on the ArcEmu svn.

http://sourceforge.n...GameObjects.cpp
class DeathGate1 : public GameObjectAIScript
{
public:
DeathGate1(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject* GO) { return new DeathGate1(GO); }

void OnSpawn()
{
  RegisterAIUpdateEvent( 500 );
}

void AIUpdate()
{
  Player* plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords( _gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ() );
  if( !plr )
   return;

  if( _gameobject->CalcDistance( _gameobject, plr ) <= 1.5f && plr->GetMapId() == 609)
  {
   plr->SafeTeleport( 609, 4298, 2390.18f, -5640.28f, 420.84f, 0.57f );
  }

  else if( _gameobject->CalcDistance( _gameobject, plr ) <= 1.5f && plr->GetMapId() == 0)
  {
   plr->SafeTeleport( 0, plr->GetInstanceID(), 2387.468994f, -5642.544922f, 420.809937f, 0.620461f);
  }
}
};

copypasting this example and modifying it a little bit (the open/close part is from ChatHandler::HandleGOActivate() )

Index: src/scripts/src/MiscScripts/GameObjects.cpp
===================================================================
--- src/scripts/src/MiscScripts/GameObjects.cpp (revision 4007)
+++ src/scripts/src/MiscScripts/GameObjects.cpp (working copy)
@@ -1168,6 +1168,55 @@
  }
};

+class GmIslandDoor : public GameObjectAIScript
+{
+public:
+ GmIslandDoor(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
+ static GameObjectAIScript *Create(GameObject* GO) { return new GmIslandDoor(GO); }
+
+ void OnSpawn()
+ {
+  //check every 500 ms if we have to open/close the door
+  RegisterAIUpdateEvent( 500 );
+  //don't let players click on it
+  _gameobject->SetFlag( GAMEOBJECT_FLAGS, GAMEOBJECT_UNCLICKABLE ); 
+ }
+
+ void AIUpdate()
+ {
+  bool activated = false;
+  std::set<Object*>::iterator begin = _gameobject->GetInRangePlayerSetBegin();
+  std::set<Object*>::iterator end = _gameobject->GetInRangePlayerSetEnd();
+  std::set<Object*>::iterator itr;
+
+  //check the players in range of the door
+  for( itr = begin; itr != end ; ++itr)
+  {
+   //activate if there's a GM near enough
+   Player* plr = TO< Player* >( *itr );
+   if( plr->GetSession()->HasGMPermissions() && _gameobject->CalcDistance( _gameobject, plr ) <= 5.0f )
+   {
+    // Open/Activate if it was closed
+    if(_gameobject->GetByte(GAMEOBJECT_BYTES_1, 0) == 1)
+    {
+ 	_gameobject->SetByte(GAMEOBJECT_BYTES_1, 0, 0);
+ 	_gameobject->SetUInt32Value(GAMEOBJECT_FLAGS, (_gameobject->GetUInt32Value(GAMEOBJECT_FLAGS) & ~1));
+    }
+    activated = true;
+    break;
+   }
+  }
+
+  //the GM went out of range, close the door (unless it was already closed)
+  if(!activated && _gameobject->GetByte(GAMEOBJECT_BYTES_1, 0) == 0)
+  {
+   // Close/Deactivate
+   _gameobject->SetByte(GAMEOBJECT_BYTES_1, 0, 1);
+   _gameobject->SetUInt32Value(GAMEOBJECT_FLAGS, (_gameobject->GetUInt32Value(GAMEOBJECT_FLAGS) | 1));
+  }
+ }
+};
+
void SetupGoHandlers(ScriptMgr * mgr)
{
  mgr->register_gameobject_script(179879, &OrbOfCommand::Create);
@@ -1217,4 +1266,6 @@
  mgr->register_gameobject_script( 310033, &AndorhalTower4::Create );

  mgr->register_gameobject_script( 184588, &TyraliusPrison::Create );
+
+ mgr->register_gameobject_script( 201760, &GmIslandDoor::Create );
}

Spend your time learning C++ instead of smashing your head with Lua :unsure:
Tested with GameObject 201760 , works fine :(

Attached File(s)


Posted Image We develop dreams. Your dreams ;)
Posted ImagePosted Image
1

#23 User is offline   iEzri 

  • < Ace of spades >
  • Group: Contributor
  • Posts: 1,692
  • Joined: 22-December 08
  • Gender:Female
  • Interests:I'm likely to cause mischief
  • Server OS:Linux

Posted 29 December 2010 - 08:54 AM

meh, braggart :unsure:
Posted Image I do not join. I lead.
0

#24 User is offline   Ceres 

  • Member
  • Pip
  • Group: Members
  • Posts: 44
  • Joined: 26-May 10
  • Gender:Male

Posted 30 December 2010 - 11:57 AM

I am learning C++. just not as fast I'd want.
Posted Image
0

#25 User is offline   jackpoz 

  • ArcEmu Lemon Priest
  • PipPipPipPipPipPipPipPip
  • Group: Developers
  • Posts: 2,153
  • Joined: 19-June 08
  • Gender:Male
  • Location:Italy
  • Server OS:Windows

Posted 30 December 2010 - 02:01 PM

View PostCeres, on 30 December 2010 - 11:57 AM, said:

I am learning C++. just not as fast I'd want.

you'd like to learn it in a day? :P
Posted Image We develop dreams. Your dreams ;)
Posted ImagePosted Image
0

#26 User is offline   iEzri 

  • < Ace of spades >
  • Group: Contributor
  • Posts: 1,692
  • Joined: 22-December 08
  • Gender:Female
  • Interests:I'm likely to cause mischief
  • Server OS:Linux

Posted 30 December 2010 - 02:24 PM

View PostSaintJamesApostle, on 30 December 2010 - 02:01 PM, said:

you'd like to learn it in a day? :P


sure, if its easy :) you teach? :lol:
Posted Image I do not join. I lead.
0

#27 User is offline   jackpoz 

  • ArcEmu Lemon Priest
  • PipPipPipPipPipPipPipPip
  • Group: Developers
  • Posts: 2,153
  • Joined: 19-June 08
  • Gender:Male
  • Location:Italy
  • Server OS:Windows

Posted 30 December 2010 - 02:33 PM

View PostiEzri, on 30 December 2010 - 02:24 PM, said:

you teach? :P

to teach I should first learn it :lol:
Posted Image We develop dreams. Your dreams ;)
Posted ImagePosted Image
0

#28 User is offline   salamanda 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 161
  • Joined: 10-July 08

Posted 31 December 2010 - 05:49 AM

Does it matter if you include the == true or not? I don't think so, it just looks better on the eye without the constant checks. I always include the checks in any language simply because it's easier for me personally to keep track of events, instead of having to notice the ! I put before it etc.

I would of done this script by this (note: having it constantly check is not the most effective way I'm sure, but neither is Lua so):


local npcid = 0
local objectID = 0

function Invis_Npc_handles_object(pUnit, Event)
	pUnit:RegisterEvent("Check_For_GM_oh_dear", 2000, 0)
end

function Check_For_GM_oh_dear(pUnit)
	local plr = pUnit:GetClosestPlayer() -- A player may prevent this
	if plr ~= nil then
		local door = pUnit:GetGameObjectNearestCoords(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), objectID)
		if plr:IsGM() then
			if door ~= nil then
				door:SetByte(0x0006+0x000B,0,0) -- Open
			end
		else
			if door ~= nil then
				door:SetByte(0x0006+0x000B,0,1) -- Close
			end
		end
	end
end

RegisterUnitEvent(npcid, 18, "Invis_Npc_handles_object")

function Door_OnSpawn(pMisc, Event)
	pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Makes it unclickable
end

RegisterGameObjectEvent(objectID, 2, "Door_OnSpawn")


I know this works as of 3.3.5 because I used it when prototyping some concepts. I have no idea what the flags are that I used, I didn't give them the names so it will be hard to update to newer/older patches. :P

edit: I hope people are playing dumb on the previous page because it's pretty obvious with whatever language is being used what was going wrong. Look at the parameters, the way it was hooked and then what was being processed. :/
0

#29 User is offline   jackpoz 

  • ArcEmu Lemon Priest
  • PipPipPipPipPipPipPipPip
  • Group: Developers
  • Posts: 2,153
  • Joined: 19-June 08
  • Gender:Male
  • Location:Italy
  • Server OS:Windows

Posted 31 December 2010 - 06:26 AM

Your script checks only the closest player, so if there's a non-gm player near the door, it will never open
Posted Image We develop dreams. Your dreams ;)
Posted ImagePosted Image
0

#30 User is offline   salamanda 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 161
  • Joined: 10-July 08

Posted 31 December 2010 - 06:43 AM

View PostSaintJamesApostle, on 31 December 2010 - 06:26 AM, said:

Your script checks only the closest player, so if there's a non-gm player near the door, it will never open


Aye which is why I commented it.

A more effective way would be to hook the gameobject on click, but last time I tested it will always open upon interaction and there is no way of preventing that. :/ Spamming close once it opens bugs out as well.

You could get all nearby players, check whether there within X range and then open if one is a GM. Would be a simple addition.

The idea for the script is rubbish anyway, simply because there are thousands of ways to get past objects, or a player could run in as a GM goes in etc. But yeah, actually doing it there is no easy solution.
0

#31 User is offline   Ceres 

  • Member
  • Pip
  • Group: Members
  • Posts: 44
  • Joined: 26-May 10
  • Gender:Male

Posted 02 January 2011 - 06:17 AM

Well, thx. The C++ script works like a charm and I have not tested the Lua one, but it seems fine too. Anyway, Since the script is right there and all you have to edit is the GO ID to make it more custom, I think you should use it ^^.
Thx James.
Posted Image
0

#32 User is offline   iEzri 

  • < Ace of spades >
  • Group: Contributor
  • Posts: 1,692
  • Joined: 22-December 08
  • Gender:Female
  • Interests:I'm likely to cause mischief
  • Server OS:Linux

Posted 02 January 2011 - 07:35 AM

Posted Image
Posted Image I do not join. I lead.
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

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