Small Code Example

The following code, will launch the named object [K] Nova at the avatar owning the object using the low theta angle and with a velocity that is half of the current region FPS. The calibration of the speed to the region FPS is meant to avoid the projectile going through the target.

This script was tested and works on OpenSim version 0.7.4!

artillery_fire_at_toucher.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
fireNova(key targetKey) {
    float initialVelocity = llGetRegionFPS()/2.0;
    vector target = llList2Vector(llGetObjectDetails(targetKey, [OBJECT_POS]), 0);
    vector origin = llGetPos();
    float distanceDelta=llVecDist(<target.x,target.y,0>,<origin.x,origin.y,0>);
    float valSin = 9.81*distanceDelta/llPow(initialVelocity, 2);
    if(valSin < -1 || valSin > 1) return;
    rotation rotationDelta = llRotBetween(<1,0,0>,llVecNorm(<target.x-origin.x,target.y-origin.y, distanceDelta*llTan((RAD_TO_DEG*llAsin(valSin)/2) * DEG_TO_RAD) + target.z-origin.z>));
    llRezObject("[K] Nova", llGetLocalPos(), llVecNorm(<1,0,0>*rotationDelta)*initialVelocity, rotationDelta, 0);
}
 
default {
    touch_start(integer num) {
        fireNova(llGetOwner());
    }
}

secondlife/artillery/fire_at_toucher.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.