Перейти к контенту

[SoC] Ковыряемся в файлах


Halford

Рекомендуемые сообщения

Ребят, тут мод скачал https://goo.gl/K73TMj но есть проблема в нем одна автор мода поломал инвентарь в bind_monster инвентарь монстров* он отрывается только если убить мутанта а затем сделать Save и Load ну вы поняли и еще он всегда пуст как можно решить эту проблему я в свой мод вставил а тут такое кто поможет тому спасибо от души и когда доработаю мод не забуду указать помощь) 


-----------------------------------------------------------------------------------
-- Monster binding
-----------------------------------------------------------------------------------

Скрытый текст

 

local particles={}
local table_enemy_cont = {}
local rand = math.random(1,100)
local BurerNum
local BurerTimer = 0
local song_start_sucks = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\vampire_sucking")

function bind(obj)
    printf("_bp: monster.bind: name='%s', id='%d'", obj:name(), obj:id())

    -- Для спауна
    --xr_spawner.spawn_client(obj)

    local new_binder = generic_object_binder(obj)
    obj:bind_object(new_binder)
end

------------------------------------------------------------------------------------
class "generic_object_binder" (object_binder)

function generic_object_binder:__init(obj) super(obj)
    self.loaded = false
    self.particles = {}
    self.MutantManager = ogsm_mutants.MutantManager()
    self.chtime = 0
    self.last_update = 0
    self.start_anim_hit_cont = false
    self.start_anim_hit_blood = false
    self.start_hit = false
end 

function generic_object_binder:reload(section)
    object_binder.reload(self, section)
end

function generic_object_binder:reinit()
    object_binder.reinit(self)

    -- У торговца нет поддержки перемещения
    if self.object:clsid() ~= clsid.script_trader then
        self.object:set_patrol_extrapolate_callback(generic_object_binder.extrapolate_callback, self)
    end

    db.storage[self.object:id()] = { }

    self.st = db.storage[self.object:id()]

    self.object:set_callback(callback.patrol_path_in_point, self.waypoint_callback, self)
    self.object:set_callback(callback.hit,                    self.hit_callback,        self)
    self.object:set_callback(callback.death,                self.death_callback,    self)
end

function generic_object_binder:update(delta)

    if string.find(self.object:name(), "crow_") then
        return false
    end

    object_binder.update(self, delta)

    if particles[self.object:id()] and table.getn(particles[self.object:id()])>0 then
        for kk,vv in pairs(particles[self.object:id()]) do
--            amk.mylog("particle found")
            table.insert(self.particles,amk_particle.amk_particle(vv))
            table.remove(particles[self.object:id()],kk)
        end
    end
        
    if table.getn(self.particles)>0 then
        for kk,vv in pairs(self.particles) do
            if vv:is_finished() then
                self.particles[kk]=nil
            else
                vv:update(delta)
            end
        end
    end


--    printf("_bp: generic_object_binder: UPDATE [name='%s' time=%d]",
--        self.object:name(), time_global())

    -- Апдейт торговли
    if self.object:clsid() == clsid.script_trader then
        trade_manager.update(self.object)
    end

    if self.object:clsid() == clsid.controller_s and self.object:alive() == true and time_global()>(self.upd_time or 0) then
        self.upd_time = time_global() + 1500
        local dist = self.object:position():distance_to(db.actor:position())
        if dist < 50 then
            if math.random()<(dist*0.1) then
                if phantom_manager.phantom_count()<5 then
                    local yaw = math.pi*2.0*math.random()
                    local radius = 30*(math.random()/2.0+0.5)
                    local height = 2.5*math.random()
                    local a_pos = db.actor:position()
                    local pos = vector():set(math.sin(yaw)*radius+a_pos.x,a_pos.y+height,math.cos(yaw)*radius+a_pos.z)
                    phantom_manager.spawn_phantom(pos)
                end
            end
        end
    end

    if self.object:alive() then
        if self.object:is_talk_enabled() then
            self.object:set_tip_text("character_use")
        else
            self.object:set_tip_text("")
        end
        
        -- Удар контролёра руками из Зова Припяти (Автор: demover123)
        if self.object:clsid() == clsid.controller_s then
            local target = self.object:get_enemy()
            if target and self.object:see(target) and IsStalker(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist <= 1.7 then
                    if not self.get_hit then
                        self.get_hit = time_global() + 100
                        self.start_anim_hit_cont = true
                    elseif self.get_hit <= time_global() then
                        if self.start_anim_hit_cont then
                            if self.object:animation_count() > 0 then
                                self.object:clear_animations()
                            end
                            self.object:play_cycle("stand_attack_1", true)
                            
                            local song_start = xr_sound.get_safe_sound_object("monsters\\controller\\controller_hit_2")
                            song_start:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                            self.start_anim_hit_cont = false
                        end
                        if not self.hit_to_enemy then
                            self.hit_to_enemy = time_global() + 300
                        elseif self.hit_to_enemy <= time_global() then
                            level.add_cam_effector("camera_effects\\hit_back_left.anm", 777, false, "")
                            
                            local h = hit()
                            h.draftsman = self.object
                            h.direction = vector():set(0,0,0)  
                            h:bone("bip01_spine")   
                            h.power     = 0.40     
                            h.impulse   = 1
                            h.type      = hit.wound
                            target:hit(h)
                            
                            self.hit_to_enemy = nil
                            self.get_hit = nil
                        end
                    end
                else
                    self.hit_to_enemy = nil
                    self.get_hit = nil
                end
            end
            if self.object:animation_count() < 1 then
                local i = math.random(0,5)
                self.object:add_animation("stand_walk_fwd_"..i, true)
            end
        end
        
        -- Новое повидение кровососа (Автор: demover123)
        if self.object:clsid() == clsid.bloodsucker_s then
            local target = self.object:get_enemy()
            if target and self.object:see(target) and (IsStalker(target) or IsMonster(target)) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 1.5 then
                    if not self.sucks and not self.steal then
                        rand = math.random(0,100)
                        if rand > 90 then
                            if self.object.health < 1.0 then
                                self.sucks = true
                            end
                        elseif rand < 90 and rand > 70 then
                            local active_slot = db.actor:active_slot()
                            if active_slot==1 or active_slot==2 then
                                self.steal = true
                            end
                        end
                    end
                    
                    if self.steal then
                        if not self.start_steal then
                            self.object:set_invisible(false)
                            self.object:play_cycle("!stand_attack_1", true)
                            local song_steal = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\hit_"..math.random(0,3))
                            if not song_steal:playing() then
                                song_steal:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                            end
                            self.start_steal = time_global() + 400
                        end
                        if self.start_steal <= time_global() then
                            db.actor:drop_item(db.actor:active_item())
                            local h = hit()
                            h.draftsman = self.object
                            h.direction = vector():set(0,0,0)  
                            h:bone("bip01_spine")   
                            h.power     = 0.10     
                            h.impulse   = 1
                            h.type      = hit.wound
                            target:hit(h)
                            self.start_steal = nil
                            self.steal = false
                            self.object:set_invisible(true)
                        end
                    end
                    
                    if self.sucks then
                        if self.object:animation_count() > 0 then
                            self.object:clear_animations()
                        end
                        if not self.bool_vamp_0 then
                            db.actor:hide_weapon()
                            self.object:set_invisible(false)
                            level.disable_input()
                            level.hide_indicators()
                            target:set_actor_direction(-self.object:position():sub(target:position()):getH())
                            self.object:play_cycle("vampire_0", true)
                            self.bool_vamp_0 = true
                        end
                        if not self.first_step then
                            self.first_step = time_global() + 1000
                        elseif self.first_step and self.first_step <= time_global() then
                            if self.object:animation_count() > 0 then
                                self.object:clear_animations()
                            end
                            if not self.bool_vamp_1 then
                                self.object:set_invisible(false)
                                self.object:play_cycle("vampire_1", true)
                                level.add_pp_effector("escape.ppe",778,true)
                                song_start_sucks:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                                self.bool_vamp_1 = true
                            end
                            if not self.bool_next_step then
                                self.second_step = time_global() + 2000
                                self.bool_next_step = true
                            end
                            
                            if self.second_step <= time_global() then
                                self.object:position():sub(target:position()):normalize()
                                
                                if not self.ending_sucks then
                                    self.ending_sucks = time_global() + 700
                                    self.object:set_invisible(false)
                                    local song_start = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\vampire_hit")
                                    song_start:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                                    self.object:play_cycle("vampire_2", true)
                                end
                                
                                if self.ending_sucks <= time_global() then
                                        
                                    level.add_cam_effector("camera_effects\\hit_back_right.anm", 779, false, "")
                                        
                                    local h = hit()
                                    h.draftsman = self.object
                                    h.direction = vector():set(0,0,0)  
                                    h:bone("bip01_spine")   
                                    h.power     = 0.40     
                                    h.impulse   = 1
                                    h.type      = hit.wound
                                    target:hit(h)
                                    
                                    self.object.health = self.object.health + 0.1
                                    
                                    db.actor:restore_weapon()
                                    
                                    level.remove_pp_effector(778)
                                    
                                    self.sucks = false
                                    self.first_step = nil
                                    self.second_step = nil
                                    self.bool_next_step = false
                                    self.bool_vamp_0 = false
                                    self.bool_vamp_1 = false
                                    self.object:set_invisible(true)
                                    rand = math.random(1,100)
                                    
                                    level.enable_input()
                                    level.show_indicators()
                                    
                                    self.ending_sucks = nil
                                end
                            end
                        end
                    end
                else 
                    if self.sucks then
                        db.actor:restore_weapon()
                        level.remove_pp_effector(778)
                        
                        self.object:clear_animations()
                        
                        self.object:set_invisible(true)
                        self.object:set_invisible(false)
                                    
                        if song_start_sucks:playing() then
                            song_start_sucks:stop()
                        end
                                    
                        self.sucks = false
                        self.first_step = nil
                        self.second_step = nil
                        self.bool_next_step = false
                        self.bool_vamp_0 = false
                        self.bool_vamp_1 = false
                        level.enable_input()
                        level.show_indicators()
                    elseif self.steal then
                        self.steal = false
                    end
                end
            end    
            if target and not self.object:see(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 20 then
                    if not self.time_to_boogie then
                        self.time_to_boogie = time_global() + (math.random(5,10) * 1000)
                    end
                    if self.time_to_boogie <= time_global() then
                        self.object:set_invisible(false)
                        self.object:play_cycle("stand_threaten_0", true)
                        local song_boogie = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\bloodsucker_script_attack_"..math.random(0,1))
                        if not song_boogie:playing() then
                            song_boogie:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 3.0)
                        end
                        if not self.gotoinvis then
                            self.gotoinvis = true
                        else
                            self.object:set_invisible(true)
                            self.time_to_boogie = nil
                            self.gotoinvis = false
                        end
                    end
                end
            end
        end
        
        -- Атака бюрера из Зова Припяти (Авторы: Shadows and Charsi and demover123)
        if self.object:clsid()==clsid.burer_s and BurerTimer < time_global() then
            local target = self.object:get_enemy()
            local v1 = self.object:direction()
            local v2 = db.actor:direction()
            if target and (target:id()==0) and (v1.x*v2.x)+(v1.z*v2.z)<-0.6 and self.object:see(db.actor) and self.object:position():distance_to(db.actor:position())<6 then
                BurerNum = 1
                db.actor.power = -1.0
                local active_slot = db.actor:active_slot()
                if active_slot==1 or active_slot==2 then
                    db.actor:drop_item(db.actor:active_item())
                    self.object:play_cycle("stand_attack_0", false)
                end
                BurerTimer = time_global() + 6000*(1+math.random(-0.2,0.2))
                self.object:add_animation("stand_idle_"..math.random(0,2), true)
            elseif BurerNum and BurerTimer < time_global() + 6000 then
                self.object:add_animation("stand_idle_"..math.random(0,2), true)
                BurerNum = nil
            end
        end
        
        -- Химера ищет жертву стоя на задних лапах идея была взята из одного квеста в Зове Припяти (Автор: demover123)
        if self.object:clsid()==clsid.chimera_s then
            local target = self.object:get_enemy()
            if target and not self.object:see(target) and IsStalker(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 10 then
                    if not self.find then
                        if self.object:animation_count() > 0 then
                            self.object:clear_animations()
                        end
                        self.object:play_cycle("look_around_0", false)
                        if not self.time_to_next_find then
                            self.time_to_next_find = time_global() + 4000
                        end
                        self.find = true
                    else
                        if self.time_to_next_find <= time_global() then
                            self.find = false
                            self.time_to_next_find = nil
                        end
                    end
                end
            end
        end
        
    else
        self.object:set_tip_text_default()
    end

   if IsMonster(self.object) and time_global() - self.last_update > 1000 then
            if self.object:alive() and self.object.health>0.01 then
                if self.object:see(db.actor) and db.actor:position():distance_to(self.object:position())<80*80 then amk.enemy_see_actor(self.object,"monster") end
                if db.actor:see(self.object) and db.actor:position():distance_to(self.object:position())<80*80 then amk.actor_see_enemy(self.object,"monster") end
            end
      self.last_update = time_global()
        end

    self.MutantManager:update(self.object)

    if self.st.active_section ~= nil then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "update", delta)
    end
end

function generic_object_binder:extrapolate_callback()
    local cur_pt = self.object:get_current_point_index()

    if self.object:get_script ()    == false then 
       return false
    end    
    
    if patrol(self.object:patrol()):flags(cur_pt):get() == 0 then
        --printf("_bp: generic_object_binder: extrapolate_callback: cur_pt = %d: true", cur_pt)
        return true
    end
    --printf("_bp: generic_object_binder: extrapolate_callback: cur_pt = %d: false", cur_pt)
    return false
end

function generic_object_binder:waypoint_callback(obj, action_type, index)
    if self.st.active_section ~= nil then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "waypoint_callback", obj, action_type, index)
    end
