Author Topic: [Request] Infinite items  (Read 2867 times)

Here you go.

Have you replaced "Weapon_HEGrenade.cs" with "Weapon_HEGrenadeInf.cs"? Make sure you're not executing the original one at the same time or it won't be infinite.

Now that you have copied the full code, i guess you don't have to use the overwritepackage for OnFire anymore...

Have you replaced "Weapon_HEGrenade.cs" with "Weapon_HEGrenadeInf.cs"? Make sure you're not executing the original one at the same time or it won't be infinite.
I renamed Weapon_HEGrenade.cs" to "Weapon_HEGrenadeInf.cs". Then I replaced this part of the script
Code: [Select]
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);

%currSlot = %obj.lastHESlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}
with this.
Code: [Select]
package HEGrenadeOverwritePackage
{
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
WeaponImage::OnFire(%this, %obj, %slot);
}
};
activatePackage(HEGrenadeOverwritePackage);

I renamed Weapon_HEGrenade.cs" to "Weapon_HEGrenadeInf.cs". Then I replaced this part of the script
Code: [Select]
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);

%currSlot = %obj.lastHESlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}
with this.
Code: [Select]
package HEGrenadeOverwritePackage
{
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
WeaponImage::OnFire(%this, %obj, %slot);
}
};
activatePackage(HEGrenadeOverwritePackage);
If you replaced it, then you don't need to package it.
Packaging is only usefull for overwriting functions (adding alternate actions to functions).

Then would you mind explaining what I need to do then?

Then would you mind explaining what I need to do then?
Only put in the function.
Delete the package thing above and underneath it.
Code: [Select]
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
WeaponImage::OnFire(%this, %obj, %slot);
}

If you renamed it without editing server.cs then it shouldn't be executing at all. Try removing the zip file if you still have it (leaving the files in a folder named Weapon_HEGrenade) and renaming the file back to Weapon_HEGrenade.cs, I think it's detecting the one in the zip file unmodified instead of your version.

This is my current code.
Code: [Select]
function hegrenadeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
serverPlay3D(hegrenadeBounceSound,%obj.getTransform());
}

function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
WeaponImage::OnFire(%this, %obj, %slot);
}

function hegrenadeImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

datablock DecalData(HEGrenadeIcon)
{
   textureName = "Add-Ons/Weapon_HEGrenade/icon_hegrenade";
};
But still:
I charge the grenade, throw it, after 1 second the grenade disappears from my hand, but not from the inventory. As such, I cannot throw the grenade again. I move one inventory slot down for another grenade, still no grenade in my hand. I move down one more and then I have a functional grenade in my hand.
« Last Edit: March 03, 2010, 12:54:28 PM by Demian »


I really want my infinite HE Grenade.

Seriously? Nobody has any idea what's wrong?

Seriously? Nobody has any idea what's wrong?

I bet it's something in the code!

I haven't worked with weapons much, but what is the ::onDone method? It sounds like that unmounts the image when you're done firing or something.

I haven't worked with weapons much, but what is the ::onDone method? It sounds like that unmounts the image when you're done firing or something.
Yes indeed, but my results in deleting that didn't work out as he wants it to.

But maybe, i was doing something wrong.

Just do it Demian, remove that damn line. :D