Page 1 of 1
Lua and Effects
Posted: Sun Mar 15, 2009 3:58 pm
by Fiodis
Two unrelated questions:
I tried attaching two effects to a unit via ODF.
The ODF:
The Error message:
Code: Select all
Message Severity: 2
.\Memory\RedMemory.cpp(634)
Allocating 448 bytes attempt failed - no free blocks left in Heap 5 (Runtime)
Message Severity: 3
.\Memory\RedMemory.cpp(538)
Allocating 448 bytes failed - no free blocks left in Heap 5 (Runtime)
And the second problem. I tried setting up a LUA "Life Steal" weapon that, when you
kill someone with it, you get a
health boost. Problem is, it doesn't work. The code:
Code: Select all
forcelifesteal = OnObjectKill (
function (object, killer)
if GetObjectLastHitWeaponClass(object) == "com_weap_inf_force_lightning" then
SetProperty(killer, "CurHealth", 1e+40)
end
end
)
Being a novice scripter, I'm certain something's wrong, but what?
Also, could I use OnEntityDamage if I wanted to create a "Force Drain" type thing?
Re: Lua and Effects
Posted: Thu Apr 02, 2009 7:41 pm
by swingking
As I have seen multiple times, this may be your problem:
forcelifesteal = OnObjectKill (
function (object, killer)
if GetObjectLastHitWeaponClass(object) == "com_weap_inf_force_lightning" then
SetProperty(killer, "CurHealth", 1e+40)
end
end
)
I could be wrong (and if I am, please tell me), but I think you have too many " = "s.
Re: Lua and Effects
Posted: Thu Apr 02, 2009 7:47 pm
by Maveritchell
swingking wrote:As I have seen multiple times, this may be your problem:
forcelifesteal = OnObjectKill (
function (object, killer)
if GetObjectLastHitWeaponClass(object) == "com_weap_inf_force_lightning" then
SetProperty(killer, "CurHealth", 1e+40)
end
end
)
I could be wrong (and if I am, please tell me), but I think you have too many " = "s.
Yes, you are wrong, you need to stop posting that because I had to edit your post so that it was correct the last time you posted it.
"==" tests for an equality (like if you're asking "is x == 5?") "=" sets a variable (like if you're defining x; "x = 5").
And to the OP, the reason you're having problems with this is that it should look like this:
Code: Select all
SetProperty(GetCharacterUnit(killer), property, variable)
Also you will find that you have problems setting the CurHealth that high without raising the maxhealth first. You will need to either use a timer and use "addhealth" or you will need to check the unit's
health, check his maxhealth, and add an amount that doesn't make his curhealth go above his maxhealth. The first option may be easier but it may be buggier if you have to run multiple timers for multiple units doing this at once.
Also switch your DamageStartPercent and DamageStopPercent values around.
Re: Lua and Effects
Posted: Thu Apr 02, 2009 8:35 pm
by Fiodis
Thanks for the LUA help, but I got that solved on my own without having to check for maxhealth or setup a timer or anything.
I'll try out the start and stop switch.
Re: Lua and Effects
Posted: Thu Apr 02, 2009 8:50 pm
by FragMe!
As well with these:
DamageStartPercent = 100.0
DamageStopPercent = 0.0
DamageEffect = "zombie_claw_trail"
DamageAttachPoint = "hp_fire_lightsabre bone_r_hand"
DamageStartPercent = 100.0
DamageStopPercent = 0.0
DamageEffect = "zombie_claw_trail"
DamageAttachPoint = "hp_fire_lightsabre bone_l_hand"
could be like this:
DamageAttachPoint = "bone_r_hand"
and
DamageAttachPoint = "bone_l_hand"
what you had doesn't exist unless of course you edited the msh file

Re: Lua and Effects
Posted: Thu Apr 02, 2009 9:06 pm
by Fiodis
Hmmm.... Fragme, with your method would the effect remain after the unit dies?
And doesn't the "red" mean I've hit some sort of hard-coded limit?
Re: Lua and Effects
Posted: Thu Apr 02, 2009 11:03 pm
by FragMe!
I was just actually point out what the attachpoints should be, but by using a damage effect it does go away when a unit dies. What Mav was pointing out is you want the effect to be there starting when there is no damge 0 to full damage (death) 100