end

function generic_object_binder:death_callback(victim, who)
    if who:id() == db.actor:id() then
        xr_statistic.addKillCount(self.object)
    end

    if self.st.mob_death then
        xr_logic.issue_event(self.object, self.st.mob_death, "death_callback", victim, who)
    end
    
    victim:set_nonscript_usable(false)

    if self.st.active_section then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "death_callback", victim, who)
    end

    smart_terrain.on_death( self.object:id() )

    --' Наносим небольшой импульс вперед.
    local h = hit()
    h.draftsman = self.object
    h.type = hit.fire_wound
    h.direction = db.actor:position():sub(self.object:position())
    h:bone("pelvis")
    h.power = 1
    h.impulse = 10
    self.object:hit(h)

    if table.getn(self.particles)>0 then
        for kk,vv in pairs(self.particles) do
                vv:on_death()
        end
    end

    self.MutantManager:on_death(self.object)

    smart_monster_parts.death_spawn(victim)
end

function generic_object_binder:hit_callback(obj, amount, local_direction, who, bone_index)
--    printf("HIT_CALLBACK: [%s] amount[%s]", obj:name(), amount)
    if self.st.hit then
        xr_logic.issue_event(self.object, self.st.hit, "hit_callback", obj, amount, local_direction, who, bone_index)
    end
  amk.on_monster_hit(obj, amount, local_direction, who, bone_index)
    
    -- Щит бюрера из Зова Припяти (Автор: demover123)
    if self.object:clsid()==clsid.burer_s then
        if not self.time_hit then
            self.time_hit = time_global() + 4000
        end
        
        self.object:play_cycle("stand_tele_1", false)
        local particle_start = particles_object("anomaly2\\burer_shield_01")
        particle_start:play_at_pos(self.object:bone_position("bip01_head"))
        self.object.health = self.object.health + 0.1
        
        if self.time_hit <= time_global() then
            if self.object:animation_count() > 0 then
                self.object:clear_animations()
                particle_start:stop()
            end
        end
    end
end

function generic_object_binder:net_spawn(sobject)

    if string.find(self.object:name(), "crow_") then
        local sobj = alife():object(self.object:id())
        if sobj then
            alife():release(sobj, true)
            return false
        end
    end

    if not object_binder.net_spawn(self, sobject) then
        return false
    end

    news_main_spawn.on_spawn(self.object)
    db.add_obj(self.object)

    xr_gulag.setup_gulag_and_logic_on_spawn( self.object, self.st, sobject, modules.stype_mobile, self.loaded )

    local particle_param = utils.cfg_get_string(system_ini(), self.object:section(), "bones_particles", null, false, false, nil)
    
    if particle_param and system_ini():section_exist(particle_param) then
        local tmp=amk.parse_ini_section_to_array(system_ini(),particle_param)
        
        for k,v in pairs(tmp) do
            local t = amk.parse_ini_section_to_array(system_ini(), v)
            t.obj = self.object
            if not t.stop_on_death or self.object:alive() then
                play_particle(self.object, t)
            end
        end
    end

    return true
end

function generic_object_binder:net_destroy()

    if table.getn(self.particles)>0 then
        for kk,vv in pairs(self.particles) do
            if not vv:is_finished() then
                vv:stop()
                self.particles[kk]=nil
            end
        end
    end

    self.object:set_callback(callback.death,                nil)
    self.object:set_callback(callback.patrol_path_in_point, nil)
    self.object:set_callback(callback.hit,                    nil)

    local st = db.storage[self.object:id()]
    if st and st.active_scheme then
        xr_logic.issue_event(self.object, st[st.active_scheme], "net_destroy")
    end
    
    db.del_obj(self.object)
    db.storage[self.object:id()] = nil

    object_binder.net_destroy(self)
end 

function generic_object_binder:reload(section)
    object_binder.reload(self, section)
    --printf("generic_object_binder:reload(): self.object:name()='%s'", self.object:name())
end

function generic_object_binder:net_save_relevant()
    --printf("generic_object_binder:net_save_relevant(): self.object:name()='%s'", self.object:name())
    return true
end

function generic_object_binder:save(packet)

    if string.find(self.object:name(), "crow_") then
        return false
    end

    printf("generic_object_binder:save(): self.object:name()='%s'", self.object:name())
    object_binder.save(self, packet)

    xr_logic.save_obj(self.object, packet)
    if self.object:clsid() == clsid.script_trader then
        trade_manager.save(self.object, packet)
    end
end

function generic_object_binder:load(reader)

    if string.find(self.object:name(), "crow_") then
        return false
    end

    self.loaded = true

    printf("generic_object_binder:load(): self.object:name()='%s'", self.object:name())
    object_binder.load(self, reader)

    if reader:r_eof() then
        abort("SAVE FILE IS CORRUPT")
    end

    xr_logic.load_obj(self.object, reader)
    if self.object:clsid() == clsid.script_trader then
        trade_manager.load(self.object, reader)
    end
end

function play_particle(obj,params)
    if not particles[obj:id()] then
        particles[obj:id()]={}
    end
    table.insert(particles[obj:id()],params)
end

 

 

Поделиться этим сообщением


Ссылка на сообщение

Вот код из архива мода с ошибкой сверху ошибся.

 

 

 

-----------------------------------------------------------------------------------
-- Monster binding
-----------------------------------------------------------------------------------

Скрытый текст

 

local table_enemy_cont = {}
local rand = math.random(1,100)
local BurerNum
local BurerTimer = 0
local song_start_sucks = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\vampire_sucking")

function bind(obj)
    printf("_bp: monster.bind: name='%s', id='%d'", obj:name(), obj:id())

    -- Для спауна
    --xr_spawner.spawn_client(obj)

    local new_binder = generic_object_binder(obj)
    obj:bind_object(new_binder)
end

------------------------------------------------------------------------------------
class "generic_object_binder" (object_binder)

function generic_object_binder:__init(obj) super(obj)
    self.loaded = false
    self.start_anim_hit_cont = false
    self.start_anim_hit_blood = false
    self.start_hit = false
end 

function generic_object_binder:reload(section)
    object_binder.reload(self, section)
end

function generic_object_binder:reinit()
    object_binder.reinit(self)

    -- У торговца нет поддержки перемещения
    if self.object:clsid() ~= clsid.script_trader then
        self.object:set_patrol_extrapolate_callback(generic_object_binder.extrapolate_callback, self)
    end

    db.storage[self.object:id()] = { }

    self.st = db.storage[self.object:id()]

    self.object:set_callback(callback.patrol_path_in_point, self.waypoint_callback, self)
    self.object:set_callback(callback.hit,                    self.hit_callback,        self)
    self.object:set_callback(callback.death,                self.death_callback,    self)
end

function generic_object_binder:update(delta)
    object_binder.update(self, delta)

