Author Topic: Sword not shooting projectiles at all  (Read 1612 times)

Okay, so this weapon I've had no problems with whatsoever until recently. It doesn't shoot the projectile and in turn hits nothing. I can make a brick spawn the projectile just fine and it hits just fine but this sword isn't working for whatever reason.

Code: [Select]
datablock ProjectileData(LoZSwordProjectile)
{
   directDamage        = 40;
   directDamageType  = $DamageType::LoZSword;
   radiusDamageType  = $DamageType::LoZSword;
   explosion           = LoZSwordExplosion;
   //particleEmitter     = as;

   muzzleVelocity      = 70;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 200;
   fadeDelay           = 70;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "LV1 Sword Slice";
};

Code: [Select]
projectile = LoZSwordProjectile;
projectileType = Projectile;
-cut-
stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "Charge";
stateTimeoutValue[3]            = 0.125;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
stateSound[3] = LoZSwordSlashSound;
stateSequence[3]                = "attack";
//stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;
Looks fine to me, but... what do I know?
« Last Edit: June 15, 2011, 03:37:00 PM by YoshiDude »

  • What's the default onFire script? I'd rather copy that than create a new image for this thing I'm working on.

I have been wondering that too. Have you tried tracing a couple of items to see?

I have been wondering that too. Have you tried tracing a couple of items to see?

Yes. The default Sword doesn't have it. Haven't checked the Gun yet.

Nothing in the Gun having to do with onFire, except the recoil animation.
It's probably not in any of the weapons, considering I have them all disabled except for what I'm testing.

Wow. Is it just me or do my topics never get replies?

I feel so badly ignored. None of these four questions have been answered yet.

  • Is there a way to check if a player has an image mounted? If so, is there a way to tell what it is?

(coming from a client:)
Code: [Select]
if(!%client.player.getMountedImage(0) $="0") and to tell what it is would be
Code: [Select]
%wep = %client.player.getMountedImage(0).getName();
  • Is there a way to toggle being able to jump/swim without changing the datablock?
I do not believe so.

  • What's the opposite of onEnterLiquid?
function whatever::onLeaveLiquid(%this,%obj,%type)

found that one through a search lol

the rest I'm very very unsure about or in other words can't help you on.
« Last Edit: June 13, 2011, 08:13:24 AM by Placid »

(coming from a client:)
Code: [Select]
if(!%client.player.getMountedImage(0) $="0") and to tell what it is would be
Code: [Select]
%wep = %client.player.getMountedImage(0).getName();I do not believe so.
function whatever::onLeaveLiquid(%this,%obj,%type)

found that one through a search lol

the rest I'm very very unsure about or in other words can't help you on.

Thank you very much.
About the toggling jumping/swimming, my idea would be since these are going to be toggled with items, I could just use velocity for the jumping, and then the swimming bit I could use to instant respawn whoever enters water without that item.

Thank you very much.
About the toggling jumping/swimming, my idea would be since these are going to be toggled with items, I could just use velocity for the jumping, and then the swimming bit I could use to instant respawn whoever enters water without that item.
do you have to use the item to go in the water or just have it? if it's using it, just use onFire to set a datablock if a variable is not true, i.e.
Code: [Select]
function lolImage::onFire(%this,%obj,%slot) {
   %client = %obj.player
   if(%client.enterWater) {
      %client.enterWater = 0;
      %client.setDatablock("PlayerStandardArmor");
   }
   else {
      %client.enterWater = 1;
      %client.setDatablock("NoJumpArmor");
   }
   Parent::onFire(%this,%obj,%slot);
}

or something like that. but that's just my idea.

do you have to use the item to go in the water or just have it?

It just has to be equipped, that's all.

EDIT: Whoops, wrong topic.

In the script that creates a new player datablock, inside of an entering water trigger:
Code: [Select]
if(%obj.getMountedImage(0) $="0")
{
%wep = %obj.getMountedImage(0).getName();
echo(%wep); //if(%obj.getMountedImage(0)==LoZFlippersImage)
if(%wep $= "Flippers")
{
%obj.changeDatablock(PlayerLinkWater);
}
else
{
%obj.kill();
}
}
else
{
%obj.kill();
}

The item is named the exact same, and is equipped, but it always kills me.

Ooh, i forgeted up. it's not getMountedObject, it's getMountedImage.

..getmountedobject is for vehicles, silly me. sorry about that.

and .getname() should work on that, too.

Locking to (hopefully) avoid crossposting, as I believe this belongs in General Modification Help. Not sure how else to move it.

EDIT: Never mind, the questions that need answered are more appropriate here.

Bump. I've been waiting 5 days for an answer...

Why have you commented out stateScript[3] = "onFire"; - it needs that to work. Even if you're not making a custom onFire function you'll need a state with that so it uses the default WeaponImage::onFire function.

The problem could also be with the rest of your states if it's still not working after that.

For the second post, the default WeaponImage::onFire function goes something like this: (from the TGE weapon example and a bit for scaled-up projectiles)
Code: [Select]
function WeaponImage::onFire(%this,%obj,%slot)
{
%projectile = %this.projectile;

if(%this.melee)
%initPos = %obj.getEyeTransform();
else
%initPos = %obj.getMuzzlePoint(%slot);

%muzzleVector = %obj.getMuzzleVector(%slot);
%scale = getWord(%obj.getScale(),2);
%vector1 = VectorScale(%muzzleVector, %projectile.muzzleVelocity * %scale);

%objectVelocity = %obj.getVelocity();
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);

%muzzleVelocity = VectorAdd(%vector1, %vector2);

%p = new (%this.projectileType)()
{
dataBlock        = %projectile;
initialVelocity  = %muzzleVelocity;
initialPosition  = %initPos;
originPoint      = %initPos; //it's in the Tank, not sure if needed
sourceObject     = %obj;
sourceSlot       = %slot;
client           = %obj.client;
};

if(isObject(%p))
{
%p.setScale(%scale SPC %scale SPC %scale);
MissionCleanup.add(%p);
return %p;
}

return -1;
}
It's not exact but should work in the same way for however you need to edit it.
« Last Edit: June 18, 2011, 03:16:39 AM by Space Guy »