Page 1 of 1

How I connect shields like "Among the ruins" campaign?

Posted: Mon Apr 09, 2018 12:26 pm
by DaviidHL
In this mission you have to destroy a shield generator to destroy a force shield. I already placed but still not working. Any solutions?

Re: How I connect shields like "Among the ruins" campaign?

Posted: Mon Apr 09, 2018 5:13 pm
by GAB
I don't remeber exactly how they did it, but have a look at the campaign script for the Mygetto mission.

Re: How I connect shields like "Among the ruins" campaign?

Posted: Mon Apr 09, 2018 8:22 pm
by Marth8880
DaviidHL wrote:In this mission you have to destroy a shield generator to destroy a force shield. I already placed but still not working. Any solutions?
It's probably something along the lines of:

Code: Select all

OnObjectKillName(KillObject("force_shield_object_name"), "shield_generator_object_name");
or

Code: Select all

local function ForceShieldDest()
    KillObject("force_shield_object_name");
end

OnObjectKillName(ForceShieldDest, "shield_generator_object_name");

Re: How I connect shields like "Among the ruins" campaign?

Posted: Mon Apr 09, 2018 9:58 pm
by Calrissian97
I've done something similar with a plasma bridge that can be disabled by destroying it's generator. Like so:

Code: Select all

  ff_bridge_destroy = OnObjectKill(
      function(object, killer)
         if GetEntityName(object) == "myg1_prop_shield_generator" then
            KillObject("myg1_prop_energy_collector_shield1")       -- if you want to link more shields to it, just add another KillObject line after this one
         end
       end 
       )
And then to respawn it when the generator is repaired, you can use this code:

Code: Select all

    ff_bridge_create = OnObjectRepair(
       function(object, repairer)
          if GetEntityName(object) == "myg1_prop_shield_generator" then
            RespawnObject("myg1_prop_energy_collector_shield1")       -- if you want to link more shields to it, just add another Respawn Object line after this one
          end
       end
       )
EDIT:
Marth's code is prettier tho, I'd go with that if it works :P

Re: How I connect shields like "Among the ruins" campaign?

Posted: Tue Apr 10, 2018 1:50 am
by Marth8880
Calrissian97 wrote:Marth's code is prettier tho, I'd go with that if it works :P
More on anonymous functions for those interested: http://lua-users.org/wiki/ShortAnonymousFunctions