Merge pull request #437 from mc-server/ShootTo_function

Shoot to function
master
STRWarrior 2013-12-15 12:05:18 -08:00
commit 9b8112dbc2
6 changed files with 50 additions and 4 deletions

View File

@ -1574,6 +1574,7 @@ a_Player:OpenWindow(Window);
DeltaExperience = { Params = "DeltaXP", Return = "", Notes = "Adds or removes XP from the current XP amount. Won't allow XP to go negative. Returns the new experience, -1 on error (XP overflow)." },
Feed = { Params = "AddFood, AddSaturation", Return = "bool", Notes = "Tries to add the specified amounts to food level and food saturation level (only positive amounts expected). Returns true if player was hungry and the food was consumed, false if too satiated." },
FoodPoison = { Params = "NumTicks", Return = "", Notes = "Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two" },
ForceSetSpeed = { Params = "{{Vector3d|Direction}}", Notes = "Forces the player to move to the given direction." },
GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left)." },
GetClientHandle = { Params = "", Return = "{{cClientHandle}}", Notes = "Returns the client handle representing the player's connection. May be nil (AI players)." },
GetColor = { Return = "string", Notes = "Returns the full color code to be used for this player (based on the first group). Prefix player messages with this code." },

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 12/15/13 14:19:12.
** Generated automatically by tolua++-1.0.92 on 12/15/13 20:25:06.
*/
#ifndef __cplusplus
@ -9395,6 +9395,39 @@ static int tolua_AllToLua_cPlayer_GetIP00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: ForceSetSpeed of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_ForceSetSpeed00
static int tolua_AllToLua_cPlayer_ForceSetSpeed00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3d",0,&tolua_err)) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
Vector3d a_Direction = *((Vector3d*) tolua_tousertype(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ForceSetSpeed'", NULL);
#endif
{
self->ForceSetSpeed(a_Direction);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'ForceSetSpeed'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: MoveTo of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_MoveTo00
static int tolua_AllToLua_cPlayer_MoveTo00(lua_State* tolua_S)
@ -31076,6 +31109,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"IsGameModeSurvival",tolua_AllToLua_cPlayer_IsGameModeSurvival00);
tolua_function(tolua_S,"IsGameModeAdventure",tolua_AllToLua_cPlayer_IsGameModeAdventure00);
tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00);
tolua_function(tolua_S,"ForceSetSpeed",tolua_AllToLua_cPlayer_ForceSetSpeed00);
tolua_function(tolua_S,"MoveTo",tolua_AllToLua_cPlayer_MoveTo00);
tolua_function(tolua_S,"GetWindow",tolua_AllToLua_cPlayer_GetWindow00);
tolua_function(tolua_S,"CloseWindow",tolua_AllToLua_cPlayer_CloseWindow00);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 12/15/13 14:19:13.
** Generated automatically by tolua++-1.0.92 on 12/15/13 20:25:06.
*/
/* Exported function */

View File

@ -1760,8 +1760,6 @@ void cClientHandle::SendEntityStatus(const cEntity & a_Entity, char a_Status)
void cClientHandle::SendEntityVelocity(const cEntity & a_Entity)
{
ASSERT(a_Entity.GetUniqueID() != m_Player->GetUniqueID()); // Must not send for self
m_Protocol->SendEntityVelocity(a_Entity);
}

View File

@ -1069,6 +1069,16 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
void cPlayer::ForceSetSpeed(Vector3d a_Direction)
{
SetSpeed(a_Direction);
m_ClientHandle->SendEntityVelocity(*this);
}
void cPlayer::MoveTo( const Vector3d & a_NewPos )
{
if ((a_NewPos.y < -990) && (GetPosY() > -100))

View File

@ -167,6 +167,9 @@ public:
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
void LoginSetGameMode(eGameMode a_GameMode);
/// Forces the player to move in the given direction.
void ForceSetSpeed(Vector3d a_Direction); // tolua_export
/// Tries to move to a new position, with attachment-related checks (y == -999)
void MoveTo(const Vector3d & a_NewPos); // tolua_export