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



Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
 Specifically random 
Author Message
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
When I attempt to spawn the actor, the console fills with
Code:
ERROR: the attribute 'AHuman.Frame' is of type:(number) and does not match:(nil)


Tue Dec 18, 2012 11:50 pm
Profile WWW
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
A little help, please?


Mon Jan 07, 2013 1:09 am
Profile WWW

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Specifically random
Ah sorry, I don't really know the ini side of things. I guess AHumans can't have frames, you'll need to change their torso frame or something, I'm not really sure. The script should work fine though once you can figure out what it is you need to change the frame of.


Mon Jan 07, 2013 2:10 am
Profile
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
Aha, so the DebugConsole.txt contains the last game session's console log. I wish I had known this. :P

I found that there is another error that happens right before the 'does not match' spam;
Code:
attempt to call field 'rand' (a nil value)


For this line
Code:
self.FrameNumber = math.floor(math.rand()*6);


Tue Jan 08, 2013 9:48 am
Profile WWW
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: Specifically random
Code:
self.FrameNumber = math.floor(math.random()*6);


Seems like the shorthand rand for random doesn't work.


Tue Jan 08, 2013 9:50 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Specifically random
Oh dear, now I feel exceedingly dumb. Not only did I miss my dumb mistake, I completely misread the error message and gave false info about the problem :(
Thanks for the save p3lb0x.


Tue Jan 08, 2013 9:59 am
Profile
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
It's my fault for not finding the debug log text file earlier, I could've provided clearer error information if so.
The code now no longer throws out errors at all, but only the head is randomised. I don't know how to reference the torso (and non-base attachables), as self.Frame doesn't work.

I don't get errors with self.BodyFrame, but it doesn't randomise the body either.


Tue Jan 08, 2013 11:06 am
Profile WWW
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
Alright, I'm definitely not a lua person, and all this beating my head against a wall is giving me a headache. Please, some help before I decide on giving up. :(
Using this script in the ahuman section (next to the ai ScriptPath), only the head is randomised.
Code:
require("Actors/AI/NativeHumanAI")
function Create(self)
   self.AI = NativeHumanAI:Create(self)
   self.FrameNumber = math.floor(math.random()*6);
end
function Update(self)
   if self.Frame ~= self.FrameNumber then
      self.Frame = self.FrameNumber;
      self.Head.Frame = self.FrameNumber;
      self.LargeHelmetFrame = self.FrameNumber; < this is an attachable that I have no idea how to reference. Named "Large Helmet A"
   end
end
function UpdateAI(self)
   self.AI:Update(self)
end


Sun Jan 13, 2013 10:59 am
Profile WWW

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Specifically random
Accessing the helmet isn't hard, I can do that for you, but I don't know enough about ini properties to tell you how to access the torso's frame or if it's possible like this.

That said, it might be easier to do it like the ronin actor does things. If it is, I apologize for giving you poor advice earlier, hopefully this'll prove better. I haven't really looked into it but it seems to make an actor with all the possible parts on and as soon as the actor is spawned one is picked at random and the rest are deleted. The advantage there is you'd be able to use ronin as a template and more or less just copy scripts over, so it shouldn't be too hard to do.


Sun Jan 13, 2013 6:52 pm
Profile
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
How would I do the helmet? I would like to learn, but I haven't seen any a global list of functions for me to experiment with.

The problem with the ronin way is that actor.Sharpness is supposed to be the part that randomises others, yet it isn't randomising anything for me.
The random trigger code;

The code I am trying for the head;


Mon Jan 14, 2013 12:53 am
Profile WWW
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
Well damn, I got it. I just had the scriptpaths in the wrong sections. All I need now is to know why frames other than 1,2,6 aren't selected at all, and how to apply this to the legs. Thank you for the help so far, Bad boy. :)

Edit - And just like that I solve the frame selection issue. Now just the legs.


Tue Jan 15, 2013 7:59 am
Profile WWW
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: Specifically random
Applying it to legs is going to be REALLY tough. Legs work by assigning the leg frames to specific length segments and then picking the one that is best suited to the length difference between the foot and the joint with the body. I am afraid you're going to have to do some pretty serious lua fiddling to accomplish this.


Tue Jan 15, 2013 11:11 am
Profile
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Specifically random
Ah I see. Well, that about finishes my lua shenanigans for now. Thank you.


Tue Jan 15, 2013 11:57 am
Profile WWW

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Specifically random
Glad I could help, though I still think I bungled this one pretty badly :D

Moving along though, just to preface, walkpaths and ini stuff is outside of my specialization so I hope I'm forgiven if I say anything stupid.
So p3l (or someone else knowledgeable), if you have different leg frames that are the same length and shape but, for example, have more armor or are a different colour or something, how would the engine choose one? I assume it'd iterate through them from 0 to n and pick the closest based on that, so I guess it'd either pick the first or the last depending on how it's done.
Is it safe to assume it wouldn't just pick one at random? In that case you could just say self.FGLeg.Frame = self.FGLeg.Frame + n where n is essentially the frame picked in the rest of this script and it should work (though I'm sure it wouldn't be so easy).

If this isn't viable at all, could some sort of attachables be used?


Oh and for the helmet, something like this would do it. Untested so I can't say for sure it'll work but it's copied from something of mine that does so it should be fine. Stick in the actor's Update Function and stick the line self.Helmet = nil; into the actor's Create Function:
Code:
   if not self.Helmet then
      local MoObj
      for i = 1, MovableMan:GetMOIDCount()-1 do
         if MovableMan:GetRootMOID(i) == self.ID then
             MoObj = MovableMan:GetMOFromID(i)
            if MoObj.PresetName == "INSERT HELMET PRESET NAME HERE" then
               self.Helmet = ToAttachable(MoObj);
               print ("helmet found"); --This line can be removed if everything works. It just prints to the console letting you know it works fine.
            end
         end
      end
   end

   self.Helmet.Frame = self.FrameNumber --Replace this with whatever variable you assigned the chosen frame to.


Tue Jan 15, 2013 6:48 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Specifically random
The animation system for CC (as far as I know) picks a leg sprite anywhere from 0 to n - 1, with n being the number of frames. Frame 0 is the least extended, frame n -1 is the most extended. No matter how many frames you give it, it'll interpolate as smoothly as it can between those frames.

If you add more frames to the leg (in this case, because you want alternate leg sprites), it'll also animate through those. This is not what you want, unfortunately, and can't really be solved by changing the leg frame — you could do some math to figure out how extended the leg is based on the frame, then use that to get the correct frame number, but this is likely going to end with your actor spazzing out because its leg keeps being jerked around.

What you might be able to do is make the leg sprite invisible. Give it the same number of frames as you want, but make them all empty. Then, put an attachment on the leg which actually contains the leg sprites. That way, you can set the attachment's frame independently of the leg. This may or may not actually work in practice, but it's probably your best bet.


Wed Jan 16, 2013 12:35 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 31 posts ]  Go to page Previous  1, 2, 3  Next

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.046s | 13 Queries | GZIP : Off ]