Animated Faces (BlizzABS and MOG HUD)

Started by Subsonic_Noise, June 05, 2009, 04:46:01 pm

Previous topic - Next topic

Subsonic_Noise

Hi.

I'm trying to make a script for animated faces for the MOG HUD using BlizzABS.

Problems:
-MOG HUD can't go below BlizzABS, so I added this piece of shit script to it:

def animated
case faces
if 1 then return "_atk"
if 2 then return "_hit"
if 3 then return "_skl"
else
return "_fc"


and changed the name of the face to (Playername) + animated
(I don't remember the syntax for playername and I'm to lazy to look it up now)


Now I'll just add a script below BlizzABS which changes the variable (the "faces" up there) if the payer uses certain actions, right? That leads to the next problems:

2. How do I "ask" BlizzABS if the player is doing these actions?
3. How do I access the variable? Let's say I defined it in Scene_faces, would it be Scene_faces.faces?

Please don't give me finished scripts because I would like to learn RGSS and perhaps release this as my first own script^^
(But you will be credited if you help me^^)

Blizzard

$game_player.current_sprite. You can easily use:

if $game_player.current_sprite == ''
 return '_fc'
end
return $game_player.current_sprite


Each character on the map that is also a battler on the map has a variable called @current_sprite which holds the extension of the current sprite animation (i.e. _atk, _skl, etc.). What I did in the code above was simply accessing that variable of the player. Also keep in mind that it might have something more than just the sprite type (i.e. _skl12 is Actor Skill Sprites are on and you are using skill with ID 12). In that case you can "cut off" only the part of the string that you need. It works like this:

a = '12345'
# str[START, LENGTH]
b = a[0, 3]
c = a[2, 2]
p a # '12345'
p b # '123'
p c # '34'


So in order to find out which sprite is currently used (since Blizz-ABS always uses "_" and 3 letters) you would use this:

$game_player.current_sprite[0, 4]

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

June 05, 2009, 05:09:07 pm #2 Last Edit: June 05, 2009, 05:17:42 pm by Subsonic_Noise
So I'll add this under Blizz-ABS as something like this?
(EDIT: made it '_idl' istead of '' because it never uses the normal sprite if I have an idle sprite, or am I wrong?)

if §game.player.current_sprite == '_idl'
§scene_faces.faces = '_fc'
else
scene_faces.faces =  §game.player.current_sprite[0, 4]
end

And change the face name to

(playername) + scene_faces.faces



Thanks for the quick help! Level ++
(But I can't try it now because I do not have RMXP on this PC)
If it works (I assume it works) i'll post it as a "scriplet" along with other "scriplets" i did and I'll do.
If you now would do graphics and music for my game you would be in every catogory of my credits :V:

EDIT: I might perhaps add that I'm not really good at scripting and learned the few things I know about
RGSS by looking at your BlizzABS script to make other things compatible to it XDDD

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

Quote from: Subsonic_Noise on June 05, 2009, 05:09:07 pm
If you now would do graphics and music for my game you would be in every catogory of my credits :V:


I knew you do music and sprites^^

Blizzard

You can always use my sprites and music in your game, that's what I meant. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

June 05, 2009, 05:40:08 pm #6 Last Edit: June 05, 2009, 05:42:06 pm by Subsonic_Noise
Ah Thanks^^

PS: Look at my Sig before it's gone! It currently sais "Heal the world with BlizzABS!"  XDDDDD
EDIT: It's gone... now it sais "BlizzABS - It's a kind of magic" XD I love Sloganizer!

Blizzard

June 05, 2009, 05:43:26 pm #7 Last Edit: June 05, 2009, 05:44:51 pm by Blizzard
"Blizz-ABS, it's a kind of magic." Sloganizer is awesome, I know. xD

EDIT: LMAO! "Blizz-ABS, better than sex."
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

It just said "BlizzABS makes me hot!" XDDDDD Imagine that with a  :naughty: smiley XD
[/offtopic]
K I'll go off soon I will tell you if it worked when I tested it^^

Subsonic_Noise

Sorry but after I got it to work (I made it compatible so it can go under BlizzABS) It always gives me the standard-face ;_;

This is my animated-method:

class Window_Base < Window   

def animated
    case $game_player.current_sprite #[0, 4]
        when ''     then return '_fc'
        when '_idl' then return '_fc'
        when '_run' then return '_fc'
        when '_hit' then return '_hit'
    end
    return $game_player.current_sprite[0, 4]
end


And this is where this code i called:
def draw_heroface(actor,x,y) 
    face = RPG::Cache.picture(actor.name + animated) rescue nada  ########
    cw = face.width
    ch = face.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x , y - ch, face, src_rect)   
end


What the fuck went wrong? The problem semms to be my code because it shows a face, but alway the same  :???:

Aqua

Quote from: Subsonic_Noise on June 06, 2009, 02:16:04 pm

    face = RPG::Cache.picture(actor.name + animated) rescue nada  ########



I /think/ that the animated here is a variable... and since you didn't define the variable, it equals nil.

Sooo you should define the variable on the line above face = RPG::Cache...
animated = Window_Base.animated

Subsonic_Noise

June 06, 2009, 02:48:53 pm #11 Last Edit: June 06, 2009, 02:54:49 pm by Subsonic_Noise
the "face =" and the "animated" are both in the same class (Window_base) so "animated" should call the class, or am I wrong?
If I write "animated = Window_Base.animated" it gives me an error telling me that animated is a missing class  :???:
But I think the
face = RPG::Cache.picture(actor.name + animated) rescue nada

must be right or else it wouldn't show any face? (nada = no face)
thanks for help!

EDIT: I came up with 2 ideas what the problem could perhaps be:
1. It doesn't refresh the faces often enough
2. It does show the face, but only very short (How could I do somthing like "wait" in rgss?)

But I'm a complete N00b so both could be wrong...

Blizzard

Are you updating it? Where are you calling the method?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

June 07, 2009, 07:37:18 am #13 Last Edit: June 07, 2009, 08:16:07 am by Subsonic_Noise
I noticed that the HUD only updates when the sp, hp ur lvl is changed so i supposed that this is the problem and made a method "refresh_faces".
How do I make it that this method is called everytime a sprite is changed?

Blizzard

The HUD has methods for that. Check out how it was done with the HP and simply copy-paste and rename the code and variables. This will ensure that it stays maximally optimized. :)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Subsonic_Noise

June 08, 2009, 02:37:25 pm #15 Last Edit: June 08, 2009, 04:13:46 pm by Subsonic_Noise
Thanks! Level ++ (I'll get you on lvl 1337!) Now it works nearly perfect, but there is one problem: BlizzABS doesn't use _hit sprites. How could I check if the player is hit?

EDIT: I just released it. I'll ad the _hit animation later. Must this topic now be locked?

Blizzard

June 09, 2009, 03:45:29 am #16 Last Edit: June 09, 2009, 03:52:50 am by Blizzard
Of course not. xD And I didn't add _hit sprites yet.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.