--    printf("_bp: generic_object_binder: UPDATE [name='%s' time=%d]",
--        self.object:name(), time_global())

    -- Апдейт торговли
    if self.object:clsid() == clsid.script_trader then
        trade_manager.update(self.object)
    end

    if self.object:alive() then
        if self.object:is_talk_enabled() then
            self.object:set_tip_text("character_use")
        else
            self.object:set_tip_text("")
        end
        
        -- Удар контролёра руками из Зова Припяти (Автор: demover123)
        if self.object:clsid() == clsid.controller_s then
            local target = self.object:get_enemy()
            if target and self.object:see(target) and IsStalker(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist <= 1.7 then
                    if not self.get_hit then
                        self.get_hit = time_global() + 100
                        self.start_anim_hit_cont = true
                    elseif self.get_hit <= time_global() then
                        if self.start_anim_hit_cont then
                            if self.object:animation_count() > 0 then
                                self.object:clear_animations()
                            end
                            self.object:play_cycle("stand_attack_1", true)
                            
                            local song_start = xr_sound.get_safe_sound_object("monsters\\controller\\controller_hit_2")
                            song_start:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                            self.start_anim_hit_cont = false
                        end
                        if not self.hit_to_enemy then
                            self.hit_to_enemy = time_global() + 300
                        elseif self.hit_to_enemy <= time_global() then
                            level.add_cam_effector("camera_effects\\hit_back_left.anm", 777, false, "")
                            
                            local h = hit()
                            h.draftsman = self.object
                            h.direction = vector():set(0,0,0)  
                            h:bone("bip01_spine")   
                            h.power     = 0.40     
                            h.impulse   = 1
                            h.type      = hit.wound
                            target:hit(h)
                            
                            self.hit_to_enemy = nil
                            self.get_hit = nil
                        end
                    end
                else
                    self.hit_to_enemy = nil
                    self.get_hit = nil
                end
            end
            if self.object:animation_count() < 1 then
                local i = math.random(0,5)
                self.object:add_animation("stand_walk_fwd_"..i, true)
            end
        end
        
        -- Новое повидение кровососа (Автор: demover123)
        if self.object:clsid() == clsid.bloodsucker_s then
            local target = self.object:get_enemy()
            if target and self.object:see(target) and (IsStalker(target) or IsMonster(target)) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 1.5 then
                    if not self.sucks and not self.steal then
                        rand = math.random(0,100)
                        if rand > 90 then
                            if self.object.health < 1.0 then
                                self.sucks = true
                            end
                        elseif rand < 90 and rand > 70 then
                            local active_slot = db.actor:active_slot()
                            if active_slot==1 or active_slot==2 then
                                self.steal = true
                            end
                        end
                    end
                    
                    if self.steal then
                        if not self.start_steal then
                            self.object:set_invisible(false)
                            self.object:play_cycle("!stand_attack_1", true)
                            local song_steal = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\hit_"..math.random(0,3))
                            if not song_steal:playing() then
                                song_steal:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                            end
                            self.start_steal = time_global() + 400
                        end
                        if self.start_steal <= time_global() then
                            db.actor:drop_item(db.actor:active_item())
                            local h = hit()
                            h.draftsman = self.object
                            h.direction = vector():set(0,0,0)  
                            h:bone("bip01_spine")   
                            h.power     = 0.10     
                            h.impulse   = 1
                            h.type      = hit.wound
                            target:hit(h)
                            self.start_steal = nil
                            self.steal = false
                            self.object:set_invisible(true)
                        end
                    end
                    
                    if self.sucks then
                        if self.object:animation_count() > 0 then
                            self.object:clear_animations()
                        end
                        if not self.bool_vamp_0 then
                            db.actor:hide_weapon()
                            self.object:set_invisible(false)
                            level.disable_input()
                            level.hide_indicators()
                            target:set_actor_direction(-self.object:position():sub(target:position()):getH())
                            self.object:play_cycle("vampire_0", true)
                            self.bool_vamp_0 = true
                        end
                        if not self.first_step then
                            self.first_step = time_global() + 1000
                        elseif self.first_step and self.first_step <= time_global() then
                            if self.object:animation_count() > 0 then
                                self.object:clear_animations()
                            end
                            if not self.bool_vamp_1 then
                                self.object:set_invisible(false)
                                self.object:play_cycle("vampire_1", true)
                                level.add_pp_effector("escape.ppe",778,true)
                                song_start_sucks:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                                self.bool_vamp_1 = true
                            end
                            if not self.bool_next_step then
                                self.second_step = time_global() + 2000
                                self.bool_next_step = true
                            end
                            
                            if self.second_step <= time_global() then
                                self.object:position():sub(target:position()):normalize()
                                
                                if not self.ending_sucks then
                                    self.ending_sucks = time_global() + 700
                                    self.object:set_invisible(false)
                                    local song_start = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\vampire_hit")
                                    song_start:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                                    self.object:play_cycle("vampire_2", true)
                                end
                                
                                if self.ending_sucks <= time_global() then
                                        
                                    level.add_cam_effector("camera_effects\\hit_back_right.anm", 779, false, "")
                                        
                                    local h = hit()
                                    h.draftsman = self.object
                                    h.direction = vector():set(0,0,0)  
                                    h:bone("bip01_spine")   
                                    h.power     = 0.40     
                                    h.impulse   = 1
                                    h.type      = hit.wound
                                    target:hit(h)
                                    
                                    self.object.health = self.object.health + 0.1
                                    
                                    db.actor:restore_weapon()
                                    
                                    level.remove_pp_effector(778)
                                    
                                    self.sucks = false
                                    self.first_step = nil
                                    self.second_step = nil
                                    self.bool_next_step = false
                                    self.bool_vamp_0 = false
                                    self.bool_vamp_1 = false
                                    self.object:set_invisible(true)
                                    rand = math.random(1,100)
                                    
                                    level.enable_input()
                                    level.show_indicators()
                                    
                                    self.ending_sucks = nil
                                end
                            end
                        end
                    end
                else 
                    if self.sucks then
                        db.actor:restore_weapon()
                        level.remove_pp_effector(778)
                        
                        self.object:clear_animations()
                        
                        self.object:set_invisible(true)
                        self.object:set_invisible(false)
                                    
                        if song_start_sucks:playing() then
                            song_start_sucks:stop()
                        end
                                    
                        self.sucks = false
                        self.first_step = nil
                        self.second_step = nil
                        self.bool_next_step = false
                        self.bool_vamp_0 = false
                        self.bool_vamp_1 = false
                        level.enable_input()
                        level.show_indicators()
                    elseif self.steal then
                        self.steal = false
                    end
                end
            end    
            if target and not self.object:see(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 20 then
                    if not self.time_to_boogie then
                        self.time_to_boogie = time_global() + (math.random(5,10) * 1000)
                    end
                    if self.time_to_boogie <= time_global() then
                        self.object:set_invisible(false)
                        self.object:play_cycle("stand_threaten_0", true)
                        local song_boogie = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\bloodsucker_script_attack_"..math.random(0,1))
                        if not song_boogie:playing() then
                            song_boogie:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 3.0)
                        end
                        if not self.gotoinvis then
                            self.gotoinvis = true
                        else
                            self.object:set_invisible(true)
                            self.time_to_boogie = nil
                            self.gotoinvis = false
                        end
                    end
                end
            end
        end
        
        -- Атака бюрера из Зова Припяти (Авторы: Shadows and Charsi and demover123)
        if self.object:clsid()==clsid.burer_s and BurerTimer < time_global() then
            local target = self.object:get_enemy()
            local v1 = self.object:direction()
            local v2 = db.actor:direction()
            if target and (target:id()==0) and (v1.x*v2.x)+(v1.z*v2.z)<-0.6 and self.object:see(db.actor) and self.object:position():distance_to(db.actor:position())<6 then
                BurerNum = 1
                db.actor.power = -1.0
                local active_slot = db.actor:active_slot()
                if active_slot==1 or active_slot==2 then
                    db.actor:drop_item(db.actor:active_item())
                    self.object:play_cycle("stand_attack_0", false)
                end
                BurerTimer = time_global() + 6000*(1+math.random(-0.2,0.2))
                self.object:add_animation("stand_idle_"..math.random(0,2), true)
            elseif BurerNum and BurerTimer < time_global() + 6000 then
                self.object:add_animation("stand_idle_"..math.random(0,2), true)
                BurerNum = nil
            end
        end
        
        -- Химера ищет жертву стоя на задних лапах идея была взята из одного квеста в Зове Припяти (Автор: demover123)
        if self.object:clsid()==clsid.chimera_s then
            local target = self.object:get_enemy()
            if target and not self.object:see(target) and IsStalker(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 10 then
                    if not self.find then
                        if self.object:animation_count() > 0 then
                            self.object:clear_animations()
                        end
                        self.object:play_cycle("look_around_0", false)
                        if not self.time_to_next_find then
                            self.time_to_next_find = time_global() + 4000
                        end
                        self.find = true
                    else
                        if self.time_to_next_find <= time_global() then
                            self.find = false
                            self.time_to_next_find = nil
                        end
                    end
                end
            end
        end
        
    else
        self.object:set_tip_text_default()
    end

    if self.st.active_section ~= nil then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "update", delta)
    end
end

function generic_object_binder:extrapolate_callback()
    local cur_pt = self.object:get_current_point_index()

    if self.object:get_script ()    == false then 
       return false
    end    
    
    if patrol(self.object:patrol()):flags(cur_pt):get() == 0 then
        --printf("_bp: generic_object_binder: extrapolate_callback: cur_pt = %d: true", cur_pt)
        return true
    end
    --printf("_bp: generic_object_binder: extrapolate_callback: cur_pt = %d: false", cur_pt)
    return false
end

function generic_object_binder:waypoint_callback(obj, action_type, index)
    if self.st.active_section ~= nil then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "waypoint_callback", obj, action_type, index)
    end
end

function generic_object_binder:death_callback(victim, who)
    if who:id() == db.actor:id() then
        xr_statistic.addKillCount(self.object)
    end

    if self.st.mob_death then
        xr_logic.issue_event(self.object, self.st.mob_death, "death_callback", victim, who)
    end
    
    victim:set_nonscript_usable(false)

    if self.st.active_section then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "death_callback", victim, who)
    end

    smart_terrain.on_death( self.object:id() )

    --' Наносим небольшой импульс вперед.
    local h = hit()
    h.draftsman = self.object
    h.type = hit.fire_wound
    h.direction = db.actor:position():sub(self.object:position())
    h:bone("pelvis")
    h.power = 1
    h.impulse = 10
    self.object:hit(h)

end

