Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: Subsonic_Noise on June 05, 2009, 04:46:01 pm

Title: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 05, 2009, 04:46:01 pm
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^^)
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 05, 2009, 04:53:19 pm
$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]

Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 05, 2009, 05:09:07 pm
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
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 05, 2009, 05:20:46 pm
Actually... ._.;

http://forum.chaos-project.com/index.php?topic=170.0
http://forum.chaos-project.com/index.php?topic=134.0
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 05, 2009, 05:23:42 pm
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^^
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 05, 2009, 05:24:47 pm
You can always use my sprites and music in your game, that's what I meant. xD
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 05, 2009, 05:40:08 pm
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!
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 05, 2009, 05:43:26 pm
"Blizz-ABS, it's a kind of magic." Sloganizer is awesome, I know. xD

EDIT: LMAO! "Blizz-ABS, better than sex."
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 05, 2009, 05:45:59 pm
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^^
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 06, 2009, 02:16:04 pm
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  :???:
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Aqua on June 06, 2009, 02:36:28 pm
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
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 06, 2009, 02:48:53 pm
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...
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 07, 2009, 06:02:58 am
Are you updating it? Where are you calling the method?
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 07, 2009, 07:37:18 am
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?
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 07, 2009, 08:22:20 am
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. :)
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Subsonic_Noise on June 08, 2009, 02:37:25 pm
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?
Title: Re: Animated Faces (BlizzABS and MOG HUD)
Post by: Blizzard on June 09, 2009, 03:45:29 am
Of course not. xD And I didn't add _hit sprites yet.