Skip to content

Commit b538813

Browse files
avoitishinXottab-DUTY
authored andcommitted
+ Actor hit script callback
1 parent 763e1c5 commit b538813

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

res/gamedata/scripts/bind_stalker.script

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ function actor_binder:net_destroy()
8585
self.object:set_callback(callback.take_item_from_box, nil)
8686
self.object:set_callback(callback.use_object, nil)
8787

88+
----| aVo |--------------------------------------------------------------------
89+
self.object:set_callback(callback.hit, nil)
90+
--self.object:set_callback(123, nil)
91+
----| end:aVo |----------------------------------------------------------------
92+
8893
log("--------->"..tostring(_G.amb_vol))
8994
log("--------->"..tostring(_G.mus_vol))
9095
if(_G.amb_vol~=0) then
@@ -118,7 +123,25 @@ function actor_binder:reinit()
118123
self.object:set_callback(callback.task_state, self.task_callback, self)
119124
self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
120125
self.object:set_callback(callback.use_object, self.use_inventory_item, self)
126+
127+
----| aVo |--------------------------------------------------------------------
128+
self.object:set_callback(callback.hit, self.actor_hit, self)
129+
-- self.object:set_callback(123, self.key_press, self)
130+
----| end:aVo |----------------------------------------------------------------
131+
end
132+
---------------------------------------------------------------------------------------------------------------------
133+
134+
135+
----| aVo |--------------------------------------------------------------------
136+
-- Actor hit callback
137+
function actor_binder:actor_hit(obj, amount, local_direction, who, bone_index)
138+
-- local msg = string.format("actor_hit %f, %i", amount, bone_index)
139+
-- get_console():execute("load ~:"..msg)
121140
end
141+
-- x-ray extensions key press callback
142+
--function actor_binder:key_press(key)
143+
--sm:call("key_press", key)
144+
--end
122145
----------------------------------------------------------------------------------------------------------------------
123146
function actor_binder:take_item_from_box(box, item)
124147
local box_name = box:name()

src/xrGame/Actor.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,20 +560,27 @@ void CActor::Hit(SHit* pHDS)
560560

561561
if (IsGameTypeSingle())
562562
{
563-
float hit_power = HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);
564-
565563
if (GodMode())
566564
{
567565
HDS.power = 0.0f;
568566
inherited::Hit(&HDS);
569-
return;
570567
}
571-
else
568+
569+
float hit_power = HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);
570+
HDS.power = hit_power;
571+
HDS.add_wound = true;
572+
if (g_Alive())
572573
{
573-
HDS.power = hit_power;
574-
HDS.add_wound = true;
575-
inherited::Hit(&HDS);
574+
/* AVO: send script callback*/
575+
callback(GameObject::eHit)(
576+
this->lua_game_object(),
577+
HDS.damage(),
578+
HDS.direction(),
579+
smart_cast<const CGameObject*>(HDS.who)->lua_game_object(),
580+
HDS.boneID
581+
);
576582
}
583+
inherited::Hit(&HDS);
577584
}
578585
else
579586
{
@@ -686,6 +693,11 @@ void CActor::HitSignal(float perc, Fvector& vLocalDir, IGameObject* who, s16 ele
686693
{
687694
if (g_Alive())
688695
{
696+
/* AVO: to get bone names from IDs*/
697+
/*Log("hit info");
698+
Log("bone ID = %s", element);
699+
Log("bone Name = %s", smart_cast<IKinematics*>(this->Visual())->LL_BoneName_dbg(element));
700+
Log("hit info END");*/
689701
// check damage bone
690702
Fvector D;
691703
XFORM().transform_dir(D, vLocalDir);

0 commit comments

Comments
 (0)