function generic_object_binder:hit_callback(obj, amount, local_direction, who, bone_index)
--    printf("HIT_CALLBACK: [%s] amount[%s]", obj:name(), amount)
    if self.st.hit then
        xr_logic.issue_event(self.object, self.st.hit, "hit_callback", obj, amount, local_direction, who, bone_index)
    end
    
    -- Щит бюрера из Зова Припяти (Автор: demover123)
    if self.object:clsid()==clsid.burer_s then
        if not self.time_hit then
            self.time_hit = time_global() + 4000
        end
        
        self.object:play_cycle("stand_tele_1", false)
        local particle_start = particles_object("anomaly2\\burer_shield_01")
        particle_start:play_at_pos(self.object:bone_position("bip01_head"))
        self.object.health = self.object.health + 0.1
        
        if self.time_hit <= time_global() then
            if self.object:animation_count() > 0 then
                self.object:clear_animations()
                particle_start:stop()
            end
        end
    end
end

function generic_object_binder:net_spawn(sobject)
    if not object_binder.net_spawn(self, sobject) then
        return false
    end

    db.add_obj(self.object)

    xr_gulag.setup_gulag_and_logic_on_spawn( self.object, self.st, sobject, modules.stype_mobile, self.loaded )

    return true
end

function generic_object_binder:net_destroy()
    self.object:set_callback(callback.death,                nil)
    self.object:set_callback(callback.patrol_path_in_point, nil)
    self.object:set_callback(callback.hit,                    nil)

    local st = db.storage[self.object:id()]
    if st and st.active_scheme then
        xr_logic.issue_event(self.object, st[st.active_scheme], "net_destroy")
    end
    
    db.del_obj(self.object)
    db.storage[self.object:id()] = nil

    object_binder.net_destroy(self)
end 

function generic_object_binder:reload(section)
    object_binder.reload(self, section)
    --printf("generic_object_binder:reload(): self.object:name()='%s'", self.object:name())
end

function generic_object_binder:net_save_relevant()
    --printf("generic_object_binder:net_save_relevant(): self.object:name()='%s'", self.object:name())
    return true
end

function generic_object_binder:save(packet)
    printf("generic_object_binder:save(): self.object:name()='%s'", self.object:name())
    object_binder.save(self, packet)

    xr_logic.save_obj(self.object, packet)
    if self.object:clsid() == clsid.script_trader then
        trade_manager.save(self.object, packet)
    end
end

function generic_object_binder:load(reader)
    self.loaded = true

    printf("generic_object_binder:load(): self.object:name()='%s'", self.object:name())
    object_binder.load(self, reader)

    if reader:r_eof() then
        abort("SAVE FILE IS CORRUPT")
    end

    xr_logic.load_obj(self.object, reader)
    if self.object:clsid() == clsid.script_trader then
        trade_manager.load(self.object, reader)
    end
end

 

 

Поделиться этим сообщением


Ссылка на сообщение
2 часа назад, Dead_Land сказал:

Вот код из архива мода с ошибкой сверху ошибся.

 

 

 

-----------------------------------------------------------------------------------
-- Monster binding
-----------------------------------------------------------------------------------

  Показать

 

local table_enemy_cont = {}
local rand = math.random(1,100)
local BurerNum
local BurerTimer = 0
local song_start_sucks = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\vampire_sucking")

function bind(obj)
    printf("_bp: monster.bind: name='%s', id='%d'", obj:name(), obj:id())

    -- Для спауна
    --xr_spawner.spawn_client(obj)

    local new_binder = generic_object_binder(obj)
    obj:bind_object(new_binder)
end

------------------------------------------------------------------------------------
class "generic_object_binder" (object_binder)

function generic_object_binder:__init(obj) super(obj)
    self.loaded = false
    self.start_anim_hit_cont = false
    self.start_anim_hit_blood = false
    self.start_hit = false
end 

function generic_object_binder:reload(section)
    object_binder.reload(self, section)
end

function generic_object_binder:reinit()
    object_binder.reinit(self)

    -- У торговца нет поддержки перемещения
    if self.object:clsid() ~= clsid.script_trader then
        self.object:set_patrol_extrapolate_callback(generic_object_binder.extrapolate_callback, self)
    end

    db.storage[self.object:id()] = { }

    self.st = db.storage[self.object:id()]

    self.object:set_callback(callback.patrol_path_in_point, self.waypoint_callback, self)
    self.object:set_callback(callback.hit,                    self.hit_callback,        self)
    self.object:set_callback(callback.death,                self.death_callback,    self)
end

function generic_object_binder:update(delta)
    object_binder.update(self, delta)

--    printf("_bp: generic_object_binder: UPDATE [name='%s' time=%d]",
--        self.object:name(), time_global())

    -- Апдейт торговли
    if self.object:clsid() == clsid.script_trader then
        trade_manager.update(self.object)
    end

    if self.object:alive() then
        if self.object:is_talk_enabled() then
            self.object:set_tip_text("character_use")
        else
            self.object:set_tip_text("")
        end
        
        -- Удар контролёра руками из Зова Припяти (Автор: demover123)
        if self.object:clsid() == clsid.controller_s then
            local target = self.object:get_enemy()
            if target and self.object:see(target) and IsStalker(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist <= 1.7 then
                    if not self.get_hit then
                        self.get_hit = time_global() + 100
                        self.start_anim_hit_cont = true
                    elseif self.get_hit <= time_global() then
                        if self.start_anim_hit_cont then
                            if self.object:animation_count() > 0 then
                                self.object:clear_animations()
                            end
                            self.object:play_cycle("stand_attack_1", true)
                            
                            local song_start = xr_sound.get_safe_sound_object("monsters\\controller\\controller_hit_2")
                            song_start:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                            self.start_anim_hit_cont = false
                        end
                        if not self.hit_to_enemy then
                            self.hit_to_enemy = time_global() + 300
                        elseif self.hit_to_enemy <= time_global() then
                            level.add_cam_effector("camera_effects\\hit_back_left.anm", 777, false, "")
                            
                            local h = hit()
                            h.draftsman = self.object
                            h.direction = vector():set(0,0,0)  
                            h:bone("bip01_spine")   
                            h.power     = 0.40     
                            h.impulse   = 1
                            h.type      = hit.wound
                            target:hit(h)
                            
                            self.hit_to_enemy = nil
                            self.get_hit = nil
                        end
                    end
                else
                    self.hit_to_enemy = nil
                    self.get_hit = nil
                end
            end
            if self.object:animation_count() < 1 then
                local i = math.random(0,5)
                self.object:add_animation("stand_walk_fwd_"..i, true)
            end
        end
        
        -- Новое повидение кровососа (Автор: demover123)
        if self.object:clsid() == clsid.bloodsucker_s then
            local target = self.object:get_enemy()
            if target and self.object:see(target) and (IsStalker(target) or IsMonster(target)) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 1.5 then
                    if not self.sucks and not self.steal then
                        rand = math.random(0,100)
                        if rand > 90 then
                            if self.object.health < 1.0 then
                                self.sucks = true
                            end
                        elseif rand < 90 and rand > 70 then
                            local active_slot = db.actor:active_slot()
                            if active_slot==1 or active_slot==2 then
                                self.steal = true
                            end
                        end
                    end
                    
                    if self.steal then
                        if not self.start_steal then
                            self.object:set_invisible(false)
                            self.object:play_cycle("!stand_attack_1", true)
                            local song_steal = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\hit_"..math.random(0,3))
                            if not song_steal:playing() then
                                song_steal:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                            end
                            self.start_steal = time_global() + 400
                        end
                        if self.start_steal <= time_global() then
                            db.actor:drop_item(db.actor:active_item())
                            local h = hit()
                            h.draftsman = self.object
                            h.direction = vector():set(0,0,0)  
                            h:bone("bip01_spine")   
                            h.power     = 0.10     
                            h.impulse   = 1
                            h.type      = hit.wound
                            target:hit(h)
                            self.start_steal = nil
                            self.steal = false
                            self.object:set_invisible(true)
                        end
                    end
                    
                    if self.sucks then
                        if self.object:animation_count() > 0 then
                            self.object:clear_animations()
                        end
                        if not self.bool_vamp_0 then
                            db.actor:hide_weapon()
                            self.object:set_invisible(false)
                            level.disable_input()
                            level.hide_indicators()
                            target:set_actor_direction(-self.object:position():sub(target:position()):getH())
                            self.object:play_cycle("vampire_0", true)
                            self.bool_vamp_0 = true
                        end
                        if not self.first_step then
                            self.first_step = time_global() + 1000
                        elseif self.first_step and self.first_step <= time_global() then
                            if self.object:animation_count() > 0 then
                                self.object:clear_animations()
                            end
                            if not self.bool_vamp_1 then
                                self.object:set_invisible(false)
                                self.object:play_cycle("vampire_1", true)
                                level.add_pp_effector("escape.ppe",778,true)
                                song_start_sucks:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                                self.bool_vamp_1 = true
                            end
                            if not self.bool_next_step then
                                self.second_step = time_global() + 2000
                                self.bool_next_step = true
                            end
                            
                            if self.second_step <= time_global() then
                                self.object:position():sub(target:position()):normalize()
                                
                                if not self.ending_sucks then
                                    self.ending_sucks = time_global() + 700
                                    self.object:set_invisible(false)
                                    local song_start = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\vampire_hit")
                                    song_start:play_at_pos(self.object, self.object:position(), sound_object.s3d)
                                    self.object:play_cycle("vampire_2", true)
                                end
                                
                                if self.ending_sucks <= time_global() then
                                        
                                    level.add_cam_effector("camera_effects\\hit_back_right.anm", 779, false, "")
                                        
                                    local h = hit()
                                    h.draftsman = self.object
                                    h.direction = vector():set(0,0,0)  
                                    h:bone("bip01_spine")   
                                    h.power     = 0.40     
                                    h.impulse   = 1
                                    h.type      = hit.wound
                                    target:hit(h)
                                    
                                    self.object.health = self.object.health + 0.1
                                    
                                    db.actor:restore_weapon()
                                    
                                    level.remove_pp_effector(778)
                                    
                                    self.sucks = false
                                    self.first_step = nil
                                    self.second_step = nil
                                    self.bool_next_step = false
                                    self.bool_vamp_0 = false
                                    self.bool_vamp_1 = false
                                    self.object:set_invisible(true)
                                    rand = math.random(1,100)
                                    
                                    level.enable_input()
                                    level.show_indicators()
                                    
                                    self.ending_sucks = nil
                                end
                            end
                        end
                    end
                else 
                    if self.sucks then
                        db.actor:restore_weapon()
                        level.remove_pp_effector(778)
                        
                        self.object:clear_animations()
                        
                        self.object:set_invisible(true)
                        self.object:set_invisible(false)
                                    
                        if song_start_sucks:playing() then
                            song_start_sucks:stop()
                        end
                                    
                        self.sucks = false
                        self.first_step = nil
                        self.second_step = nil
                        self.bool_next_step = false
                        self.bool_vamp_0 = false
                        self.bool_vamp_1 = false
                        level.enable_input()
                        level.show_indicators()
                    elseif self.steal then
                        self.steal = false
                    end
                end
            end    
            if target and not self.object:see(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 20 then
                    if not self.time_to_boogie then
                        self.time_to_boogie = time_global() + (math.random(5,10) * 1000)
                    end
                    if self.time_to_boogie <= time_global() then
                        self.object:set_invisible(false)
                        self.object:play_cycle("stand_threaten_0", true)
                        local song_boogie = xr_sound.get_safe_sound_object("monsters\\bloodsucker\\bloodsucker_script_attack_"..math.random(0,1))
                        if not song_boogie:playing() then
                            song_boogie:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 3.0)
                        end
                        if not self.gotoinvis then
                            self.gotoinvis = true
                        else
                            self.object:set_invisible(true)
                            self.time_to_boogie = nil
                            self.gotoinvis = false
                        end
                    end
                end
            end
        end
        
        -- Атака бюрера из Зова Припяти (Авторы: Shadows and Charsi and demover123)
        if self.object:clsid()==clsid.burer_s and BurerTimer < time_global() then
            local target = self.object:get_enemy()
            local v1 = self.object:direction()
            local v2 = db.actor:direction()
            if target and (target:id()==0) and (v1.x*v2.x)+(v1.z*v2.z)<-0.6 and self.object:see(db.actor) and self.object:position():distance_to(db.actor:position())<6 then
                BurerNum = 1
                db.actor.power = -1.0
                local active_slot = db.actor:active_slot()
                if active_slot==1 or active_slot==2 then
                    db.actor:drop_item(db.actor:active_item())
                    self.object:play_cycle("stand_attack_0", false)
                end
                BurerTimer = time_global() + 6000*(1+math.random(-0.2,0.2))
                self.object:add_animation("stand_idle_"..math.random(0,2), true)
            elseif BurerNum and BurerTimer < time_global() + 6000 then
                self.object:add_animation("stand_idle_"..math.random(0,2), true)
                BurerNum = nil
            end
        end
        
        -- Химера ищет жертву стоя на задних лапах идея была взята из одного квеста в Зове Припяти (Автор: demover123)
        if self.object:clsid()==clsid.chimera_s then
            local target = self.object:get_enemy()
            if target and not self.object:see(target) and IsStalker(target) then
                local dist = self.object:position():distance_to(target:position())
                if dist < 10 then
                    if not self.find then
                        if self.object:animation_count() > 0 then
                            self.object:clear_animations()
                        end
                        self.object:play_cycle("look_around_0", false)
                        if not self.time_to_next_find then
                            self.time_to_next_find = time_global() + 4000
                        end
                        self.find = true
                    else
                        if self.time_to_next_find <= time_global() then
                            self.find = false
                            self.time_to_next_find = nil
                        end
                    end
                end
            end
        end
        
    else
        self.object:set_tip_text_default()
    end

    if self.st.active_section ~= nil then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "update", delta)
    end
