Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

sensor question

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-03-2007 13:10
i have been randomly working on a sensor combat system for a wile now, i started it a few months before i came from teen grid and when i got over here i saw terras and CCC combat systems, ive been working on a simaler type of thing, only problem i have right now with the gun im working on, havent got the recivers for the sensors done yet but, i saw on both the combat systems that they will onyl fire to the east side of a prim ( east side of sim when spawned) and im trying to recreate that, i have a type of debuged sensor that i did, fires a particle beam to were the sensor is going,

ok main problem, my sensor fires at anyone that is in range nomater if they are in front or not, but i can still pinpoint peaple in a group when i fire off the sensor threw mouse look

here is my sensor so far

CODE

integer looking;
float distance;
integer forceDist;
key targetKey;

default
{

state_entry() {
llSay(0,"Ready for use.");
llParticleSystem([]);
}



attach(key id) {
if(id != NULL_KEY) {
llRequestPermissions(llGetOwner(),PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
}
else {
llReleaseControls();
llStopAnimation("hold_r_handgun");
}
}

run_time_permissions(integer perm) {
if(perm) {
llStartAnimation("hold_r_handgun");
llTakeControls(CONTROL_ML_LBUTTON,1,0);
string ownerFirst;
ownerFirst = llList2String(llParseString2List(llKey2Name(llGetOwner()),[" "],[]),0);
llSay(0,"Powered up. Ready for use, " + ownerFirst);
}
else {
llSay(0,"Try again..");
llDetachFromAvatar();
}
}

control(key id, integer lev, integer edge) {
if(lev & edge & CONTROL_ML_LBUTTON) {
looking = TRUE;
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_DOWN,1,0);

llSensor("","",AGENT ,100,PI/4);
}
if(~lev & edge & CONTROL_ML_LBUTTON) {
llSensorRemove();
llTakeControls(CONTROL_ML_LBUTTON,1,0);
looking = FALSE;
llMessageLinked(LINK_SET,1,"","");
llMessageLinked(LINK_SET,2,"",targetKey);
llParticleSystem([]);
}
if(lev & edge & CONTROL_DOWN) {
llMessageLinked(LINK_SET,2,"",targetKey);
llTakeControls(CONTROL_ML_LBUTTON,1,0);
}
}
sensor(integer det) {
if(looking) {
llWhisper(0,"Targeted on " + (string)llDetectedName(0));
targetKey = llDetectedKey(0);
llParticleSystem([
PSYS_PART_START_SCALE,<0,0,0>,
PSYS_PART_START_COLOR,<1,0,0>,
PSYS_PART_END_COLOR,<0,0,1>,
PSYS_PART_END_SCALE,<0.5,1,0.5>,
PSYS_SRC_TARGET_KEY,targetKey,
PSYS_SRC_BURST_RATE,0.1,
PSYS_PART_MAX_AGE,2.0,
PSYS_SRC_BURST_PART_COUNT,5,
PSYS_PART_FLAGS,PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_TARGET_POS_MASK | PSYS_PART_EMISSIVE_MASK | PSYS_PART_FOLLOW_SRC_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK

]);
if(forceDist == FALSE) {
distance = llVecDist(llGetPos(),llDetectedPos(0));
}
looking = FALSE;
llMessageLinked(LINK_SET,0,(string)distance,targetKey);
}

}


}
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-04-2007 14:27
here is a better question, would it be posible to send some type of message to a avatar or hud on the avatar, be like damages ect or something to that effect?
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
12-05-2007 02:10
Yes that is entirely possible and is I believe how a lot of the combat sytems work. Allowing you to have damage(health), magic etc attributes that become dpeleted and replenished according to messages recieved.

I think the common way of doing it is an attachment sensor to pick up the collision from bullets and that passes a message to the hud. I don'tt hink you need the HUD but it is very common in the systems I've used. DCS2, COLA etc all use that kind of system. I believe COLA is now open source although that may just be the weapon system as opposed to the HUD.

On the downside I have no idea how to script it :(
_____________________
Tread softly upon the Earth for you walk on my face.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-05-2007 13:10
ya, im trying to do it completly without any objects other then sensors and messages, i came up with a idea today that logicly should work have to test it out,

weapon fires a sensor
sensors sees someone (returns avatars key)
sends a messages out on -(#) channel
weapon Key2Name key recived (weapon detected Mrc Homewood for ex)
llShouts(-(#),"Mrc Homewood hit (weapon type)";)
~llShout would be weapon range
enamy hud listens on -(#) channel
hud recives (Mrc Homewood hit (weapon type))
hud reacts reduces hp and trigers a action

it was something i was thinking of, and the hud will llGetOwner() so i belive if you have it defined it be something like

if(message == Owner += "hit (weapon type)";);

if anyone has any sugestions and if that idea wont work let me know :)