testFunction = OnCharacterDeath(
function(player, killer)
SetProperty(GetCharacterClass(killer), "AddHealth", 1000) --higher than maxhealth in order to fully replinish
end
end
)
EnableSPHeroRules()
end
[/code][/size]
gives me
Hidden/Spoiler:
C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\DEF\DEFg_con.lua:50: `)' expected (to close `(' at line 46) near `end'
ERROR[scriptmunge scripts\DEF\DEFg_con.lua]:Could not read input file.ERROR[scriptmunge scripts\DEF\DEFg_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
ERROR[levelpack mission\DEFg_con.req]:Expecting bracket, but none was found.
File : munged\pc\defg_con.script.req(1)...
ucft <--
ERROR[levelpack mission\DEFg_con.req]:Expecting bracket, but none was found.
File : munged\pc\defg_con.script.req(1)...
testFunction = OnCharacterDeath(
function(player, killer)
SetProperty(GetCharacterClass(killer), "AddHealth", 1000) --higher than maxhealth in order to fully replinish
end
end
)
EnableSPHeroRules()
end
[/code][/size]
gives me
Hidden/Spoiler:
C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\DEF\DEFg_con.lua:50: `)' expected (to close `(' at line 46) near `end'
ERROR[scriptmunge scripts\DEF\DEFg_con.lua]:Could not read input file.ERROR[scriptmunge scripts\DEF\DEFg_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
ERROR[levelpack mission\DEFg_con.req]:Expecting bracket, but none was found.
File : munged\pc\defg_con.script.req(1)...
ucft <--
ERROR[levelpack mission\DEFg_con.req]:Expecting bracket, but none was found.
File : munged\pc\defg_con.script.req(1)...
ucft <--
2 Errors 0 Warnings
i had it many times xD, surely end words are bad placed try moving enableheroe line up of it
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
conquest:Start()
SetUberMode(1);
testFunction = OnCharacterDeath(
function(player, killer)
SetProperty(GetCharacterClass(killer), "AddHealth", 1000) --higher than maxhealth in order to fully replinish
end
)
end
EnableSPHeroRules()
end
You have too many "end" statements. It's good practice to write your code with a clear nesting, like you're doing, but I wonder why you thought it necessary to put your "end" (the extra one) in-line with your SetProperty command. If you meant to have an "if" statement there, you left it out.
testFunction = OnCharacterDeath(
function(player, killer)
SetProperty(GetCharacterUnit(killer), "AddHealth", 10)
end
)
give the unit a +10 health/sec regen rate after the first kill.
how would I make it only give health once?
EDIT:
how could GetObjectHealth be used to add health
EDIT2:
Hidden/Spoiler:
[code]
function(killer)
-- if IsCharacterHuman(killer) == true then
SetProperty(GetCharacterUnit(killer), "AddHealth", 10)
timeoutTimer = CreateTimer("timeout")
SetTimerValue(timeoutTimer, 20)
ShowTimer(timeoutTimer)
StartTimer("timeout")
OnTimerElapse(
function(timer)
SetProperty(GetCharacterUnit(killer), "AddHealth", -10)
ShowTimer(true)
DestroyTimer(timer)
end,
timeoutTimer
)
-- end
end
)
[/code][/size]
was a code that attempted to give health regen or a certain amount for a certain period of time, to reward a kill. It did not work, and I cannot generate a debug log as my disc is at a friends house.
testFunction = OnCharacterDeath(
function(player, killer)
if killer == nil then return end --make sure there is a killer
local unit = GetCharacterUnit(killer) --get the killer's unit object
if unit == nil then return end --make sure the killer wasn't also killed
SetProperty(unit, "CurHealth", GetObjectHealth(unit)+10) --increase the killer's unit's health by 10
end
)
lucasfart wrote:Just curious, would anything happen if you received +10 health when you were at 100% health? Would it increase, or could you just not get anymore?
It will roll over above 100% (when you have greater health than your maxhealth value it is stored in a lighter-blue flashing bar over your health bar). If you're being conscientious about your code, you'll make sure to check for hitting your maxhealth and making sure it doesn't get larger than that.
testFunction = OnCharacterDeath(
function(player, killer)
if killer == nil then return end --make sure there is a killer
local unit = GetCharacterUnit(killer) --get the killer's unit object
if unit == nil then return end --make sure the killer wasn't also killed
SetProperty(unit, "CurHealth", GetObjectHealth(unit)+(MaxHealth-CurHealth))
end
)
I tried that but nothing happened, but when I replaced (MaxHealth-CurHealth) with a number it worked.
testFunction = OnCharacterDeath(
function(player, killer)
if killer == nil then return end --make sure there is a killer
local unit = GetCharacterUnit(killer) --get the killer's unit object
if unit == nil then return end --make sure the killer wasn't also killed
SetProperty(unit, "CurHealth", GetObjectHealth(unit)+(MaxHealth-CurHealth))
end
)
I tried that but nothing happened, but when I replaced (MaxHealth-CurHealth) with a number it worked.
That's because you used two variables that had no definition. "MaxHealth" by itself doesn't mean anything; neither does "CurHealth."