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:
Hidden/Spoiler:
[code]// Obiwan
[GameObjectClass]
ClassParent = "com_jedi_default"
GeometryName = "jed_inf_jedi.msh"

[Properties]
AISizeType = "HOVER"

GeometryName = "jed_inf_jedi"
GeometryLowRes = "jed_inf_jedi_low1"
OverrideTexture = "jed_inf_jedi02"

AnimationName = "wampa"
//ClothODF = "rep_inf_ep3obiwan_skirt"

HealthType = "person"
MaxHealth = 200.0
AddHealth = 20.0

MaxSpeed = 8.0
MaxStrafeSpeed = 6.0
MaxTurnSpeed = 5.0
JumpHeight = 3.5
RecoverFromTumble = "1"

NoEnterVehicles = 1

//Jet Jump
JetJump = "10.0" //The initial jump-push given when enabling the jet
JetPush = "0.0" //The constant push given while the jet is enabled (20 is gravity)
JetAcceleration = "10.0" // for characters with jet jump, use this acceleration for in air control
JetEffect = ""
JetFuelRechargeRate = "0.0" //Additional fuel per second (fuel is 0 to 1)
JetFuelCost = "0.0" //Cost per second when hovering (only used for jet-hovers)(fuel is 0 to 1)
JetFuelInitialCost = "0.0" //4initial cost when jet jumping(fuel is 0 to 1)
JetFuelMinBorder = "0.0" //minimum fuel to perform a jet jump(fuel is 0 to 1)
JetShowHud = 0
JetEnergyDrain = 40.0

CollisionScale = "0.0 0.0 0.0" // don't take damage from collisions
//Jet Jump End

WEAPONSECTION = 1
WeaponName1 = "hot_weap_lightsaber_wampa"
WeaponAmmo1 = 0

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"

//SOUND
//SndHeroSelectable = ""
//SndHeroSpawned = "hero_obiWan_spawn"
//SndHeroDefeated = "hero_obiWan_exhausted"
//SndHeroKiller = "hero_obiWan_exhausted"

//VOSound = "hero_obiWan_AcquiredTarget AcquiredTarget"
//VOSound = "hero_obiWan_KillingSpree4 KillingSpree4"

VOUnitType = 0181
//SoldierMusic = "rep_hero_ObiWan_lp"
HurtSound = ""
DeathSound = ""
AcquiredTargetSound = ""
HidingSound = ""
//ApproachingTargetSound = ""
FleeSound = ""
PreparingForDamageSound = ""
HeardEnemySound = ""
ShockFadeOutTime = ""
ShockFadeInTime = ""
ShockFadeOutGain = ""
ShockSound = ""
ClothingRustleSound = ""
//LowHealthSound = "com_inf_saber_ambient"
LowHealthThreshold = "1.1"
FoleyFXClass = "rep_inf_soldier"

[/code]
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. :P

"==" 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 :D

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