Changing Actor sprites dependent on variable?

Status
Not open for further replies.

WeepyDev

Warper
Member
Joined
Nov 5, 2013
Messages
1
Reaction score
0
First Language
English
Primarily Uses
I haven't messed around with it much since I'm just getting into working on this new game of mine, but the most prominent system is a karma system a la Fable where the character's graphic will morph based on Karma (so a karma variable). 

Setting up the karma is easy. 

How would you go about changing the graphic though? 

I could make a common event that checks karma and switches sprites if applicable and then plug that into all my Map changes / major events but that seems...messy. Is there a more eloquent way to do this? I feel like there is and I'm just too damn tired to see it. 

Sorry if I mixed up my languages, I've been working in several different programs (Gamemaker, Python/Pygame, Stencyl) in the past few days and I may have mixed up some terminology! 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You'd need to provide more information on what you're trying to do.


Are all your graphics for the character in a single character sheet? Or are there several? How will the variable determine which one to use?


You can run

Code:
$game_actors[id].set_graphic(character_name, character_index, face_name, face_index)
in a Call Script event command, where id is the actor's id, and the parameters are pretty self-explanatory. Depending on how your images are set up, you should be able to use the variable to either form the character and face name, or as the index.
 

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
For an event-only option, use a common event set to parallel process. Obviously, a switch is needed to make it run, so don't forget to turn this switch on at the beginning of the time.


In this common event, have a bunch of conditional branches check the value of the variable. So if your 'karma' is at 50, or 100, or 500 etc. make a conditional branch for each stage you want to show, and be sure to pick the less than or equal to, and to put all other conditional branches in the 'else' branch of each other. Obviously, in each conditional branch, change the actor sprite accordingly.


This should make the actor sprite change when his 'karma' hits a certain value.
 

oldbone

Veteran
Veteran
Joined
May 10, 2012
Messages
101
Reaction score
5
First Language
English
Primarily Uses
Is there a way to change the SPRITE only and leave the face intact with just the one script call? (need to use a script)

Or, it is more involved than that with saving the old values... ?
 
Last edited by a moderator:

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
Is there a way to change the SPRITE only and leave the face intact with just the one script call? (need to use a script)
I'm not 100% this is what you are asking for.  But just in case:

You can change just the sprite graphic by using the options inside the Set Move Route/Change Graphic commands on page 2 under your event commands. 

There are probably other ways.  But that's how I do it when I just want to change the sprites but keep the face the same.  Your focus seems to be on script calls though so I am not sure if this is what you are looking for.  So if not just ignore me.
 
Last edited by a moderator:

oldbone

Veteran
Veteran
Joined
May 10, 2012
Messages
101
Reaction score
5
First Language
English
Primarily Uses
Yeah.. I need to do it in a script...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
So if you want to change the sprite only but leave the face intact, do this:

Code:
$game_actors[id].set_graphic(character_name, character_index, $game_actors[id].face_name, $game_actors[id].face_index)
where you're passing it the new character (sprite) name and index, and telling it to use the face that's already assigned. Here, you'll need to replace id with the actual id of the actor (no leading zeros) three times.
 

oldbone

Veteran
Veteran
Joined
May 10, 2012
Messages
101
Reaction score
5
First Language
English
Primarily Uses
Sweet. 

Is there a script call I can make to force an update to the actor graphic? I can refresh it in a messy way... but would like to have it refresh immediately, without any intervention.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That's it. I just gave it to you. Did you try it?


If it doesn't change straight away, try adding $game_player.refresh afterwards
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
try to call $game_player.refresh or $game_player.update or try refreshing the $game_map's spriteset
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Actually, I just realized you aren't the OP. You should probably create your own thread next time, since your requirements aren't quite the same as the question originally asked.
 
Last edited by a moderator:

oldbone

Veteran
Veteran
Joined
May 10, 2012
Messages
101
Reaction score
5
First Language
English
Primarily Uses
Apologies. And thanks
 

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
oldbone don't necro-post nor hijack someone else's thread. Please create your own, thank you.


Closing this unless OP returns and wants it reopened.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top