Page 1 of 2

Force Fields

Posted: Sun Nov 23, 2008 6:45 pm
by Tourny
I know this was probably already asked somewhere, but I searched everything I could think of and nothing came up for what I wanted.

I'm trying to make a shield that goes down when I blow up a panel. Like the prison cells on Battle Of The Titans. I followed Boeing's advice and looked at the Mustafar script, but it talked about bridges and that just confused me.

EDIT: Does anybody know how to do it?

Re: Force Fields

Posted: Sun Nov 23, 2008 7:02 pm
by Silas
that involves lua stuff that always crashes my map when i try to do it. There's some tuts in the modding FAQ section, but they seem to be somewhat confusing to me.

You could just give the force field health, if you want an easy solution

Re: Force Fields

Posted: Sun Nov 23, 2008 7:37 pm
by Master_Ben
For the LUA stuff, check the Mygeeto shipped campaign. That happens in the level. It'll show you what you need.

EDIT: I think this is it: (I didn't put much effort into the search, though so it seems unlikely to be it.)
Hidden/Spoiler:
[code]
OnObjectKillName(DestroyShield1, "generator_01");
OnObjectKillName(DestroyShield2, "generator_02");
OnObjectKillName(DestroyShield3, "generator_03");
[/code]

Re: Force Fields

Posted: Sun Nov 23, 2008 7:46 pm
by Tourny
I checked Mygeeto Campaign, it didn't make much sense at all.

Re: Force Fields

Posted: Sun Nov 23, 2008 7:50 pm
by Maveritchell
This is why we have an FAQ and documentation. The doc "scripting_system" is a great doc with a lot of information (when combined with the stock .luas as a reference). We also have this exact same issue prewritten out for you in tutorial form in the FAQ:
How to trigger an animation on destruction of an object

Re: Force Fields

Posted: Sun Nov 23, 2008 8:10 pm
by Tourny
...since when is that in the FAQ?....

Thank you anyway...

Re: Force Fields

Posted: Sun Nov 23, 2008 8:16 pm
by Maveritchell
Tourny wrote:...since when is that in the FAQ?....
It's been in there with all the other helpful information about scripting in the "Lua" section of the FAQ. There are a few other simple scripting examples as well.

Re: Force Fields

Posted: Sun Nov 23, 2008 8:54 pm
by Tourny
I'm still confused...

animateobja = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "objectBnameinZeroEditor" then
PlayAnimation("whateveranimationgroup")
end
end
)

What do I replace with what? I have an idea but I don't understand the specifics.

Re: Force Fields

Posted: Sun Nov 23, 2008 8:58 pm
by Maveritchell
"animatedobja" is whatever you want - it's just a random variable assigned to the function
"objectBnameinZeroEditor" is the name of the object you're planning on killing to trigger the animation (the name assigned in Zero Editor)
"whateveranimationgroup" is the name of the animation group (not the animation) that you'll want to start playing.

Re: Force Fields

Posted: Mon Nov 24, 2008 10:39 pm
by Tourny
Um, Mav? It isn't working... I smash the panel and the Field ain't moving.

Code: Select all

    PrisonField = OnObjectKill(
    function(object,  killer)
    if GetEntityName(object) == "Container" then
    PlayAnimation("FieldOn")
    end
    end
    )
All I did was copy and paste from the FAQ, and replace the stuff. Why isn't it working?

Re: Force Fields

Posted: Mon Nov 24, 2008 11:46 pm
by Maveritchell
Good question. Show me your .lua, a screenshot of the object (to be destroyed) in ZE, and a screenshot of your anim mode in ZE.

Re: Force Fields

Posted: Mon Nov 24, 2008 11:59 pm
by Tourny
Here is my .Lua:
Hidden/Spoiler:
[code]
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")

-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
-- These variables do not change
local ATT = 1
local DEF = 2

function ScriptPostLoad()


--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)

conquest:Start()

EnableSPHeroRules()

OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"IrugoEntrance")
end,
"IrugoEntrance"
)
ActivateRegion("IrugoEntrance")

OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"IrugoExit")
end,
"IrugoExit"
)
ActivateRegion("IrugoExit")

PrisonField = OnObjectKill(
function(object,killer)
if GetEntityName(object) == "Container" then
PlayAnimation("FieldOn")
end
end
)

end

---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------

function ScriptInit()

ReadDataFile("ingame.lvl")



SetMaxFlyHeight(40)
SetMaxPlayerFlyHeight(40)


SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo


ReadDataFile("sound\\tat.lvl;tat2gcw")
ReadDataFile("DC:SIDE\\klg.lvl",
"klg_inf_soldier",
"klg_inf_assault",
"klg_inf_engineer",
"klg_inf_hunter",
"klg_inf_marine")

ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_bobafett",
"imp_fly_destroyer_dome" )

ReadDataFile("DC:SIDE\\vat.lvl",
"imp_fly_trooptrans",
"rep_hero_cloakedanakin")

ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_tat_barge",
"tur_bldg_laser")

SetupTeams{
all = {
team = ALL,
units = 20,
reinforcements = 150,
soldier = { "klg_inf_soldier",9, 25},
assault = { "klg_inf_assault",1,4},
engineer = { "klg_inf_engineer",1,4},
sniper = { "klg_inf_hunter",1,4},
officer = { "klg_inf_marine",1,4}

},
imp = {
team = IMP,
units = 20,
reinforcements = 150,
soldier = { "imp_inf_rifleman",9, 25},
assault = { "imp_inf_rocketeer",1,4},
engineer = { "imp_inf_engineer",1,4},
sniper = { "imp_inf_sniper",1,4},
officer = { "imp_inf_officer",1,4},
special = { "imp_inf_dark_trooper",1,4},
},
}

