Jump to content

Why does llRegionSay() from a bullet fail to send?


You are about to reply to a thread that has been inactive for 4706 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Can someone tell me why the llRegionSay() in this script is not transmitting anything?  I've put debug statements in it and have verified 100% that its being called when it impacts an avatar.  An llOwnerSay() call right one line above it dumps the msg out just fine, but the llRegionSay() sends nothing.  llSay() also fails to transmit.  I tried delaying the bullet a few seconds before it deletes itself to see if its a timing thing.  The call still failed to transmit.

 

integer WEAPON_CHANNEL = -12020423;
integer timerTicks     = 0;
float LIFETIME = 5.0;
float BASEVELOCITY = 50;

init() {
	//Preset the needed settings.
	llSetBuoyancy(1.0);
	llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE, PRIM_PHYSICS, TRUE]);
	llSetStatus(STATUS_DIE_AT_EDGE, TRUE);
	llCollisionSound("", 0.0);
}

remove() {
	//Remove the bullet.
	llSetStatus(STATUS_PHYSICS, FALSE);
	llSetAlpha(0.0, ALL_SIDES);
	llDie();
}

setVelocity(float velocity) {
	//Applies the correct impulse to the bullet
	vector vect = ((<velocity,0,0> - llGetVel() / llGetRot()) * llGetMass());
	llApplyImpulse(vect,TRUE);
}

default {
	state_entry() {
		init();
	}

	on_rez(integer start_param) {
		//The bullet has been fired.
		//Sets the bullet in motion at the correct velocity in meters per second.
		setVelocity( (((float)start_param / 100) * BASEVELOCITY) );
		llSetTimerEvent(LIFETIME);
	}

	collision_start(integer total_number) {
		key avatarKey = llDetectedKey(0);
		key ownerKey = llGetOwner();
		if (avatarKey != ownerKey) {
			string msg = "BulletImpact, " + (string) avatarKey;
			llRegionSay(WEAPON_CHANNEL, msg);
			remove();
		}
	}

	land_collision_start(vector pos) {
		remove();
	}

	timer() {
		remove();
	}
}

 

 

 

 

Link to comment
Share on other sites

I assume that you're actually listening for the message on channel -12020423 with another script somewhere, right?  You can always hear llOwnerSay in your own chat, but only a scripted object can hear llRegionSay or llSay on a negative channel. 

Incidentally, if your bullet is moving fast enough it can pass entirely through a target before the servers register a collision.  That's not normally much of a problem, but it can lead to confusion if you are using a bullet as a range finder, or if you have two potential targets in the line of flight (like one av standing in front of another). . 

Link to comment
Share on other sites

there's a multitude of problems you might encounter with that script...

temp rez objects retain a countdown when taken... if you rez the bullet and drop the script in, it starts counting down immediately, so you need to take it to inventory immediately. also items that are temp when rezzed can get queued.

velocity can and probably should be set by the bullet rezzor ('m assing some sort of gun) if such is used, and you must be sure to set it's proper rotation. if not, llSetForce is probably preferable to llApplyImpulse, and you'll need to rework it so that it sets a correct rotation (else it will always fire in the same direction)

die at edge is always true when rezzed by script, so probably unneeded

the timer is probably overkill, max lifetime firing straight up from the ground is 60 sec (temp on rez limit)

MONO rezzed script hay be subject to queuing so use LSO

functions slow down the time to insert a script, so if you need high response times, it's actually better to insert all function code into the events, same for global variables.

 

none of those would cause the problem you are seeing though.... the only two ways I can see that you'd fail to get the region say but get an ownersay on the line before are if the object is no longer in your region (crossed into another) or your listening script is not set up to receive the message properly (wrong channel or filtered incorrectly)

 

 

 

Link to comment
Share on other sites

I'm using a Novatech channel scanner to watch for the message as well as have my listening script nearby in an object.  So I'm certain its not transmitting the message.  I've coding things with messages quite a few times before.  What's unique this time is that the object is a bullet in motion.  

Pretty sure that is not a hitting the end of the region problem since it never transmits and I've seen the bullet bounce off my crash dummy, lose all its motion, and then expire.

Seeing the same behavior when its set to Mono or LSO.

Link to comment
Share on other sites

skip the novatech scanner and just use a simple listen script such as...

integer WEAPON_CHANNEL = -12020423;default{    state_entry(){        llListen( WEAPON_CHANNEL, "", "", "" );    }        listen( integer vIntChn, string vStrNom, key vKeySrc, string vStrMsg ){        llOwnerSay( vStrNom + " said:\n" + vStrMsg );    }}

 

  • Like 1
Link to comment
Share on other sites

What happens if you take out the remove() fuction from the two collision events and let the timer remove the bullet?  I know you say you've tried delaying it a few seconds, but I suspect that's where the problem might be.   I've certainly had issues in the past with scripts not managing to complete their tasks before  deleting the object that contains them.   If you hear the message then, at least you know that's where the trouble stems from.

If if works then, setting it to non-physics as soon as it strikes the target, before it does anything else.   I'm just wondering if, after hitting the target, it falls to the floor and calls remove() before it gets a chance to say anything.

Link to comment
Share on other sites

Sure enough, that was the problem.  Thanks for the advice! 


Innula Zenovka wrote:

What happens if you take out the remove() fuction from the two collision events and let the timer remove the bullet?  I know you say you've tried delaying it a few seconds, but I suspect that's where the problem might be.   I've certainly had issues in the past with scripts not managing to complete their tasks before  deleting the object that contains them.   If you hear the message then, at least you know that's where the trouble stems from.

If if works then, setting it to non-physics as soon as it strikes the target, before it does anything else.   I'm just wondering if, after hitting the target, it falls to the floor and calls remove() before it gets a chance to say anything.

 

Link to comment
Share on other sites

that's very odd then, since the message code should trigger first.

the only way that should happen is something was trying to process a callback function on the key within the listen and dropping it as failed because the callback failed since the item got remove by the die command... but the actual message should still have been sent, and it's base properties (name key and message) should all still be valid.

that's why I suggested the simple listen... because callbacks like llGetOjectDetails will return null results for removed items. if the region itself is performing a callback for messages, that's a bug.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4706 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...