Random mshes for units [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Random mshes for units [Solved]

Post by ARCTroopaNate »

Looked through a bunch of topics, searched and everything and I couldn't find anything on giving units random mshes. (Maybe my eyes are just tired after staring at a a screen for the past 16 hours) :sleep: I know I've seen it on gametoast and on mods and stuff, and if anyone could point me to a tutorial or help me add them it'd be greatly appreciated.
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

My unit doesn't change models. The map doesn't crash or anything but my unit stays the same the entire match. I didn't get any related munge or debug errors. I think I'm missing something...

Meh lua
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;


function ScriptPostLoad()

-- Timer for skins--

--interval is the number of seconds between model changes
--maxskin is the number of versions to use

interval = 60 --i had been testing this at 10 second waves, but it could be changed
--in MP, it will probably cause each 15 second spawn-wave to be the same model
skintimer = CreateTimer("timeout") -- i don't know what significance "timeout" has, copied from hoth campaign this way
SetTimerValue(skintimer , interval )
--ShowTimer(skintimer )
skin = 1
maxskin = 4

OnTimerElapse(
function(timer)


if (skin == 1) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_feluciatrooper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_feluciatrooper_low1")
end
if (skin == 2) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_greytroper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_greytroper_low1")
end
if (skin == 3) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_greentroop")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_greentroop_low1")
end
if (skin == 4) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_kashyyktrooper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_kashyyktrooper_low1")
end



skin = skin + 1

if (skin > maxskin) then
skin = 1
end

--ShowTimer(nil)
--DestroyTimer(timer)



SetTimerValue(skintimer , interval )
StartTimer(skintimer)


end,
skintimer
)



--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()

end
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: Random mshes for units

Post by Noobasaurus »

skintimer = CreateTimer("timeout")
Not sure if "timeout" should be "skintimer" instead, but I'm fairly sure "timeout" is just the name they wanted it to have.
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

You need to start the timer once outside the OnTimerElapse function, otherwise it doesn't start the chain.
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

Sorry for me being stupid, I've never worked with timers before. How do you start the timer outside the OnTimerElapse?
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

ARCTroopaNate wrote:Sorry for me being stupid, I've never worked with timers before. How do you start the timer outside the OnTimerElapse?
You missed the last line of executable code in my example, it was between a couple chunks of comments.

this part
Hidden/Spoiler:
...
end,
skintimer
)

-------------------------------------------------------------------------
--resume normal conquest script, or whatever gamemode...
--------------------------------------------------------------------------

StartTimer(skintimer) --starts the timer the first time, after it starts, it will restart itself one ending.

--------------wait start the timer first! ok, now go...
---------------------------------------------------------------------
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

Like this? Or does it go after the last end.
Hidden/Spoiler:
-- Timer for skins--

--interval is the number of seconds between model changes
--maxskin is the number of versions to use

interval = 60 --i had been testing this at 10 second waves, but it could be changed
--in MP, it will probably cause each 15 second spawn-wave to be the same model
skintimer = CreateTimer("skintimer") -- i don't know what significance "timeout" has, copied from hoth campaign this way
SetTimerValue(skintimer , interval )
--ShowTimer(skintimer )
skin = 1
maxskin = 4

OnTimerElapse(
function(timer)

--REP Trooper
if (skin == 1) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_feluciatrooper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_feluciatrooper_low1")
end
if (skin == 2) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_greytroper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_greytroper_low1")
end
if (skin == 3) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_greentroop")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_greentroop_low1")
end
if (skin == 4) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_kashyyktrooper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_kashyyktrooper_low1")
end

--REP Pilot
if (skin == 1) then
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_atrt_ph2")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_atrt_ph2")
end
if (skin == 2) then
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_greytroper")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_greytroper_low1")
end
if (skin == 3) then
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_feluciatrooper")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_feluciatrooper_low1")
end
if (skin == 4) then
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_greentroop")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_greentroop_low1")
end


skin = skin + 1

if (skin > maxskin) then
skin = 1
end

--ShowTimer(nil)
--DestroyTimer(timer)



SetTimerValue(skintimer , interval )
StartTimer(skintimer)


end,
skintimer
)



--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()

StartTimer(skintimer)

end
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

That should work.
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

When the game tries to change the mshes in my map it crashes and I get this in my log. The msh is there. Is there anything I have to edit in the units odf to get this to work?
Hidden/Spoiler:
Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\EntityGeometry.cpp(619)
Entity "rep_inf_trooper_41" missing geometry "rep_inf_greytroper"
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

