|
20 | 20 | #include "CharacterPhysicsSupport.h" |
21 | 21 | #include "inventory.h" |
22 | 22 |
|
| 23 | +#include "pch_script.h" |
| 24 | +#include "game_object_space.h" |
| 25 | +#include "script_callback_ex.h" |
| 26 | +#include "script_game_object.h" |
| 27 | + |
23 | 28 | void CActor::attach_Vehicle(CHolderCustom* vehicle) |
24 | 29 | { |
25 | | - /* |
26 | | - if(!vehicle) return; |
27 | | - if(m_holder) return; |
| 30 | + if(!vehicle || m_holder) |
| 31 | + return; |
28 | 32 |
|
29 | | - PickupModeOff (); |
30 | | - m_holder=vehicle; |
| 33 | + //PickupModeOff(); |
| 34 | + m_holder=vehicle; |
31 | 35 |
|
32 | | - IRenderVisual *pVis = Visual(); |
33 | | - IKinematicsAnimated* V = smart_cast<IKinematicsAnimated*>(pVis); R_ASSERT(V); |
34 | | - IKinematics* pK = smart_cast<IKinematics*>(pVis); |
| 36 | + IRenderVisual* pVis = Visual(); |
| 37 | + IKinematicsAnimated* V = smart_cast<IKinematicsAnimated*>(pVis); |
| 38 | + R_ASSERT(V); |
| 39 | + IKinematics* pK = smart_cast<IKinematics*>(pVis); |
35 | 40 |
|
36 | | - if(!m_holder->attach_Actor(this)){ |
37 | | - m_holder=NULL; |
38 | | - return; |
39 | | - } |
40 | | - // temp play animation |
41 | | - CCar* car = smart_cast<CCar*>(m_holder); |
42 | | - u16 anim_type = car->DriverAnimationType(); |
43 | | - SVehicleAnimCollection& anims = m_vehicle_anims->m_vehicles_type_collections[anim_type]; |
44 | | - V->PlayCycle (anims.idles[0],FALSE); |
| 41 | + if (!m_holder->attach_Actor(this)) |
| 42 | + { |
| 43 | + m_holder = nullptr; |
| 44 | + return; |
| 45 | + } |
| 46 | + |
| 47 | + // temp play animation |
| 48 | + CCar* car = smart_cast<CCar*>(m_holder); |
| 49 | + u16 anim_type = car->DriverAnimationType(); |
| 50 | + SVehicleAnimCollection& anims = m_vehicle_anims->m_vehicles_type_collections[anim_type]; |
| 51 | + V->PlayCycle(anims.idles[0], false); |
| 52 | + |
| 53 | + ResetCallbacks(); |
| 54 | + u16 head_bone = pK->LL_BoneID("bip01_head"); |
| 55 | + pK->LL_GetBoneInstance(u16(head_bone)).set_callback(bctPhysics, VehicleHeadCallback, this); |
45 | 56 |
|
46 | | - ResetCallbacks (); |
47 | | - u16 head_bone = pK->LL_BoneID("bip01_head"); |
48 | | - pK->LL_GetBoneInstance (u16(head_bone)).set_callback (bctPhysics, VehicleHeadCallback,this); |
| 57 | + character_physics_support()->movement()->DestroyCharacter(); |
| 58 | + mstate_wishful = 0; |
| 59 | + m_holderID = car->ID(); |
49 | 60 |
|
50 | | - character_physics_support ()->movement()->DestroyCharacter(); |
51 | | - mstate_wishful = 0; |
52 | | - m_holderID=car->ID (); |
| 61 | + SetWeaponHideState(INV_STATE_CAR, true); |
53 | 62 |
|
54 | | - SetWeaponHideState (INV_STATE_CAR, true); |
| 63 | + CStepManager::on_animation_start(MotionID(), nullptr); |
55 | 64 |
|
56 | | - CStepManager::on_animation_start(MotionID(), 0); |
57 | | - */ |
| 65 | + // Real Wolf: Колбек на посадку в машину. 01.08.2014. |
| 66 | + this->callback(GameObject::eAttachVehicle)(car->lua_game_object()); |
58 | 67 | } |
59 | 68 |
|
60 | 69 | void CActor::detach_Vehicle() |
@@ -97,6 +106,9 @@ void CActor::detach_Vehicle() |
97 | 106 |
|
98 | 107 | //. SetWeaponHideState(whs_CAR, FALSE); |
99 | 108 | SetWeaponHideState(INV_STATE_CAR, false); |
| 109 | + |
| 110 | + // Real Wolf: колбек на высадку из машины. 01.08.2014. |
| 111 | + this->callback(GameObject::eDetachVehicle)(car->lua_game_object()); |
100 | 112 | } |
101 | 113 |
|
102 | 114 | bool CActor::use_Vehicle(CHolderCustom* object) |
@@ -131,6 +143,9 @@ bool CActor::use_Vehicle(CHolderCustom* object) |
131 | 143 |
|
132 | 144 | attach_Vehicle(vehicle); |
133 | 145 | } |
| 146 | + // Real Wolf: колбек на использование машины (но не посадку) без учета расстояния. 01.08.2014. |
| 147 | + else if (auto car = smart_cast<CCar*>(vehicle)) |
| 148 | + this->callback(GameObject::eUseVehicle)(car->lua_game_object()); |
134 | 149 | return true; |
135 | 150 | } |
136 | 151 | return false; |
|
0 commit comments