Author Topic: Constant RadiusImpulse force  (Read 2964 times)

I had another idea to create a Forcefield gun that creates Forcefields that constantly pushes anyone who tries to get into the area of effect out of it. Is there a way to prolongate the effects of impulseForce?

Code: [Select]
   impulseRadius = 5;
   impulseForce = 1000;

This is from the ExplosionData datablock.

I thought of using something like the Wii Remote's function but I don't think that would work out quite right.

Maybe look at the impulser script and make your gun spawn a trigger.

Make it spawn sometghing that continuously causes explosions?

Maybe look at the impulser script and make your gun spawn a trigger.

I don't know what that is, I'm guessing it's got something to do with Functions, which boggle my mind.

No, triggers are pretty simple.

No, triggers are pretty simple.

Oh, well, where could I learn about them?

Hmm, for what your trying to do, try looking at Terrors impulse script, i think it uses triggers.

It does, I think, I see trigger here and there

Code: [Select]
function PulserImage::onFire(%this, %obj, %slot)
{
//messageAll( 'MsgClient', 'pushBroom prefired!!!');
Parent::onFire(%this, %obj, %slot);
%obj.playthread(2, rotCW);
}

function PulserImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
//messageAll( 'MsgClient', 'stopfire');
}

datablock TriggerData(ImpulseTrigger)
{
// tickPeriodMS is a value is used to control how often the console
// onTriggerTick callback is called while there are any objects
// in the trigger. The default value is 100 MS.
tickPeriodMS = 100;
};

function ImpulseTrigger::onTickTrigger(%this)
{
//Do nothing as it spams console :(
}

function ImpulseTrigger::onEnterTrigger(%this, %trigger, %obj)
{
if(%obj.getClassName() $= "WheeledVehicle")
{
if($Pref::Server::Impulse_AllowVehicles == 1)
{
return;
}
}
%impulse = %trigger.brick.impulse;
if(%impulse $= "")
{
schedule(100,0,"KillImpTrig",%trigger);
return;
}
if(!isObject(%trigger.brick)){
schedule(100,0,"KillImpTrig",%trigger);
return;
}
%impulse = %trigger.brick.impulse;
%obj.applyImpulse(0,%impulse);
}

function CreateImpulseTrigger(%brick)
{
if(!isobject(%brick)) return;
%triggerX = %brick.dataBlock.brickSizeX/2 + 0.1;
%triggerY = %brick.dataBlock.brickSizeY/2 + 0.1;
%triggerZ = %brick.dataBlock.brickSizeZ*0.2 + 0.1;

if(%brick.angleid == 2){
%newpos = getWord(%brick.getTransform(),0) + %triggerX/2 SPC getWord(%brick.getTransform(),1) - %triggerY/2 SPC getWord(%brick.getTransform(),2) - (%triggerZ / 2);
%newrot = %brick.rotation;
}
if(%brick.angleid == 0){
%triggerXnew = %triggerX/2;
%triggerYnew = %triggerY/2;
%newpos = getWord(%brick.getTransform(),0) - %triggerXnew SPC getWord(%brick.getTransform(),1) + %triggerYnew SPC getWord(%brick.getTransform(),2) - (%triggerZ / 2);
%newrot = %brick.rotation;
}
if(%brick.angleid == 1){
%triggerYsq = %triggerX/2;
%triggerYsq = %triggerYsq - %triggerYsq*2;
%triggerXsq = %triggerY/2;
%triggerXsq = %triggerXsq - %triggerXsq*2;
%newrot = %brick.rotation;
%newpos = getWord(%brick.getTransform(),0) - %TriggerXsq SPC getWord(%brick.getTransform(),1) - %triggerYsq SPC getWord(%brick.getTransform(),2) - (%triggerZ / 2);
}
if(%brick.angleid == 3){
%triggerXsq = %triggerY/2;
%triggerYsq = %triggerX/2;
%newrot = %brick.rotation;
%newpos = getWord(%brick.getTransform(),0) - %TriggerXsq SPC getWord(%brick.getTransform(),1) - %triggerYsq SPC getWord(%brick.getTransform(),2) - (%triggerZ / 2);
}
%trigger = new Trigger() {
position = %newpos;
rotation = %newrot;
scale = "1 1 1.2";
dataBlock = ImpulseTrigger;
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
};
%brick.trigger = %trigger;
%trigger.brick = %brick;
%trigger.setScale(%triggerX SPC %triggerY SPC %triggerZ);
}

function KillImpTrig(%obj)
{
%obj.delete();
}

function serverCmdSetImpulse(%client,%x,%y,%z)
{
if(%x $= "" || %y $= "" || %z $= "")
{
Messageclient(%client,'',"\c2You did not fill in all the specified values!");
%client.impulse = "";
return;
}
if(%x > 100 || %y > 100 || %z > 100)
{
Messageclient(%client,'',"\c2One or more of your values were too big! (< 100)");
%client.impulse = "";
return;
}
if(%x < -100 || %y < -100 || %z < -100)
{
Messageclient(%client,'',"\c2One or more of your values were too small! (> -100)");
%client.impulse = "";
return;
}
%client.impulse = (%x*100) SPC (%y*100) SPC (%z*100);
Messageclient(%client,'',"\c2You have set your impulse, now use the Pulser to create a impulse!");
}

I have absolutely no idea what any of this means, but from what Terror says it allows the projectile to make a brick Impulse anyone who touches it.

I just need to get a weapon to create an Impulse field when the projectile hits a wall (brick or not) or detonates mid air, and make it last a set amount of time.

Easy done. Remove the if(!isObject(%brick)) return; then make a schedule that deletes the trigger.

Easy done. Remove the if(!isObject(%brick)) return; then make a schedule that deletes the trigger.

Ok, thanks for all help you've given me until now, so I just need to figure out how to make the schedule and I'll be one happy guy  :cookieMonster:

schedule(time,TriggerDelete,0);

function TriggerDelete(%obj){
%obj.delete
}

Put the schedule in any function, best place would be the on collision function. Sorry for typo's im on psp.

Thanks alot for all your help :cookieMonster:

Doesn't work...

There's allot of Brick related stuff in that function, and I don't know where I can change the duration of the impulse, or change the impulse at all.

Is there a way to just create a function to prolongates the basic Impulse Force duration?

Ill help when i get on my comp.

Ok, Pretty simple i just done this quickly for you so if it dont work tell me and ill try and fix for you. Only Admins and Super Admins can put the trigger down.

Quote
function ForceShieldProjectile::onCollision(%this, %obj, %slot){
     if(!%obj.client.isSuperAdmin && !%obj.client.isAdmin)
         return;
         %i = new Trigger() {
            position = %pos;
            rotation = "1 0 0 0";
            scale = "3 24 3";
            dataBlock = LastingImpulse;
            polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
         };
   schedule(time,TriggerDelete,0);
}

datablock TriggerData(LastingImpulse){
   tickPeriodMS = 100;
};

function LastingImpulse::OnEnter(%this, %trigger, %obj){
   %obj.applyImpulse(0,time)
}

function TriggerDelete(%obj){
   %obj.delete();
}

Replace the bold stuff