Author Topic: Playertype - crouching abilities  (Read 6594 times)

You can do something like
Code: [Select]
function weaponimage::onFire(%this,%obj,%slot)
{
    if(%this.player.isCrouched)
        return;
    //more code
}

Don't forget the () for isCrouched, also, %this is the weapon datablock, %obj is the player


Wait a minute, Is that a script of a weapon? I don't want a script of a weapon. I need a script of a playertype!
Something that should look like
Code: [Select]
function BlockAlphaPlayertype::onCrouching(%this,%obj,%slot)
{
    if(%this.weaponImage.isfired)
        return;
    //more code
}
Something like that..lol
If you know how to make only the playertype to not use the weapon while he's crouching
I'll thank you alot

Wait a minute, Is that a script of a weapon? I don't want a script of a weapon. I need a script of a playertype!
Something that should look like
Code: [Select]
function BlockAlphaPlayertype::onCrouching(%this,%obj,%slot)
{
    if(%this.weaponImage.isfired)
        return;
    //more code
}
Something like that..lol
If you know how to make only the playertype to not use the weapon while he's crouching
I'll thank you alot
I think the closest you'll be able to get to what you want is making them put away their weapon when they crouch and make them unable to take out a weapon when they're crouching. If you do it any other way then it may not work with some weapons.

You can do something like
Code: [Select]
function weaponimage::onFire(%this,%obj,%slot)
{
    if(%this.player.isCrouched)
        return;
    //more code
}
It doesn't work it's still shooting  :(
Here
Code: [Select]
function weaponimage::onFire(%this,%obj,%slot)
{
    if(%this.player.isCrouched)
        return;
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}

It doesn't work it's still shooting  :(
Here
Code: [Select]
function weaponimage::onFire(%this,%obj,%slot)
{
    if(%this.player.isCrouched)
        return;
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}
Don't forget the () for isCrouched

« Last Edit: October 11, 2014, 05:37:49 PM by BlockAlpha »

Still doesn't work :(
also, %this is the weapon datablock, %obj is the player
The weapon datablock does not have a .player variable.

The weapon datablock does not have a .player variable.
Oh ok

problem solved!
code:
Code: [Select]
function M16Images::onFire1(%this,%obj,%slot)

{
    if(%obj.isCrouched())
        return;
And another problem, I need to know how to let him shoot his projectiles when he come back to stand..because he still can't shoot anything when he is standing with any other weapon (like granade and gunsAkibo.. and even sword, they just don't attack)
Sorry again for my very bad english
« Last Edit: October 11, 2014, 06:08:57 PM by BlockAlpha »

Oh ok

problem solved!
code:
Code: [Select]
function M16Images::onFire1(%this,%obj,%slot)

{
    if(%obj.isCrouched())
        return;
And another problem, I need to know how to let him shoot his projectiles when he come back to stand..because he still can't shoot anything when he is standing with any other weapon (like granade and gunsAkibo.. and even sword, they just don't attack)
Sorry again for my very bad english
Give us your full code.

Give us your full code.
There is no need for full code. I'll explain for you
I add the code which you guys gave me in the weapon "Uzi"
Well in the game when I start playing, no matter if I'm standing or crouching, the projectiles of Uzie didn't shoot, also rocketL and sword and more but in the other side, few weapons still can shoot projectiles, (even if I'm crouching). Then, I add the new code I showed here in those few weapons and it worked for them(I mean, when I'm crouching they don't shoot projectiles, and when they are standing they do) Now I delete the old code in Uzie and those guns(sword, RochetL, GunsAkibo, Uzi, grenades and more)
BUT STILL I can't shoot any projectile or attack even if I'm standing with them.
I'm stuck with a problem that I can't shoot any projectiles with those costume weapons no matter if I antering again and again to the game, although I alredy delete this code you gave me..

There is no need for full code. I'll explain for you
I add the code which you guys gave me in the weapon "Uzi"
Well in the game when I start playing, no matter if I'm standing or crouching, the projectiles of Uzie didn't shoot, also rocketL and sword and more but in the other side, few weapons still can shoot projectiles, (even if I'm crouching). Then, I add the new code I showed here in those few weapons and it worked for them(I mean, when I'm crouching they don't shoot projectiles, and when they are standing they do) Now I delete the old code in Uzie and those guns(sword, RochetL, GunsAkibo, Uzi, grenades and more)
BUT STILL I can't shoot any projectile or attack even if I'm standing with them.
I'm stuck with a problem that I can't shoot any projectiles with those costume weapons no matter if I antering again and again to the game, although I alredy delete this code you gave me..
Thorfin did not intend you to replace weaponImage with the weapon's image. If you just leave it as weaponImage then I believe it should cover just about every weapon with an onFire state. (Or if onFire is only ever called as a callback, then this won't do anything at all)

Now I delete the old code
If it works with the old code, don't delete the old code. And honestly if you place the return BEFORE the parent then it'll do exactly what you want, as it'll check if the player is crouching before attempting to fire the weapon.

If it works with the old code, don't delete the old code.
But it not actually worked properly, it didn't let me shoot projectiles even when I'm standing, and also with other weopons when I'm standing and crouching..
And honestly if you place the return BEFORE the parent then it'll do exactly what you want, as it'll check if the player is crouching before attempting to fire the weapon.
It doesn't work for me properly, like I said before..
Thorfin did not intend you to replace weaponImage with the weapon's image. If you just leave it as weaponImage then I believe it should cover just about every weapon with an onFire state. (Or if onFire is only ever called as a callback, then this won't do anything at all)
Now I get it why it happened with those guns

Well done! thank you guys., it works, but in the other hand, it still do the the sounds and effects of the gun when it fired
Does it possible to do that the gun won't do the effects and sounds when the player is crouching?