• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore WotLK Creating a door that can open and close by code

Hello y'all! Just as the title says, I'm trying to open a door by code. The gate is already added to template and I can spawn it correctly. The problem is that I want to open it after a dialog is done. With the SetGoState I can change it to closed or opened on spawn, but I can't animate it. Don't know the syntax :smile:
This is all I've written so long.

Code:
local CellGate = 5000006 -- ID

function OnSpawnGate(event, go)
	go:SetGoState(1)
end


RegisterGameObjectEvent(CellGate, 2, OnSpawnGate)
 

Tommy

Founder
Did you read the description for each GOState type? Look at: :SetGoState(gostate). You're using GO_STATE_READY = 1 and it only shows as ready which means the door is closed. You should use GO_STATE_ACTIVE = 0 instead.

So:

Code:
local CellGate = 5000006 -- ID

function OnSpawnGate(event, go)
	go:SetGoState([COLOR="#00FF00"]0[/COLOR])
end


RegisterGameObjectEvent(CellGate, 2, OnSpawnGate)
 
I should be closed by default because I want to open it later on so you can walk out.

This is the gate that will be closed at start and then open up like you said (go:SetGoState(0)) I just cant get it to move up...

Capture.jpg
 

Tommy

Founder
I should be closed by default because I want to open it later on so you can walk out.

Perhaps you should spawn the door (as an actual world gameobject) and put the door open code in the dialog script (if there is one), and when the dialog finishes, get the guid of the gameobject and open it. That's mainly how doors work in Wow regardless (the advice I gave).

I just cant get it to move up...

View attachment 563

Looks like the door is up to me. A still screenshot won't help the situation. :p
 
Yeah I know, just wanted you to understand the situation ^^'

How do you mean "spawn the door (as an actual world gameobject)"? I've already spawned it?

I get i to work animate by altering my code. The problem is now that I have to be GM and click on it, I still can't activate it remotely...

How it looks now https://i.gyazo.com/aec6c800ac037cb567a69a2a2f51e769.gif

I got the code from here. http://emudevs.com/showthread.php/5441-Unlock-door-s-for-guild-member-s?highlight=door

Code:
function handleLockedGuildDoor(event, player, go ,quest) 
    if([COLOR="#00FF00"]isGM() == true[/COLOR]) then
        go:SetGoState(0) 

RegisterGameObjectEvent(Object.CellGate, 4, handleLockedGuildDoor)



I also tried checking for a quest I had a quest on me, cause I could easly add a quest after a dialog. But it didn't work either...

Code:
--GAMEOBJECT_EVENT_ON_QUEST_ACCEPT = 4, // (event, player, go, quest)

function QuestAdd(event, player, creature, quest)
   if (quest:GetId() == 27002) then
   go:SetGoState(0) 

RegisterGameObjectEvent(Object.CellGate, 4, QuestAdd)
 

Tommy

Founder
How do you mean "spawn the door (as an actual world gameobject)"? I've already spawned it?

I think I saw stuff wrong. Seemed as if you spawned the door after the dialog ended, just misunderstood at the time. I'm not awesome when I first get on the PC.

If I could test and explain I would, but I don't have an active source at the moment. Perhaps Rochet2 or someone who can test in-game can help further. Being blind sucks.
 

slp13at420

Mad Scientist
n hey side note . gm mode can cause nightmares in stuff like when you have gm on and a gameObject is supposed to despawn but its visually still there . switch to player mode and poof its gone lol it gave me many !!WTF!! moments rofl I do all my testing with just a player char unless it gm related the yea gm tag on/off testing .
 
I made up my mind now. I want it to open when I receive a quest. Which I will add with Player:AddQuest( entry )
 
Last edited:

Foereaper

Founder
I made up my mind now. I want it to open when I receive a quest. Which I will add with Player:AddQuest( entry )

So OnQuestAccept, trigger the gate to open from a closed position, and then re-close it after a set amount of time? Considering the objectr cannot open for a specific player only, it would make sense to close it again after some time yeah? Or is this in an instance?

Edit:

Untested example, but should work:

http://pastebin.com/jNgByxQq
 

slp13at420

Mad Scientist
what about phasing..? erm k within a couple months ago some one posted a video where a player could open a gate (while it appeared to the other players as closed and they could not pass, it would appear open to the player who opened it and the could pass).
I don't remember who it was but it was here ...
 

Foereaper

Founder
what about phasing..? erm k within a couple months ago some one posted a video where a player could open a gate (while it appeared to the other players as closed and they could not pass, it would appear open to the player who opened it and the could pass).
I don't remember who it was but it was here ...

Have fun dealing with phase swapping :D
 

slp13at420

Mad Scientist
lol I never played with it but if I remember it had a check for then allows the player to open and go thru while the other players see it closed while the player runs thru it.
imo it would be the right way to handle it so another player cant just run in behind the allowed player or exploit it I guess .
 
Last edited:

Foereaper

Founder
lol I never played with it but if I remember it had a check for then allows the player to open and go thru while the other players see it closed while the player runs thru it.
imo it would be the right way to handle it so another player cant just run in behind the allowed player or exploit it I guess .

Easy, on spawn event on the gate, check nearby players by 0.5 yards, if they do not have the quest, teleport them back outside ;)
 
Top