Is rep_inf_greytroper being munged into the .lvl? It has to either be loaded in a unit's odf or explicitly by a .req.

Another thing, the code should work how it is, but you have 8 if statements for selecting skins, 4 for rifleman, 4 for pilot. The code would run a little more efficiently if they were combined like this
Hidden/Spoiler:
if skin 1
-geometry for rifleman
-low geometry for rifleman
-geometry for pilot
-low geometry for pilot

if skin 2
-geometry for rifleman
-low geometry for rifleman
-geometry for pilot
-low geometry for pilot
instead of this
Hidden/Spoiler:
if skin 1
-geometry for rifleman
-low geometry for rifleman
if skin 2
-geometry for rifleman
-low geometry for rifleman

if skin 1
-geometry for pilot
-low geometry for pilot
if skin 2
-geometry for pilot
-low geometry for pilot
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

How would you load it into a Req separately?
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

Code: Select all

ucft
{
    REQN
    {
        "model"
        "rep_inf_greytroper"
        "rep_inf_greytroper_low1"
    }
}
kinda like that
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

Cool! Thanks.

EDIT: Sorry for all the questions... :oops: would I also have to load the models into the side req?

EDIT2: Still not working.

Team Req
Hidden/Spoiler:
ucft
{
REQN
{
"lvl"
"rep_inf_greentroop"
"rep_inf_greytroper"
"rep_inf_kashyyktrooper"
"rep_inf_pilot_41"
"rep_inf_trooper_41"
}
}
Added all the individual msh reqs as you asked.

Lua.
Hidden/Spoiler:
-- Timer for skins--

--interval is the number of seconds between model changes
--maxskin is the number of versions to use

interval = 60 --i had been testing this at 10 second waves, but it could be changed
--in MP, it will probably cause each 15 second spawn-wave to be the same model
skintimer = CreateTimer("skintimer") -- i don't know what significance "timeout" has, copied from hoth campaign this way
SetTimerValue(skintimer , interval )
--ShowTimer(skintimer )
skin = 1
maxskin = 4

OnTimerElapse(
function(timer)

--REP Trooper
if (skin == 1) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_feluciatrooper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_feluciatrooper_low1")
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_atrt_ph2")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_atrt_ph2")
end
if (skin == 2) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_greytroper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_greytroper_low1")
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_greytroper")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_greytroper_low1")
end
if (skin == 3) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_greentroop")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_greentroop_low1")
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_feluciatrooper")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_feluciatrooper_low1")
end
if (skin == 4) then
SetClassProperty("rep_inf_trooper_41", "GeometryName", "rep_inf_kashyyktrooper")
SetClassProperty("rep_inf_trooper_41", "GeometryLowRes", "rep_inf_kashyyktrooper_low1")
SetClassProperty("rep_inf_pilot_41", "GeometryName", "rep_inf_greentroop")
SetClassProperty("rep_inf_pilot_41", "GeometryLowRes", "rep_inf_greentroop_low1")
end

skin = skin + 1

if (skin > maxskin) then
skin = 1
end

--ShowTimer(nil)
--DestroyTimer(timer)



SetTimerValue(skintimer , interval )
StartTimer(skintimer)


end,
skintimer
)



--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()

StartTimer(skintimer)

end
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

your req is looking for other req's instead of msh's with the "lvl" section, not a "model" section.
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

OOOOOOOH...

Is it like dis?
Hidden/Spoiler:
ucft
{
REQN
{
"lvl"
"rep_inf_pilot_41"
"rep_inf_trooper_41"
}
}

ucft
{
REQN
{
"model"
"rep_inf_greentroop"
"rep_inf_greytroper"
"rep_inf_kashyyktrooper"
}
}
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Random mshes for units

Post by kinetosimpetus »

almost. only one ucft section
Hidden/Spoiler:
[code]ucft
{
REQN
{
"lvl"
"rep_inf_pilot_41"
"rep_inf_trooper_41"
}
REQN
{
"model"
"rep_inf_greentroop"
"rep_inf_greytroper"
"rep_inf_kashyyktrooper"
}
}[/code]
ARCTroopaNate
Jedi
Jedi
Posts: 1161
Joined: Mon Mar 21, 2011 8:12 pm
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4
Location: STALKER!
Contact:

Re: Random mshes for units

Post by ARCTroopaNate »

YES! It works! Thanks so much Kinetos! :P :clone:
Post Reply