end

function generic_object_binder:extrapolate_callback()
    local cur_pt = self.object:get_current_point_index()

    if self.object:get_script ()    == false then 
       return false
    end    
    
    if patrol(self.object:patrol()):flags(cur_pt):get() == 0 then
        --printf("_bp: generic_object_binder: extrapolate_callback: cur_pt = %d: true", cur_pt)
        return true
    end
    --printf("_bp: generic_object_binder: extrapolate_callback: cur_pt = %d: false", cur_pt)
    return false
end

function generic_object_binder:waypoint_callback(obj, action_type, index)
    if self.st.active_section ~= nil then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "waypoint_callback", obj, action_type, index)
    end
end

function generic_object_binder:death_callback(victim, who)
    if who:id() == db.actor:id() then
        xr_statistic.addKillCount(self.object)
    end

    if self.st.mob_death then
        xr_logic.issue_event(self.object, self.st.mob_death, "death_callback", victim, who)
    end
    
    victim:set_nonscript_usable(false)

    if self.st.active_section then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "death_callback", victim, who)
    end

    smart_terrain.on_death( self.object:id() )

    --' Наносим небольшой импульс вперед.
    local h = hit()
    h.draftsman = self.object
    h.type = hit.fire_wound
    h.direction = db.actor:position():sub(self.object:position())
    h:bone("pelvis")
    h.power = 1
    h.impulse = 10
    self.object:hit(h)

end

function generic_object_binder:hit_callback(obj, amount, local_direction, who, bone_index)
--    printf("HIT_CALLBACK: [%s] amount[%s]", obj:name(), amount)
    if self.st.hit then
        xr_logic.issue_event(self.object, self.st.hit, "hit_callback", obj, amount, local_direction, who, bone_index)
    end
    
    -- Щит бюрера из Зова Припяти (Автор: demover123)
    if self.object:clsid()==clsid.burer_s then
        if not self.time_hit then
            self.time_hit = time_global() + 4000
        end
        
        self.object:play_cycle("stand_tele_1", false)
        local particle_start = particles_object("anomaly2\\burer_shield_01")
        particle_start:play_at_pos(self.object:bone_position("bip01_head"))
        self.object.health = self.object.health + 0.1
        
        if self.time_hit <= time_global() then
            if self.object:animation_count() > 0 then
                self.object:clear_animations()
                particle_start:stop()
            end
        end
    end
end

function generic_object_binder:net_spawn(sobject)
    if not object_binder.net_spawn(self, sobject) then
        return false
    end

    db.add_obj(self.object)

    xr_gulag.setup_gulag_and_logic_on_spawn( self.object, self.st, sobject, modules.stype_mobile, self.loaded )

    return true
end

function generic_object_binder:net_destroy()
    self.object:set_callback(callback.death,                nil)
    self.object:set_callback(callback.patrol_path_in_point, nil)
    self.object:set_callback(callback.hit,                    nil)

    local st = db.storage[self.object:id()]
    if st and st.active_scheme then
        xr_logic.issue_event(self.object, st[st.active_scheme], "net_destroy")
    end
    
    db.del_obj(self.object)
    db.storage[self.object:id()] = nil

    object_binder.net_destroy(self)
end 

function generic_object_binder:reload(section)
    object_binder.reload(self, section)
    --printf("generic_object_binder:reload(): self.object:name()='%s'", self.object:name())
end

function generic_object_binder:net_save_relevant()
    --printf("generic_object_binder:net_save_relevant(): self.object:name()='%s'", self.object:name())
    return true
end

function generic_object_binder:save(packet)
    printf("generic_object_binder:save(): self.object:name()='%s'", self.object:name())
    object_binder.save(self, packet)

    xr_logic.save_obj(self.object, packet)
    if self.object:clsid() == clsid.script_trader then
        trade_manager.save(self.object, packet)
    end
end

function generic_object_binder:load(reader)
    self.loaded = true

    printf("generic_object_binder:load(): self.object:name()='%s'", self.object:name())
    object_binder.load(self, reader)

    if reader:r_eof() then
        abort("SAVE FILE IS CORRUPT")
    end

    xr_logic.load_obj(self.object, reader)
    if self.object:clsid() == clsid.script_trader then
        trade_manager.load(self.object, reader)
    end
end

 

 

Есть кто шарит в этом?

Поделиться этим сообщением


Ссылка на сообщение
4 часа назад, Купер сказал:

@Змея

  Показать

- Видно, встал не с той ноги?

- Не болтай, а помоги!(с) :biggrin:

Хотя, да, модная нынче манера - "...дайте мне таблеток от жадности, побольше и желательно сразу...", несколько... м-мм... раздражает.

@Dead_Land, "сварщик не настоящий"(с), но, как вариант, почитать здесь о методе  set_nonscript_usable(bool) и где-то здесь

  Скрыть


function generic_object_binder:death_callback(victim, who)
...  
--   victim:set_nonscript_usable(false)
...
end

 

применить на практике.

p.s.: бли-и-ин, граммар-наци бесится: всё-таки "повИдение" через "е".

--   victim:set_nonscript_usable(false)
Вот я на него и думал щас попробую чёнить забабахать спасибо)

Поделиться этим сообщением


Ссылка на сообщение
4 часа назад, Купер сказал:

@Змея

  Показать

- Видно, встал не с той ноги?

- Не болтай, а помоги!(с) :biggrin:

Хотя, да, модная нынче манера - "...дайте мне таблеток от жадности, побольше и желательно сразу...", несколько... м-мм... раздражает.

@Dead_Land, "сварщик не настоящий"(с), но, как вариант, почитать здесь о методе  set_nonscript_usable(bool) и где-то здесь

  Скрыть


function generic_object_binder:death_callback(victim, who)
...  
--   victim:set_nonscript_usable(false)
...
end

 

применить на практике.

p.s.: бли-и-ин, граммар-наци бесится: всё-таки "повИдение" через "е".

Вообщем-то я просто вырезал эту строчку зачем автор мода её туда вставил остается загадкой так как она вообще роли особой не играет но спасибо иду дальше мод пилить.

P.S Ребят с АМК  как вы в логике задали военным на насыпи координаты передвижения ?

Поделиться этим сообщением


Ссылка на сообщение

Ребят что это может значить?

 

Expression    : fatal error
Function      : CScriptEngine::lua_error
File          : E:\stalker\patch_1_0004\xr_3da\xrGame\script_engine.cpp
Line          : 73
Description   : <no expression>
Arguments     : LUA error: ...yl way of death\gamedata\scripts\xr_motivator.script:409: attempt to call field 'on_npc_hit' (a nil value) Раньше не было мод кстати Interactive_Music_Mod ругает когда неписи начинают Pvp так сказать)

Поделиться этим сообщением


Ссылка на сообщение
В 24.12.2018 в 11:20, Houdini_one сказал:

@Dead_Land, мы совершенно не знаем, что ты делал.
Возможно, твой мод на версию 1.0006, в следствии несовместимости вылетает.

Мод поддерживает версии 1.0004-5, вот код с мотиватора проблемный on_npc_hit понятия не имею почему он ругает может я его как-то нетуда прописал ?!

 

 

 


--[[------------------------------------------------------------------------------------------------------------------
автор: Диденко Руслан (Stohe)

порядок вызова методов биндера:
reload
reinit
load
net_spawn
--------------------------------------------------------------------------------------------------------------------]]
memtsg = {} --' временная таблица
lasthealth = 0
lastime = nil

