Author Topic: [solved] function keeps repeating itself  (Read 2337 times)

i have these two steam emitters and whenever i look toward the ground, they shoot forward instead of outward

how its supposed to look



how it looks when i look down


Code: [Select]
datablock ParticleData(bfgSteamParticle)
{
dragCoefficient      = 0;
gravityCoefficient   = -1.0;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 50;
lifetimeVarianceMS   = 10;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0.7 0.7 0.7 1";
colors[1]     = "0.5 0.5 0.5 0.6";
colors[2]     = "0.5 .5 0.5 0";
sizes[0]      = 0.3;
sizes[1]      = 0.15;
sizes[2]      = 0.05;
times[0] = 0.0;
times[1] = 0.2;
times[2] = 0.4;
windCoefficient = 0.0;
useInvAlpha = false;
};

datablock ParticleEmitterData(bfgSteamEmitter)
{
ejectionPeriodMS = 4;
periodVarianceMS = 1;
ejectionVelocity = 20.0;
velocityVariance = 1.0;
ejectionOffset   = 0;
thetaMin         = 0;
thetaMax         = 0;
phiReferenceVel  = 0;
phiVariance      = 0;
overrideAdvance = false;
particles = "bfgSteamParticle";
uiName = "bfgSteam";
};



also, this is a chargeup weapon that has a 3 second cooldown after its fired. you can basically dequip and reequip the weapon to instantly charge it up again. minShottime doesnt work since (i'm guessing) it only prevents the onfire function from happening. is there any way i can get around this?


giving up on first part and found a solution to second part. new problem look below
« Last Edit: September 21, 2016, 04:19:02 PM by Trogtor »

For reference of anyone else reading this, I had a similar issue when trying to make a jetpack (unsolved)
https://forum.blockland.us/index.php?topic=287584.msg8680255#msg8680255

When the player looks towards the ground, the particles seem to change direction to where the eye vector intersects with the ground.


also, this is a chargeup weapon that has a 3 second cooldown after its fired. you can basically dequip and reequip the weapon to instantly charge it up again. minShottime doesnt work since (i'm guessing) it only prevents the onfire function from happening. is there any way i can get around this?
kyuande posted this a week or so ago so maybe it will be useful? hm

If you do create a special onFire function make sure you create timeouts using getSimTime() (or something like that) and then subtract the time based on how long you want it to be. (Prevents people from doing rapid fire switching)

Example:
function ShotgunImage::onFire(%image, %obj, %slot)
{
   if(getSimTime() - %obj.lastFire[%image] < 3000) //less than 3 seconds
      return; //Prevent them from firing

   %obj.lastFire[%image] = getSimTime();
   //Spreadshell code
}

and if that doesn't help find an add-on that does work and look inside it like the Ballistic Gauss Cannon i think

This is probabaly something in the engine because the sandman's dizzy image flips the angle when the player is looking down
I've created fire images before, they'll stick up correctly until I look down

Give us all the code.
http://hastebin.com/tujegaveli.java

kyuande posted this a week or so ago so maybe it will be useful? hm
and if that doesn't help find an add-on that does work and look inside it like the Ballistic Gauss Cannon i think
i need for the player to prevent initiating charge-up when they re-equip it right after fire. that looks like it only effects onfire

let me test this out first actually i have no idea what im talking about
« Last Edit: September 18, 2016, 04:06:18 PM by Trogtor »

i need for the player to prevent initiating charge-up when they re-equip it right after fire. that looks like it only effects onfire
yeah ok i was right about this. it didnt work

Hey is that our BFG that eclipse made


I've managed to get a working script that prevents re-equipping instant charge up

i have a problem though, but before i get to it i guess i need to explain what the code is for

if you re-equip the item during cooldown, it gives you a separate item with no charge up or firing state, just a cooldown state. once cooldown is complete, it switches back to the regular bfg ready to fire.

it all works, my only problem is that whenever you re equip it, the function that checks if the item is in cooldown keeps looping itself (line 191) causing the cooldown bfg item to keep re equipping itself

http://hastebin.com/eholonewex.php
check line 191
« Last Edit: September 21, 2016, 12:09:49 AM by Trogtor »

Line 183.
Code: [Select]
stateTimeoutValue[1]            = %client.bfgRecharge();
You can't do that.

didn't know that and i understand completely what's happening now.

ill probably make a schedule instead

so after removing the timeout and the 3rd state (or state 2) completely, i made it work on a schedule instead but its just doing the same thing except extremely fast

also getting this error



Code: [Select]
function bfgImage::OnEquip(%this,%obj,%slot,%client)
{
if(getSimTime() - %obj.lastFire[%image] < 3000)
{
%obj.mountImage(bfgCooldwnImage,0);
%client.bfgRecharge = (getSimTime() + 3000) - (getsimtime() + (getSimTime() - %obj.lastFire[%image])) | 0;
%obj.schedule(%client.bfgRecharge(), mountImage, bfgImage, 0);
}
}

function bfgCooldwnImage::OnUnMount(%this,%obj,%slot,%client)
{
parent::OnUnMount(%this,%obj,%slot);
cancel(%obj.schedule(%client.bfgRecharge(), mountImage, bfgImage, 0));
}

Is your bfgrecharge function header "gameconnection::bfgrecharge"? If not try bfgrecharge(%client) instead of %client.bfgrecharge()

Also for an easier fix you might try looking at how kaje's sniper prevents the player from insta-firing.

Is your bfgrecharge function header "gameconnection::bfgrecharge"? If not try bfgrecharge(%client) instead of %client.bfgrecharge()

Also for an easier fix you might try looking at how kaje's sniper prevents the player from insta-firing.
kajes sniper just uses the default minShottime which only has a cooldown on the onFire function. this wont work in my case since im trying to prevent the player from charging up the weapon completely