![]() |
![]() |
Forums
Far Cry
Far Cry Community Creativity Forum
Regenerating Health Mod Scripting Help Needed|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
I'm currently working on a mod and one of the things I need is for the players health to slowly regenerate if their stamina is full.
I used the drowning script as a starting point since it works off of stamina and only damages health, so it seems like a good place to start. However after I finished my scripting I tried it out in the game and it won't load (The load bar for the new game will go 100% then the screen will turn black and just sit there.), here is the scripting addition I did to the "BasicPlayer.Lua" I added it right after the "BasicPlayer:IsDrowning()" function:
Can anybody help me? |
|||
|
Jib him!!!![]() |
post this at http://www.crymod.com
|
|||
|
Thanks, I figured it out though. I was just missing a ")" after "stats.health<100".
Whoops. |
||||
|
Figured I'd do a little necromancy and revive this thread, since I was working on it anyway for a similar scripting question on CryMod.
The problem with the original script isn't just an issue of syntax. Stamina is a percent in game, so stats.stamina will always return a number less than or equal to 1. So if you used if(stats.stamina == 100) as an argument the script would never run. Takaro had posted a response about a similar script on CryMod, so I played around with his script a little for a few days, and finally came up with this. I hadn't heard of LUA before these last couple weeks, much less scripting for it, but I'm pretty sure this is about as clean a script as you could make, to do what you wanted it to do. if(self == _localplayer) then if(stats.health < self.Properties.max_health) then if(stats.stamina == 1) then if (not self.healthRegenStartTime) then self.healthRegenStartTime = 0; end self.healthRegenStartTime = self.healthRegenStartTime + self.UpdateTime/1000; if (self.healthRegenStartTime > 2) then local healFactor = 20; local healTotal = self.Properties.max_health/healFactor; if(self.Properties.max_health - stats.health > healTotal) then stats.health = stats.health + healTotal; else stats.health = self.Properties.max_health; end self.healthRegenStartTime = nil; end end end end Once again, sorry about necromancy here, but figured if someone was using the search function, at least they could find a working script sample. Forgot to add that this has to be added to the function BasicPlayer:Client_OnTimer() in basicPlayer.LUA |
||||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|
Forums
Far Cry
Far Cry Community Creativity Forum
Regenerating Health Mod Scripting Help Needed