SetHeroClass(ALL, "all_hero_hansolo_tat")
SetHeroClass(IMP, "rep_hero_cloakedanakin")

-- Level Stats
ClearWalkers()
AddWalkerType(0, 0) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 0) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)

local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
ReadDataFile("dc:IGO\\IGO.lvl", "IGO_conquest")
SetDenseEnvironment("false")


-- Fishies
SetNumFishTypes(1)
SetFishType(0,0.8,"fish")


-- Sound Stats

voiceSlow = OpenAudioStream("sound\\global.lvl", "all_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "des_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "all_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "gcw_music")
OpenAudioStream("sound\\tat.lvl", "tat2")
OpenAudioStream("sound\\tat.lvl", "tat2")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")

SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1)

SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(ALL, IMP, "all_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(2, "Allleaving")
SetOutOfBoundsVoiceOver(1, "Impleaving")

SetAmbientMusic(ALL, 1.0, "all_tat_amb_start", 0,1)
SetAmbientMusic(ALL, 0.8, "all_tat_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.2, "all_tat_amb_end", 2,1)
SetAmbientMusic(IMP, 1.0, "imp_tat_amb_start", 0,1)
SetAmbientMusic(IMP, 0.8, "imp_tat_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.2, "imp_tat_amb_end", 2,1)

SetVictoryMusic(ALL, "all_tat_amb_victory")
SetDefeatMusic (ALL, "all_tat_amb_defeat")
SetVictoryMusic(IMP, "imp_tat_amb_victory")
SetDefeatMusic (IMP, "imp_tat_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")

-- Camera Stats
--Tat2 Mos Eisley
AddCameraShot(0.974338, -0.222180, 0.035172, 0.008020, -82.664650, 23.668301, 43.955681);
AddCameraShot(0.390197, -0.089729, -0.893040, -0.205362, 23.563562, 12.914885, -101.465561);
AddCameraShot(0.169759, 0.002225, -0.985398, 0.012916, 126.972809, 4.039628, -22.020613);
AddCameraShot(0.677453, -0.041535, 0.733016, 0.044942, 97.517807, 4.039628, 36.853477);
AddCameraShot(0.866029, -0.156506, 0.467299, 0.084449, 7.685640, 7.130688, -10.895234);
end

function MoveEntityToNode(entIn,pathIn,nodeIn)
if not entIn then
print("Warning!: Entity not specified for move")
return false
elseif not pathIn then
print("Warning!: Path not specified for Entity " .. entIn .. " move")
return false
end

local node
if nodeIn then
node = nodeIn
else
node = 0
end

local locDest = GetPathPoint(pathIn,node)
local charUnit = GetCharacterUnit(entIn)
if charUnit then
SetEntityMatrix(charUnit,locDest)
return true
end
return false
end
[/code]
Screenshot underway...

EDIT: How do I get a screen shot of the object in ZE? EDIT EDIT: Scratch that, I found the tut. But I don't think I can get away with uploading them...

EDIT EDIT EDIT: My Object is a dea1_prop_panel and I named it "Container". In anims mode, I have the group name as "FieldOn" and then under "Animation/Object Pairs" I have "Open" as the anim and "PrisonField" as the object. (I named the Force Field "PrisonField") And then under the animations section I have that animation "Open" and it has two steps. Phase 1 it doesn't move and for phase2 I have the transition as "Pop" and the field moves approximately -10 along the Y axis. The run time is 1.

Re: Force Fields

Posted: Tue Nov 25, 2008 1:37 am
by Maveritchell
Did you check "disable hierarchies" for your animation group?

Re: Force Fields

Posted: Tue Nov 25, 2008 12:30 pm
by Tourny
No XD. I think I forgot to save the animations too.

EDIT: It still won't budge.

Re: Force Fields

Posted: Tue Nov 25, 2008 2:13 pm
by Maveritchell
First make sure you can get your animation to work at all. The setup you're telling me you have should work, so there's no way for me to tell the mistake. Test to see if your animation works by setting it to "play at level start" in the animation editor.

Re: Force Fields

Posted: Tue Nov 25, 2008 3:03 pm
by Tourny
When I click "Play" in the amins menu it works. I'll try what you saud though...

EDIT: Yes, my animation does work.

Re: Force Fields

Posted: Tue Nov 25, 2008 4:24 pm
by Maveritchell
I've got nothing to say, then. If everything is as you've said it, then that will work. You could try changing the variable for the callback (don't call it "PrisonField," call it something else like "shieldanim"), you could try making sure your capitalization is the same for everything, and you can try a clean and remunge, but frankly there's nothing wrong there and if it doesn't work there must be some error I can't see.

Re: Force Fields

Posted: Tue Nov 25, 2008 5:20 pm
by Tourny
Has anybody ever tried this and made it work before?

Re: Force Fields

Posted: Tue Nov 25, 2008 5:57 pm
by Maveritchell
...

Yes.

Re: Force Fields

Posted: Tue Nov 25, 2008 6:16 pm
by Tourny
This particular code from that particular tutorial?

EDIT: I made it work with something different, case closed.