View unanswered posts | View active topics It is currently Wed Dec 25, 2024 5:24 pm



Reply to topic  [ 8 posts ] 
 Random Head 
Author Message
User avatar

Joined: Wed Jul 16, 2008 12:49 am
Posts: 226
Reply with quote
Post Random Head
Hi,

So I am aware that the Ronin use a small script to basically choose one frame from an "animated" head sprite to make it seem as though the head is random. My question would be is it easily possible to make it so that the random head is the actual attachable head instead of a frame on the sprite?

Let me try to elaborate:

Say I have head1000, head2000, and head3000. 3 separately coded heads with their own attachable and what-have-you. Can I edit the Ronin script to pick from one of these heads for any given actor? Would I attach the script to my base actor and then it would choose a random head from a table or something?

Also I'm sure it probably doesn't matter but would a head be displayed in the buy menu for the actor?


Sun Aug 09, 2015 5:46 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Random Head
There's not really a way to swap out the actual head of an actor. There are, however, workarounds, depending on what exactly you're trying to do.

For example, if your goal is: Actor has multiple random heads, with the only differences being different attachments on the heads (helmets, sunglasses, etc.).

Solution: The actor has a single head, and all possible attachables are attached to the head. The actor's head is scripted to randomly "choose" a set of attachments to use - all other attachments are deleted.


If that's not what you're trying to do, being a bit more specific would help.


Wed Aug 12, 2015 2:04 am
Profile
User avatar

Joined: Wed Jul 16, 2008 12:49 am
Posts: 226
Reply with quote
Post Re: Random Head
Ok I will try to explain better :grin:

lets say I have 3 heads that each have their own unique attachment, such as a helmet or hat or what-have-you.

Head001 has Hat001, Head002 has Hat002 and so-forth.

They will all use the same body.

Is there a workaround for such a thing? Basically what I'm trying to do is keep the mod more vanilla-ish with only 2 or 3 buy-able actors (light, med, heavy) but still being able to include a variety of unique sprites for fun and diversity.

All X heads are different, in terms of sprite dimensions and overall look, so it wouldn't be an option to do the Ronin animation thing I don't think. Also the attachables specific to a given head is important. Head001 cant wear Hat002 if that makes sense. The attachables are also important in that I dont want to include them as part of the head because I would like to stay away from my actor taking damage if he gets shot in the hat.

Or would it be easier or possible to make all the faces into frames in a sprite and make it so if, for example, frame001 is chosen through lua it will force it to have hat001?


Wed Aug 12, 2015 4:16 am
Profile
Forum Moderator
User avatar

Joined: Fri Feb 02, 2007 3:53 pm
Posts: 1896
Location: in my little gay bunker
Reply with quote
Post Re: Random Head
You could have a Lua script on creation that picks a random head, and then positions the hat attachment appropriately while changing both of the sprites.


Thu Aug 13, 2015 5:20 pm
Profile
User avatar

Joined: Wed Jul 16, 2008 12:49 am
Posts: 226
Reply with quote
Post Re: Random Head
So the script would make it so if head001 was picked it would choose hat001 and change the offsets of the hat to a specific point through lua? Or would it be head and hat are both frames in a sprite and it changes offsets depending on which hat frame it picked?

What would be needed to keep it from picking frame X if frame Y is chosen?

Like I said, if possible I'd like it so head a can't wear hat b.

Also if I don't make sense then let me know and I'll post the mod and sprites and pic of what I'm trying to do :)


Fri Aug 14, 2015 4:59 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Random Head
SnowMonster20 wrote:
What would be needed to keep it from picking frame X if frame Y is chosen?


self.Frame = Y;


You just tell it what to do.


Sat Aug 15, 2015 8:07 am
Profile
Forum Moderator
User avatar

Joined: Fri Feb 02, 2007 3:53 pm
Posts: 1896
Location: in my little gay bunker
Reply with quote
Post Re: Random Head
Something like this pseudocode. While I am sure there's some distribution problems with this, something like it should work. Even if it's probably hella inefficient. You'd probably also need some code to find the hat attachable, but I don't remember enough about Cortex Commands lua to do anything about that

Code:
function Create(self)

local hatOffsets = {
                   {0,0},
                   {1,5},
                   etc
                   }
local legalHats = {
                  {1,5,13},
                  etc
                  }

self.headIndex = math.random(1, #legalHats)
self.head.frame = self.headIndex


repeat
   local legalHat = false
   self.hatIndex = math.random(1,#hatOffsets)
   for i = 1, 1, #legalHats[self.headIndex] do
      if(self.hatIndex == legalHats[self.headIndex][i]) then
         legalHat = true
         break
      end
   end
until legalHat == true

self.hat.frame = self.hatIndex
self.hat.jointOffset = hatOffets[self.hatIndex]

end


Sat Aug 15, 2015 2:12 pm
Profile
User avatar

Joined: Wed Jul 16, 2008 12:49 am
Posts: 226
Reply with quote
Post Re: Random Head
Would that attach to the head or the hat object?

would i have the ronin script on the head itself and have a script on the attachables to make it so if head x is picked then it picks hat x and sets the offsets?


Sat Aug 15, 2015 8:54 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.116s | 13 Queries | GZIP : Off ]