This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] Opening/Closing door system  (Read 3363 times)

Zorak

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 9
    • View Profile
[QUESTION] Opening/Closing door system
« on: September 07, 2013, 01:01:48 pm »
Hi there,

I would like to ask, if someone has some experience with creating door system. I saw (on another server) doors, which were able to just open on one click, and on second click close itself, no matter who clicked on them (one player opens it, another closes).

I tried to go through the code, but even if I am able to understand the code in general, I am not able edit it.
Now, there is a timer, which closes the door in time (which is load from object's record in DB).
After the timer comes to zero, it resets the door (closes).

Maybe, I would be able to edit it myself, but I cannot find any click function.

now it is something like

case GO_activated (but it says only IS activated, not HOW)
> if door with the right activate state
>set timer
>reset door

but I need something like

if activated
onclick deactivate
if deactivated
onclick activated



So, is here somebody, who is willing to help me?

I am uploading the source file now. If you go CTRL+F "door" (od "DOOR" if your editor need exact letter), you will find any functions attacched to this problem.



Thanks a lot :)

[attachment=0:1s0flh33]GameObject.cpp[/attachment:1s0flh33]
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] Opening/Closing door system
« Reply #1 on: September 07, 2013, 01:39:38 pm »
Generally the gameobjects that are flagged to open and close on click are client side. So other players won't see the change when you open the door.

What you could do is listen for the event firing on gameobject activate, then see if what the current gameobject bytes are set to. If bytes are set to open, close the object, else open.

*shrug* On which gameobject type the event fires and whether it produces the desirable effects will require testing.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [QUESTION] Opening/Closing door system
« Reply #2 on: September 07, 2013, 01:51:53 pm »
Orientate around the instancescripts regarding doors, maybe it helps.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION] Opening/Closing door system
« Reply #3 on: September 07, 2013, 06:08:46 pm »
Shadow labyrinth door is not character specific iirc.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

iindigo

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 198
    • View Profile
Re: [QUESTION] Opening/Closing door system
« Reply #4 on: September 08, 2013, 06:02:23 am »
Quote from: "schlumpf"
Shadow labyrinth door is not character specific iirc.
Neither is the door in front of the PvP place in Stormwind’s Old Town. During the zombie invasion, zombies were the only one that could click on it, so when they closed the door they locked everybody who wasn’t a zombie out. It made for a lot of angry players who couldn’t get in to buy their BG and arena gear.

EDIT: wouldn’t BG gates also qualify as non-character-specifc doors?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

fearless_wind

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 349
    • View Profile
    • http://modcraft-rus.ucoz.ru
Re: [QUESTION] Opening/Closing door system
« Reply #5 on: September 08, 2013, 07:05:36 pm »
I saw these doors on Mythia server. They really work. Both players see it. So, ask Filipsons how to do it.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Daweo

  • Registred Member
  • Race Changer
  • *****
  • Posts: 39
    • View Profile
Re: [QUESTION] Opening/Closing door system
« Reply #6 on: September 24, 2013, 08:09:10 am »
Hi guys!
It really works. I have this system on my server quite long time, but I didnt want to share.
Nowadays, many servers have this system, so I will share.
Its really easy.

I was inspired by .gob activate command...
This work only for unlocked door. Locked door can be opened, but not closed. I didnt have time to rework it and find solution.
Status of door is reseted by server restart.

Code: [Select]
#include "ScriptPCH.h"
#include "ScriptMgr.h"
#include "GameObject.h"

class door_script : public GameObjectScript
{
    public:

        door_script()
            : GameObjectScript("door_script")
{
}
bool OnGossipHello(Player* player, GameObject* go)
{
if (go->GetGoState() == GO_STATE_READY) //if closed -> open
{
go->SetGoState(GO_STATE_ACTIVE);
}
else //if open -> close
{
go->SetGoState(GO_STATE_READY);
}
return true;
}
};

void AddSC_door_script()
{
    new door_script();
}
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Zorak

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 9
    • View Profile
Re: [QUESTION] Opening/Closing door system
« Reply #7 on: October 01, 2013, 06:54:32 pm »
hi there, thanks a lot, I will try :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »