Author |
Message |
iKP
Joined: Sat Jul 04, 2009 9:30 pm Posts: 55 Location: Bangkok, Thailand
|
Need help with changing sprites when hit.
I'm working on a Big Daddy mod from Bioshock, and I want to know how I can change his eye color (Basically changing sprites) when he gets hit by gunfire. As Bioshock fans know, Big Daddies' eyes change from yellow to red when he gets angry. If you can, how about changing his eye colors back to yellow after a while of non-gunfire?
Please help, thanks.
|
Sat Sep 05, 2009 11:19 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Need help with changing sprites when hit.
Lua should do the trick. Code: function Create(self) self.ETimer = Timer() self.RHealth = self.Health end
function Update(self) if self.ETimer.PastSimMS(<timehere>) then self.Frame = 0 else self.Frame = 1 end if self.RHealth != self.Health then if self.RHealth > self.Health then self.ETimer:Reset() end self.RHealth = self.Health end end
You need two frames of animation, the first for when it's eyes are yellow, the second when they are red.
|
Sat Sep 05, 2009 5:52 pm |
|
|
iKP
Joined: Sat Jul 04, 2009 9:30 pm Posts: 55 Location: Bangkok, Thailand
|
Re: Need help with changing sprites when hit.
Yay! Thanks alot! That really helped me. Now I just gotta make a Lua file. All I need in the file is the script you posted right?
|
Sat Sep 05, 2009 8:08 pm |
|
|
Benpasko
Joined: Sun Aug 09, 2009 9:26 am Posts: 1633
|
Re: Need help with changing sprites when hit.
This mod is gonna be amazing, I think. A big daddy? I'll test for you, if you want.
|
Sat Sep 05, 2009 10:37 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Need help with changing sprites when hit.
Download Notepad++ for one. Second, when saving it, save it as "whateveryournameis.lua" Then, for whatever you want to attach the script to, put this in the code for it Code: ScriptPath = Whateveryourrteis.rte/YourLuaFile.lua
|
Sat Sep 05, 2009 11:03 pm |
|
|
iKP
Joined: Sat Jul 04, 2009 9:30 pm Posts: 55 Location: Bangkok, Thailand
|
Bioshock mod help.
Well, sorry but can I change this topic to overall Bioshock mod I'm working on? Anyways, one more question. I tried searching and found nothing so How do we attach a weapon via ini? I have: Code: AddInventory = HDFirearm CopyOf = Rivet Gun But all I get is an error saying "Referring to an Instance ('Rivet Gun') that hasn't been defined!" Please help!
|
Sun Sep 06, 2009 4:29 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Need help with changing sprites when hit.
First of all, where is this in the mod? The actor?
Second, looks like your tabbing is all messed up. Should only be one tab there.
Third-ly? uh That prolly means you have that copyof either before the rivet gun is defined or there is no rivet gun at all. Make sure that code comes after] the rivet gun is defined.
|
Sun Sep 06, 2009 5:00 pm |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Need help with changing sprites when hit.
Check the preset names and confirm that they are identical.
|
Sun Sep 06, 2009 6:15 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Need help with changing sprites when hit.
Also Mail's script will not work right because Lua has ~=, not !=.
|
Mon Sep 07, 2009 4:22 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Need help with changing sprites when hit.
Was half alseep. So just change that.
|
Mon Sep 07, 2009 6:38 am |
|
|
iKP
Joined: Sat Jul 04, 2009 9:30 pm Posts: 55 Location: Bangkok, Thailand
|
Re: Need help with changing sprites when hit.
Mind wrote: First of all, where is this in the mod? The actor?
Second, looks like your tabbing is all messed up. Should only be one tab there.
Third-ly? uh That prolly means you have that copyof either before the rivet gun is defined or there is no rivet gun at all. Make sure that code comes after the rivet gun is defined. - This is in the actor -Sorry, typo there. Theres just 1 tab in the ini -It's the last line of the actor's code. Where do we define it? They are identical, the preset name in Rivet Gun.ini and this codein the Rosie.ini I'm such a n00b. Sorry.
|
Mon Sep 07, 2009 12:56 pm |
|
|
Lizardheim
DRL Developer
Joined: Fri May 15, 2009 10:29 am Posts: 4107 Location: Russia
|
Re: Need help with changing sprites when hit.
In the index.ini you should have the rivetgun above the big daddy.
|
Mon Sep 07, 2009 2:50 pm |
|
|
iKP
Joined: Sat Jul 04, 2009 9:30 pm Posts: 55 Location: Bangkok, Thailand
|
Re: Need help with changing sprites when hit.
YEA! Tahnk you so much guys! Now the Rosie comes with a Rivet Gun! Thanks again! Should I remove it from the buy menu now? Now I have to get working on offsets and, more importantly, THE LUA TO MAKE HIS LIGHTS CHANGE! NOES!
|
Mon Sep 07, 2009 2:59 pm |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Need help with changing sprites when hit.
Code: function Create(self) self.ETimer = Timer() self.RHealth = self.Health end
function Update(self) if self.ETimer.PastSimMS(<timehere>) then self.Frame = 0 else self.Frame = 1 end if self.RHealth ~= self.Health then if self.RHealth > self.Health then self.ETimer:Reset() end self.RHealth = self.Health end end Now open Notepad++ and save that file as "Actor.lua" in your rte Go to the actor's code and go down to where he is defined. Put a line in that says this "ScriptPath = [filepath to the lua file]/Actor.Lua" Hope this helps
|
Mon Sep 07, 2009 4:36 pm |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Need help with changing sprites when hit.
You should probably make the Rivet Gun unbuyable. Copy this into gun code:
|
Mon Sep 07, 2009 5:10 pm |
|
|
|