diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-12-21 12:04:08 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-12-21 12:04:08 +0100 |
commit | 912a1e7adc650d20b0302a3dfe45816b5e541bc7 (patch) | |
tree | 65e7ffbf33d8f1335a4997fc5a727739f9dcdd34 /source | |
parent | Extended player inventory by direct r/o access to armor slots (diff) | |
download | cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.gz cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.bz2 cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.lz cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.xz cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.tar.zst cuberite-912a1e7adc650d20b0302a3dfe45816b5e541bc7.zip |
Diffstat (limited to '')
62 files changed, 2460 insertions, 1068 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 1c6f25351..c6c5c65a4 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 11/20/12 22:18:11. +** Generated automatically by tolua++-1.0.92 on 12/21/12 19:26:06. */ #ifndef __cplusplus @@ -4182,7 +4182,7 @@ static int tolua_AllToLua_cEntity_GetPosX00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosX'", NULL); #endif { - const double tolua_ret = (const double) self->GetPosX(); + double tolua_ret = (double) self->GetPosX(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -4214,7 +4214,7 @@ static int tolua_AllToLua_cEntity_GetPosY00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosY'", NULL); #endif { - const double tolua_ret = (const double) self->GetPosY(); + double tolua_ret = (double) self->GetPosY(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -4246,7 +4246,7 @@ static int tolua_AllToLua_cEntity_GetPosZ00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosZ'", NULL); #endif { - const double tolua_ret = (const double) self->GetPosZ(); + double tolua_ret = (double) self->GetPosZ(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -4541,16 +4541,15 @@ static int tolua_AllToLua_cEntity_SetPosX00(lua_State* tolua_S) #endif { cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); - const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0)); + double a_PosX = ((double) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosX'", NULL); #endif { self->SetPosX(a_PosX); - tolua_pushnumber(tolua_S,(lua_Number)a_PosX); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'SetPosX'.",&tolua_err); @@ -4575,16 +4574,15 @@ static int tolua_AllToLua_cEntity_SetPosY00(lua_State* tolua_S) #endif { cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); - const double a_PosY = ((const double) tolua_tonumber(tolua_S,2,0)); + double a_PosY = ((double) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosY'", NULL); #endif { self->SetPosY(a_PosY); - tolua_pushnumber(tolua_S,(lua_Number)a_PosY); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'SetPosY'.",&tolua_err); @@ -4609,16 +4607,15 @@ static int tolua_AllToLua_cEntity_SetPosZ00(lua_State* tolua_S) #endif { cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); - const double a_PosZ = ((const double) tolua_tonumber(tolua_S,2,0)); + double a_PosZ = ((double) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosZ'", NULL); #endif { self->SetPosZ(a_PosZ); - tolua_pushnumber(tolua_S,(lua_Number)a_PosZ); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'SetPosZ'.",&tolua_err); @@ -4645,20 +4642,17 @@ static int tolua_AllToLua_cEntity_SetPosition00(lua_State* tolua_S) #endif { cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); - const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0)); + double a_PosX = ((double) tolua_tonumber(tolua_S,2,0)); + double a_PosY = ((double) tolua_tonumber(tolua_S,3,0)); + double a_PosZ = ((double) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosition'", NULL); #endif { self->SetPosition(a_PosX,a_PosY,a_PosZ); - tolua_pushnumber(tolua_S,(lua_Number)a_PosX); - tolua_pushnumber(tolua_S,(lua_Number)a_PosY); - tolua_pushnumber(tolua_S,(lua_Number)a_PosZ); } } - return 3; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'SetPosition'.",&tolua_err); @@ -5067,7 +5061,7 @@ public: void cEntity__SpawnOn( cClientHandle& a_Client) { return ( void )cEntity::SpawnOn(a_Client); }; - Lua__cEntity( const double& a_X, const double& a_Y, const double& a_Z): cEntity(a_X,a_Y,a_Z){}; + Lua__cEntity( double a_X, double a_Y, double a_Z): cEntity(a_X,a_Y,a_Z){}; }; /* method: tolua__set_instance of class Lua__cEntity */ @@ -5284,18 +5278,15 @@ static int tolua_AllToLua_Lua__cEntity_new00(lua_State* tolua_S) else #endif { - const double a_X = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_Y = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_Z = ((const double) tolua_tonumber(tolua_S,4,0)); + double a_X = ((double) tolua_tonumber(tolua_S,2,0)); + double a_Y = ((double) tolua_tonumber(tolua_S,3,0)); + double a_Z = ((double) tolua_tonumber(tolua_S,4,0)); { Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_X,a_Y,a_Z)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity"); - tolua_pushnumber(tolua_S,(lua_Number)a_X); - tolua_pushnumber(tolua_S,(lua_Number)a_Y); - tolua_pushnumber(tolua_S,(lua_Number)a_Z); } } - return 4; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); @@ -5321,19 +5312,16 @@ static int tolua_AllToLua_Lua__cEntity_new00_local(lua_State* tolua_S) else #endif { - const double a_X = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_Y = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_Z = ((const double) tolua_tonumber(tolua_S,4,0)); + double a_X = ((double) tolua_tonumber(tolua_S,2,0)); + double a_Y = ((double) tolua_tonumber(tolua_S,3,0)); + double a_Z = ((double) tolua_tonumber(tolua_S,4,0)); { Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_X,a_Y,a_Z)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - tolua_pushnumber(tolua_S,(lua_Number)a_X); - tolua_pushnumber(tolua_S,(lua_Number)a_Y); - tolua_pushnumber(tolua_S,(lua_Number)a_Z); } } - return 4; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); @@ -5383,61 +5371,151 @@ static int tolua_collect_Lua__cEntity (lua_State* tolua_S) } #endif -/* get function: Damage of class TakeDamageInfo */ -#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_Damage -static int tolua_get_TakeDamageInfo_Damage(lua_State* tolua_S) +/* get function: DamageType of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_DamageType +static int tolua_get_TakeDamageInfo_DamageType(lua_State* tolua_S) +{ + TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'DamageType'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->DamageType); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: DamageType of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_DamageType +static int tolua_set_TakeDamageInfo_DamageType(lua_State* tolua_S) +{ + TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'DamageType'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->DamageType = ((eDamageType) (int) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: Attacker of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_Attacker_ptr +static int tolua_get_TakeDamageInfo_Attacker_ptr(lua_State* tolua_S) +{ + TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Attacker'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->Attacker,"cPawn"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: Attacker of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_Attacker_ptr +static int tolua_set_TakeDamageInfo_Attacker_ptr(lua_State* tolua_S) +{ + TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Attacker'",NULL); + if (!tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->Attacker = ((cPawn*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: RawDamage of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_RawDamage +static int tolua_get_TakeDamageInfo_RawDamage(lua_State* tolua_S) +{ + TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'RawDamage'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->RawDamage); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: RawDamage of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_RawDamage +static int tolua_set_TakeDamageInfo_RawDamage(lua_State* tolua_S) +{ + TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'RawDamage'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->RawDamage = ((int) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: FinalDamage of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_FinalDamage +static int tolua_get_TakeDamageInfo_FinalDamage(lua_State* tolua_S) { TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Damage'",NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'FinalDamage'",NULL); #endif - tolua_pushnumber(tolua_S,(lua_Number)self->Damage); + tolua_pushnumber(tolua_S,(lua_Number)self->FinalDamage); return 1; } #endif //#ifndef TOLUA_DISABLE -/* set function: Damage of class TakeDamageInfo */ -#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_Damage -static int tolua_set_TakeDamageInfo_Damage(lua_State* tolua_S) +/* set function: FinalDamage of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_FinalDamage +static int tolua_set_TakeDamageInfo_FinalDamage(lua_State* tolua_S) { TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Damage'",NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'FinalDamage'",NULL); if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif - self->Damage = ((int) tolua_tonumber(tolua_S,2,0)) + self->FinalDamage = ((int) tolua_tonumber(tolua_S,2,0)) ; return 0; } #endif //#ifndef TOLUA_DISABLE -/* get function: Instigator of class TakeDamageInfo */ -#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_Instigator_ptr -static int tolua_get_TakeDamageInfo_Instigator_ptr(lua_State* tolua_S) +/* get function: Knockback of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_Knockback +static int tolua_get_TakeDamageInfo_Knockback(lua_State* tolua_S) { TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Instigator'",NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Knockback'",NULL); #endif - tolua_pushusertype(tolua_S,(void*)self->Instigator,"cEntity"); + tolua_pushusertype(tolua_S,(void*)&self->Knockback,"Vector3d"); return 1; } #endif //#ifndef TOLUA_DISABLE -/* set function: Instigator of class TakeDamageInfo */ -#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_Instigator_ptr -static int tolua_set_TakeDamageInfo_Instigator_ptr(lua_State* tolua_S) +/* set function: Knockback of class TakeDamageInfo */ +#ifndef TOLUA_DISABLE_tolua_set_TakeDamageInfo_Knockback +static int tolua_set_TakeDamageInfo_Knockback(lua_State* tolua_S) { TakeDamageInfo* self = (TakeDamageInfo*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Instigator'",NULL); - if (!tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err)) + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Knockback'",NULL); + if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3d",0,&tolua_err))) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); #endif - self->Instigator = ((cEntity*) tolua_tousertype(tolua_S,2,0)) + self->Knockback = *((Vector3d*) tolua_tousertype(tolua_S,2,0)) ; return 0; } @@ -5451,7 +5529,7 @@ static int tolua_AllToLua_cPawn_TeleportToEntity00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; @@ -5464,7 +5542,7 @@ static int tolua_AllToLua_cPawn_TeleportToEntity00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportToEntity'", NULL); #endif { - self->TeleportToEntity(a_Entity); + self->TeleportToEntity(*a_Entity); } } return 0; @@ -5494,20 +5572,17 @@ static int tolua_AllToLua_cPawn_TeleportTo00(lua_State* tolua_S) #endif { cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); - const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0)); + double a_PosX = ((double) tolua_tonumber(tolua_S,2,0)); + double a_PosY = ((double) tolua_tonumber(tolua_S,3,0)); + double a_PosZ = ((double) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportTo'", NULL); #endif { self->TeleportTo(a_PosX,a_PosY,a_PosZ); - tolua_pushnumber(tolua_S,(lua_Number)a_PosX); - tolua_pushnumber(tolua_S,(lua_Number)a_PosY); - tolua_pushnumber(tolua_S,(lua_Number)a_PosZ); } } - return 3; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'TeleportTo'.",&tolua_err); @@ -5532,12 +5607,12 @@ static int tolua_AllToLua_cPawn_Heal00(lua_State* tolua_S) #endif { cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); - int a_Health = ((int) tolua_tonumber(tolua_S,2,0)); + int a_HitPoints = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Heal'", NULL); #endif { - self->Heal(a_Health); + self->Heal(a_HitPoints); } } return 0; @@ -5549,6 +5624,38 @@ static int tolua_AllToLua_cPawn_Heal00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: GetHealth of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetHealth00 +static int tolua_AllToLua_cPawn_GetHealth00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPawn* self = (const cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetHealth'", NULL); +#endif + { + int tolua_ret = (int) self->GetHealth(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetHealth'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: TakeDamage of class cPawn */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_TakeDamage00 static int tolua_AllToLua_cPawn_TakeDamage00(lua_State* tolua_S) @@ -5557,22 +5664,20 @@ static int tolua_AllToLua_cPawn_TakeDamage00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); - int a_Damage = ((int) tolua_tonumber(tolua_S,2,0)); - cEntity* a_Instigator = ((cEntity*) tolua_tousertype(tolua_S,3,0)); + cPawn* a_Attacker = ((cPawn*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TakeDamage'", NULL); #endif { - self->TakeDamage(a_Damage,a_Instigator); + self->TakeDamage(*a_Attacker); } } return 0; @@ -5584,6 +5689,109 @@ static int tolua_AllToLua_cPawn_TakeDamage00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: TakeDamage of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_TakeDamage01 +static int tolua_AllToLua_cPawn_TakeDamage01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"cPawn",0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); + eDamageType a_DamageType = ((eDamageType) (int) tolua_tonumber(tolua_S,2,0)); + cPawn* a_Attacker = ((cPawn*) tolua_tousertype(tolua_S,3,0)); + int a_RawDamage = ((int) tolua_tonumber(tolua_S,4,0)); + double a_KnockbackAmount = ((double) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TakeDamage'", NULL); +#endif + { + self->TakeDamage(a_DamageType,a_Attacker,a_RawDamage,a_KnockbackAmount); + } + } + return 0; +tolua_lerror: + return tolua_AllToLua_cPawn_TakeDamage00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: TakeDamage of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_TakeDamage02 +static int tolua_AllToLua_cPawn_TakeDamage02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"cPawn",0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnoobj(tolua_S,7,&tolua_err) + ) + goto tolua_lerror; + else + { + cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); + eDamageType a_DamageType = ((eDamageType) (int) tolua_tonumber(tolua_S,2,0)); + cPawn* a_Attacker = ((cPawn*) tolua_tousertype(tolua_S,3,0)); + int a_RawDamage = ((int) tolua_tonumber(tolua_S,4,0)); + int a_FinalDamage = ((int) tolua_tonumber(tolua_S,5,0)); + double a_KnockbackAmount = ((double) tolua_tonumber(tolua_S,6,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TakeDamage'", NULL); +#endif + { + self->TakeDamage(a_DamageType,a_Attacker,a_RawDamage,a_FinalDamage,a_KnockbackAmount); + } + } + return 0; +tolua_lerror: + return tolua_AllToLua_cPawn_TakeDamage01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: DoTakeDamage of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_DoTakeDamage00 +static int tolua_AllToLua_cPawn_DoTakeDamage00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"TakeDamageInfo",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); + TakeDamageInfo* a_TDI = ((TakeDamageInfo*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DoTakeDamage'", NULL); +#endif + { + self->DoTakeDamage(*a_TDI); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'DoTakeDamage'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: KilledBy of class cPawn */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_KilledBy00 static int tolua_AllToLua_cPawn_KilledBy00(lua_State* tolua_S) @@ -5592,7 +5800,7 @@ static int tolua_AllToLua_cPawn_KilledBy00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; @@ -5600,7 +5808,7 @@ static int tolua_AllToLua_cPawn_KilledBy00(lua_State* tolua_S) #endif { cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); - cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,2,0)); + cPawn* a_Killer = ((cPawn*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KilledBy'", NULL); #endif @@ -5617,33 +5825,317 @@ static int tolua_AllToLua_cPawn_KilledBy00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: GetHealth of class cPawn */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetHealth00 -static int tolua_AllToLua_cPawn_GetHealth00(lua_State* tolua_S) +/* method: GetRawDamageAgainst of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetRawDamageAgainst00 +static int tolua_AllToLua_cPawn_GetRawDamageAgainst00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPawn",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); + const cPawn* a_Receiver = ((const cPawn*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetHealth'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRawDamageAgainst'", NULL); #endif { - int tolua_ret = (int) self->GetHealth(); + int tolua_ret = (int) self->GetRawDamageAgainst(*a_Receiver); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'GetHealth'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'GetRawDamageAgainst'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetArmorCoverAgainst of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetArmorCoverAgainst00 +static int tolua_AllToLua_cPawn_GetArmorCoverAgainst00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"const cPawn",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); + const cPawn* a_Attacker = ((const cPawn*) tolua_tousertype(tolua_S,2,0)); + eDamageType a_DamageType = ((eDamageType) (int) tolua_tonumber(tolua_S,3,0)); + int a_RawDamage = ((int) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetArmorCoverAgainst'", NULL); +#endif + { + int tolua_ret = (int) self->GetArmorCoverAgainst(a_Attacker,a_DamageType,a_RawDamage); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetArmorCoverAgainst'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetKnockbackAmountAgainst of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetKnockbackAmountAgainst00 +static int tolua_AllToLua_cPawn_GetKnockbackAmountAgainst00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPawn",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPawn",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cPawn* self = (cPawn*) tolua_tousertype(tolua_S,1,0); + const cPawn* a_Receiver = ((const cPawn*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetKnockbackAmountAgainst'", NULL); +#endif + { + double tolua_ret = (double) self->GetKnockbackAmountAgainst(*a_Receiver); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetKnockbackAmountAgainst'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedWeapon of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetEquippedWeapon00 +static int tolua_AllToLua_cPawn_GetEquippedWeapon00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPawn* self = (const cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedWeapon'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->GetEquippedWeapon(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedWeapon'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedHelmet of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetEquippedHelmet00 +static int tolua_AllToLua_cPawn_GetEquippedHelmet00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPawn* self = (const cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedHelmet'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->GetEquippedHelmet(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedHelmet'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedChestplate of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetEquippedChestplate00 +static int tolua_AllToLua_cPawn_GetEquippedChestplate00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPawn* self = (const cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedChestplate'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->GetEquippedChestplate(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedChestplate'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedLeggings of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetEquippedLeggings00 +static int tolua_AllToLua_cPawn_GetEquippedLeggings00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPawn* self = (const cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedLeggings'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->GetEquippedLeggings(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedLeggings'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedBoots of class cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPawn_GetEquippedBoots00 +static int tolua_AllToLua_cPawn_GetEquippedBoots00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPawn* self = (const cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedBoots'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->GetEquippedBoots(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedBoots'.",&tolua_err); return 0; #endif } @@ -5651,15 +6143,15 @@ static int tolua_AllToLua_cPawn_GetHealth00(lua_State* tolua_S) class Lua__cPawn : public cPawn, public ToluaBase { public: - void TeleportToEntity( cEntity* a_Entity) { + void TeleportToEntity( cEntity& a_Entity) { if (push_method("TeleportToEntity", tolua_AllToLua_cPawn_TeleportToEntity00)) { - tolua_pushusertype(lua_state, (void*)a_Entity, "cEntity"); + tolua_pushusertype(lua_state, (void*)&a_Entity, "cEntity"); ToluaBase::dbcall(lua_state, 2, 0); } else { return ( void ) cPawn:: TeleportToEntity(a_Entity); }; }; - void TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) { + void TeleportTo( double a_PosX, double a_PosY, double a_PosZ) { if (push_method("TeleportTo", tolua_AllToLua_cPawn_TeleportTo00)) { tolua_pushnumber(lua_state, (lua_Number)a_PosX); tolua_pushnumber(lua_state, (lua_Number)a_PosY); @@ -5669,23 +6161,107 @@ public: return ( void ) cPawn:: TeleportTo(a_PosX,a_PosY,a_PosZ); }; }; - void TakeDamage( int a_Damage, cEntity* a_Instigator) { - if (push_method("TakeDamage", tolua_AllToLua_cPawn_TakeDamage00)) { - tolua_pushnumber(lua_state, (lua_Number)a_Damage); - tolua_pushusertype(lua_state, (void*)a_Instigator, "cEntity"); - ToluaBase::dbcall(lua_state, 3, 0); + void DoTakeDamage( TakeDamageInfo& a_TDI) { + if (push_method("DoTakeDamage", tolua_AllToLua_cPawn_DoTakeDamage00)) { + tolua_pushusertype(lua_state, (void*)&a_TDI, "TakeDamageInfo"); + ToluaBase::dbcall(lua_state, 2, 0); } else { - return ( void ) cPawn:: TakeDamage(a_Damage,a_Instigator); + return ( void ) cPawn:: DoTakeDamage(a_TDI); }; }; - void KilledBy( cEntity* a_Killer) { + void KilledBy( cPawn* a_Killer) { if (push_method("KilledBy", tolua_AllToLua_cPawn_KilledBy00)) { - tolua_pushusertype(lua_state, (void*)a_Killer, "cEntity"); + tolua_pushusertype(lua_state, (void*)a_Killer, "cPawn"); ToluaBase::dbcall(lua_state, 2, 0); } else { return ( void ) cPawn:: KilledBy(a_Killer); }; }; + int GetRawDamageAgainst( const cPawn& a_Receiver) { + if (push_method("GetRawDamageAgainst", tolua_AllToLua_cPawn_GetRawDamageAgainst00)) { + tolua_pushusertype(lua_state, (void*)&a_Receiver, "const cPawn"); + ToluaBase::dbcall(lua_state, 2, 1); + int tolua_ret = ( int )tolua_tonumber(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( int ) cPawn:: GetRawDamageAgainst(a_Receiver); + }; + }; + int GetArmorCoverAgainst( const cPawn* a_Attacker, eDamageType a_DamageType, int a_RawDamage) { + if (push_method("GetArmorCoverAgainst", tolua_AllToLua_cPawn_GetArmorCoverAgainst00)) { + tolua_pushusertype(lua_state, (void*)a_Attacker, "const cPawn"); + tolua_pushnumber(lua_state, (lua_Number)a_DamageType); + tolua_pushnumber(lua_state, (lua_Number)a_RawDamage); + ToluaBase::dbcall(lua_state, 4, 1); + int tolua_ret = ( int )tolua_tonumber(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( int ) cPawn:: GetArmorCoverAgainst(a_Attacker,a_DamageType,a_RawDamage); + }; + }; + double GetKnockbackAmountAgainst( const cPawn& a_Receiver) { + if (push_method("GetKnockbackAmountAgainst", tolua_AllToLua_cPawn_GetKnockbackAmountAgainst00)) { + tolua_pushusertype(lua_state, (void*)&a_Receiver, "const cPawn"); + ToluaBase::dbcall(lua_state, 2, 1); + double tolua_ret = ( double )tolua_tonumber(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( double ) cPawn:: GetKnockbackAmountAgainst(a_Receiver); + }; + }; + cItem GetEquippedWeapon( void )const { + if (push_method("GetEquippedWeapon", tolua_AllToLua_cPawn_GetEquippedWeapon00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPawn:: GetEquippedWeapon(); + }; + }; + cItem GetEquippedHelmet( void )const { + if (push_method("GetEquippedHelmet", tolua_AllToLua_cPawn_GetEquippedHelmet00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPawn:: GetEquippedHelmet(); + }; + }; + cItem GetEquippedChestplate( void )const { + if (push_method("GetEquippedChestplate", tolua_AllToLua_cPawn_GetEquippedChestplate00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPawn:: GetEquippedChestplate(); + }; + }; + cItem GetEquippedLeggings( void )const { + if (push_method("GetEquippedLeggings", tolua_AllToLua_cPawn_GetEquippedLeggings00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPawn:: GetEquippedLeggings(); + }; + }; + cItem GetEquippedBoots( void )const { + if (push_method("GetEquippedBoots", tolua_AllToLua_cPawn_GetEquippedBoots00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPawn:: GetEquippedBoots(); + }; + }; void Initialize( cWorld* a_World) { if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) { tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); @@ -5748,18 +6324,42 @@ public: }; }; - void cPawn__TeleportToEntity( cEntity* a_Entity) { + void cPawn__TeleportToEntity( cEntity& a_Entity) { return ( void )cPawn::TeleportToEntity(a_Entity); }; - void cPawn__TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) { + void cPawn__TeleportTo( double a_PosX, double a_PosY, double a_PosZ) { return ( void )cPawn::TeleportTo(a_PosX,a_PosY,a_PosZ); }; - void cPawn__TakeDamage( int a_Damage, cEntity* a_Instigator) { - return ( void )cPawn::TakeDamage(a_Damage,a_Instigator); + void cPawn__DoTakeDamage( TakeDamageInfo& a_TDI) { + return ( void )cPawn::DoTakeDamage(a_TDI); }; - void cPawn__KilledBy( cEntity* a_Killer) { + void cPawn__KilledBy( cPawn* a_Killer) { return ( void )cPawn::KilledBy(a_Killer); }; + int cPawn__GetRawDamageAgainst( const cPawn& a_Receiver) { + return ( int )cPawn::GetRawDamageAgainst(a_Receiver); + }; + int cPawn__GetArmorCoverAgainst( const cPawn* a_Attacker, eDamageType a_DamageType, int a_RawDamage) { + return ( int )cPawn::GetArmorCoverAgainst(a_Attacker,a_DamageType,a_RawDamage); + }; + double cPawn__GetKnockbackAmountAgainst( const cPawn& a_Receiver) { + return ( double )cPawn::GetKnockbackAmountAgainst(a_Receiver); + }; + cItem cPawn__GetEquippedWeapon( void ) { + return ( cItem )cPawn::GetEquippedWeapon(); + }; + cItem cPawn__GetEquippedHelmet( void ) { + return ( cItem )cPawn::GetEquippedHelmet(); + }; + cItem cPawn__GetEquippedChestplate( void ) { + return ( cItem )cPawn::GetEquippedChestplate(); + }; + cItem cPawn__GetEquippedLeggings( void ) { + return ( cItem )cPawn::GetEquippedLeggings(); + }; + cItem cPawn__GetEquippedBoots( void ) { + return ( cItem )cPawn::GetEquippedBoots(); + }; void cPawn__Initialize( cWorld* a_World) { return ( void )cPawn::Initialize(a_World); }; @@ -5818,7 +6418,7 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__TeleportToEntity00(lua_State* tolua_ tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; @@ -5831,7 +6431,7 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__TeleportToEntity00(lua_State* tolua_ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__TeleportToEntity'", NULL); #endif { - self->cPawn__TeleportToEntity(a_Entity); + self->cPawn__TeleportToEntity(*a_Entity); } } return 0; @@ -5861,20 +6461,17 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00(lua_State* tolua_S) #endif { Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); - const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0)); + double a_PosX = ((double) tolua_tonumber(tolua_S,2,0)); + double a_PosY = ((double) tolua_tonumber(tolua_S,3,0)); + double a_PosZ = ((double) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__TeleportTo'", NULL); #endif { self->cPawn__TeleportTo(a_PosX,a_PosY,a_PosZ); - tolua_pushnumber(tolua_S,(lua_Number)a_PosX); - tolua_pushnumber(tolua_S,(lua_Number)a_PosY); - tolua_pushnumber(tolua_S,(lua_Number)a_PosZ); } } - return 3; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'cPawn__TeleportTo'.",&tolua_err); @@ -5883,36 +6480,34 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: cPawn__TakeDamage of class Lua__cPawn */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__TakeDamage00 -static int tolua_AllToLua_Lua__cPawn_cPawn__TakeDamage00(lua_State* tolua_S) +/* method: cPawn__DoTakeDamage of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__DoTakeDamage00 +static int tolua_AllToLua_Lua__cPawn_cPawn__DoTakeDamage00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"TakeDamageInfo",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); - int a_Damage = ((int) tolua_tonumber(tolua_S,2,0)); - cEntity* a_Instigator = ((cEntity*) tolua_tousertype(tolua_S,3,0)); + TakeDamageInfo* a_TDI = ((TakeDamageInfo*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__TakeDamage'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__DoTakeDamage'", NULL); #endif { - self->cPawn__TakeDamage(a_Damage,a_Instigator); + self->cPawn__DoTakeDamage(*a_TDI); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPawn__TakeDamage'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPawn__DoTakeDamage'.",&tolua_err); return 0; #endif } @@ -5926,7 +6521,7 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; @@ -5934,7 +6529,7 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00(lua_State* tolua_S) #endif { Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); - cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,2,0)); + cPawn* a_Killer = ((cPawn*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__KilledBy'", NULL); #endif @@ -5951,6 +6546,322 @@ static int tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: cPawn__GetRawDamageAgainst of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetRawDamageAgainst00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetRawDamageAgainst00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPawn",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); + const cPawn* a_Receiver = ((const cPawn*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetRawDamageAgainst'", NULL); +#endif + { + int tolua_ret = (int) self->cPawn__GetRawDamageAgainst(*a_Receiver); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetRawDamageAgainst'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetArmorCoverAgainst of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetArmorCoverAgainst00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetArmorCoverAgainst00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"const cPawn",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); + const cPawn* a_Attacker = ((const cPawn*) tolua_tousertype(tolua_S,2,0)); + eDamageType a_DamageType = ((eDamageType) (int) tolua_tonumber(tolua_S,3,0)); + int a_RawDamage = ((int) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetArmorCoverAgainst'", NULL); +#endif + { + int tolua_ret = (int) self->cPawn__GetArmorCoverAgainst(a_Attacker,a_DamageType,a_RawDamage); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetArmorCoverAgainst'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetKnockbackAmountAgainst of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetKnockbackAmountAgainst00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetKnockbackAmountAgainst00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPawn",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); + const cPawn* a_Receiver = ((const cPawn*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetKnockbackAmountAgainst'", NULL); +#endif + { + double tolua_ret = (double) self->cPawn__GetKnockbackAmountAgainst(*a_Receiver); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetKnockbackAmountAgainst'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetEquippedWeapon of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedWeapon00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedWeapon00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetEquippedWeapon'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->cPawn__GetEquippedWeapon(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetEquippedWeapon'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetEquippedHelmet of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedHelmet00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedHelmet00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetEquippedHelmet'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->cPawn__GetEquippedHelmet(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetEquippedHelmet'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetEquippedChestplate of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedChestplate00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedChestplate00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetEquippedChestplate'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->cPawn__GetEquippedChestplate(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetEquippedChestplate'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetEquippedLeggings of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedLeggings00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedLeggings00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetEquippedLeggings'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->cPawn__GetEquippedLeggings(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetEquippedLeggings'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPawn__GetEquippedBoots of class Lua__cPawn */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedBoots00 +static int tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedBoots00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPawn",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPawn* self = (Lua__cPawn*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPawn__GetEquippedBoots'", NULL); +#endif + { + cItem tolua_ret = (cItem) self->cPawn__GetEquippedBoots(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((cItem)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(cItem)); + tolua_pushusertype(tolua_S,tolua_obj,"cItem"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPawn__GetEquippedBoots'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: Initialize of class cPlayer */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_Initialize00 static int tolua_AllToLua_cPlayer_Initialize00(lua_State* tolua_S) @@ -6186,46 +7097,6 @@ static int tolua_AllToLua_cPlayer_GetEquippedItem00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: TeleportTo of class cPlayer */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_TeleportTo00 -static int tolua_AllToLua_cPlayer_TeleportTo00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnumber(tolua_S,4,0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0); - const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TeleportTo'", NULL); -#endif - { - self->TeleportTo(a_PosX,a_PosY,a_PosZ); - tolua_pushnumber(tolua_S,(lua_Number)a_PosX); - tolua_pushnumber(tolua_S,(lua_Number)a_PosY); - tolua_pushnumber(tolua_S,(lua_Number)a_PosZ); - } - } - return 3; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'TeleportTo'.",&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) @@ -7090,74 +7961,6 @@ static int tolua_AllToLua_cPlayer_AddFoodExhaustion00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: TakeDamage of class cPlayer */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_TakeDamage00 -static int tolua_AllToLua_cPlayer_TakeDamage00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cEntity",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0); - int a_Damage = ((int) tolua_tonumber(tolua_S,2,0)); - cEntity* a_Instigator = ((cEntity*) tolua_tousertype(tolua_S,3,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'TakeDamage'", NULL); -#endif - { - self->TakeDamage(a_Damage,a_Instigator); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'TakeDamage'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: KilledBy of class cPlayer */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_KilledBy00 -static int tolua_AllToLua_cPlayer_KilledBy00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cEntity",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0); - cEntity* a_Killer = ((cEntity*) tolua_tousertype(tolua_S,2,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'KilledBy'", NULL); -#endif - { - self->KilledBy(a_Killer); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'KilledBy'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - /* method: Respawn of class cPlayer */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_Respawn00 static int tolua_AllToLua_cPlayer_Respawn00(lua_State* tolua_S) @@ -7229,14 +8032,14 @@ static int tolua_AllToLua_cPlayer_IsVisible00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { - cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0); + const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsVisible'", NULL); #endif @@ -7329,16 +8132,6 @@ public: return ( void ) cPlayer:: Initialize(a_World); }; }; - void TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) { - if (push_method("TeleportTo", tolua_AllToLua_cPlayer_TeleportTo00)) { - tolua_pushnumber(lua_state, (lua_Number)a_PosX); - tolua_pushnumber(lua_state, (lua_Number)a_PosY); - tolua_pushnumber(lua_state, (lua_Number)a_PosZ); - ToluaBase::dbcall(lua_state, 4, 0); - } else { - return ( void ) cPlayer:: TeleportTo(a_PosX,a_PosY,a_PosZ); - }; - }; void MoveTo( const Vector3d& a_NewPos) { if (push_method("MoveTo", tolua_AllToLua_cPlayer_MoveTo00)) { tolua_pushusertype(lua_state, (void*)&a_NewPos, "const Vector3d"); @@ -7347,31 +8140,125 @@ public: return ( void ) cPlayer:: MoveTo(a_NewPos); }; }; - void TeleportToEntity( cEntity* a_Entity) { + void TeleportToEntity( cEntity& a_Entity) { if (push_method("TeleportToEntity", tolua_AllToLua_cPawn_TeleportToEntity00)) { - tolua_pushusertype(lua_state, (void*)a_Entity, "cEntity"); + tolua_pushusertype(lua_state, (void*)&a_Entity, "cEntity"); ToluaBase::dbcall(lua_state, 2, 0); } else { return ( void ) cPlayer:: TeleportToEntity(a_Entity); }; }; - void TakeDamage( int a_Damage, cEntity* a_Instigator) { - if (push_method("TakeDamage", tolua_AllToLua_cPawn_TakeDamage00)) { - tolua_pushnumber(lua_state, (lua_Number)a_Damage); - tolua_pushusertype(lua_state, (void*)a_Instigator, "cEntity"); - ToluaBase::dbcall(lua_state, 3, 0); + void TeleportTo( double a_PosX, double a_PosY, double a_PosZ) { + if (push_method("TeleportTo", tolua_AllToLua_cPawn_TeleportTo00)) { + tolua_pushnumber(lua_state, (lua_Number)a_PosX); + tolua_pushnumber(lua_state, (lua_Number)a_PosY); + tolua_pushnumber(lua_state, (lua_Number)a_PosZ); + ToluaBase::dbcall(lua_state, 4, 0); + } else { + return ( void ) cPlayer:: TeleportTo(a_PosX,a_PosY,a_PosZ); + }; + }; + void DoTakeDamage( TakeDamageInfo& a_TDI) { + if (push_method("DoTakeDamage", tolua_AllToLua_cPawn_DoTakeDamage00)) { + tolua_pushusertype(lua_state, (void*)&a_TDI, "TakeDamageInfo"); + ToluaBase::dbcall(lua_state, 2, 0); } else { - return ( void ) cPlayer:: TakeDamage(a_Damage,a_Instigator); + return ( void ) cPlayer:: DoTakeDamage(a_TDI); }; }; - void KilledBy( cEntity* a_Killer) { + void KilledBy( cPawn* a_Killer) { if (push_method("KilledBy", tolua_AllToLua_cPawn_KilledBy00)) { - tolua_pushusertype(lua_state, (void*)a_Killer, "cEntity"); + tolua_pushusertype(lua_state, (void*)a_Killer, "cPawn"); ToluaBase::dbcall(lua_state, 2, 0); } else { return ( void ) cPlayer:: KilledBy(a_Killer); }; }; + int GetRawDamageAgainst( const cPawn& a_Receiver) { + if (push_method("GetRawDamageAgainst", tolua_AllToLua_cPawn_GetRawDamageAgainst00)) { + tolua_pushusertype(lua_state, (void*)&a_Receiver, "const cPawn"); + ToluaBase::dbcall(lua_state, 2, 1); + int tolua_ret = ( int )tolua_tonumber(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( int ) cPlayer:: GetRawDamageAgainst(a_Receiver); + }; + }; + int GetArmorCoverAgainst( const cPawn* a_Attacker, eDamageType a_DamageType, int a_RawDamage) { + if (push_method("GetArmorCoverAgainst", tolua_AllToLua_cPawn_GetArmorCoverAgainst00)) { + tolua_pushusertype(lua_state, (void*)a_Attacker, "const cPawn"); + tolua_pushnumber(lua_state, (lua_Number)a_DamageType); + tolua_pushnumber(lua_state, (lua_Number)a_RawDamage); + ToluaBase::dbcall(lua_state, 4, 1); + int tolua_ret = ( int )tolua_tonumber(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( int ) cPlayer:: GetArmorCoverAgainst(a_Attacker,a_DamageType,a_RawDamage); + }; + }; + double GetKnockbackAmountAgainst( const cPawn& a_Receiver) { + if (push_method("GetKnockbackAmountAgainst", tolua_AllToLua_cPawn_GetKnockbackAmountAgainst00)) { + tolua_pushusertype(lua_state, (void*)&a_Receiver, "const cPawn"); + ToluaBase::dbcall(lua_state, 2, 1); + double tolua_ret = ( double )tolua_tonumber(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( double ) cPlayer:: GetKnockbackAmountAgainst(a_Receiver); + }; + }; + cItem GetEquippedWeapon( void )const { + if (push_method("GetEquippedWeapon", tolua_AllToLua_cPawn_GetEquippedWeapon00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPlayer:: GetEquippedWeapon(); + }; + }; + cItem GetEquippedHelmet( void )const { + if (push_method("GetEquippedHelmet", tolua_AllToLua_cPawn_GetEquippedHelmet00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPlayer:: GetEquippedHelmet(); + }; + }; + cItem GetEquippedChestplate( void )const { + if (push_method("GetEquippedChestplate", tolua_AllToLua_cPawn_GetEquippedChestplate00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPlayer:: GetEquippedChestplate(); + }; + }; + cItem GetEquippedLeggings( void )const { + if (push_method("GetEquippedLeggings", tolua_AllToLua_cPawn_GetEquippedLeggings00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPlayer:: GetEquippedLeggings(); + }; + }; + cItem GetEquippedBoots( void )const { + if (push_method("GetEquippedBoots", tolua_AllToLua_cPawn_GetEquippedBoots00)) { + ToluaBase::dbcall(lua_state, 1, 1); + cItem tolua_ret = ( cItem )*(cItem*)tolua_tousertype(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( cItem ) cPlayer:: GetEquippedBoots(); + }; + }; unsigned int GetEntityType( void ) { if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) { ToluaBase::dbcall(lua_state, 1, 1); @@ -7429,21 +8316,45 @@ public: void cPlayer__Initialize( cWorld* a_World) { return ( void )cPlayer::Initialize(a_World); }; - void cPlayer__TeleportTo( const double& a_PosX, const double& a_PosY, const double& a_PosZ) { - return ( void )cPlayer::TeleportTo(a_PosX,a_PosY,a_PosZ); - }; void cPlayer__MoveTo( const Vector3d& a_NewPos) { return ( void )cPlayer::MoveTo(a_NewPos); }; - void cPlayer__TeleportToEntity( cEntity* a_Entity) { + void cPlayer__TeleportToEntity( cEntity& a_Entity) { return ( void )cPlayer::TeleportToEntity(a_Entity); }; - void cPlayer__TakeDamage( int a_Damage, cEntity* a_Instigator) { - return ( void )cPlayer::TakeDamage(a_Damage,a_Instigator); + void cPlayer__TeleportTo( double a_PosX, double a_PosY, double a_PosZ) { + return ( void )cPlayer::TeleportTo(a_PosX,a_PosY,a_PosZ); + }; + void cPlayer__DoTakeDamage( TakeDamageInfo& a_TDI) { + return ( void )cPlayer::DoTakeDamage(a_TDI); }; - void cPlayer__KilledBy( cEntity* a_Killer) { + void cPlayer__KilledBy( cPawn* a_Killer) { return ( void )cPlayer::KilledBy(a_Killer); }; + int cPlayer__GetRawDamageAgainst( const cPawn& a_Receiver) { + return ( int )cPlayer::GetRawDamageAgainst(a_Receiver); + }; + int cPlayer__GetArmorCoverAgainst( const cPawn* a_Attacker, eDamageType a_DamageType, int a_RawDamage) { + return ( int )cPlayer::GetArmorCoverAgainst(a_Attacker,a_DamageType,a_RawDamage); + }; + double cPlayer__GetKnockbackAmountAgainst( const cPawn& a_Receiver) { + return ( double )cPlayer::GetKnockbackAmountAgainst(a_Receiver); + }; + cItem cPlayer__GetEquippedWeapon( void ) { + return ( cItem )cPlayer::GetEquippedWeapon(); + }; + cItem cPlayer__GetEquippedHelmet( void ) { + return ( cItem )cPlayer::GetEquippedHelmet(); + }; + cItem cPlayer__GetEquippedChestplate( void ) { + return ( cItem )cPlayer::GetEquippedChestplate(); + }; + cItem cPlayer__GetEquippedLeggings( void ) { + return ( cItem )cPlayer::GetEquippedLeggings(); + }; + cItem cPlayer__GetEquippedBoots( void ) { + return ( cItem )cPlayer::GetEquippedBoots(); + }; unsigned int cPlayer__GetEntityType( void ) { return (unsigned int )cPlayer::GetEntityType(); }; @@ -7524,46 +8435,6 @@ static int tolua_AllToLua_Lua__cPlayer_cPlayer__Initialize00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: cPlayer__TeleportTo of class Lua__cPlayer */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00 -static int tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Lua__cPlayer",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnumber(tolua_S,4,0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - Lua__cPlayer* self = (Lua__cPlayer*) tolua_tousertype(tolua_S,1,0); - const double a_PosX = ((const double) tolua_tonumber(tolua_S,2,0)); - const double a_PosY = ((const double) tolua_tonumber(tolua_S,3,0)); - const double a_PosZ = ((const double) tolua_tonumber(tolua_S,4,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlayer__TeleportTo'", NULL); -#endif - { - self->cPlayer__TeleportTo(a_PosX,a_PosY,a_PosZ); - tolua_pushnumber(tolua_S,(lua_Number)a_PosX); - tolua_pushnumber(tolua_S,(lua_Number)a_PosY); - tolua_pushnumber(tolua_S,(lua_Number)a_PosZ); - } - } - return 3; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlayer__TeleportTo'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - /* method: cPlayer__MoveTo of class Lua__cPlayer */ #ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlayer_cPlayer__MoveTo00 static int tolua_AllToLua_Lua__cPlayer_cPlayer__MoveTo00(lua_State* tolua_S) @@ -8602,8 +9473,8 @@ static int tolua_AllToLua_cPlugin_OnTakeDamage00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err)) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; @@ -8611,16 +9482,17 @@ static int tolua_AllToLua_cPlugin_OnTakeDamage00(lua_State* tolua_S) #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0)); + cPawn* a_Receiver = ((cPawn*) tolua_tousertype(tolua_S,2,0)); TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnTakeDamage'", NULL); #endif { - self->OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool tolua_ret = (bool) self->OnTakeDamage(*a_Receiver,*a_TakeDamageInfo); + tolua_pushboolean(tolua_S,(bool)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'OnTakeDamage'.",&tolua_err); @@ -9366,13 +10238,16 @@ public: return ( bool ) cPlugin:: OnPreCrafting(a_Player,a_Grid,a_Recipe); }; }; - void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { + bool OnTakeDamage( cPawn& a_Receiver, TakeDamageInfo& a_TakeDamageInfo) { if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) { - tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn"); - tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo"); - ToluaBase::dbcall(lua_state, 3, 0); + tolua_pushusertype(lua_state, (void*)&a_Receiver, "cPawn"); + tolua_pushusertype(lua_state, (void*)&a_TakeDamageInfo, "TakeDamageInfo"); + ToluaBase::dbcall(lua_state, 3, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; } else { - return ( void ) cPlugin:: OnTakeDamage(a_Pawn,a_TakeDamageInfo); + return ( bool ) cPlugin:: OnTakeDamage(a_Receiver,a_TakeDamageInfo); }; }; bool OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4, cPlayer* a_Player) { @@ -9499,8 +10374,8 @@ public: bool cPlugin__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { return ( bool )cPlugin::OnPreCrafting(a_Player,a_Grid,a_Recipe); }; - void cPlugin__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { - return ( void )cPlugin::OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool cPlugin__OnTakeDamage( cPawn& a_Receiver, TakeDamageInfo& a_TakeDamageInfo) { + return ( bool )cPlugin::OnTakeDamage(a_Receiver,a_TakeDamageInfo); }; bool cPlugin__OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4, cPlayer* a_Player) { return ( bool )cPlugin::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4,a_Player); @@ -10235,8 +11110,8 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00(lua_State* tolua_ tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err)) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; @@ -10244,16 +11119,17 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00(lua_State* tolua_ #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0)); + cPawn* a_Receiver = ((cPawn*) tolua_tousertype(tolua_S,2,0)); TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnTakeDamage'", NULL); #endif { - self->cPlugin__OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool tolua_ret = (bool) self->cPlugin__OnTakeDamage(*a_Receiver,*a_TakeDamageInfo); + tolua_pushboolean(tolua_S,(bool)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'cPlugin__OnTakeDamage'.",&tolua_err); @@ -10919,13 +11795,16 @@ public: return ( bool ) cPlugin_NewLua:: OnPreCrafting(a_Player,a_Grid,a_Recipe); }; }; - void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { + bool OnTakeDamage( cPawn& a_Receiver, TakeDamageInfo& a_TakeDamageInfo) { if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) { - tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn"); - tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo"); - ToluaBase::dbcall(lua_state, 3, 0); + tolua_pushusertype(lua_state, (void*)&a_Receiver, "cPawn"); + tolua_pushusertype(lua_state, (void*)&a_TakeDamageInfo, "TakeDamageInfo"); + ToluaBase::dbcall(lua_state, 3, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; } else { - return ( void ) cPlugin_NewLua:: OnTakeDamage(a_Pawn,a_TakeDamageInfo); + return ( bool ) cPlugin_NewLua:: OnTakeDamage(a_Receiver,a_TakeDamageInfo); }; }; bool OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4, cPlayer* a_Player) { @@ -11055,8 +11934,8 @@ public: bool cPlugin_NewLua__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { return ( bool )cPlugin_NewLua::OnPreCrafting(a_Player,a_Grid,a_Recipe); }; - void cPlugin_NewLua__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { - return ( void )cPlugin_NewLua::OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool cPlugin_NewLua__OnTakeDamage( cPawn& a_Receiver, TakeDamageInfo& a_TakeDamageInfo) { + return ( bool )cPlugin_NewLua::OnTakeDamage(a_Receiver,a_TakeDamageInfo); }; bool cPlugin_NewLua__OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4, cPlayer* a_Player) { return ( bool )cPlugin_NewLua::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4,a_Player); @@ -12458,7 +13337,7 @@ static int tolua_AllToLua_cWorld_GetSpawnX00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSpawnX'", NULL); #endif { - const double tolua_ret = (const double) self->GetSpawnX(); + double tolua_ret = (double) self->GetSpawnX(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -12490,7 +13369,7 @@ static int tolua_AllToLua_cWorld_GetSpawnY00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSpawnY'", NULL); #endif { - const double tolua_ret = (const double) self->GetSpawnY(); + double tolua_ret = (double) self->GetSpawnY(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -12522,7 +13401,7 @@ static int tolua_AllToLua_cWorld_GetSpawnZ00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSpawnZ'", NULL); #endif { - const double tolua_ret = (const double) self->GetSpawnZ(); + double tolua_ret = (double) self->GetSpawnZ(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -13763,6 +14642,134 @@ static int tolua_AllToLua_cInventory_GetEquippedSlot00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: GetEquippedHelmet of class cInventory */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetEquippedHelmet00 +static int tolua_AllToLua_cInventory_GetEquippedHelmet00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cInventory",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cInventory* self = (const cInventory*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedHelmet'", NULL); +#endif + { + const cItem& tolua_ret = (const cItem&) self->GetEquippedHelmet(); + tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedHelmet'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedChestplate of class cInventory */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetEquippedChestplate00 +static int tolua_AllToLua_cInventory_GetEquippedChestplate00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cInventory",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cInventory* self = (const cInventory*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedChestplate'", NULL); +#endif + { + const cItem& tolua_ret = (const cItem&) self->GetEquippedChestplate(); + tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedChestplate'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedLeggings of class cInventory */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetEquippedLeggings00 +static int tolua_AllToLua_cInventory_GetEquippedLeggings00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cInventory",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cInventory* self = (const cInventory*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedLeggings'", NULL); +#endif + { + const cItem& tolua_ret = (const cItem&) self->GetEquippedLeggings(); + tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedLeggings'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEquippedBoots of class cInventory */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_GetEquippedBoots00 +static int tolua_AllToLua_cInventory_GetEquippedBoots00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cInventory",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cInventory* self = (const cInventory*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEquippedBoots'", NULL); +#endif + { + const cItem& tolua_ret = (const cItem&) self->GetEquippedBoots(); + tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEquippedBoots'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: SendSlot of class cInventory */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_SendSlot00 static int tolua_AllToLua_cInventory_SendSlot00(lua_State* tolua_S) @@ -22429,8 +23436,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_ITEM_WOODEN_PRESSURE_PLATE",E_ITEM_WOODEN_PRESSURE_PLATE); tolua_constant(tolua_S,"E_ITEM_REDSTONE_ORE",E_ITEM_REDSTONE_ORE); tolua_constant(tolua_S,"E_ITEM_REDSTONE_ORE_GLOWING",E_ITEM_REDSTONE_ORE_GLOWING); - tolua_constant(tolua_S,"E_ITEM_REDSTONE_TORCH_ON",E_ITEM_REDSTONE_TORCH_ON); tolua_constant(tolua_S,"E_ITEM_REDSTONE_TORCH_OFF",E_ITEM_REDSTONE_TORCH_OFF); + tolua_constant(tolua_S,"E_ITEM_REDSTONE_TORCH_ON",E_ITEM_REDSTONE_TORCH_ON); tolua_constant(tolua_S,"E_ITEM_STONE_BUTTON",E_ITEM_STONE_BUTTON); tolua_constant(tolua_S,"E_ITEM_SNOW",E_ITEM_SNOW); tolua_constant(tolua_S,"E_ITEM_ICE",E_ITEM_ICE); @@ -22813,6 +23820,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"eGameMode_NotSet",eGameMode_NotSet); tolua_constant(tolua_S,"eGameMode_Survival",eGameMode_Survival); tolua_constant(tolua_S,"eGameMode_Creative",eGameMode_Creative); + tolua_constant(tolua_S,"eGameMode_Adventure",eGameMode_Adventure); tolua_constant(tolua_S,"eWeather_Sunny",eWeather_Sunny); tolua_constant(tolua_S,"eWeather_Rain",eWeather_Rain); tolua_constant(tolua_S,"eWeather_ThunderStorm",eWeather_ThunderStorm); @@ -22929,30 +23937,82 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cEntity_new00_local); tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cEntity_delete00); tolua_endmodule(tolua_S); + tolua_constant(tolua_S,"dtAttack",dtAttack); + tolua_constant(tolua_S,"dtLightning",dtLightning); + tolua_constant(tolua_S,"dtFalling",dtFalling); + tolua_constant(tolua_S,"dtDrowning",dtDrowning); + tolua_constant(tolua_S,"dtSuffocating",dtSuffocating); + tolua_constant(tolua_S,"dtStarving",dtStarving); + tolua_constant(tolua_S,"dtCactusContact",dtCactusContact); + tolua_constant(tolua_S,"dtLavaContact",dtLavaContact); + tolua_constant(tolua_S,"dtPoisoning",dtPoisoning); + tolua_constant(tolua_S,"dtOnFire",dtOnFire); + tolua_constant(tolua_S,"dtFireContact",dtFireContact); + tolua_constant(tolua_S,"dtInVoid",dtInVoid); + tolua_constant(tolua_S,"dtPotionOfHarming",dtPotionOfHarming); + tolua_constant(tolua_S,"dtPawnAttack",dtPawnAttack); + tolua_constant(tolua_S,"dtEntityAttack",dtEntityAttack); + tolua_constant(tolua_S,"dtMob",dtMob); + tolua_constant(tolua_S,"dtMobAttack",dtMobAttack); + tolua_constant(tolua_S,"dtFall",dtFall); + tolua_constant(tolua_S,"dtDrown",dtDrown); + tolua_constant(tolua_S,"dtSuffocation",dtSuffocation); + tolua_constant(tolua_S,"dtStarvation",dtStarvation); + tolua_constant(tolua_S,"dtHunger",dtHunger); + tolua_constant(tolua_S,"dtCactus",dtCactus); + tolua_constant(tolua_S,"dtCactuses",dtCactuses); + tolua_constant(tolua_S,"dtCacti",dtCacti); + tolua_constant(tolua_S,"dtLava",dtLava); + tolua_constant(tolua_S,"dtPoison",dtPoison); + tolua_constant(tolua_S,"dtBurning",dtBurning); + tolua_constant(tolua_S,"dtInFire",dtInFire); tolua_cclass(tolua_S,"TakeDamageInfo","TakeDamageInfo","",NULL); tolua_beginmodule(tolua_S,"TakeDamageInfo"); - tolua_variable(tolua_S,"Damage",tolua_get_TakeDamageInfo_Damage,tolua_set_TakeDamageInfo_Damage); - tolua_variable(tolua_S,"Instigator",tolua_get_TakeDamageInfo_Instigator_ptr,tolua_set_TakeDamageInfo_Instigator_ptr); + tolua_variable(tolua_S,"DamageType",tolua_get_TakeDamageInfo_DamageType,tolua_set_TakeDamageInfo_DamageType); + tolua_variable(tolua_S,"Attacker",tolua_get_TakeDamageInfo_Attacker_ptr,tolua_set_TakeDamageInfo_Attacker_ptr); + tolua_variable(tolua_S,"RawDamage",tolua_get_TakeDamageInfo_RawDamage,tolua_set_TakeDamageInfo_RawDamage); + tolua_variable(tolua_S,"FinalDamage",tolua_get_TakeDamageInfo_FinalDamage,tolua_set_TakeDamageInfo_FinalDamage); + tolua_variable(tolua_S,"Knockback",tolua_get_TakeDamageInfo_Knockback,tolua_set_TakeDamageInfo_Knockback); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"cPawn","cPawn","cEntity",NULL); tolua_beginmodule(tolua_S,"cPawn"); tolua_function(tolua_S,"TeleportToEntity",tolua_AllToLua_cPawn_TeleportToEntity00); tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPawn_TeleportTo00); tolua_function(tolua_S,"Heal",tolua_AllToLua_cPawn_Heal00); + tolua_function(tolua_S,"GetHealth",tolua_AllToLua_cPawn_GetHealth00); tolua_function(tolua_S,"TakeDamage",tolua_AllToLua_cPawn_TakeDamage00); + tolua_function(tolua_S,"TakeDamage",tolua_AllToLua_cPawn_TakeDamage01); + tolua_function(tolua_S,"TakeDamage",tolua_AllToLua_cPawn_TakeDamage02); + tolua_function(tolua_S,"DoTakeDamage",tolua_AllToLua_cPawn_DoTakeDamage00); tolua_function(tolua_S,"KilledBy",tolua_AllToLua_cPawn_KilledBy00); - tolua_function(tolua_S,"GetHealth",tolua_AllToLua_cPawn_GetHealth00); + tolua_function(tolua_S,"GetRawDamageAgainst",tolua_AllToLua_cPawn_GetRawDamageAgainst00); + tolua_function(tolua_S,"GetArmorCoverAgainst",tolua_AllToLua_cPawn_GetArmorCoverAgainst00); + tolua_function(tolua_S,"GetKnockbackAmountAgainst",tolua_AllToLua_cPawn_GetKnockbackAmountAgainst00); + tolua_function(tolua_S,"GetEquippedWeapon",tolua_AllToLua_cPawn_GetEquippedWeapon00); + tolua_function(tolua_S,"GetEquippedHelmet",tolua_AllToLua_cPawn_GetEquippedHelmet00); + tolua_function(tolua_S,"GetEquippedChestplate",tolua_AllToLua_cPawn_GetEquippedChestplate00); + tolua_function(tolua_S,"GetEquippedLeggings",tolua_AllToLua_cPawn_GetEquippedLeggings00); + tolua_function(tolua_S,"GetEquippedBoots",tolua_AllToLua_cPawn_GetEquippedBoots00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"Lua__cPawn","Lua__cPawn","cPawn",NULL); tolua_beginmodule(tolua_S,"Lua__cPawn"); tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPawn_tolua__set_instance00); tolua_function(tolua_S,"cPawn__TeleportToEntity",tolua_AllToLua_Lua__cPawn_cPawn__TeleportToEntity00); tolua_function(tolua_S,"cPawn__TeleportTo",tolua_AllToLua_Lua__cPawn_cPawn__TeleportTo00); - tolua_function(tolua_S,"cPawn__TakeDamage",tolua_AllToLua_Lua__cPawn_cPawn__TakeDamage00); + tolua_function(tolua_S,"cPawn__DoTakeDamage",tolua_AllToLua_Lua__cPawn_cPawn__DoTakeDamage00); tolua_function(tolua_S,"cPawn__KilledBy",tolua_AllToLua_Lua__cPawn_cPawn__KilledBy00); + tolua_function(tolua_S,"cPawn__GetRawDamageAgainst",tolua_AllToLua_Lua__cPawn_cPawn__GetRawDamageAgainst00); + tolua_function(tolua_S,"cPawn__GetArmorCoverAgainst",tolua_AllToLua_Lua__cPawn_cPawn__GetArmorCoverAgainst00); + tolua_function(tolua_S,"cPawn__GetKnockbackAmountAgainst",tolua_AllToLua_Lua__cPawn_cPawn__GetKnockbackAmountAgainst00); + tolua_function(tolua_S,"cPawn__GetEquippedWeapon",tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedWeapon00); + tolua_function(tolua_S,"cPawn__GetEquippedHelmet",tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedHelmet00); + tolua_function(tolua_S,"cPawn__GetEquippedChestplate",tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedChestplate00); + tolua_function(tolua_S,"cPawn__GetEquippedLeggings",tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedLeggings00); + tolua_function(tolua_S,"cPawn__GetEquippedBoots",tolua_AllToLua_Lua__cPawn_cPawn__GetEquippedBoots00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"cPlayer","cPlayer","cPawn",NULL); tolua_beginmodule(tolua_S,"cPlayer"); + tolua_constant(tolua_S,"MAX_HEALTH",cPlayer::MAX_HEALTH); tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlayer_Initialize00); tolua_function(tolua_S,"GetEyeHeight",tolua_AllToLua_cPlayer_GetEyeHeight00); tolua_function(tolua_S,"GetEyePosition",tolua_AllToLua_cPlayer_GetEyePosition00); @@ -22960,7 +24020,6 @@ 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,"TeleportTo",tolua_AllToLua_cPlayer_TeleportTo00); tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cPlayer_GetGameMode00); tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00); tolua_function(tolua_S,"GetLastBlockActionTime",tolua_AllToLua_cPlayer_GetLastBlockActionTime00); @@ -22987,8 +24046,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetMaxFoodSaturationLevel",tolua_AllToLua_cPlayer_GetMaxFoodSaturationLevel00); tolua_function(tolua_S,"GetFoodSaturationLevel",tolua_AllToLua_cPlayer_GetFoodSaturationLevel00); tolua_function(tolua_S,"AddFoodExhaustion",tolua_AllToLua_cPlayer_AddFoodExhaustion00); - tolua_function(tolua_S,"TakeDamage",tolua_AllToLua_cPlayer_TakeDamage00); - tolua_function(tolua_S,"KilledBy",tolua_AllToLua_cPlayer_KilledBy00); tolua_function(tolua_S,"Respawn",tolua_AllToLua_cPlayer_Respawn00); tolua_function(tolua_S,"SetVisible",tolua_AllToLua_cPlayer_SetVisible00); tolua_function(tolua_S,"IsVisible",tolua_AllToLua_cPlayer_IsVisible00); @@ -22999,7 +24056,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_beginmodule(tolua_S,"Lua__cPlayer"); tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPlayer_tolua__set_instance00); tolua_function(tolua_S,"cPlayer__Initialize",tolua_AllToLua_Lua__cPlayer_cPlayer__Initialize00); - tolua_function(tolua_S,"cPlayer__TeleportTo",tolua_AllToLua_Lua__cPlayer_cPlayer__TeleportTo00); tolua_function(tolua_S,"cPlayer__MoveTo",tolua_AllToLua_Lua__cPlayer_cPlayer__MoveTo00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"cPluginManager","cPluginManager","",NULL); @@ -23229,6 +24285,10 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetEquippedItem",tolua_AllToLua_cInventory_GetEquippedItem00); tolua_function(tolua_S,"SetEquippedSlot",tolua_AllToLua_cInventory_SetEquippedSlot00); tolua_function(tolua_S,"GetEquippedSlot",tolua_AllToLua_cInventory_GetEquippedSlot00); + tolua_function(tolua_S,"GetEquippedHelmet",tolua_AllToLua_cInventory_GetEquippedHelmet00); + tolua_function(tolua_S,"GetEquippedChestplate",tolua_AllToLua_cInventory_GetEquippedChestplate00); + tolua_function(tolua_S,"GetEquippedLeggings",tolua_AllToLua_cInventory_GetEquippedLeggings00); + tolua_function(tolua_S,"GetEquippedBoots",tolua_AllToLua_cInventory_GetEquippedBoots00); tolua_function(tolua_S,"SendSlot",tolua_AllToLua_cInventory_SendSlot00); tolua_endmodule(tolua_S); #ifdef __cplusplus diff --git a/source/Bindings.h b/source/Bindings.h index b51c94b8f..ccf2051d8 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 11/20/12 22:18:11. +** Generated automatically by tolua++-1.0.92 on 12/21/12 19:26:06. */ /* Exported function */ diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 8148c081e..ffcda9bda 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -918,7 +918,7 @@ void cClientHandle::HandleUseEntity(int a_TargetEntityID, bool a_IsLeftClick) if (!a_Entity->GetWorld()->IsPVPEnabled()) { // PVP is disabled - if (a_Entity->IsA("cPlayer") && Instigator->IsA("cPlayer")) + if (a_Entity->IsA("cPlayer") && m_Attacker->IsA("cPlayer")) { // Player is hurting another player which is not allowed when PVP is disabled so ignore it return true; @@ -926,17 +926,15 @@ void cClientHandle::HandleUseEntity(int a_TargetEntityID, bool a_IsLeftClick) } if (a_Entity->IsA("cPawn")) { - reinterpret_cast<cPawn *>(a_Entity)->TakeDamage(Damage, Instigator); + reinterpret_cast<cPawn *>(a_Entity)->TakeDamage(*m_Attacker); } return true; } public: - int Damage; - cEntity * Instigator; + cPawn * m_Attacker; } Callback; - Callback.Damage = 1; // TODO: Find proper damage from current item equipped - Callback.Instigator = m_Player; + Callback.m_Attacker = m_Player; cWorld * World = m_Player->GetWorld(); World->DoWithEntityByID(a_TargetEntityID, Callback); diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index 4cc74ec2b..24ce88184 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -7,7 +7,7 @@ -cBat::cBat()
+cBat::cBat(void)
{
m_MobType = 65;
GetMonsterConfig("Bat");
@@ -17,29 +17,12 @@ cBat::cBat() -cBat::~cBat()
+bool cBat::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cBat") == 0) || super::IsA(a_EntityType));
}
-bool cBat::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cBat" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cBat::KilledBy( cEntity* a_Killer )
-{
- cMonster::KilledBy( a_Killer );
-}
-
-
-
-
diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h index 94ae595d0..7965072fc 100644 --- a/source/Mobs/Bat.h +++ b/source/Mobs/Bat.h @@ -1,14 +1,23 @@ +
#pragma once
#include "PassiveMonster.h"
-class cBat : public cPassiveMonster
+
+
+
+
+class cBat :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cBat();
- ~cBat();
+ cBat(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp index c3e68518f..e53cbb44d 100644 --- a/source/Mobs/Blaze.cpp +++ b/source/Mobs/Blaze.cpp @@ -7,7 +7,7 @@ -cBlaze::cBlaze()
+cBlaze::cBlaze(void)
{
m_MobType = 61;
GetMonsterConfig("Blaze");
@@ -17,31 +17,18 @@ cBlaze::cBlaze() -cBlaze::~cBlaze()
+bool cBlaze::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cBlaze") == 0) || super::IsA(a_EntityType));
}
-bool cBlaze::IsA( const char* a_EntityType )
+void cBlaze::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cBlaze" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cBlaze::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 1, E_ITEM_BLAZE_ROD);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD);
}
diff --git a/source/Mobs/Blaze.h b/source/Mobs/Blaze.h index bd722d529..6dca7fed0 100644 --- a/source/Mobs/Blaze.h +++ b/source/Mobs/Blaze.h @@ -1,14 +1,25 @@ +
#pragma once
#include "AggressiveMonster.h"
-class cBlaze : public cAggressiveMonster
+
+
+
+
+class cBlaze :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
- cBlaze();
- ~cBlaze();
+ cBlaze(void);
+
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp index 6c7ed0a7a..9336f8f5b 100644 --- a/source/Mobs/Cavespider.cpp +++ b/source/Mobs/Cavespider.cpp @@ -7,7 +7,7 @@ -cCavespider::cCavespider() +cCavespider::cCavespider(void) { m_MobType = 59; GetMonsterConfig("Cavespider"); @@ -17,18 +17,9 @@ cCavespider::cCavespider() -cCavespider::~cCavespider() +bool cCavespider::IsA(const char * a_EntityType) { -} - - - - - -bool cCavespider::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cCavespider" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); + return ((strcmp(a_EntityType, "cCaveSpider") == 0) || super::IsA(a_EntityType)); } @@ -37,7 +28,8 @@ bool cCavespider::IsA( const char* a_EntityType ) void cCavespider::Tick(float a_Dt) { - cMonster::Tick(a_Dt); + super::Tick(a_Dt); + // TODO: Check vanilla if cavespiders really get passive during the day m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; } @@ -45,13 +37,10 @@ void cCavespider::Tick(float a_Dt) -void cCavespider::KilledBy( cEntity* a_Killer ) +void cCavespider::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_STRING); - AddRandomDropItem(Drops, 0, 1, E_ITEM_SPIDER_EYE); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING); + AddRandomDropItem(a_Drops, 0, 1, E_ITEM_SPIDER_EYE); } diff --git a/source/Mobs/Cavespider.h b/source/Mobs/Cavespider.h index 163bb1f92..10b462bea 100644 --- a/source/Mobs/Cavespider.h +++ b/source/Mobs/Cavespider.h @@ -1,15 +1,26 @@ + #pragma once #include "AggressiveMonster.h" -class cCavespider : public cAggressiveMonster + + + + +class cCavespider : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: - cCavespider(); - ~cCavespider(); + cCavespider(void); + + virtual bool IsA(const char * a_EntityType) override; + + virtual void Tick(float a_Dt) override; + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + - virtual bool IsA( const char* a_EntityType ); - virtual void Tick(float a_Dt); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index 940491ad4..cd282f5ed 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -7,13 +7,13 @@ -// TODO Drop egg every 5-10 minutes +// TODO: Drop egg every 5-10 minutes -cChicken::cChicken() +cChicken::cChicken(void) { m_MobType = 93; GetMonsterConfig("Chicken"); @@ -23,32 +23,19 @@ cChicken::cChicken() -cChicken::~cChicken() +bool cChicken::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cChicken") == 0) || super::IsA(a_EntityType)); } -bool cChicken::IsA( const char* a_EntityType ) +void cChicken::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cChicken" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cChicken::KilledBy( cEntity* a_Killer ) -{ - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_FEATHER); - Drops.push_back(cItem((GetMetaData() == BURNING) ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN, 1)); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_FEATHER); + a_Drops.push_back(cItem((GetMetaData() == BURNING) ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN, 1)); } diff --git a/source/Mobs/Chicken.h b/source/Mobs/Chicken.h index acfb202e3..49c88a059 100644 --- a/source/Mobs/Chicken.h +++ b/source/Mobs/Chicken.h @@ -1,14 +1,25 @@ + #pragma once #include "PassiveMonster.h" -class cChicken : public cPassiveMonster + + + + +class cChicken : + public cPassiveMonster { + typedef cPassiveMonster super; + public: - cChicken(); - ~cChicken(); + cChicken(void); + + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + - virtual bool IsA( const char* a_EntityType ); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index 0d107e1b5..8e1837434 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -13,7 +13,7 @@ -cCow::cCow() +cCow::cCow(void) { m_MobType = 92; GetMonsterConfig("Cow"); @@ -23,32 +23,19 @@ cCow::cCow() -cCow::~cCow() +bool cCow::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cCow") == 0) || super::IsA(a_EntityType)); } -bool cCow::IsA( const char* a_EntityType ) +void cCow::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cCow" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cCow::KilledBy( cEntity* a_Killer ) -{ - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_LEATHER); - AddRandomDropItem(Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); + AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); } diff --git a/source/Mobs/Cow.h b/source/Mobs/Cow.h index bb604bad4..cc7db7af9 100644 --- a/source/Mobs/Cow.h +++ b/source/Mobs/Cow.h @@ -1,14 +1,25 @@ + #pragma once #include "PassiveMonster.h" -class cCow : public cPassiveMonster + + + + +class cCow : + public cPassiveMonster { + typedef cPassiveMonster super; + public: cCow(); - ~cCow(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp index b42d5690b..d247df96c 100644 --- a/source/Mobs/Creeper.cpp +++ b/source/Mobs/Creeper.cpp @@ -7,7 +7,7 @@ -cCreeper::cCreeper() +cCreeper::cCreeper(void) { m_MobType = 50; GetMonsterConfig("Creeper"); @@ -17,34 +17,20 @@ cCreeper::cCreeper() -cCreeper::~cCreeper() +bool cCreeper::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cCreeper") == 0) || super::IsA(a_EntityType)); } -bool cCreeper::IsA( const char* a_EntityType ) +void cCreeper::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cCreeper" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cCreeper::KilledBy( cEntity* a_Killer ) -{ - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_GUNPOWDER); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER); // TODO Check if killed by a skeleton, then drop random music disk - - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); } diff --git a/source/Mobs/Creeper.h b/source/Mobs/Creeper.h index e5c755103..bd6b1e992 100644 --- a/source/Mobs/Creeper.h +++ b/source/Mobs/Creeper.h @@ -1,14 +1,25 @@ + #pragma once #include "AggressiveMonster.h" -class cCreeper : public cAggressiveMonster + + + + +class cCreeper : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: - cCreeper(); - ~cCreeper(); + cCreeper(void); + + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + - virtual bool IsA( const char* a_EntityType ); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp index 216fab85f..b41f8f405 100644 --- a/source/Mobs/Enderman.cpp +++ b/source/Mobs/Enderman.cpp @@ -7,7 +7,7 @@ -cEnderman::cEnderman() +cEnderman::cEnderman(void) { m_MobType = 58; GetMonsterConfig("Enderman"); @@ -17,18 +17,9 @@ cEnderman::cEnderman() -cEnderman::~cEnderman() +bool cEnderman::IsA(const char * a_EntityType) { -} - - - - - -bool cEnderman::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cEnderman" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); + return ((strcmp(a_EntityType, "cEnderman") == 0) || super::IsA(a_EntityType)); } @@ -50,13 +41,9 @@ void cEnderman::Tick(float a_Dt) -void cEnderman::KilledBy( cEntity* a_Killer ) +void cEnderman::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - cItems Drops; - AddRandomDropItem(Drops, 0, 1, E_ITEM_ENDER_PEARL); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ENDER_PEARL); } diff --git a/source/Mobs/Enderman.h b/source/Mobs/Enderman.h index 788cc1314..b175e8b1b 100644 --- a/source/Mobs/Enderman.h +++ b/source/Mobs/Enderman.h @@ -1,15 +1,26 @@ + #pragma once #include "PassiveAggressiveMonster.h" -class cEnderman : public cPassiveAggressiveMonster + + + + +class cEnderman : + public cPassiveAggressiveMonster { + typedef cPassiveAggressiveMonster super; + public: - cEnderman(); - ~cEnderman(); + cEnderman(void); + + virtual bool IsA(const char * a_EntityType) override; + + virtual void Tick(float a_Dt) override; + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + - virtual bool IsA( const char* a_EntityType ); - virtual void Tick(float a_Dt); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp index 4993f25c0..3bcb5e4ab 100644 --- a/source/Mobs/Ghast.cpp +++ b/source/Mobs/Ghast.cpp @@ -7,7 +7,7 @@ -cGhast::cGhast() +cGhast::cGhast(void) { m_MobType = 56; GetMonsterConfig("Ghast"); @@ -17,31 +17,19 @@ cGhast::cGhast() -cGhast::~cGhast() +bool cGhast::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cGhast") == 0) || super::IsA(a_EntityType)); } -bool cGhast::IsA( const char* a_EntityType ) +void cGhast::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cGhast" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cGhast::KilledBy( cEntity* a_Killer ) -{ - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_GUNPOWDER); - AddRandomDropItem(Drops, 0, 1, E_ITEM_GHAST_TEAR); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER); + AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GHAST_TEAR); } diff --git a/source/Mobs/Ghast.h b/source/Mobs/Ghast.h index 6991419e7..e6248b656 100644 --- a/source/Mobs/Ghast.h +++ b/source/Mobs/Ghast.h @@ -1,14 +1,25 @@ + #pragma once #include "AggressiveMonster.h" -class cGhast : public cAggressiveMonster + + + + +class cGhast : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: - cGhast(); - ~cGhast(); + cGhast(void); + + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + - virtual bool IsA( const char* a_EntityType ); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index d73041baf..21c6f17b3 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -17,31 +17,18 @@ cMagmacube::cMagmacube() -cMagmacube::~cMagmacube()
+bool cMagmacube::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cMagmacube") == 0) || super::IsA(a_EntityType));
}
-bool cMagmacube::IsA( const char* a_EntityType )
+void cMagmacube::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cMagmacube" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cMagmacube::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 1, E_ITEM_MAGMA_CREAM);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM);
}
diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h index 1a36ef2c1..8c61a7853 100644 --- a/source/Mobs/Magmacube.h +++ b/source/Mobs/Magmacube.h @@ -1,14 +1,25 @@ +
#pragma once
#include "AggressiveMonster.h"
-class cMagmacube : public cAggressiveMonster
+
+
+
+
+class cMagmacube :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cMagmacube();
- ~cMagmacube();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 82d69df57..88cfcd992 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -28,8 +28,8 @@ -cMonster::cMonster() - : m_Target(0) +cMonster::cMonster(void) + : m_Target(NULL) , m_bMovingToDestination(false) , m_DestinationTime( 0 ) , m_Gravity( -9.81f) @@ -318,20 +318,23 @@ void cMonster::HandlePhysics(float a_Dt) -void cMonster::TakeDamage(int a_Damage, cEntity* a_Instigator) +void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - cPawn::TakeDamage( a_Damage, a_Instigator ); - m_Target = a_Instigator; - AddReference( m_Target ); + super::DoTakeDamage(a_TDI); + if (a_TDI.Attacker != NULL) + { + m_Target = a_TDI.Attacker; + AddReference(m_Target); + } } -void cMonster::KilledBy( cEntity* a_Killer ) +void cMonster::KilledBy(cPawn * a_Killer) { - cPawn::KilledBy( a_Killer ); + super::KilledBy(a_Killer); m_DestroyTimer = 0; } @@ -513,7 +516,7 @@ void cMonster::Attack(float a_Dt) { // Setting this higher gives us more wiggle room for attackrate m_AttackInterval = 0.0; - ((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage, this); + ((cPawn *)m_Target)->TakeDamage(*this); } } diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index f0da23977..6d3d1d775 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -17,14 +17,18 @@ class cClientHandle; -class cMonster : public cPawn //tolua_export -{ //tolua_export +// tolua_begin +class cMonster : + public cPawn +{ + typedef cPawn super; public: - - cMonster(); + // tolua_end + + cMonster(void); virtual ~cMonster(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType); virtual void SpawnOn(cClientHandle & a_ClientHandle) override; @@ -33,8 +37,9 @@ public: virtual void HandlePhysics(float a_Dt); virtual void ReplicateMovement(void); - virtual void TakeDamage(int a_Damage, cEntity * a_Instigator) override; - virtual void KilledBy(cEntity * a_Killer) override; + virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; + + virtual void KilledBy(cPawn * a_Killer) override; virtual void MoveToPosition(const Vector3f & a_Position); virtual bool ReachedDestination(void); @@ -47,7 +52,7 @@ public: virtual void CheckEventSeePlayer(); virtual void EventSeePlayer(cEntity *); float m_SightDistance; - virtual cPlayer *FindClosestPlayer(); //non static is easier. also virtual so other mobs can implement their own searching algo + virtual cPlayer * FindClosestPlayer(); // non static is easier. also virtual so other mobs can implement their own searching algo virtual void GetMonsterConfig(const char* pm_name); virtual void EventLosePlayer(); virtual void CheckEventLostPlayer(); @@ -69,7 +74,7 @@ public: protected: - cEntity* m_Target; + cEntity * m_Target; float m_AttackRate; float idle_interval; @@ -94,7 +99,7 @@ protected: float m_AttackInterval; void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); -}; //tolua_export +} ; // tolua_export diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp index f70349e97..0732b3fea 100644 --- a/source/Mobs/Mooshroom.cpp +++ b/source/Mobs/Mooshroom.cpp @@ -13,7 +13,7 @@ -cMooshroom::cMooshroom()
+cMooshroom::cMooshroom(void)
{
m_MobType = 96;
GetMonsterConfig("Mooshroom");
@@ -23,32 +23,19 @@ cMooshroom::cMooshroom() -cMooshroom::~cMooshroom()
+bool cMooshroom::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cMooshroom") == 0) || super::IsA(a_EntityType));
}
-bool cMooshroom::IsA( const char* a_EntityType )
+void cMooshroom::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cMooshroom" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cMooshroom::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 2, E_ITEM_LEATHER);
- AddRandomDropItem(Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
+ AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
}
diff --git a/source/Mobs/Mooshroom.h b/source/Mobs/Mooshroom.h index ea8ed5b08..b15bfc76f 100644 --- a/source/Mobs/Mooshroom.h +++ b/source/Mobs/Mooshroom.h @@ -1,14 +1,25 @@ +
#pragma once
#include "PassiveMonster.h"
-class cMooshroom : public cPassiveMonster
+
+
+
+
+class cMooshroom :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
- cMooshroom();
- ~cMooshroom();
+ cMooshroom(void);
+
+ virtual bool IsA(const char * a_EntityType);
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
- virtual bool IsA( const char* a_EntityType );
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Ocelot.cpp b/source/Mobs/Ocelot.cpp index ec50a9656..374161bde 100644 --- a/source/Mobs/Ocelot.cpp +++ b/source/Mobs/Ocelot.cpp @@ -17,29 +17,12 @@ cOcelot::cOcelot() -cOcelot::~cOcelot()
+bool cOcelot::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cOcelot") == 0) || super::IsA(a_EntityType));
}
-bool cOcelot::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cOcelot" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cOcelot::KilledBy( cEntity* a_Killer )
-{
- cMonster::KilledBy( a_Killer );
-}
-
-
-
-
diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h index 87571022f..07095c660 100644 --- a/source/Mobs/Ocelot.h +++ b/source/Mobs/Ocelot.h @@ -1,14 +1,23 @@ +
#pragma once
#include "PassiveMonster.h"
-class cOcelot : public cPassiveMonster
+
+
+
+
+class cOcelot :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
cOcelot();
- ~cOcelot();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp index 9d9e156ee..465c302a1 100644 --- a/source/Mobs/PassiveAggressiveMonster.cpp +++ b/source/Mobs/PassiveAggressiveMonster.cpp @@ -9,30 +9,27 @@ -cPassiveAggressiveMonster::cPassiveAggressiveMonster() +cPassiveAggressiveMonster::cPassiveAggressiveMonster(void) { m_EMPersonality = PASSIVE; } -cPassiveAggressiveMonster::~cPassiveAggressiveMonster() -{ -} -void cPassiveAggressiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator) + + + +void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - cMonster::TakeDamage(a_Damage, a_Instigator); - if(m_Target->GetEntityType() == cEntity::eEntityType_Player) + if ((m_Target != NULL) && (m_Target->GetEntityType() == cEntity::eEntityType_Player)) { cPlayer * Player = (cPlayer *) m_Target; - if(Player->GetGameMode() != 1) + if (Player->GetGameMode() != 1) { m_EMState = CHASING; } } - } -void cPassiveAggressiveMonster::EventSeePlayer(cEntity *a_Entity) -{ - return cMonster::EventSeePlayer(a_Entity); -}
\ No newline at end of file + + + diff --git a/source/Mobs/PassiveAggressiveMonster.h b/source/Mobs/PassiveAggressiveMonster.h index 972d2a11d..e6e50677d 100644 --- a/source/Mobs/PassiveAggressiveMonster.h +++ b/source/Mobs/PassiveAggressiveMonster.h @@ -1,13 +1,23 @@ + #pragma once #include "AggressiveMonster.h" -class cPassiveAggressiveMonster : public cAggressiveMonster + + + + +class cPassiveAggressiveMonster : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: - cPassiveAggressiveMonster(); - ~cPassiveAggressiveMonster(); + cPassiveAggressiveMonster(void); + + virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; +} ; + + + - virtual void TakeDamage(int a_Damage, cEntity* a_Instigator); - void EventSeePlayer(cEntity *a_Entity); -}; diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp index bc3f70b4b..6224b284a 100644 --- a/source/Mobs/PassiveMonster.cpp +++ b/source/Mobs/PassiveMonster.cpp @@ -8,39 +8,50 @@ -cPassiveMonster::cPassiveMonster() +cPassiveMonster::cPassiveMonster(void) { m_EMPersonality = PASSIVE; } -cPassiveMonster::~cPassiveMonster() -{ -} -void cPassiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator) + + + +void cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - cMonster::TakeDamage(a_Damage, a_Instigator); - if(a_Instigator != this) + super::DoTakeDamage(a_TDI); + if ((a_TDI.Attacker != this) && (a_TDI.Attacker != NULL)) + { m_EMState = ESCAPING; + } } + + + + void cPassiveMonster::Tick(float a_Dt) { cMonster::Tick(a_Dt); m_SeePlayerInterval += a_Dt; - if(m_SeePlayerInterval > 1) + if (m_SeePlayerInterval > 1) // Check every second { MTRand r1; - int rem = r1.randInt() % 3 + 1; //check most of the time but miss occasionally + int rem = r1.randInt() % 3 + 1; // Check most of the time but miss occasionally m_SeePlayerInterval = 0.0; - if(rem >= 2) { - if(m_EMState == ESCAPING) + if (rem >= 2) + { + if (m_EMState == ESCAPING) { CheckEventLostPlayer(); } } } -}
\ No newline at end of file +} + + + + diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h index 1265dc737..14a4e9d24 100644 --- a/source/Mobs/PassiveMonster.h +++ b/source/Mobs/PassiveMonster.h @@ -1,14 +1,26 @@ + #pragma once #include "Monster.h" -class cPassiveMonster : public cMonster + + + + +class cPassiveMonster : + public cMonster { + typedef cMonster super; + public: - cPassiveMonster(); - ~cPassiveMonster(); + cPassiveMonster(void); + + virtual void Tick(float a_Dt) override; + + /// When hit by someone, run away + virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; +} ; + + - virtual void Tick(float a_Dt); - virtual void TakeDamage(int a_Damage, cEntity* a_Instigator); -}; diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp index 48954dc73..8abd0a10e 100644 --- a/source/Mobs/Pig.cpp +++ b/source/Mobs/Pig.cpp @@ -7,7 +7,7 @@ -cPig::cPig() +cPig::cPig(void) { m_MobType = 90; GetMonsterConfig("Pig"); @@ -17,33 +17,18 @@ cPig::cPig() -cPig::~cPig() +bool cPig::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cPig") == 0) || super::IsA(a_EntityType)); } -bool cPig::IsA( const char* a_EntityType ) +void cPig::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cPig" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cPig::KilledBy( cEntity* a_Killer ) -{ - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_RAW_MEAT); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - // TODO: Check for burning state - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_MEAT); } diff --git a/source/Mobs/Pig.h b/source/Mobs/Pig.h index e701535ba..018477778 100644 --- a/source/Mobs/Pig.h +++ b/source/Mobs/Pig.h @@ -1,14 +1,25 @@ + #pragma once #include "PassiveMonster.h" -class cPig : public cPassiveMonster + + + + +class cPig : + public cPassiveMonster { + typedef cPassiveMonster super; + public: - cPig(); - ~cPig(); + cPig(void); + + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + - virtual bool IsA( const char* a_EntityType ); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 1f5f1815f..9c67aba29 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -2,12 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Sheep.h" - - - - - -//Todo: Implement color +#include "../BlockID.h" @@ -15,7 +10,7 @@ cSheep::cSheep(void) : m_IsSheared(false), - m_WoolColor(0) // TODO: E_META_WOOL_WHITE + m_WoolColor(E_META_WOOL_WHITE) { m_MobType = 91; GetMonsterConfig("Sheep"); @@ -25,41 +20,23 @@ cSheep::cSheep(void) : -cSheep::~cSheep() +bool cSheep::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cSheep") == 0) || super::IsA(a_EntityType)); } -bool cSheep::IsA( const char* a_EntityType ) +void cSheep::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if (strcmp( a_EntityType, "cSheep" ) == 0) - { - return true; - } - return cMonster::IsA( a_EntityType ); -} - - - - - -void cSheep::KilledBy( cEntity* a_Killer ) -{ - // TODO: Check whether it is sheared - // TODO: Check color - if (!m_IsSheared) { - cItems Drops; - Drops.push_back(cItem(E_ITEM_WHITE_CLOTH, 1, m_WoolColor)); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); + a_Drops.push_back(cItem(E_ITEM_WHITE_CLOTH, 1, m_WoolColor)); } - - cMonster::KilledBy( a_Killer ); } + diff --git a/source/Mobs/Sheep.h b/source/Mobs/Sheep.h index 28c2b97dc..ea43537cc 100644 --- a/source/Mobs/Sheep.h +++ b/source/Mobs/Sheep.h @@ -1,17 +1,28 @@ + #pragma once #include "PassiveMonster.h" -class cSheep : public cPassiveMonster + + + + +class cSheep : + public cPassiveMonster { + typedef cPassiveMonster super; + public: - cSheep(); - ~cSheep(); + cSheep(void); bool m_IsSheared; NIBBLETYPE m_WoolColor; // Uses E_META_WOOL_ constants for colors - virtual bool IsA(const char * a_EntityType); + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual void KilledBy(cEntity * a_Killer); -}; diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h index fe23a4ba1..453995ec6 100644 --- a/source/Mobs/Silverfish.h +++ b/source/Mobs/Silverfish.h @@ -8,5 +8,5 @@ public: cSilverfish(); ~cSilverfish(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType); }; diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index b35cdb68e..f219713e0 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -7,7 +7,7 @@ -cSkeleton::cSkeleton() +cSkeleton::cSkeleton(void) { m_MobType = 51; GetMonsterConfig("Skeleton"); @@ -17,18 +17,9 @@ cSkeleton::cSkeleton() -cSkeleton::~cSkeleton() -{ -} - - - - - bool cSkeleton::IsA( const char* a_EntityType ) { - if( strcmp( a_EntityType, "cSkeleton" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); + return ((strcmp(a_EntityType, "cSkeleton") == 0) || super::IsA(a_EntityType)); } @@ -51,14 +42,10 @@ void cSkeleton::Tick(float a_Dt) -void cSkeleton::KilledBy( cEntity* a_Killer ) +void cSkeleton::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_ARROW); - AddRandomDropItem(Drops, 0, 2, E_ITEM_BONE); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ARROW); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_BONE); } diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h index 84a434905..101358f18 100644 --- a/source/Mobs/Skeleton.h +++ b/source/Mobs/Skeleton.h @@ -1,16 +1,26 @@ + #pragma once #include "AggressiveMonster.h" -class cSkeleton : public cAggressiveMonster + + + + +class cSkeleton : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: cSkeleton(); - ~cSkeleton(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType) override; + + virtual void Tick(float a_Dt) override; + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual void Tick(float a_Dt); - virtual void KilledBy( cEntity* a_Killer ); - -}; diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp index b8dc52d7c..d85b97c97 100644 --- a/source/Mobs/Slime.cpp +++ b/source/Mobs/Slime.cpp @@ -3,13 +3,13 @@ #include "Slime.h" -//TODO Implement sized slimes +// TODO: Implement sized slimes -cSlime::cSlime() +cSlime::cSlime(void) { m_MobType = 55; GetMonsterConfig("Slime"); @@ -19,32 +19,19 @@ cSlime::cSlime() -cSlime::~cSlime() +bool cSlime::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cSlime") == 0) || super::IsA(a_EntityType)); } -bool cSlime::IsA( const char* a_EntityType ) +void cSlime::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cSlime" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cSlime::KilledBy( cEntity* a_Killer ) -{ - //TODO: only when tiny - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_SLIMEBALL); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + // TODO: only when tiny + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_SLIMEBALL); } diff --git a/source/Mobs/Slime.h b/source/Mobs/Slime.h index cceac617d..1f155e6f8 100644 --- a/source/Mobs/Slime.h +++ b/source/Mobs/Slime.h @@ -1,14 +1,21 @@ + #pragma once #include "AggressiveMonster.h" -class cSlime : public cAggressiveMonster +class cSlime : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: cSlime(); - ~cSlime(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp index dfa7a8a6a..82a24f9b3 100644 --- a/source/Mobs/Spider.cpp +++ b/source/Mobs/Spider.cpp @@ -17,32 +17,19 @@ cSpider::cSpider() -cSpider::~cSpider() +bool cSpider::IsA(const char * a_EntityType) { + return ((strcmp(a_EntityType, "cSpider") == 0) || super::IsA(a_EntityType)); } -bool cSpider::IsA( const char* a_EntityType ) +void cSpider::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - if( strcmp( a_EntityType, "cSpider" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} - - - - - -void cSpider::KilledBy( cEntity* a_Killer ) -{ - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_STRING); - AddRandomDropItem(Drops, 0, 1, E_ITEM_SPIDER_EYE); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING); + AddRandomDropItem(a_Drops, 0, 1, E_ITEM_SPIDER_EYE); } diff --git a/source/Mobs/Spider.h b/source/Mobs/Spider.h index 12133bdb8..c375df593 100644 --- a/source/Mobs/Spider.h +++ b/source/Mobs/Spider.h @@ -1,14 +1,25 @@ + #pragma once #include "AggressiveMonster.h" -class cSpider : public cAggressiveMonster + + + + +class cSpider : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: cSpider(); - ~cSpider(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType) override; + + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp index f88c295a4..720eb05e5 100644 --- a/source/Mobs/Squid.cpp +++ b/source/Mobs/Squid.cpp @@ -12,32 +12,25 @@ cSquid::cSquid() { m_MobType = 94; GetMonsterConfig("Squid"); - m_NoWater = 0.f; } -cSquid::~cSquid() -{ - -} -bool cSquid::IsA( const char* a_EntityType ) + + + +bool cSquid::IsA(const char * a_EntityType) { - if( strcmp( a_EntityType, "cSquid" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); + return ((strcmp(a_EntityType, "cSquid") == 0) || super::IsA(a_EntityType)); } -void cSquid::KilledBy( cEntity* a_Killer ) +void cSquid::GetDrops(cItems & a_Drops, cPawn * a_Killer) { // Drops 0-3 Ink Sacs - cItems Drops; - AddRandomDropItem(Drops, 0, 3, E_ITEM_DYE, E_META_DYE_BLACK); - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); + AddRandomDropItem(a_Drops, 0, 3, E_ITEM_DYE, E_META_DYE_BLACK); } @@ -46,15 +39,17 @@ void cSquid::KilledBy( cEntity* a_Killer ) void cSquid::Tick(float a_Dt) { - cPassiveMonster::Tick(a_Dt); + super::Tick(a_Dt); Vector3d Pos = GetPosition(); - - //TODO Not a real behavior, but cool :D - if(!IsBlockWater(GetWorld()->GetBlock((int) Pos.x, (int) Pos.y, (int) Pos.z)) && GetMetaData() != BURNING) + // TODO: Not a real behavior, but cool :D + if (!IsBlockWater(GetWorld()->GetBlock((int) Pos.x, (int) Pos.y, (int) Pos.z)) && GetMetaData() != BURNING) { SetMetaData(BURNING); } +} + + + -}
\ No newline at end of file diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h index eaf13b5c7..6500a3fea 100644 --- a/source/Mobs/Squid.h +++ b/source/Mobs/Squid.h @@ -1,18 +1,26 @@ + #pragma once #include "PassiveMonster.h" -class cSquid : public cPassiveMonster + + + + +class cSquid : + public cPassiveMonster { + typedef cPassiveMonster super; + public: cSquid(); - ~cSquid(); - virtual void Tick(float a_Dt); + virtual void Tick(float a_Dt) override; + + virtual bool IsA(const char * a_EntityType) override; + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual bool IsA( const char* a_EntityType ); - virtual void KilledBy( cEntity* a_Killer ); - -protected: - float m_NoWater; -}; diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp index 65b2ac5b5..0e6d364d7 100644 --- a/source/Mobs/Villager.cpp +++ b/source/Mobs/Villager.cpp @@ -17,27 +17,9 @@ cVillager::cVillager() -cVillager::~cVillager()
+bool cVillager::IsA(const char * a_EntityType)
{
-}
-
-
-
-
-
-bool cVillager::IsA( const char* a_EntityType )
-{
- if( strcmp( a_EntityType, "cVillager" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cVillager::KilledBy( cEntity* a_Killer )
-{
- cMonster::KilledBy( a_Killer );
+ return ((strcmp(a_EntityType, "cVillager") == 0) || super::IsA(a_EntityType));
}
diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h index 02272378b..74a6af868 100644 --- a/source/Mobs/Villager.h +++ b/source/Mobs/Villager.h @@ -1,14 +1,23 @@ +
#pragma once
#include "PassiveMonster.h"
-class cVillager : public cPassiveMonster
+
+
+
+
+class cVillager :
+ public cPassiveMonster
{
+ typedef cPassiveMonster super;
+
public:
cVillager();
- ~cVillager();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char * a_EntityType) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp index 02d1de4fe..5077f0cdd 100644 --- a/source/Mobs/Witch.cpp +++ b/source/Mobs/Witch.cpp @@ -17,37 +17,24 @@ cWitch::cWitch() -cWitch::~cWitch()
+bool cWitch::IsA(const char * a_EntityType)
{
+ return ((strcmp(a_EntityType, "cWitch") == 0) || super::IsA(a_EntityType));
}
-bool cWitch::IsA( const char* a_EntityType )
+void cWitch::GetDrops(cItems & a_Drops, cPawn * a_Killer)
{
- if( strcmp( a_EntityType, "cWitch" ) == 0 ) return true;
- return cMonster::IsA( a_EntityType );
-}
-
-
-
-
-
-void cWitch::KilledBy( cEntity* a_Killer )
-{
- cItems Drops;
- AddRandomDropItem(Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_GUNPOWDER);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_REDSTONE_DUST);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_SPIDER_EYE);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_STICK);
- AddRandomDropItem(Drops, 0, 6, E_ITEM_SUGAR);
- m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z);
-
- cMonster::KilledBy( a_Killer );
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GUNPOWDER);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_REDSTONE_DUST);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SPIDER_EYE);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_STICK);
+ AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SUGAR);
}
diff --git a/source/Mobs/Witch.h b/source/Mobs/Witch.h index 303aa7595..2d21037bb 100644 --- a/source/Mobs/Witch.h +++ b/source/Mobs/Witch.h @@ -1,14 +1,25 @@ +
#pragma once
#include "AggressiveMonster.h"
-class cWitch : public cAggressiveMonster
+
+
+
+
+class cWitch :
+ public cAggressiveMonster
{
+ typedef cAggressiveMonster super;
+
public:
cWitch();
- ~cWitch();
- virtual bool IsA( const char* a_EntityType );
+ virtual bool IsA(const char* a_EntityType) override;
+
+ virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override;
+} ;
+
+
+
- virtual void KilledBy( cEntity* a_Killer );
-};
diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp index b0a429f25..5d753c4f8 100644 --- a/source/Mobs/Zombie.cpp +++ b/source/Mobs/Zombie.cpp @@ -17,18 +17,9 @@ cZombie::cZombie() -cZombie::~cZombie() +bool cZombie::IsA(const char * a_EntityType) { -} - - - - - -bool cZombie::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cZombie" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); + return ((strcmp(a_EntityType, "cZombie") == 0) || super::IsA(a_EntityType)); } @@ -37,7 +28,7 @@ bool cZombie::IsA( const char* a_EntityType ) void cZombie::Tick(float a_Dt) { - cMonster::Tick(a_Dt); + super::Tick(a_Dt); // TODO Same as in cSkeleton :D if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && (GetMetaData() != BURNING)) @@ -50,16 +41,11 @@ void cZombie::Tick(float a_Dt) -void cZombie::KilledBy( cEntity* a_Killer ) +void cZombie::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - cItems Drops; - AddRandomDropItem(Drops, 0, 2, E_ITEM_ROTTEN_FLESH); + AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ROTTEN_FLESH); // TODO: Rare drops - - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); - - cMonster::KilledBy( a_Killer ); } diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h index 6adaaf41f..8256c040a 100644 --- a/source/Mobs/Zombie.h +++ b/source/Mobs/Zombie.h @@ -2,14 +2,24 @@ #include "AggressiveMonster.h" -class cZombie : public cAggressiveMonster + + + + +class cZombie : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: cZombie(); - ~cZombie(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType) override; + + virtual void Tick(float a_Dt) override; + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; +} ; + + + - virtual void Tick(float a_Dt); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index a33d78efa..9d3106829 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -17,18 +17,9 @@ cZombiepigman::cZombiepigman() -cZombiepigman::~cZombiepigman() +bool cZombiepigman::IsA(const char * a_EntityType) { -} - - - - - -bool cZombiepigman::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cZombiepigman" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); + return ((strcmp(a_EntityType, "cZombiepigman") == 0) || super::IsA(a_EntityType)); } @@ -37,7 +28,7 @@ bool cZombiepigman::IsA( const char* a_EntityType ) void cZombiepigman::Tick(float a_Dt) { - cMonster::Tick(a_Dt); + super::Tick(a_Dt); // TODO Same as noticed in cSkeleton AND Do they really burn by sun?? :D In the neather is no sun :D if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && (GetMetaData() != BURNING)) @@ -50,17 +41,27 @@ void cZombiepigman::Tick(float a_Dt) -void cZombiepigman::KilledBy(cEntity * a_Killer) +void cZombiepigman::GetDrops(cItems & a_Drops, cPawn * a_Killer) { - cItems Drops; - AddRandomDropItem(Drops, 0, 1, E_ITEM_ROTTEN_FLESH); - AddRandomDropItem(Drops, 0, 1, E_ITEM_GOLD_NUGGET); + AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ROTTEN_FLESH); + AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GOLD_NUGGET); // TODO: Rare drops - - m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); +} - cMonster::KilledBy( a_Killer ); + + + + +void cZombiepigman::KilledBy(cPawn * a_Killer) +{ + super::KilledBy(a_Killer); + + if ((a_Killer != NULL) && (a_Killer->GetEntityType() == eEntityType_Player)) + { + // TODO: Anger all nearby zombie pigmen + // TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker? + } } diff --git a/source/Mobs/Zombiepigman.h b/source/Mobs/Zombiepigman.h index 93fe2d607..02ad21562 100644 --- a/source/Mobs/Zombiepigman.h +++ b/source/Mobs/Zombiepigman.h @@ -1,15 +1,27 @@ + #pragma once #include "PassiveAggressiveMonster.h" -class cZombiepigman : public cPassiveAggressiveMonster + + + + +class cZombiepigman : + public cPassiveAggressiveMonster { + typedef cPassiveAggressiveMonster super; + public: cZombiepigman(); - ~cZombiepigman(); - virtual bool IsA( const char* a_EntityType ); + virtual bool IsA(const char * a_EntityType) override; + + virtual void Tick(float a_Dt) override; + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; + virtual void KilledBy(cPawn * a_Killer) override; +} ; + + + - virtual void Tick(float a_Dt); - virtual void KilledBy( cEntity* a_Killer ); -}; diff --git a/source/Pawn.cpp b/source/Pawn.cpp index da878bf49..8d530abb4 100644 --- a/source/Pawn.cpp +++ b/source/Pawn.cpp @@ -21,8 +21,10 @@ CLASS_DEFINITION( cPawn, cEntity ) -cPawn::cPawn() +cPawn::cPawn(void) : cEntity( 0, 0, 0 ) + , m_Health(1) + , m_MaxHealth(1) , m_LastPosX( 0.0 ) , m_LastPosY( 0.0 ) , m_LastPosZ( 0.0 ) @@ -30,7 +32,6 @@ cPawn::cPawn() , m_bBurnable(true) , m_MetaData(NORMAL) { - SetMaxHealth(20); } @@ -39,40 +40,83 @@ cPawn::cPawn() cPawn::~cPawn() { + // Nothing needed yet +} + + + + +void cPawn::Heal(int a_HitPoints) +{ + m_Health += a_HitPoints; + if (m_Health > m_MaxHealth) + { + m_Health = m_MaxHealth; + } } -void cPawn::Heal( int a_Health ) +void cPawn::TakeDamage(cPawn & a_Attacker) { - (void)a_Health; + int RawDamage = a_Attacker.GetRawDamageAgainst(*this); + + TakeDamage(dtAttack, &a_Attacker, RawDamage, a_Attacker.GetKnockbackAmountAgainst(*this)); } -void cPawn::TakeDamage(int a_Damage, cEntity * a_Instigator) +void cPawn::TakeDamage(eDamageType a_DamageType, cPawn * a_Attacker, int a_RawDamage, double a_KnockbackAmount) +{ + int FinalDamage = a_RawDamage - GetArmorCoverAgainst(a_Attacker, a_DamageType, a_RawDamage); + TakeDamage(a_DamageType, a_Attacker, a_RawDamage, FinalDamage, a_KnockbackAmount); +} + + + + + +void cPawn::TakeDamage(eDamageType a_DamageType, cPawn * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount) { TakeDamageInfo TDI; - TDI.Damage = a_Damage; - TDI.Instigator = a_Instigator; - cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_TAKE_DAMAGE, 2, this, &TDI); + TDI.DamageType = a_DamageType; + TDI.Attacker = a_Attacker; + TDI.RawDamage = a_RawDamage; + TDI.FinalDamage = a_FinalDamage; + Vector3d Heading; + Heading.x = sin(m_Rot.x); + Heading.y = 0.4; // TODO: adjust the amount of "up" knockback when testing + Heading.z = cos(m_Rot.x); + TDI.Knockback = Heading * a_KnockbackAmount; + DoTakeDamage(TDI); +} + - if (TDI.Damage == 0) + + + +void cPawn::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) { return; } + if (m_Health <= 0) { // Can't take damage if already dead return; } - m_Health -= (short)TDI.Damage; + m_Health -= (short)a_TDI.FinalDamage; + + // TODO: Apply damage to armor + if (m_Health < 0) { m_Health = 0; @@ -82,7 +126,7 @@ void cPawn::TakeDamage(int a_Damage, cEntity * a_Instigator) if (m_Health <= 0) { - KilledBy(TDI.Instigator); + KilledBy(a_TDI.Attacker); } } @@ -90,15 +134,23 @@ void cPawn::TakeDamage(int a_Damage, cEntity * a_Instigator) -void cPawn::KilledBy(cEntity * a_Killer) +void cPawn::KilledBy(cPawn * a_Killer) { + short OldHealth = m_Health; m_Health = 0; - if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_KILLED, 2, this, a_Killer ) ) + if (cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_KILLED, 2, this, a_Killer)) { - return; // Give plugins a chance to 'unkill' the pawn. + // Plugin wants to 'unkill' the pawn. Set health back and abort + m_Health = OldHealth; + return; } + // Drop loot: + cItems Drops; + GetDrops(Drops, a_Killer); + m_World->SpawnItemPickups(Drops, m_Pos.x, m_Pos.y, m_Pos.z); + m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_DEAD); } @@ -106,18 +158,147 @@ void cPawn::KilledBy(cEntity * a_Killer) -void cPawn::TeleportToEntity(cEntity * a_Entity) +int cPawn::GetRawDamageAgainst(const cPawn & a_Receiver) { - TeleportTo(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ()); + // Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items + // Ref: http://www.minecraftwiki.net/wiki/Damage#Dealing_damage as of 2012_12_20 + switch (this->GetEquippedWeapon().m_ItemType) + { + case E_ITEM_WOODEN_SWORD: return 4; + case E_ITEM_GOLD_SWORD: return 4; + case E_ITEM_STONE_SWORD: return 5; + case E_ITEM_IRON_SWORD: return 6; + case E_ITEM_DIAMOND_SWORD: return 7; + + case E_ITEM_WOODEN_AXE: return 3; + case E_ITEM_GOLD_AXE: return 3; + case E_ITEM_STONE_AXE: return 4; + case E_ITEM_IRON_AXE: return 5; + case E_ITEM_DIAMOND_AXE: return 6; + + case E_ITEM_WOODEN_PICKAXE: return 2; + case E_ITEM_GOLD_PICKAXE: return 2; + case E_ITEM_STONE_PICKAXE: return 3; + case E_ITEM_IRON_PICKAXE: return 4; + case E_ITEM_DIAMOND_PICKAXE: return 5; + + case E_ITEM_WOODEN_SHOVEL: return 1; + case E_ITEM_GOLD_SHOVEL: return 1; + case E_ITEM_STONE_SHOVEL: return 2; + case E_ITEM_IRON_SHOVEL: return 3; + case E_ITEM_DIAMOND_SHOVEL: return 4; + } + // All other equipped items give a damage of 1: + return 1; } -void cPawn::TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ) +int cPawn::GetArmorCoverAgainst(const cPawn * a_Attacker, eDamageType a_DamageType, int a_Damage) { - SetPosition( a_PosX, a_PosY, a_PosZ ); + // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover + + // Filter out damage types that are not protected by armor: + // Ref.: http://www.minecraftwiki.net/wiki/Armor#Effects as of 2012_12_20 + switch (a_DamageType) + { + case dtOnFire: + case dtSuffocating: + case dtDrowning: // TODO: This one could be a special case - in various MC versions (PC vs XBox) it is and isn't armor-protected + case dtStarving: + case dtInVoid: + case dtPoisoning: + case dtPotionOfHarming: + case dtFalling: + case dtLightning: + { + return 0; + } + } + + // Add up all armor points: + // Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20 + int ArmorValue = 0; + switch (GetEquippedHelmet().m_ItemType) + { + case E_ITEM_LEATHER_CAP: ArmorValue += 1; break; + case E_ITEM_GOLD_HELMET: ArmorValue += 2; break; + case E_ITEM_CHAIN_HELMET: ArmorValue += 2; break; + case E_ITEM_IRON_HELMET: ArmorValue += 2; break; + case E_ITEM_DIAMOND_HELMET: ArmorValue += 3; break; + } + switch (GetEquippedChestplate().m_ItemType) + { + case E_ITEM_LEATHER_TUNIC: ArmorValue += 3; break; + case E_ITEM_GOLD_CHESTPLATE: ArmorValue += 5; break; + case E_ITEM_CHAIN_CHESTPLATE: ArmorValue += 5; break; + case E_ITEM_IRON_CHESTPLATE: ArmorValue += 6; break; + case E_ITEM_DIAMOND_CHESTPLATE: ArmorValue += 8; break; + } + switch (GetEquippedLeggings().m_ItemType) + { + case E_ITEM_LEATHER_PANTS: ArmorValue += 2; break; + case E_ITEM_GOLD_LEGGINGS: ArmorValue += 3; break; + case E_ITEM_CHAIN_LEGGINGS: ArmorValue += 4; break; + case E_ITEM_IRON_LEGGINGS: ArmorValue += 5; break; + case E_ITEM_DIAMOND_LEGGINGS: ArmorValue += 6; break; + } + switch (GetEquippedBoots().m_ItemType) + { + case E_ITEM_LEATHER_BOOTS: ArmorValue += 1; break; + case E_ITEM_GOLD_BOOTS: ArmorValue += 1; break; + case E_ITEM_CHAIN_BOOTS: ArmorValue += 1; break; + case E_ITEM_IRON_BOOTS: ArmorValue += 2; break; + case E_ITEM_DIAMOND_BOOTS: ArmorValue += 3; break; + } + + // TODO: Special armor cases, such as wool, saddles, dog's collar + // Ref.: http://www.minecraftwiki.net/wiki/Armor#Mob_armor as of 2012_12_20 + + // Now ArmorValue is in [0, 20] range, which corresponds to [0, 80%] protection. Calculate the hitpoints from that: + return a_Damage * (ArmorValue * 4) / 100; +} + + + + + +double cPawn::GetKnockbackAmountAgainst(const cPawn & a_Receiver) +{ + // Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit + + // TODO: Enchantments + return 1; +} + + + + + +void cPawn::GetDrops(cItems & a_Drops, cPawn * a_Killer) +{ + UNUSED(a_Drops); + UNUSED(a_Killer); +} + + + + + +void cPawn::TeleportToEntity(cEntity & a_Entity) +{ + TeleportTo(a_Entity.GetPosX(), a_Entity.GetPosY(), a_Entity.GetPosZ()); +} + + + + + +void cPawn::TeleportTo(double a_PosX, double a_PosY, double a_PosZ) +{ + SetPosition(a_PosX, a_PosY, a_PosZ); GetWorld()->BroadcastTeleportEntity(*this); } @@ -155,9 +336,9 @@ void cPawn::SetMetaData(MetaData a_MetaData) //----Change Entity MetaData void cPawn::CheckMetaDataBurn() { - char Block = GetWorld()->GetBlock((int) m_Pos.x, (int) m_Pos.y, (int) m_Pos.z); - char BlockAbove = GetWorld()->GetBlock((int) m_Pos.x, (int) m_Pos.y + 1, (int) m_Pos.z); - char BlockBelow = GetWorld()->GetBlock((int) m_Pos.x, (int) m_Pos.y - 1, (int) m_Pos.z); + BLOCKTYPE Block = GetWorld()->GetBlock((int) m_Pos.x, (int) m_Pos.y, (int) m_Pos.z); + BLOCKTYPE BlockAbove = GetWorld()->GetBlock((int) m_Pos.x, (int) m_Pos.y + 1, (int) m_Pos.z); + BLOCKTYPE BlockBelow = GetWorld()->GetBlock((int) m_Pos.x, (int) m_Pos.y - 1, (int) m_Pos.z); if ( (GetMetaData() == BURNING) && @@ -184,35 +365,36 @@ void cPawn::CheckMetaDataBurn() -//What to do if On fire +// What to do if On fire void cPawn::InStateBurning(float a_Dt) { m_FireDamageInterval += a_Dt; - char Block = GetWorld()->GetBlock( (int)m_Pos.x, (int)m_Pos.y, (int)m_Pos.z ); - char BlockAbove = GetWorld()->GetBlock( (int)m_Pos.x, (int)m_Pos.y + 1, (int)m_Pos.z ); - if (m_FireDamageInterval > 800) + if (m_FireDamageInterval < 800) { + return; + } - m_FireDamageInterval = 0; - TakeDamage(1, this); + BLOCKTYPE Block = GetWorld()->GetBlock((int)m_Pos.x, (int)m_Pos.y, (int)m_Pos.z); + BLOCKTYPE BlockAbove = GetWorld()->GetBlock((int)m_Pos.x, (int)m_Pos.y + 1, (int)m_Pos.z); + m_FireDamageInterval = 0; + TakeDamage(dtOnFire, NULL, 1, 0); - m_BurnPeriod++; - if (IsBlockLava(Block) || Block == E_BLOCK_FIRE - || IsBlockLava(BlockAbove) || BlockAbove == E_BLOCK_FIRE) - { - m_BurnPeriod = 0; - TakeDamage(6, this); - } - else - { - TakeDamage(1, this); - } - - if (m_BurnPeriod > 7) - { - SetMetaData(NORMAL); - m_BurnPeriod = 0; - } + m_BurnPeriod++; + if ( + IsBlockLava(Block) || + (Block == E_BLOCK_FIRE) || + IsBlockLava(BlockAbove) || + (BlockAbove == E_BLOCK_FIRE) + ) + { + m_BurnPeriod = 0; + TakeDamage(dtLavaContact, NULL, 6, 0); + } + + if (m_BurnPeriod > 7) + { + SetMetaData(NORMAL); + m_BurnPeriod = 0; } } @@ -224,7 +406,7 @@ void cPawn::SetMaxHealth(short a_MaxHealth) { this->m_MaxHealth = a_MaxHealth; - //Reset health + // Reset health m_Health = a_MaxHealth; } diff --git a/source/Pawn.h b/source/Pawn.h index cb3381644..8c20ee1e6 100644 --- a/source/Pawn.h +++ b/source/Pawn.h @@ -2,38 +2,145 @@ #pragma once #include "Entity.h" +#include "Item.h" -struct TakeDamageInfo //tolua_export -{ //tolua_export - int Damage; //tolua_export - cEntity* Instigator; //tolua_export -}; //tolua_export +// fwd: +class cPawn; -class cPawn : public cEntity //tolua_export -{ //tolua_export +// tolua_begin +enum eDamageType +{ + // Canonical names for the types (as documented in the plugin wiki): + dtAttack, // Being attacked by a mob + dtLightning, // Hit by a lightning strike + dtFalling, // Falling down; dealt when hitting the ground + dtDrowning, // Drowning in water / lava + dtSuffocating, // Suffocating inside a block + dtStarving, // Hunger + dtCactusContact, // Contact with a cactus block + dtLavaContact, // Contact with a lava block + dtPoisoning, // Having the poison effect + dtOnFire, // Being on fire + dtFireContact, // Standing inside a fire block + dtInVoid, // Falling into the Void (Y < 0) + dtPotionOfHarming, + + // Some common synonyms: + dtPawnAttack = dtAttack, + dtEntityAttack = dtAttack, + dtMob = dtAttack, + dtMobAttack = dtAttack, + dtFall = dtFalling, + dtDrown = dtDrowning, + dtSuffocation = dtSuffocating, + dtStarvation = dtStarving, + dtHunger = dtStarving, + dtCactus = dtCactusContact, + dtCactuses = dtCactusContact, + dtCacti = dtCactusContact, + dtLava = dtLavaContact, + dtPoison = dtPoisoning, + dtBurning = dtOnFire, + dtInFire = dtFireContact, +} ; + + + + + +struct TakeDamageInfo +{ + eDamageType DamageType; // Where does the damage come from? Being hit / on fire / contact with cactus / ... + cPawn * Attacker; // The attacking pawn; valid only for dtAttack + int RawDamage; // What damage would the receiver get without any armor. Usually: attacker mob type + weapons + int FinalDamage; // What actual damage will be received. Usually: m_RawDamage minus armor + Vector3d Knockback; // The amount and direction of knockback received from the damage + // TODO: Effects - list of effects that the hit is causing. Unknown representation yet +} ; +// tolua_end + + + + + +// tolua_begin +class cPawn : + public cEntity +{ + // tolua_end public: CLASS_PROTOTYPE() - cPawn(); + cPawn(void); virtual ~cPawn(); - virtual void TeleportToEntity( cEntity* a_Entity ); //tolua_export - virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export - virtual void Tick(float a_Dt) override; - void Heal( int a_Health ); //tolua_export - virtual void TakeDamage( int a_Damage, cEntity* a_Instigator ); //tolua_export - virtual void KilledBy( cEntity* a_Killer ); //tolua_export - int GetHealth() { return m_Health; } //tolua_export + // tolua_begin + + /// Teleports to the entity specified + virtual void TeleportToEntity(cEntity & a_Entity); + + /// Teleports to the coordinates specified + virtual void TeleportTo(double a_PosX, double a_PosY, double a_PosZ); + + /// Heals the specified amount of HPs + void Heal(int a_HitPoints); + + /// Returns the health of this pawn + int GetHealth(void) const { return m_Health; } + + /// Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called + void TakeDamage(cPawn & a_Attacker); + + /// Makes this pawn take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called + void TakeDamage(eDamageType a_DamageType, cPawn * a_Attacker, int a_RawDamage, double a_KnockbackAmount); + + /// Makes this pawn take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage() + void TakeDamage(eDamageType a_DamageType, cPawn * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount); + + /// Makes this pawn take damage specified in the a_TDI. The TDI is sent through plugins first, then applied + virtual void DoTakeDamage(TakeDamageInfo & a_TDI); + + /// Called when the health drops below zero. a_Killer may be NULL (environmental damage) + virtual void KilledBy(cPawn * a_Killer); + + /// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items + virtual int GetRawDamageAgainst(const cPawn & a_Receiver); + + /// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover + virtual int GetArmorCoverAgainst(const cPawn * a_Attacker, eDamageType a_DamageType, int a_RawDamage); + + /// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit + virtual double GetKnockbackAmountAgainst(const cPawn & a_Receiver); + + /// Returns the curently equipped weapon; empty item if none + virtual cItem GetEquippedWeapon(void) const { return cItem(); } + + /// Returns the currently equipped helmet; empty item if nonte + virtual cItem GetEquippedHelmet(void) const { return cItem(); } + + /// Returns the currently equipped chestplate; empty item if nonte + virtual cItem GetEquippedChestplate(void) const { return cItem(); } + + /// Returns the currently equipped leggings; empty item if nonte + virtual cItem GetEquippedLeggings(void) const { return cItem(); } + + /// Returns the currently equipped boots; empty item if nonte + virtual cItem GetEquippedBoots(void) const { return cItem(); } + + // tolua_end + + /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL); enum MetaData {NORMAL, BURNING, CROUCHED, RIDING, SPRINTING, EATING, BLOCKING}; @@ -48,10 +155,8 @@ public: virtual short GetMaxHealth() { return m_MaxHealth; } protected: - short m_Health; short m_MaxHealth; - bool m_bBurnable; diff --git a/source/Player.cpp b/source/Player.cpp index 555b8d3f9..9460bfd97 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -70,6 +70,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) LOGD("Inventory window for player %p is at %p", this, m_InventoryWindow); SetMaxHealth(20); + m_MaxFoodLevel = 20; m_MaxFoodSaturationLevel = 20.f; @@ -222,18 +223,19 @@ void cPlayer::Tick(float a_Dt) { m_World->CollectPickupsByPlayer(this); - //Handle Health: + // Handle Health: m_FoodTickTimer++; - if(m_FoodTickTimer >= 80) + if (m_FoodTickTimer >= 80) { m_FoodTickTimer = 0; - if(m_FoodLevel >= 17) + if (m_FoodLevel >= 17) { Heal(1); - }else if(m_FoodLevel == 0) + } + else if (m_FoodLevel == 0) { - TakeDamage(1, NULL); + super::TakeDamage(dtStarving, NULL, 1, 1, 0); } } @@ -248,7 +250,7 @@ void cPlayer::Tick(float a_Dt) } else { - m_FoodLevel = MAX(m_FoodLevel -1, 0); + m_FoodLevel = MAX(m_FoodLevel - 1, 0); } SendHealth(); @@ -297,7 +299,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) m_LastJumpHeight = (float)m_Pos.y; if (Damage > 0) { - TakeDamage(Damage, 0); + super::TakeDamage(dtFalling, NULL, Damage, Damage, 0); } m_LastGroundHeight = (float)m_Pos.y; @@ -353,23 +355,30 @@ void cPlayer::SendHealth() -void cPlayer::TakeDamage( int a_Damage, cEntity* a_Instigator ) +void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) { - if (m_GameMode != eGameMode_Creative) + if (m_GameMode == eGameMode_Creative) { - cPawn::TakeDamage( a_Damage, a_Instigator ); - + // No damage / health in creative mode + return; + } + + super::DoTakeDamage(a_TDI); + + if (a_TDI.Attacker != NULL) + { + // Only increase hunger if being attacked by a mob AddFoodExhaustion(0.3f); - - SendHealth(); } + + SendHealth(); } -void cPlayer::KilledBy(cEntity * a_Killer) +void cPlayer::KilledBy(cPawn * a_Killer) { cPawn::KilledBy(a_Killer); @@ -544,7 +553,7 @@ void cPlayer::SendMessage(const AString & a_Message) -void cPlayer::TeleportTo(const double & a_PosX, const double & a_PosY, const double & a_PosZ) +void cPlayer::TeleportTo(double a_PosX, double a_PosY, double a_PosZ) { SetPosition( a_PosX, a_PosY, a_PosZ ); diff --git a/source/Player.h b/source/Player.h index d24850a19..a220e8fee 100644 --- a/source/Player.h +++ b/source/Player.h @@ -17,9 +17,17 @@ class cClientHandle; -class cPlayer : public cPawn //tolua_export -{ //tolua_export +// tolua_begin +class cPlayer : + public cPawn +{ public: + enum + { + MAX_HEALTH = 20, + } ; + // tolua_end + typedef cPawn super; CLASS_PROTOTYPE() @@ -33,6 +41,21 @@ public: virtual void Tick(float a_Dt) override; + /// Returns the curently equipped weapon; empty item if none + virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } + + /// Returns the currently equipped helmet; empty item if nonte + virtual cItem GetEquippedHelmet(void) const override { return m_Inventory.GetEquippedHelmet(); } + + /// Returns the currently equipped chestplate; empty item if none + virtual cItem GetEquippedChestplate(void) const override { return m_Inventory.GetEquippedChestplate(); } + + /// Returns the currently equipped leggings; empty item if none + virtual cItem GetEquippedLeggings(void) const override { return m_Inventory.GetEquippedLeggings(); } + + /// Returns the currently equipped boots; empty item if none + virtual cItem GetEquippedBoots(void) const override { return m_Inventory.GetEquippedBoots(); } + void SetTouchGround( bool a_bTouchGround ); inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; } double GetEyeHeight(); //tolua_export @@ -44,7 +67,7 @@ public: inline const cItem & GetEquippedItem(void) const {return GetInventory().GetEquippedItem(); } // tolua_export - virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export + virtual void TeleportTo(double a_PosX, double a_PosY, double a_PosZ) override; eGameMode GetGameMode(void) const { return m_GameMode; } //tolua_export std::string GetIP() { return m_IP; } //tolua_export @@ -100,18 +123,18 @@ public: void AddFoodExhaustion(float a_Exhaustion) { m_FoodExhaustionLevel += a_Exhaustion; } //tolua_export - void TakeDamage( int a_Damage, cEntity* a_Instigator ); //tolua_export - void KilledBy( cEntity* a_Killer ); //tolua_export - void Respawn(); //tolua_export + virtual void KilledBy(cPawn * a_Killer) override; + + void Respawn(void); //tolua_export void SetVisible( bool a_bVisible ); //tolua_export - bool IsVisible() { return m_bVisible; } //tolua_export + bool IsVisible(void) const { return m_bVisible; } //tolua_export - bool MoveToWorld( const char* a_WorldName ); //tolua_export + bool MoveToWorld(const char * a_WorldName ); //tolua_export - bool SaveToDisk(); - bool LoadFromDisk(); - void LoadPermissionsFromDisk(); //tolua_export + bool SaveToDisk(void); + bool LoadFromDisk(void); + void LoadPermissionsFromDisk(void); //tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } @@ -171,4 +194,12 @@ protected: static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second cClientHandle* m_ClientHandle; -}; //tolua_export + + /// Filters out damage for creative mode + virtual void DoTakeDamage(TakeDamageInfo & TDI) override; + +} ; //tolua_export + + + + diff --git a/source/Plugin.cpp b/source/Plugin.cpp index 7a22f803e..427c30a69 100644 --- a/source/Plugin.cpp +++ b/source/Plugin.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Plugin.h" +#include "Pawn.h" @@ -228,10 +229,11 @@ bool cPlugin::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Gr -void cPlugin::OnTakeDamage(cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo) +bool cPlugin::OnTakeDamage(cPawn & a_Pawn, TakeDamageInfo & a_TakeDamageInfo) { UNUSED(a_Pawn); UNUSED(a_TakeDamageInfo); + return false; } diff --git a/source/Plugin.h b/source/Plugin.h index 52508eb6a..9ee06e369 100644 --- a/source/Plugin.h +++ b/source/Plugin.h @@ -57,7 +57,7 @@ public: virtual void OnPlayerSpawn (cPlayer* a_Player ); virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - virtual void OnTakeDamage (cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo ); + virtual bool OnTakeDamage (cPawn & a_Receiver, TakeDamageInfo & a_TakeDamageInfo); virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player); virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player); virtual bool OnWeatherChanged (cWorld * a_World); diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 1123f3615..162aaf2e3 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -253,21 +253,6 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...) break; } - case HOOK_TAKE_DAMAGE: - { - if( a_NumArgs != 2 ) break; - va_list argptr; - va_start( argptr, a_NumArgs); - cPawn* Pawn = va_arg(argptr, cPawn* ); - TakeDamageInfo* TDI = va_arg(argptr, TakeDamageInfo* ); - va_end (argptr); - for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr ) - { - (*itr)->OnTakeDamage( Pawn, TDI ); - } - break; - } - case HOOK_KILLED: { if( a_NumArgs != 2 ) break; @@ -482,16 +467,16 @@ bool cPluginManager::CallHookCollectPickup(cPlayer * a_Player, cPickup & a_Picku -bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING); + HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe)) + if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe)) { return true; } @@ -503,16 +488,16 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Reason) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE); + HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe)) + if ((*itr)->OnDisconnect(a_Player, a_Reason)) { return true; } @@ -524,16 +509,16 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC -bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Reason) +bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT); + HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnDisconnect(a_Player, a_Reason)) + if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe)) { return true; } @@ -545,16 +530,37 @@ bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Re -bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); + HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe)) + if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe)) + { + return true; + } + } + return false; +} + + + + + +bool cPluginManager::CallHookTakeDamage(cPawn & a_Receiver, TakeDamageInfo & a_TDI) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_TAKE_DAMAGE); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnTakeDamage(a_Receiver, a_TDI)) { return true; } diff --git a/source/PluginManager.h b/source/PluginManager.h index ebbd0ca89..8dacc3ccb 100644 --- a/source/PluginManager.h +++ b/source/PluginManager.h @@ -12,22 +12,26 @@ class cLuaCommandBinder; class cPlugin; -// fwd: cWorld.h +// fwd: World.h class cWorld; -// fwd: cLuaChunk.h +// fwd: LuaChunk.h class cLuaChunk; -// fwd: cPlayer.h +// fwd: Player.h class cPlayer; // fwd: CraftingRecipes.h class cCraftingGrid; class cCraftingRecipe; -// fwd: cPickup.h +// fwd: Pickup.h class cPickup; +// fwd: Pawn.h +struct TakeDamageInfo; +class cPawn; + @@ -54,7 +58,7 @@ public: //tolua_export HOOK_PLAYER_SPAWN, HOOK_PLAYER_JOIN, HOOK_PLAYER_MOVE, - HOOK_TAKE_DAMAGE, + HOOK_TAKE_DAMAGE, // cPawn, TakeDamageInfo HOOK_KILLED, HOOK_CHUNK_GENERATED, HOOK_CHUNK_GENERATING, @@ -115,6 +119,7 @@ public: //tolua_export bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); + bool CallHookTakeDamage (cPawn & a_Receiver, TakeDamageInfo & a_TDI); bool CallHookUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player); bool CallHookUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player); bool CallHookWeatherChanged (cWorld * a_World); diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp index 373f990c2..8003dffbc 100644 --- a/source/Plugin_NewLua.cpp +++ b/source/Plugin_NewLua.cpp @@ -366,16 +366,25 @@ void cPlugin_NewLua::OnPlayerMove( cPlayer* a_Player ) -void cPlugin_NewLua::OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) +bool cPlugin_NewLua::OnTakeDamage(cPawn & a_Receiver, TakeDamageInfo & a_TDI) { - cCSLock Lock( m_CriticalSection ); - if( !PushFunction("OnTakeDamage") ) - return; + cCSLock Lock(m_CriticalSection); + if (!PushFunction("OnTakeDamage")) + { + return false; + } - tolua_pushusertype(m_LuaState, a_Pawn, "cPawn"); - tolua_pushusertype(m_LuaState, a_TakeDamageInfo, "TakeDamageInfo"); + tolua_pushusertype(m_LuaState, &a_Receiver, "cPawn"); + tolua_pushusertype(m_LuaState, &a_TDI, "TakeDamageInfo"); - CallFunction(2, 0, "OnTakeDamage"); + if (!CallFunction(2, 1, "OnTakeDamage")) + { + return false; + } + + bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) != 0); + lua_pop(m_LuaState, 1); + return bRetVal; } diff --git a/source/Plugin_NewLua.h b/source/Plugin_NewLua.h index 88fd98963..dbaf3b6c6 100644 --- a/source/Plugin_NewLua.h +++ b/source/Plugin_NewLua.h @@ -14,9 +14,14 @@ typedef struct lua_State lua_State; -class cPlugin_NewLua : public cPlugin, public cWebPlugin //tolua_export -{ //tolua_export -public: //tolua_export +// tolua_begin +class cPlugin_NewLua : + public cPlugin, + public cWebPlugin +{ +public: + // tolua_end + cPlugin_NewLua( const AString & a_PluginDirectory ); ~cPlugin_NewLua(); @@ -41,7 +46,7 @@ public: //tolua_export virtual void OnPlayerSpawn (cPlayer * a_Player ) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; - virtual void OnTakeDamage (cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo ) override; + virtual bool OnTakeDamage (cPawn & a_Receiver, TakeDamageInfo & a_TakeDamageInfo) override; virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) override; virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) override; virtual bool OnWeatherChanged (cWorld * a_World) override; |