Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Clarification for Sword Script

KeeperS Karu
Registered User
Join date: 18 Oct 2008
Posts: 31
11-14-2008 16:59
Heyla!

I've been playing with a free sword script, basically trying to get to know exactly what makes the sword work the way it does. Now, while I was able to understand most of the code in the script, things got a little fuzzy when I tried to make out exactly what the code is trying to accomplish in the sensor event:

**********************

sensor(integer tnum)
{
vector dir = llDetectedPos(0) - llGetPos();
dir.z = 0.0;
dir = llVecNorm(dir);
rotation rot = llGetRot();
if (strike_type == SWORD)
{
llTriggerSound("crunch", 0.5);
dir += llRot2Up(rot);
dir *= 20.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == PUNCH12)
{
llTriggerSound("crunch", 0.2);
dir += dir;
dir *= 20.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == PUNCHL)
{
llTriggerSound("crunch", 0.2);
dir -= llRot2Left(rot);
dir *= 20.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == KICK)
{
llTriggerSound("crunch", 0.2);
dir += dir;
dir *= 20.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == FLIP)
{
llTriggerSound("crunch", 0.2);
llPushObject(llDetectedKey(0), <0,0,20>, ZERO_VECTOR, FALSE);
}
strike_type= 0;


************************

Now, looking at this, my thoughts are that this section first obtains the location of the detected object in relation to the avatar with the sword. From there, if the attack type used was, say, a SWORD attack type, then a sound effect plays, then... hm... at this point, I'm not quite too sure what's happening. My best guess is that, it makes some caluclations concerning where the avatar is facing in relation to the target, and it uses this information to push the target away from the avatar? Say, if the target is directly in front of the avatar, then the avatar pushes the target in the direction it's facing? Or... if the attack type was a punch, and the target was to the right of the avatar, then the target gets pushed further right?

Am I at least on the right track, or am I way off with this?

Thanks for your help,
Keeper S. Karu
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
11-14-2008 17:10
Yes, its attempting to push the target further away from you in whatever direction they're already in, or atleast thats what I think that math is doing. >.<

Though given that most land owners disable Push, or atleast should, its a mostly useless feature.
KeeperS Karu
Registered User
Join date: 18 Oct 2008
Posts: 31
11-15-2008 08:16
Nice to know I'm beginning to understand this!

As far as landowners disabling push goes, I was under the impression that for those areas that use some sort of combat system, push was needed to calculate whether damage is taken by the target? Or is that already built into whatever combat hud a person is using? For example, I bought a DCS Hud so that my friend and I could see how my sword, with its custom animations, handled in a real duel that dealt health damage. I thought that the way the DCS works is that it detects whether or not the avatar actually managed to push its target, and thus, the DCS decides that a hit was successfully delivered and deducts the proper amount of health points. Is this wrong? Does the DCS already have its own system built in that decides how and when contact is made with the target? Are most combat systems designed the same way?

Thanks for further clarifying my understanding of things,
Keeper S. Karu
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
11-15-2008 19:39
DCS and other Combat Systems communicate with one another by chat commands, with varying degrees of security from system to system.
(Though I'm hearing SpellFire uses Data about Collisions.)

In this instance, the DCS watches for you to input a Left Click + Movement key, then sensors a short range then whispers a command + name or key or some other info about the target. Other units in range check that the target is them, if they are, reads the rest of the command and processes it accordingly.

I don't believe theres any real way to detect pushes, movement yes, but not its cause.
KeeperS Karu
Registered User
Join date: 18 Oct 2008
Posts: 31
11-16-2008 00:02
From: Faust Vollmar
DCS and other Combat Systems communicate with one another by chat commands, with varying degrees of security from system to system.
(Though I'm hearing SpellFire uses Data about Collisions.)

In this instance, the DCS watches for you to input a Left Click + Movement key, then sensors a short range then whispers a command + name or key or some other info about the target. Other units in range check that the target is them, if they are, reads the rest of the command and processes it accordingly.

I don't believe theres any real way to detect pushes, movement yes, but not its cause.


Oh, I see. Thanks for clearing that up!