ID:2007208
 
(See the best response by Sillenium.)
If I have a moving state called for example limp.dmi that displays my hero to limp/not walk well in certain injury situations, how can I make it so it is displayed in certain times? A sample code would really help...
Thanks

var/previousIcon

previousIcon=src.icon
src.icon='limp.dmi'

Revert back to original icon
src.icon=previousIcon


This is rather silly tho and u should ptob just keep that as a icon state within the same icon and change that instead.
Best response
When you're damaging the mob you'll want to put something like this in/near your health reduction:
if (src.health<=src.health/src.maxHealth*25) 'this would check if the user is at or below 25% health and then put them in the Injured icon state
src.icon_state="Injured"


Then when the user gains health you'd just want to revert back to their previous icon_state if it was specified or:
if (src.health>src.health/src.maxHealth*25) 'this would do the opposite to the above, if they are above 25% it will restore the icon state to the default, or you can place another icon state in between the speech marks
src.icon_state=""


if(src.health<=round(src.maxhealth*0.25))//if hp is greater than 25%
src.icon_state="limp"
else
src.icon_state=""//normal.

A bit simpler way to write it.
Did you guys really just not read the different .dmi file part at all?
In response to GreatPirateEra
Yes. As someone mentioned up above, you should really just make both files into one and change to the limping icon state.

If for some reason you absolutely need to have 2 files(which you probably don't)

then just replace icon_state with icon.
It's a really simple matter.
I was the one who mentioned that btw. It's a bigger deal than you're making it out to be. You need to keep track of their icon prior to changing to the limp state, and if the icon they're currently using even has a limp state available. Take something like this for example: you have a human base and a monster base, or their icon is something you didn't take into account. The monster base doesn't have a limping state. You don't take any of this into consideration and change their icon to 'limp.dmi', transforming the monster into a human. If he goes with the icon method instead of utilizing icon states, he needs to include a lot of bulletproofing.
In response to GreatPirateEra
I understand that, and agree with you whole heartedly.
The only reason he might ever need 2 seperate icons is if they are different sizes (which even then he shouldn't really need 2 seperate icons).

As far as me making anything out to be a big deal (wasn't aware I actually did unless you weren't talking to me. lol)