ubi.com    Forums  Hop To Forum Categories  Far Cry  Hop To Forums  Far Cry Community Creativity Forum    Regenerating Health Mod Scripting Help Needed
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
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:


quote:
function BasicPlayer:IsRegen()
local stats = self.cnt;

if (stats.stamina=100 and stats.health>0 and stats.health<100 then

local dmgScale = _frametime;
-- let's cap it to prevent lots of damage if frame was long (was loading in this frame)
if(dmgScale>0.03) then dmgScale = 0.03 end

return {
dir = g_Vectors.v001,
damage = -230*dmgScale,
target = self,
shooter = self,
landed = 1,
impact_force_mul_final=5,
impact_force_mul=5,
damage_type="healthonly",
drowning=0,
};
end
end



Can anybody help me? Sad Thanks in advance.
 
Posts: 2 | Registered: Mon August 22 2005Reply With QuoteEdit or Delete MessageReport This Post
Jib him!!!
Picture of bjanga
Posted Hide Post
 
Posts: 710 | Registered: Tue July 20 2004Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Thanks, I figured it out though. I was just missing a ")" after "stats.health<100".

Whoops. Hammer
 
Posts: 2 | Registered: Mon August 22 2005Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
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
 
Posts: 24 | Registered: Wed October 04 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

ubi.com    Forums  Hop To Forum Categories  Far Cry  Hop To Forums  Far Cry Community Creativity Forum    Regenerating Health Mod Scripting Help Needed

Terms of Use