ArcEmu: Lua Functions For Vehicles - 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

Labels

Make sure when posting a help or release topic you put [c++] or [lua] BEFORE your topic title!
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Lua Functions For Vehicles so far...

#1 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 18 September 2011 - 06:44 PM

Hi there!
Since vehicles are pretty much done now on my branch ( still there are some small details and some refactoring to be done ), I've started to add scripting support for them.
This of course includes Lua scripting support, which manifested itself in some new Unit functions and some hooks!
So here are they:

Unit functions

AddVehiclePassenger( creature_entry );

description

Spawns and adds a new NPC passenger to the vehicle.

parameter(s)
creature_entry - The entry id of the NPC.

return value(s)
None


DismissVehicle();

description
Dismisses the current vehicle of the Unit.

parameter(s)
None

return value(s)
None

EjectAllVehiclePassengers();

description
Ejects all the passengers from the vehicle ( in case of a vehicle mount, the player doesn't count )

parameter(s)
None

return value(s)
None


EjectVehiclePassengerFromSeat( seat );

description
Ejects the passenger from the specified seat.

parameter(s)
seat - Seat id

return value(s)
None


MoveVehiclePassengerToSeat( unit, seat );

description
Moves a passenger to another seat.

parameter(s)
unit - A passenger of the vehicle
seat - the seat where we want to move the passenger

return value(s)
None


EnterVehicle( guid, delay );

description
Makes the Unit enter a vehicle after a delay

parameter(s)
guid - guid of the vehicle to enter
delay - delay before entering in milliseconds

return value(s)
None



ExitVehicle();

description
Makes the Unit exit the vehicle it's currently on

parameter(s)
None

return value(s)
None



GetVehicleBase();

description
Returns the vehicle unit the unit is currently on.

parameter(s)
None

return value(s)
Returns a Unit on success.
Returns NIL on failure.



IsOnVehicle();

description

Tells if the Unit is on a vehicle.

parameter(s)
None

return value(s)
Returns true on success.
Returns false on failure.



HasEmptyVehicleSeat();

description

Tells if the vehicle has empty seats.

parameter(s)
None

return value(s)
Returns true if the vehicle has empty seats.
Returns false otherwise.


SpawnAndEnterVehicle( creature_entry, delay );

description

Spawns a new vehicle creature, and makes the Unit enter it after a delay.

parameter(s)
creature_entry - the creature entry of the vehicle to spawn.
delay - the delay in milliseconds after the Unit will enter the vehicle.


return value(s)
None



Unit event hooks
You can use these by using the RegisterUnitEvent call.

Passenger hooks:

CREATURE_EVENT_ON_ENTER_VEHICLE = 24

function SWGuard_OnEnterVehicle( unit )
	unit:SendChatMessage( 12, 0, "Naice! I'm on a vehicle now!" );
end

RegisterUnitEvent( 68, 24, "SWGuard_OnEnterVehicle" );


CREATURE_EVENT_ON_EXIT_VEHICLE = 25
example:
function SWGuard_OnExitVehicle( unit )
	unit:SendChatMessage( 12, 0, "Aw I got booted :P" );
end

RegisterUnitEvent( 68, 25, "SWGuard_OnExitVehicle" );


Vehicle hooks:

CREATURE_EVENT_ON_FIRST_PASSENGER_ENTERED = 26
example:
function Horsey_OnFirstPassengerEntered( vehicle, passenger )
	vehicle:SendChatMessage( 12, 0, "Finally someone!" );
end

RegisterUnitEvent( 28605, 26, "Horsey_OnFirstPassengerEntered" );



CREATURE_EVENT_ON_VEHICLE_FULL = 27
example:
function Horsey_OnVehicleFull( vehicle )
	vehicle:SendChatMessage( 12, 0, "Now I feel full :S" );
end

RegisterUnitEvent( 28605, 27, "Horsey_OnVehicleFull" );


CREATURE_EVENT_ON_LAST_PASSENGER_LEFT = 28
example:
function Horsey_OnLastPassengerLeft( vehicle, passenger )
	vehicle:SendChatMessage( 12, 0, "So ronery..." );
end

RegisterUnitEvent( 28605, 28, "Horsey_OnLastPassengerLeft" );




full code samples I used to develop/test:
http://pastebin.com/VNnWb53Q
http://pastebin.com/qEN8gJNM


NOTE: I will delete this thread once all this gets into the Trunk, and move the information here to the wiki!

Feedback is most welcome, especially suggestions for more functions!
"The demand for free goods is infinite."
0

#2 User is offline   salamanda 

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

Posted 19 September 2011 - 01:29 AM

SpawnAndEnterVehicle( creature_entry, delay );
^
What is the delay for? Is this the animation in which the unit jumps into the seat? :P
0

#3 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 19 September 2011 - 10:00 AM

View Postsalamanda, on 19 September 2011 - 01:29 AM, said:

SpawnAndEnterVehicle( creature_entry, delay );
^
What is the delay for? Is this the animation in which the unit jumps into the seat? :P

No it's literally a delay. It won't even start moving onto the vehicle before delay milliseconds.
It's necessary because the client needs to be aware of the vehicle before you can move anything onto it.
However you can also use it to execute some event before the unit jumps on the vehicle, or whatever, that's why I left it as a parameter and it's not hardcoded ^^
"The demand for free goods is infinite."
0

#4 User is offline   salamanda 

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

Posted 19 September 2011 - 11:25 AM

Ah, nice. :P Very handy. However, you say that the client requires time to load it, if that is the case then maybe you should make it clear when you update this onto the wiki otherwise people will put 0 or 1.
0

#5 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 19 September 2011 - 11:28 AM

View Postsalamanda, on 19 September 2011 - 11:25 AM, said:

Ah, nice. :P Very handy. However, you say that the client requires time to load it, if that is the case then maybe you should make it clear when you update this onto the wiki otherwise people will put 0 or 1.

It's not about loading. It just needs to see the vehicle "spawning", since otherwise the GUID of the vehicle is invalid. Not to mention it cannot place the unit on the vehicle without knowing where to place it.
Also it doesn't let you specify 0, if you specify below 1000 it will override it to 1000.
"The demand for free goods is infinite."
0

#6 User is offline   salamanda 

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

Posted 19 September 2011 - 11:40 AM

Oh, right...

Good work! :P
0

#7 User is offline   Zandron 

  • Newbie
  • Group: Members
  • Posts: 2
  • Joined: 29-May 12
  • Gender:Male
  • Location:Philippines
  • Server OS:Windows

Posted 05 June 2012 - 08:21 AM

How do you spawn a vehicle in given coordinates and force a player to enter it?
0

#8 User is offline   Satanail 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 11-March 12
  • Gender:Male
  • Location:Absurdistan
  • Server OS:Windows

Posted 05 June 2012 - 03:51 PM

View PostZandron, on 05 June 2012 - 08:21 AM, said:

How do you spawn a vehicle in given coordinates and force a player to enter it?

Well, this works with spells. Here is one, used for argent tournament mount spawn: http://old.wowhead.com/spell=62787
0

#9 User is offline   Zandron 

  • Newbie
  • Group: Members
  • Posts: 2
  • Joined: 29-May 12
  • Gender:Male
  • Location:Philippines
  • Server OS:Windows

Posted 06 June 2012 - 12:39 AM

View PostSatanail, on 05 June 2012 - 03:51 PM, said:

Well, this works with spells. Here is one, used for argent tournament mount spawn: http://old.wowhead.com/spell=62787


Oh, right thanks.
0

#10 User is offline   sanctum32 

  • Occasional Poster
  • PipPip
  • Group: Members
  • Posts: 118
  • Joined: 28-November 10
  • Gender:Male

Posted 16 June 2012 - 02:02 AM

how to make, that vehicles will take all comming agroo, dmg and similar to self from passenger?
best example is ulduar vehicles, when player enters in vehicle, vehicle hp is increasing by specific calculation and vehicle takes all agroo, dmg. Player takes only combat status...
Posted Image
Posted Image
Sorry for my bad english
0

Share this topic:


Page 1 of 1
  • 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