Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Bad death "formula"?

Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
09-18-2007 18:14
I have a small problem with my combat HUD, when people die they are supposed to play a certain animation depending on which direction they are shot from. But, sometimes when they die they will automatically revive again, instead of waiting the deathtime, which is 45 seconds. Here's the death part, and the death state.

Here's the section in timer:
CODE

if (health <= 1)
{
llSetText(name + "\nDV Combat System " + version + "\nHealth | DEAD", COLOR, 1);
animation = llGetAnimation(llGetOwner());
llOwnerSay(killer + " killed you.");
llSay(-3467, "dead");
llRegionSay(CHANNELDEATH, avkey);
llRegionSay(CHANNELKILL, killerkey);
state dead;
}


and here's state dead:

CODE

state dead
{
state_entry()
{
if (speed >= 3.5 && llVecMag(detvel) >= 3.5)
{
llMoveToTarget(llGetPos() + <0.0, 0.0, (2.0 - size.z) / 3.5>, 0.05);
if (llRot2Fwd(llGetRot()) * llVecNorm(detvel) <= 0.0)
{
llStartAnimation(fall_anim_back);
llSleep(deathtime);
llStopAnimation(fall_anim_back);
llStopMoveToTarget();
llOwnerSay("You're alive!");
state default;
}
else
{
llStartAnimation(fall_anim_fwd);
llSleep(deathtime);
llStopAnimation(fall_anim_fwd);
llStopMoveToTarget();
llOwnerSay("You're alive!");
state default;
}
}
}
}



any ideas? I am wondering if it has something to the part in timer:
if (health <= 1).

When people do die, they do indeed get killed from either direction like its supposed to. Also, all the information and integers used in the formula on who shot is received during collision.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-18-2007 18:28
The only reason they would immediately revive again is if deathtime was not what you think it is. Try putting a debugging llOwnerSay to print out its value somewhere before the llSleep is called to be *SURE* it is what you think it is.

Otherwise, I have no idea, as it looks correct.
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
09-18-2007 18:30
Yeah, i've checked this lots of time.

integer deathtime = 45;

Forgot to say this: SOMETIMES people revive right away, but most of the time, maybe 80 to 90% of the time it will work correctly.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-18-2007 18:35
Well, try putting llOwnerSays around the llSleeps and see if it is a failing llSleep call
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
09-18-2007 18:41
I tested it, and also people who has told me about the glitches say that when they die, it says "You're dead!" and "You're alive!" instantly, and them the script is reset.

I thought i fixed the problem when I switched the script to llSleep, i used to used Timer() but it bugged out a LOT more.


I had a theory: what if I removed timer all together, and instead had it so every time you get shot is when the HUD will update the text, have all worked out in collision only. Would use less resource since it wont be timing each and every second?
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
09-18-2007 18:45
I had a theory: what if I removed timer all together, and instead had it so every time you get shot is when the HUD will update the text, have all worked out in collision only. Would use less resource since it wont be timing each and every second?
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-19-2007 01:31
The thing is this: there is no known issue with llSleep not sleeping your script the whole time, so I have a feeling that there is something else going on. I have no clue, because I don't have all the facts needed to analyze it, but the little bit you have given does not show a problem that I can see.

Thus, I suggest some serious debugging effort to determine why it is failing. It may be something as bizarre as having another copy of the script in another prim that you somehow missed, and you're actually seeing that old script failing, even though the current one is also working.

In other words, I don't think we have enough info to help you here. :)
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
09-19-2007 02:50
From what I have seen of the code here...

You will want to stop any timer events using llSetTimerEvent(0.0) before switching states as those timer events tend to behave quite unpredictably when switching states.

This may eventually fix this issue.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
09-19-2007 08:47
I can verify that llSleep() works without error (as I have it working without error in my own combat system actually...heh). Squirrel is also right--since llSetTimerEvent() works across states, you'll want to make sure that your timer is set at 0.0 before switching states.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.