Skip to content

Commit

Permalink
+ Actor hit script callback
Browse files Browse the repository at this point in the history
  • Loading branch information
avoitishin authored and Xottab-DUTY committed Aug 14, 2017
1 parent 763e1c5 commit b538813
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
23 changes: 23 additions & 0 deletions res/gamedata/scripts/bind_stalker.script
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ function actor_binder:net_destroy()
self.object:set_callback(callback.take_item_from_box, nil)
self.object:set_callback(callback.use_object, nil)

----| aVo |--------------------------------------------------------------------
self.object:set_callback(callback.hit, nil)
--self.object:set_callback(123, nil)
----| end:aVo |----------------------------------------------------------------

log("--------->"..tostring(_G.amb_vol))
log("--------->"..tostring(_G.mus_vol))
if(_G.amb_vol~=0) then
Expand Down Expand Up @@ -118,7 +123,25 @@ function actor_binder:reinit()
self.object:set_callback(callback.task_state, self.task_callback, self)
self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
self.object:set_callback(callback.use_object, self.use_inventory_item, self)

----| aVo |--------------------------------------------------------------------
self.object:set_callback(callback.hit, self.actor_hit, self)
-- self.object:set_callback(123, self.key_press, self)
----| end:aVo |----------------------------------------------------------------
end
---------------------------------------------------------------------------------------------------------------------


----| aVo |--------------------------------------------------------------------
-- Actor hit callback
function actor_binder:actor_hit(obj, amount, local_direction, who, bone_index)
-- local msg = string.format("actor_hit %f, %i", amount, bone_index)
-- get_console():execute("load ~:"..msg)
end
-- x-ray extensions key press callback
--function actor_binder:key_press(key)
--sm:call("key_press", key)
--end
----------------------------------------------------------------------------------------------------------------------
function actor_binder:take_item_from_box(box, item)
local box_name = box:name()
Expand Down
26 changes: 19 additions & 7 deletions src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,20 +560,27 @@ void CActor::Hit(SHit* pHDS)

if (IsGameTypeSingle())
{
float hit_power = HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);

if (GodMode())
{
HDS.power = 0.0f;
inherited::Hit(&HDS);
return;
}
else

float hit_power = HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);
HDS.power = hit_power;
HDS.add_wound = true;
if (g_Alive())
{
HDS.power = hit_power;
HDS.add_wound = true;
inherited::Hit(&HDS);
/* AVO: send script callback*/
callback(GameObject::eHit)(
this->lua_game_object(),
HDS.damage(),
HDS.direction(),
smart_cast<const CGameObject*>(HDS.who)->lua_game_object(),
HDS.boneID
);
}
inherited::Hit(&HDS);
}
else
{
Expand Down Expand Up @@ -686,6 +693,11 @@ void CActor::HitSignal(float perc, Fvector& vLocalDir, IGameObject* who, s16 ele
{
if (g_Alive())
{
/* AVO: to get bone names from IDs*/
/*Log("hit info");
Log("bone ID = %s", element);
Log("bone Name = %s", smart_cast<IKinematics*>(this->Visual())->LL_BoneName_dbg(element));
Log("hit info END");*/
// check damage bone
Fvector D;
XFORM().transform_dir(D, vLocalDir);
Expand Down

0 comments on commit b538813

Please sign in to comment.