----------------------------------------------------------------------------------------------------------------------
function look_to_shot(object, who)
    if object and who then
        if IsStalker(object) and 
        (object:alive() and who:alive()) and
        not xr_wounded.is_wounded(object) and
        ((IsStalker(who) and object:relation(who) ~= game_object.friend) or IsMonster(who)) then
            if object:best_enemy() then
                local be = object:best_enemy()
                local enemy_dist = object:position():distance_to_sqr(be:position())
                local who_dist = object:position():distance_to_sqr(who:position())
                if who_dist < enemy_dist then
                    object:set_sight(look.danger,who:bone_position("bip01_head"))
                end        
            else    
                object:set_sight(look.danger,who:bone_position("bip01_head"))
            end
        end
    end
end

function recognize_sound(sound_type)
    -- Выясняем тип звука
    local sn_t = "NIL"
    
    if bit_and(sound_type, snd_type.weapon) == snd_type.weapon then
        sn_t = "WPN"
        if bit_and(sound_type, snd_type.weapon_shoot) == snd_type.weapon_shoot then
            sn_t = "WPN_shoot"
        elseif bit_and(sound_type, snd_type.weapon_empty) == snd_type.weapon_empty then
            sn_t = "WPN_empty"
        elseif bit_and(sound_type, snd_type.weapon_bullet_hit) == snd_type.weapon_bullet_hit then
            sn_t = "WPN_hit"
        elseif bit_and(sound_type, snd_type.weapon_reload) == snd_type.weapon_reload then
            sn_t = "WPN_reload"
        end
    elseif bit_and(sound_type, snd_type.item) == snd_type.item then
        sn_t = "ITM"
        if bit_and(sound_type, snd_type.item_pick_up) == snd_type.item_pick_up then
            sn_t = "ITM_pckup"
        elseif bit_and(sound_type, snd_type.item_drop) == snd_type.item_drop then
            sn_t = "ITM_drop"
        elseif bit_and(sound_type, snd_type.item_hide) == snd_type.item_hide then
            sn_t = "ITM_hide"
        elseif bit_and(sound_type, snd_type.item_take) == snd_type.item_take then
            sn_t = "ITM_take"
        elseif bit_and(sound_type, snd_type.item_use) == snd_type.item_use then
            sn_t = "ITM_use"
        end
    elseif bit_and(sound_type, snd_type.monster) == snd_type.monster then
        sn_t = "MST"
        if bit_and(sound_type, snd_type.monster_die) == snd_type.monster_die then
            sn_t = "MST_die"
        elseif bit_and(sound_type, snd_type.monster_injure) == snd_type.monster_injure then
            sn_t = "MST_damage"
        elseif bit_and(sound_type, snd_type.monster_step) == snd_type.monster_step then
            sn_t = "MST_step"
        elseif bit_and(sound_type, snd_type.monster_talk) == snd_type.monster_talk then
            sn_t = "MST_talk"
        elseif bit_and(sound_type, snd_type.monster_attack) == snd_type.monster_attack then
            sn_t = "MST_attack"
        elseif bit_and(sound_type, snd_type.monster_eat) == snd_type.monster_eat then
            sn_t = "MST_eat"
        end
    end
    
    return sn_t
end

function check_sound(self, who, sound_type, sound_position, sound_power)
    -- secure and optimize
    
    if not self or
        not who or
        not sound_type or
        not sound_position or
        not sound_power then
    return end
    
    local actsch = nil
    
    if db.storage[self:id()] and db.storage[self:id()].active_scheme then
        actsch = db.storage[self:id()].active_scheme
    end
    
    if actsch and (actsch == "remark" or actsch == "wounded" or actsch == "actor_dialogs")
    then return end

    -- Реакция на звуки --
    -- Расстояния проверки
    local who_dist = 1000
    local check_dist = 25*sound_power
    
    -- Отсеиваем свои звуки и звуки друзей
    if (IsMonster(who) or IsStalker(who)) 
    and (who:alive() and self:alive()) 
    and self:id() ~= db.actor:id() 
    and who:id() ~= db.actor:id() then
        who_dist = self:position():distance_to(who:position())
        if who_dist > check_dist 
        or who:id() == self:id() 
        or who:id() == db.actor:id()
        or db.cars[who:id()]
        or self:relation(who) == game_object.friend 
        or self:relation(who) == game_object.neutral
        or xr_wounded.is_wounded(self) then
            return
        end
    else    
        return
    end
    
    local snd_t = recognize_sound(sound_type)
    
    local self_hit = hit()
    self_hit.type = hit.strike
    self_hit.power = 0
    self_hit.impulse = 0.01
    self_hit.draftsman = self
    self_hit.direction = vector():set(0,0,0)    
    
    local hit = hit()
    hit.type = hit.strike
    hit.power = 0
    hit.impulse = 0.01
    hit.draftsman = self
    hit.direction = vector():set(0,0,0)        
    
    -- Если тип задан проверим реакцию на него
    if snd_t and snd_t ~= "NIL" and not self:best_enemy() then
        self:set_sight(look.point,sound_position)
        if IsStalker(who) and (self:relation(who) == game_object.enemy) then
            if snd_t == "WPN_empty" or
            snd_t == "WPN_reload" or 
            snd_t == "ITM_drop" or
            snd_t == "ITM_use" then        
                check_dist = 10*sound_power
                who_dist = self:position():distance_to(who:position())
                if who_dist > check_dist then
                    return
                else                
                    self:set_mental_state(anim.danger)
                end
            elseif snd_t == "WPN_shoot" then
                self:hit(self_hit)
                self:set_mental_state(anim.danger)            
            end        
        elseif IsMonster(who) then
            if snd_t == "MST_step" or snd_t == "MST_talk" then
                if string.find(who:name(), "gigant") then
                    self:hit(hit)
                    self:set_mental_state(anim.panic)
                else
                    self:set_mental_state(anim.danger)
                end                
            elseif snd_t == "MST_attack" then
                self:hit(self_hit)
                self:set_mental_state(anim.danger)            
            end
        end
    end
end

function check_art_weapon(npc)
------------------------------
--' Изредка движок сглюкивает,
--' назначая неписю в слот артефакт
--' этого следует избежать,
--' так как такие неписи
--' застревают на попытке 
--' применения арта как оружия
------------------------------
    local item_in_slot = npc:item_in_slot(1)
    local act_item = npc:active_item()
    if act_item and item_in_slot and act_item:id() == item_in_slot:id() then
        local item_in_slot_sec = act_item:section()
        local item_in_slot_id = act_item:id()
        if item_in_slot_sec and item_in_slot_id and (string.find(item_in_slot_sec, "caps_") or string.find(item_in_slot_sec, "af_")) then
            --' Если непись получил арт в слот по ошибке при загрузке игры, мы просто
            --' обновим ему оружие в руках и всё. Иначе, если он взял арт в руки и отказывается
            --' его убирать, а лучшее оружие получить не удаётся, придётся арт выбросить, отрелизить и вернуть ему в рюкзак.
            -- amk.logf("WARNING! Engine error - art in NPC weapon slot! "..tostring(item_in_slot_sec).." ID "..tostring(item_in_slot_id))
            -- local s_obj = alife():object(item_in_slot_id)
            local bw = npc:best_weapon()
            local be = npc:best_enemy()
            local rem_id = npc:active_item():id()
            npc:drop_item(npc:active_item())
            local s_obj = alife():object(rem_id)
            if s_obj then
                -- amk.logf("ITEM RESET "..tostring(item_in_slot_sec))
                alife():release(s_obj, true)
                alife():create(item_in_slot_sec,npc:position(),npc:level_vertex_id(),npc:game_vertex_id(),npc:id())
            end            
            if bw and string.find(bw:section(), "wpn_") then
                -- amk.logf("TOSS WEAPON TO "..bw:section().." FROM "..tostring(rem_id))
                if be then
                    npc:set_item(object.fire1, bw)
                    return
                else
                    npc:set_item(object.idle, bw)
                    return
                end
            end
        end
    end
end

---------------------------------------------------------------------------------------------------------------------
class "motivator_binder" (object_binder)

function motivator_binder:__init (obj) super(obj)
    self.loaded = false
    self.last_update = 0
    ----memusage.collect_info(self.object, "__init")

    self.first_update = false
    self.treasure_processed = false
end

function motivator_binder:extrapolate_callback(cur_pt)
    if self.st.active_section then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "extrapolate_callback")
        self.st.move_mgr:extrapolate_callback(self.object)
    end

    if patrol(self.object:patrol()):flags(cur_pt):get() == 0 then
        return true
    end
    return false
end

function motivator_binder:reinit()
    object_binder.reinit(self)
    --memusage.collect_info(self.object, "reinit_start")
    --printf("motivator_binder:reinit(): self.object:name()='%s'", self.object:name())

    -- КОЛЛБЕКИ ЗДЕСЬ СТАВИТЬ НЕЛЬЗЯ! Здесь еще неизвестна активная схема.
    -- Ставьте коллбеки в методе update в отмеченном комментарием месте.

    local char_ini = self.object:spawn_ini() or ini_file("scripts\\dummy.ltx")

----------------------------------------------------------------------------------------------------------------------
-- Общие скрипты
----------------------------------------------------------------------------------------------------------------------
    db.storage[self.object:id()] = {  followers = {} }
    self.st = db.storage[self.object:id()]

    --' Создание менеджера контроля положений тела
    --memusage.collect_info(self.object, "before_statemgr")
    self.st.state_mgr = state_mgr.bind_manager(self.object)

    self.st.move_mgr = move_mgr.move_mgr(self.object)
    self.st.move_mgr:initialize()

    --memusage.collect_info(self.object, "after_statemgr")
    --memusage.collect_info(self.object, "reinit_end")
end
----------------------------------------------------------------------------------------------------------------------
function motivator_binder:net_spawn(sobject)
    printf("motivator_binder:net_spawn(): self.object:name()='%s'", self.object:name())
    --memusage.collect_info(self.object, "netspawn_start")
    if not object_binder.net_spawn(self, sobject) then
        return false
    end

-- ----------------------------------------------------- ARENA_EXTENSION_MOD--------------------------------------------------------

--if self.object: profile_name() == "arena_military_1on1" then

if string.find(self.object:section(),"arena_military_") then
self.object:add_restrictions("bar_arena_restrictor","")
end

if string.find(self.object:section(),"arena_killer_") then
self.object:add_restrictions("bar_arena_restrictor","")
end

