Page 1 of 1

Random mshes for units [Solved]

Posted: Mon Jan 16, 2012 7:41 pm
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.

Re: Random mshes for units

Posted: Mon Jan 16, 2012 8:29 pm
by kinetosimpetus

Re: Random mshes for units

Posted: Mon Jan 16, 2012 9:46 pm
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

Re: Random mshes for units

Posted: Mon Jan 16, 2012 9:49 pm
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.

Re: Random mshes for units

Posted: Mon Jan 16, 2012 10:04 pm
by kinetosimpetus
You need to start the timer once outside the OnTimerElapse function, otherwise it doesn't start the chain.

Re: Random mshes for units

Posted: Tue Jan 17, 2012 4:42 pm
by ARCTroopaNate
Sorry for me being stupid, I've never worked with timers before. How do you start the timer outside the OnTimerElapse?

Re: Random mshes for units

Posted: Tue Jan 17, 2012 5:37 pm
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...
---------------------------------------------------------------------

Re: Random mshes for units

Posted: Tue Jan 17, 2012 6:18 pm
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

Re: Random mshes for units

Posted: Tue Jan 17, 2012 6:22 pm
by kinetosimpetus
That should work.

Re: Random mshes for units

Posted: Tue Jan 17, 2012 6:42 pm
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"

Re: Random mshes for units

Posted: Tue Jan 17, 2012 6:53 pm
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

Re: Random mshes for units

Posted: Tue Jan 17, 2012 7:14 pm
by ARCTroopaNate
How would you load it into a Req separately?

Re: Random mshes for units

Posted: Tue Jan 17, 2012 7:29 pm
by kinetosimpetus

Code: Select all

ucft
{
    REQN
    {
        "model"
        "rep_inf_greytroper"
        "rep_inf_greytroper_low1"
    }
}
kinda like that

Re: Random mshes for units

Posted: Tue Jan 17, 2012 9:16 pm
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

Re: Random mshes for units

Posted: Tue Jan 17, 2012 9:25 pm
by kinetosimpetus
your req is looking for other req's instead of msh's with the "lvl" section, not a "model" section.

Re: Random mshes for units

Posted: Tue Jan 17, 2012 9:33 pm
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"
}
}

Re: Random mshes for units

Posted: Tue Jan 17, 2012 9:37 pm
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]

Re: Random mshes for units

Posted: Tue Jan 17, 2012 9:58 pm
by ARCTroopaNate
YES! It works! Thanks so much Kinetos! :P :clone: