Lightning damage
by Howard Dortch · in Torque Game Engine · 07/09/2004 (5:52 am) · 7 replies
I found this subject one day now I can't remember where.
I want my characters to take damage on hit by lightning can anyone point me?
I want my characters to take damage on hit by lightning can anyone point me?
#2
07/15/2004 (8:22 am)
How do I know a lightning event took place? I looked at the c code and dont see a notification like Lightning::onStrike()
#3
07/15/2004 (1:15 pm)
I'd suggest adding the notification, if there isn't a callback happening. Just look at the lightning strike event and see what's up...
#4
I thought I saw one of these threads that had it in script.
How do I find point of impact in script?
07/15/2004 (1:36 pm)
You mean the lightning strike event as in the engine code?I thought I saw one of these threads that had it in script.
How do I find point of impact in script?
#5
Add the two lines under:
datablock LightningData(DefaultStorm){
directDamageType = $DamageType::Lightning; // added
directDamage = 100; // added, player default life is 100
Then add this function below the datablock:
function LightningData::applyDamage(%data, %lightningObj, %targetObject, %position, %normal){
%targetObject.damage(%lightningObj, %position, %data.directDamage, %data.directDamageType);
}
07/16/2004 (2:55 am)
This works for me:Add the two lines under:
datablock LightningData(DefaultStorm){
directDamageType = $DamageType::Lightning; // added
directDamage = 100; // added, player default life is 100
Then add this function below the datablock:
function LightningData::applyDamage(%data, %lightningObj, %targetObject, %position, %normal){
%targetObject.damage(%lightningObj, %position, %data.directDamage, %data.directDamageType);
}
#6
Just when I thought I was starting to understand the scripting this routine tosses me back into the dark ages...sigh
I looked at the applyDamage() function in the lightning.cc source and saw that it was called internally. I can't make the mental connection with how this one gets called in script and can't see how the parameters get loaded.
07/16/2004 (5:30 am)
Sabrecyd, thanks, that works for me too.Just when I thought I was starting to understand the scripting this routine tosses me back into the dark ages...sigh
I looked at the applyDamage() function in the lightning.cc source and saw that it was called internally. I can't make the mental connection with how this one gets called in script and can't see how the parameters get loaded.
#7
Looking for the "Con::executef" line is how I find some script related stuff that might be available but not shown in the demo scripting.
Hope that helps a little.
07/16/2004 (6:16 am)
It's a struggle I know. The part in the lightning.cc code that works with the script is this function:void Lightning::applyDamage( const Point3F& hitPosition,
const Point3F& hitNormal,
SceneObject* hitObject)
{
if (!isClientObject() && hitObject != NULL)
{
char *posArg = Con::getArgBuffer(64);
char *normalArg = Con::getArgBuffer(64);
dSprintf(posArg, 64, "%f %f %f", hitPosition.x, hitPosition.y, hitPosition.z);
dSprintf(normalArg, 64, "%f %f %f", hitNormal.x, hitNormal.y, hitNormal.z);
Con::executef(mDataBlock, 5, "applyDamage",
Con::getIntArg(getId()),
Con::getIntArg(hitObject->getId()),
posArg,
normalArg);
}
}Looking for the "Con::executef" line is how I find some script related stuff that might be available but not shown in the demo scripting.
Hope that helps a little.
Associate Kyle Carter