if string.find(self.object:section(),"arena_freedom_") then
self.object:add_restrictions("bar_arena_restrictor","")
end

if string.find(self.object:section(),"arena_dolg_") then
self.object:add_restrictions("bar_arena_restrictor","")
end

-- ----------------------------------------------------- ARENA_EXTENSION_MOD--------------------------------------------------------

--    if self.object:spawn_ini():section_exist("dont_spawn_online") then
--        printf("!!!OFFLINE")
--        alife():object(self.object:id()).dont_spawn_online = true
--    end

    db.add_obj(self.object)

    -- Все CALLBACK-и ставить здесь:
    self.object:set_patrol_extrapolate_callback(motivator_binder.extrapolate_callback, self)
    self.object:set_callback(callback.hit, motivator_binder.hit_callback, self)
    self.object:set_callback(callback.death, motivator_binder.death_callback, self)
    self.object:set_callback(callback.use_object, motivator_binder.use_callback, self)
    --memusage.collect_info(self.object, "after__callback")

    --self.object:set_callback(callback.sound, motivator_binder.hear_callback, self)

    --' Загрузка историй для лагеря.
    if self.loaded == false then
        local char_ini = self.object:spawn_ini() or ini_file("scripts\\dummy.ltx")
        xr_info.loadInfo(self.object, char_ini)
    end

    if not self.object:alive() then
        return true
    end

  --' Для зомбированных чуваков говорим что аномалий не существует
  if self.object:character_community() == "zombied" then
    local manager = self.object:motivation_action_manager()
    manager:remove_evaluator  (stalker_ids.property_anomaly)
    manager:add_evaluator   (stalker_ids.property_anomaly, property_evaluator_const(false))
    if outfit_evaluator then
      manager:add_evaluator(1101, property_evaluator_const(false))    
    end
  else
    local manager = self.object:motivation_action_manager()
    manager:remove_evaluator  (stalker_ids.property_anomaly)
    manager:add_evaluator   (stalker_ids.property_anomaly, property_evaluator_const(false))
    if outfit_evaluator then
      manager:add_evaluator(1101, outfit_evaluator.evaluator_outfit(self.object,"evaluator_outfit"))
      local action = manager:action (xr_actions_id.alife) 
      action:add_precondition   (world_property(1101,    false))  
    end
  end

  if ogsm_hideout then
    local manager = self.object:motivation_action_manager()
      manager:add_evaluator(ogsm_hideout.property_blowout, property_evaluator_const(false))
      manager:add_evaluator(ogsm_hideout.property_hideout_lost, property_evaluator_const(false))
      manager:add_evaluator(ogsm_hideout.property_inhide, property_evaluator_const(false))
  end

    --' загрузка озвучки
    --memusage.collect_info(self.object, "before_soundmgr")
    xr_sound.load_sound(self.object)
    --memusage.collect_info(self.object, "after_soundmgr_netspawn_end")

    xr_gulag.setup_gulag_and_logic_on_spawn( self.object, self.st, sobject, modules.stype_stalker, self.loaded )

    return true
end

function motivator_binder:net_destroy()
    if xrs_ai then xrs_ai.npc_net_destroy(self.object) end
--  if rx_ai then rx_ai.npc_switch_offline(self.object) end
    --printf("motivator_binder:net_destroy(): self.object:name()='%s'", self.object:name())

    local st = db.storage[self.object:id()]
    if st.active_scheme then
        xr_logic.issue_event(self.object, st[st.active_scheme], "net_destroy", self.object)
    end

    db.del_obj(self.object)

    db.storage[self.object:id()] = nil

    self:clear_callbacks()
    self.object:set_callback(callback.use_object, nil)

    object_binder.net_destroy(self)
end

function motivator_binder:clear_callbacks()
    self.object:set_patrol_extrapolate_callback(nil)
    self.object:set_callback(callback.hit, nil)
    self.object:set_callback(callback.death, nil)
end

function motivator_binder:hit_callback(obj, amount, local_direction, who, bone_index)
    -- FIXME: коллбеки неплохо было бы регистрировать в общем storage, а не посхемно...
    -- просто всегда ставить их при включении схемы и снимать при отключении.
    if self.st.active_section then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "hit_callback", obj, amount, local_direction, who, bone_index)
    end
    if self.st.combat_ignore then
        xr_logic.issue_event(self.object, self.st.combat_ignore, "hit_callback", obj, amount, local_direction, who, bone_index)
    end
    if self.st.combat then
        xr_logic.issue_event(self.object, self.st.combat, "hit_callback", obj, amount, local_direction, who, bone_index)
    end
    if self.st.hit then
        xr_logic.issue_event(self.object, self.st.hit, "hit_callback", obj, amount, local_direction, who, bone_index)
    end
    if amount > 0 then
        printf("HIT_CALLBACK: %s amount=%s bone=%s", obj:name(), amount, tostring(bone_index))
        sr_territory.issue_event(self.object, "hit_callback", obj, amount, local_direction, who, bone_index)
        xr_wounded.hit_callback(self.object:id())
    end
  amk.on_npc_hit(obj, amount, local_direction, who, bone_index)
    if rx_ai then rx_ai.npc_hit(obj,amount,local_direction,who,bone_index,self.object) end
end

function motivator_binder:death_callback(victim, who)
    if xrs_ai then xrs_ai.npc_death_callback(self.object,who) end
  if rx_ai then rx_ai.npc_death(self.object,who) end

    if who:id() == db.actor:id() then
        xr_statistic.addKillCount(self.object)
    end
    
    if self.st.death then
        xr_logic.issue_event(self.object, self.st.death, "death_callback", victim, who)
    end
    if self.st.active_section then
        xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "death_callback", victim, who)
    end
    sr_territory.issue_event(self.object, "death_callback", victim, who)

    sr_light.check_light(self.object)

    smart_terrain.on_death( self.object:id() )
    
    death_manager.drop_manager(self.object):create_release_item()

    self:clear_callbacks()

    --' Наносим небольшой импульс вперед.
    local h = hit()
    h.draftsman = self.object
    h.type = hit.fire_wound
    h.direction = db.actor:position():sub(self.object:position())
    h:bone("pelvis")
    h.power = 1
    h.impulse = 10
    self.object:hit(h)

    if(actor_stats.remove_from_ranking~=nil)then
        local community = self.object:character_community()
        if community == "zombied" or
           community == "monolith" or
           community == "arena_enemy"
        then
            return
        end
        actor_stats.remove_from_ranking(self.object:id())
    end
end

function motivator_binder:use_callback(obj, who)
    if self.object:alive() then
        xr_use.notify_on_use(obj, who)
        if self.st.active_section then
            xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "use_callback", obj, who)
        end
    else
        if self.treasure_processed == false then
            treasure_manager:get_treasure_manager():use(self.object)
            self.treasure_processed = true
        end
    end
end

function motivator_binder:update(delta)
    object_binder.update(self, delta)
--    self.prev_action_id = debug_helper.print_action(self.object, self.prev_action_id)

    if self.first_update == false then
        if self.object:alive() == false then
            death_manager.drop_manager(self.object):create_release_item()
        end        
        self.first_update = true
    end

    if time_global() - self.last_update > 1000 then
            if amk.get_npc_relation(self.object,db.actor)=="enemy" and self.object:alive() and self.object.health>0.01 then 
                    if self.object:see(db.actor) then 
                        amk.enemy_see_actor(self.object,"npc") 
                    end
                    if db.actor:see(self.object) then
                        amk.actor_see_enemy(self.object,"npc") 
                    end
            end
       sr_light.check_light(self.object)

       self.last_update = time_global()
    end

        local wpn = utils.wpn_info_get(self.object)
        if wpn["ammo"]~=nil then
            local enemy = self.object:best_enemy()
            if enemy and enemy:id()==db.actor:id() and self.object:see(db.actor) and self.prev_ammo>wpn["ammo"] then
                amk.npc_shot_actor(self.object)
            end
        end
        
        self.prev_ammo = wpn["ammo"] or 0

    --' Апдейт менеджера состояний тела
    if self.st.state_mgr then
        if self.object:alive() then
            self.st.state_mgr:update()
            -- Апдейт торговли
            if self.st.state_mgr.combat == false and
               self.st.state_mgr.alife == false
            then
                trade_manager.update(self.object)
            end            
        else
            self.st.state_mgr = nil
        end
    end
    
    --' Апдейт саундменеджера
    if self.object:alive() then
        xr_sound.update(self.object)
    end

    if self.object:alive() then
        if self.object:is_talk_enabled() then
            self.object:set_tip_text("character_use")
        else
            self.object:set_tip_text("")
        end
    else
        self.object:set_tip_text_default()
    end


    self.object:info_clear()
    local best_enemy = self.object:best_enemy()
    if best_enemy then
        self.object:info_add('enemy -- ' .. best_enemy:name())
    end
    local active_section = db.storage[self.object:id()].active_section
    if active_section then
        self.object:info_add('section -- ' .. active_section)
    end
    self.object:info_add('name -- ' .. self.object:name())

    --' Проверка потери жизни
--[[
    if lasttime == nil or
       game.get_game_time():diffSec(lasttime) > 1
    then
        printf("%f * %f", self.object.health, self.object.health - lasthealth)
        lasthealth = self.object.health
        lasttime = game.get_game_time()
    end
]]
--[[    if not self.debug_smrt then
        for k, v in pairs( db.smart_terrain_by_id ) do
            self.debug_smrt = true

            local o = alife():object( self.object:id() )

            if v:enabled(o) then
                v:register(o)
            end

            break
        end
    end]]

    if xrs_ai then xrs_ai.npc_update(self) end

  if rx_ai then rx_ai.npc_update(self.object,self.st) end
end

function motivator_binder:reload(section)
    --memusage.collect_info(self.object, "reload_start")
    object_binder.reload(self, section)
    --printf("motivator_binder:reload(): self.object:name()='%s'", self.object:name())
    --self.object:set_pda_callback(pda_callback)
    --memusage.collect_info(self.object, "reload_end")
end

function motivator_binder:net_save_relevant()
    --printf("motivator_binder:net_save_relevant(): self.object:name()='%s'", self.object:name())
    return true
end

function motivator_binder:save(packet)
    printf("motivator_binder:save(): self.object:name()='%s'", self.object:name())
    object_binder.save(self, packet)

    packet:w_bool(self.treasure_processed)

    xr_logic.save_obj(self.object, packet)
    dialog_manager.save(self.object, packet)
    trade_manager.save(self.object, packet)
