summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-30 17:29:46 +0200
committermadmaxoft <github@xoft.cz>2013-08-30 17:29:46 +0200
commit88f3fe7f000992fe7a3c47d4e235f725e9b77b69 (patch)
treed6b7590cc71e3849ae3388760bb2c87b03d6c4be
parentUpdated ProtectionAreas to the latest version. (diff)
downloadcuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.tar
cuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.tar.gz
cuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.tar.bz2
cuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.tar.lz
cuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.tar.xz
cuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.tar.zst
cuberite-88f3fe7f000992fe7a3c47d4e235f725e9b77b69.zip
-rw-r--r--source/Bindings.cpp174
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Entities/Player.cpp30
-rw-r--r--source/Entities/Player.h8
-rw-r--r--source/Entities/ProjectileEntity.cpp32
-rw-r--r--source/Entities/ProjectileEntity.h6
6 files changed, 128 insertions, 124 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index af3e83dda..898d3af1b 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/30/13 14:30:24.
+** Generated automatically by tolua++-1.0.92 on 08/30/13 17:24:30.
*/
#ifndef __cplusplus
@@ -7650,6 +7650,92 @@ static int tolua_AllToLua_cPlayer_GetEquippedItem00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetThrowStartPos of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetThrowStartPos00
+static int tolua_AllToLua_cPlayer_GetThrowStartPos00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetThrowStartPos'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->GetThrowStartPos();
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetThrowStartPos'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetThrowSpeed of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetThrowSpeed00
+static int tolua_AllToLua_cPlayer_GetThrowSpeed00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+ double a_SpeedCoeff = ((double) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetThrowSpeed'", NULL);
+#endif
+ {
+ Vector3d tolua_ret = (Vector3d) self->GetThrowSpeed(a_SpeedCoeff);
+ {
+#ifdef __cplusplus
+ void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#else
+ void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
+ tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+#endif
+ }
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetThrowSpeed'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetGameMode of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetGameMode00
static int tolua_AllToLua_cPlayer_GetGameMode00(lua_State* tolua_S)
@@ -9704,88 +9790,6 @@ static int tolua_AllToLua_cProjectileEntity_IsInGround00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: PosFromPlayerPos of class cArrowEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cArrowEntity_PosFromPlayerPos00
-static int tolua_AllToLua_cArrowEntity_PosFromPlayerPos00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertable(tolua_S,1,"cArrowEntity",0,&tolua_err) ||
- (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err)) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0));
- {
- Vector3d tolua_ret = (Vector3d) cArrowEntity::PosFromPlayerPos(*a_Player);
- {
-#ifdef __cplusplus
- void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
- tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
-#else
- void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
- tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
-#endif
- }
- }
- }
- return 1;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'PosFromPlayerPos'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* method: SpeedFromPlayerLook of class cArrowEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cArrowEntity_SpeedFromPlayerLook00
-static int tolua_AllToLua_cArrowEntity_SpeedFromPlayerLook00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertable(tolua_S,1,"cArrowEntity",0,&tolua_err) ||
- (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err)) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,4,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0));
- double a_Force = ((double) tolua_tonumber(tolua_S,3,0));
- {
- Vector3d tolua_ret = (Vector3d) cArrowEntity::SpeedFromPlayerLook(*a_Player,a_Force);
- {
-#ifdef __cplusplus
- void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret));
- tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
-#else
- void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d));
- tolua_pushusertype(tolua_S,tolua_obj,"Vector3d");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
-#endif
- }
- }
- }
- return 1;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SpeedFromPlayerLook'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
/* method: GetPickupState of class cArrowEntity */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cArrowEntity_GetPickupState00
static int tolua_AllToLua_cArrowEntity_GetPickupState00(lua_State* tolua_S)
@@ -28588,6 +28592,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetStance",tolua_AllToLua_cPlayer_GetStance00);
tolua_function(tolua_S,"GetInventory",tolua_AllToLua_cPlayer_GetInventory00);
tolua_function(tolua_S,"GetEquippedItem",tolua_AllToLua_cPlayer_GetEquippedItem00);
+ tolua_function(tolua_S,"GetThrowStartPos",tolua_AllToLua_cPlayer_GetThrowStartPos00);
+ tolua_function(tolua_S,"GetThrowSpeed",tolua_AllToLua_cPlayer_GetThrowSpeed00);
tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cPlayer_GetGameMode00);
tolua_function(tolua_S,"SetGameMode",tolua_AllToLua_cPlayer_SetGameMode00);
tolua_function(tolua_S,"IsGameModeCreative",tolua_AllToLua_cPlayer_IsGameModeCreative00);
@@ -28677,8 +28683,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"psNoPickup",cArrowEntity::psNoPickup);
tolua_constant(tolua_S,"psInSurvivalOrCreative",cArrowEntity::psInSurvivalOrCreative);
tolua_constant(tolua_S,"psInCreative",cArrowEntity::psInCreative);
- tolua_function(tolua_S,"PosFromPlayerPos",tolua_AllToLua_cArrowEntity_PosFromPlayerPos00);
- tolua_function(tolua_S,"SpeedFromPlayerLook",tolua_AllToLua_cArrowEntity_SpeedFromPlayerLook00);
tolua_function(tolua_S,"GetPickupState",tolua_AllToLua_cArrowEntity_GetPickupState00);
tolua_function(tolua_S,"SetPickupState",tolua_AllToLua_cArrowEntity_SetPickupState00);
tolua_function(tolua_S,"GetDamageCoeff",tolua_AllToLua_cArrowEntity_GetDamageCoeff00);
diff --git a/source/Bindings.h b/source/Bindings.h
index e5b7e0f76..e4871e9f6 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/30/13 14:30:25.
+** Generated automatically by tolua++-1.0.92 on 08/30/13 17:24:30.
*/
/* Exported function */
diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp
index 0cb047933..0943f61ff 100644
--- a/source/Entities/Player.cpp
+++ b/source/Entities/Player.cpp
@@ -857,6 +857,36 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
+Vector3d cPlayer::GetThrowStartPos(void) const
+{
+ Vector3d res = GetEyePosition();
+
+ // Adjust the position to be just outside the player's bounding box:
+ res.x += 0.16 * cos(GetPitch());
+ res.y += -0.1;
+ res.z += 0.16 * sin(GetPitch());
+
+ return res;
+}
+
+
+
+
+
+Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
+{
+ Vector3d res = GetLookVector();
+ res.Normalize();
+
+ // TODO: Add a slight random change (+-0.0075 in each direction)
+
+ return res * a_SpeedCoeff;
+}
+
+
+
+
+
void cPlayer::MoveTo( const Vector3d & a_NewPos )
{
if ((a_NewPos.y < -990) && (GetPosY() > -100))
diff --git a/source/Entities/Player.h b/source/Entities/Player.h
index 4adf946db..82ff48954 100644
--- a/source/Entities/Player.h
+++ b/source/Entities/Player.h
@@ -73,7 +73,7 @@ public:
void CancelChargingBow(void);
/// Returns true if the player is currently charging the bow
- bool IsChargingBox(void) const { return m_IsChargingBow; }
+ bool IsChargingBow(void) const { return m_IsChargingBow; }
void SetTouchGround( bool a_bTouchGround );
inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; }
@@ -90,6 +90,12 @@ public:
// tolua_begin
+ /// Returns the position where projectiles thrown by this player should start, player eye position + adjustment
+ Vector3d GetThrowStartPos(void) const;
+
+ /// Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff.
+ Vector3d GetThrowSpeed(double a_SpeedCoeff) const;
+
/// Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable
eGameMode GetGameMode(void) const { return m_GameMode; }
diff --git a/source/Entities/ProjectileEntity.cpp b/source/Entities/ProjectileEntity.cpp
index f405e9aa4..1dbc46ca1 100644
--- a/source/Entities/ProjectileEntity.cpp
+++ b/source/Entities/ProjectileEntity.cpp
@@ -230,7 +230,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
- super(pkArrow, &a_Player, PosFromPlayerPos(a_Player), SpeedFromPlayerLook(a_Player, a_Force), 0.5, 0.5),
+ super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5),
m_PickupState(psInSurvivalOrCreative),
m_DamageCoeff(2)
{
@@ -240,36 +240,6 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
-Vector3d cArrowEntity::PosFromPlayerPos(const cPlayer & a_Player)
-{
- Vector3d res = a_Player.GetEyePosition();
-
- // Adjust the position to be just outside the player's bounding box:
- res.x += 0.16 * cos(a_Player.GetPitch());
- res.y += -0.1;
- res.z += 0.16 * sin(a_Player.GetPitch());
-
- return res;
-}
-
-
-
-
-
-Vector3d cArrowEntity::SpeedFromPlayerLook(const cPlayer & a_Player, double a_Force)
-{
- Vector3d res = a_Player.GetLookVector();
- res.Normalize();
-
- // TODO: Add a slight random change (+-0.0075 in each direction)
-
- return res * a_Force * 1.5 * 20;
-}
-
-
-
-
-
bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
{
switch (m_PickupState)
diff --git a/source/Entities/ProjectileEntity.h b/source/Entities/ProjectileEntity.h
index 1569ad035..aa7ecc772 100644
--- a/source/Entities/ProjectileEntity.h
+++ b/source/Entities/ProjectileEntity.h
@@ -112,12 +112,6 @@ public:
// tolua_begin
- /// Returns the initial arrow position, as defined by the player eye position + adjustment.
- static Vector3d PosFromPlayerPos(const cPlayer & a_Player);
-
- /// Returns the initial arrow speed, as defined by the player look vector and the force coefficient
- static Vector3d SpeedFromPlayerLook(const cPlayer & a_Player, double a_Force);
-
/// Returns whether the arrow can be picked up by players
ePickupState GetPickupState(void) const { return m_PickupState; }