end

function motivator_binder:load(reader)
    self.loaded = true

    printf("motivator_binder:load(): self.object:name()='%s'", self.object:name())
    object_binder.load(self, reader)
    printf("motivator_binder:object_binder.load(): self.object:name()='%s'", self.object:name())

    if reader:r_eof() then
        abort("SAVE FILE IS CORRUPT")
    end


    local unused = reader:r_bool()

    self.treasure_processed = reader:r_bool()

    xr_logic.load_obj(self.object, reader)

    self.npc_script_version = alife():object(self.object:id()).script_version
    dialog_manager.load(self.object, reader, self.npc_script_version)
    trade_manager.load(self.object, reader)
end

function motivator_binder:hear_callback(self, who, sound_type, sound_position, sound_power)
    if who:id() == self:id() then
        return
    end
    local type = "NIL"
    if bit_and(sound_type, snd_type.weapon) == snd_type.weapon then
        type = "WPN"
        if bit_and(sound_type, snd_type.weapon_shoot) == snd_type.weapon_shoot then
            type = "WPN_shoot"
        elseif bit_and(sound_type, snd_type.weapon_empty) == snd_type.weapon_empty then
            type = "WPN_empty"
        elseif bit_and(sound_type, snd_type.weapon_bullet_hit) == snd_type.weapon_bullet_hit then
            type = "WPN_hit"
        elseif bit_and(sound_type, snd_type.weapon_reload) == snd_type.weapon_reload then
            type = "WPN_reload"
        end
    elseif bit_and(sound_type, snd_type.item) == snd_type.item then
        type = "ITM"
        if bit_and(sound_type, snd_type.item_pick_up) == snd_type.item_pick_up then
            type = "ITM_pckup"
        elseif bit_and(sound_type, snd_type.item_drop) == snd_type.item_drop then
            type = "ITM_drop"
        elseif bit_and(sound_type, snd_type.item_hide) == snd_type.item_hide then
            type = "ITM_hide"
        elseif bit_and(sound_type, snd_type.item_take) == snd_type.item_take then
            type = "ITM_take"
        elseif bit_and(sound_type, snd_type.item_use) == snd_type.item_use then
            type = "ITM_use"
        end
    elseif bit_and(sound_type, snd_type.monster) == snd_type.monster then
        type = "MST"
        if bit_and(sound_type, snd_type.monster_die) == snd_type.monster_die then
            type = "MST_die"
        elseif bit_and(sound_type, snd_type.monster_injure) == snd_type.monster_injure then
            type = "MST_damage"
        elseif bit_and(sound_type, snd_type.monster_step) == snd_type.monster_step then
            type = "MST_step"
        elseif bit_and(sound_type, snd_type.monster_talk) == snd_type.monster_talk then
            type = "MST_talk"
        elseif bit_and(sound_type, snd_type.monster_attack) == snd_type.monster_attack then
            type = "MST_attack"
        elseif bit_and(sound_type, snd_type.monster_eat) == snd_type.monster_eat then
            type = "MST_eat"
        end
    end
    if type ~= "NIL" then
        printf("SND *%s* dist: %d [%f], %s -> %s", type, self:position():distance_to(who:position()), sound_power, who:name(), self:name())
    end
end

function AddToMotivator(npc)
    if alife() then
        npc:bind_object(this.motivator_binder(npc))
    end
end

-- Эвалюаторы, которые имеют высший приоритет, и, соответственно, перебивают остальные скрипты собой
function addCommonPrecondition(action)
    --action:add_precondition (world_property(xr_evaluators_id.reaction,false))
    action:add_precondition (world_property(xr_evaluators_id.stohe_meet_base + 1,false))
    action:add_precondition (world_property(xr_evaluators_id.sidor_wounded_base + 0,  false))
    action:add_precondition (world_property(xr_evaluators_id.chugai_heli_hunter_base, false))
    action:add_precondition (world_property(xr_evaluators_id.abuse_base, false))
    if ogsm_hideout then
        action:add_precondition(world_property(ogsm_hideout.property_blowout, false))
        action:add_precondition(world_property(ogsm_hideout.property_hideout_lost, false))
        action:add_precondition(world_property(ogsm_hideout.property_inhide, false))
    end
    if anomaly_evader then
        action:add_precondition (world_property(1099,false))
    end
    if watcher_act then
        action:add_precondition(world_property(watcher_act.evid_see_stuff, false))
    end

    if outfit_evaluator then
        action:add_precondition (world_property(1101,false))
    end

    if xrs_ai then 
        xrs_ai.addCommonPrecondition(action) 
    end

  if rx_ai then rx_ai.addCommonPrecondition(action) end

end

 

Изменено пользователем Dead_Land
Q

Поделиться этим сообщением


Ссылка на сообщение

@Jekyll, Там есть всё и функция есть проблема только что огрызается вылетами при выстрелах нпс.

Поделиться этим сообщением


Ссылка на сообщение
12 часов назад, Jekyll сказал:

Можешь выложить сюда свой текущий amk.script, а заодно этот Interactive_Music_Mod?

На какую базу ты его устанавливал? АМК 1.4.1? Вылеты в боевке начались именно после установки Interactive_Music_Mod?

У меня там сборка её кидать или нет? Просто весит многовато не у всех есть инет безлимитный.

Поделиться этим сообщением


Ссылка на сообщение
12 часов назад, Jekyll сказал:

Можешь выложить сюда свой текущий amk.script, а заодно этот Interactive_Music_Mod?

На какую базу ты его устанавливал? АМК 1.4.1? Вылеты в боевке начались именно после установки Interactive_Music_Mod?

У меня там сборка может её кинуть или нет? Просто весит многовато не у всех есть инет безлимитный. База мода OGSM Ultimate он использует амк скрипт.

Изменено пользователем Dead_Land

Поделиться этим сообщением


Ссылка на сообщение

1.gamedata это оригинал Interactive_Music_Mod. http://mega.dp.ua/file?source=18122611031733205819

2.Новая папка это мои уже. http://mega.dp.ua/file?source=18122611082467510180

3. Администрации сверху багнулось что-то я не знаю почему оно профлудило 2 раза я просто отредактировал старое.

Поделиться этим сообщением


Ссылка на сообщение
5 часов назад, Купер сказал:

 

  Скрыть

в amk.script

всё, начиная с -- Багфикс радара2 и до if id_cleaner ... end end end перенести выше function on_npc_hit

нету  if id_cleaner там

Поделиться этим сообщением


Ссылка на сообщение
26 минут назад, Houdini_one сказал:

Ребят, вот у меня есть мутант, кабан к примеру. Мне нужно, чтобы во время боя с ним появилась шкала его здоровья на ХУД-е (тоже самое, что с вертушкой в ЧН), а после его смерти - исчезла. Как такое сделать?

интересная штука получилась бы а для чего именно? ТЧ?

Поделиться этим сообщением


Ссылка на сообщение
1 минуту назад, Houdini_one сказал:

@Dead_Land, я в теме для ТЧ же вопрос написал. Просто в моём моде будет что-то типа боссов. Но это уже не относится к вопросу....

Да я забыл что это тема ТЧ, подобная система есть в ЗП  но в тч тоже можно влепить надо просто мод с подобной сисмой найти и вырезать так проще.

Поделиться этим сообщением


Ссылка на сообщение

Пацаны поймал маслину, нужна помощь )

Как в логике НПС прописать возвращение на стандартную точку после того как он среагировал на НПС или мутанта ?

Буду реально благодарен, просто базу для Чистого неба делаю а они бегают как стадо ежей после провокации

P.S есть у кого модельки Чн-вцев(а) ))

 

 

 

--Стадо баранов 
[smart_terrains]
none = true

[dont_spawn_loot]

[logic]
active = remark@base
danger = danger_condition
combat_ignore = combat_ignore
meet = meet

[remark@base]
anim = hello_wpn
target = actor
meet = meet
on_actor_dist_le = 2| remark@sit
combat_ignore_cond = always
no_move = true

[meet] 
meet_state = 10|salut@esc_bridge_soldiers|
victim = 10|actor
victim_wpn = 10|actor
use = true
use_wpn = true
meet_dialog = escape_lager_guard_start_dialog
no_move = true

[remark]
anim = mode_shlem
combat_ignore_cond = combat_ignore

 

Изменено пользователем Dead_Land

Поделиться этим сообщением


Ссылка на сообщение
52 минуты назад, Змея сказал:

@Dead_Land, ты сделал логику перцев на ремарках и хочешь, чтобы они куда-то вернулись?

Ты сам то посмотри - у тебя хоть где-то прописано в логике местоположение НПС?

Ага...Читать от корки до корки.

 



Тут интересная штука но как путь задавать я не понял?

[walker]
path_walk = <имя_пути> - основной путь, по которому ходит NPC
path_look = <имя_пути> - путь, куда смотрит NPC
team = <имя_команды> - команда для синхронизации
def_state_moving1 = <название_анимации> - состояние, в котором NPC движется к первой точке пути, если она близко (patrol по умолчанию)
def_state_moving2 = <название_анимации> - состояние, в котором NPC движется к первой точке пути, если она не слишком далеко (rush по умолчанию)
def_state_moving3 = <название_анимации> - состояние, в котором NPC движется к первой точке пути, если она далеко (sprint по умолчанию)
def_state_standing = <название_анимации> - дефолтное состояние в котором он стоит и смотрит на точку, если в этой точке не задана другое состояние.

В точках path_walk, которым соответствуют точки пути path_look (стоят одинаковые флажки) персонаж останавливается и смотрит в определенную точку, при этом отыгрывая (или не отыгрывая) определенную анимацию.

Поделиться этим сообщением


Ссылка на сообщение

@Змея, вот как раз таки декомпилировать OGSM алл.spawn невозможно, вот незадача. А можно создать например allcs.spawn или же ругать будет?

  • Смешно 1

Поделиться этим сообщением


Ссылка на сообщение

Кто находил модели Чн-овцев для ТЧ ребят можете ссылку дать)

Поделиться этим сообщением


Ссылка на сообщение

@UriZzz, пробовал декомпилировать не вышло.

 

Ребята где можно запретить вносить изменение в 2 строчки которые на скрине, а именно "Громкость" и "Громкость музыки" мой мод ломается при их изменении, как сделать их неактивными?

 

Меню оригинальное просто картинка изменена задняя.


3CKM3gY.jpg
 

 

  • Сочувствую 1

Поделиться этим сообщением


Ссылка на сообщение
  • Недавно просматривали   1 пользователь

×
×
  • Создать...