Home   Help Search Login Register  

Author Topic: shovel spawning objects etc  (Read 1674 times)

0 Members and 1 Guest are viewing this topic.

Offline The_Blink

  • Members
  • *
shovel spawning objects etc
« on: 02 Apr 2010, 15:41:46 »
hey guys

I made a simple shovel tool to have the player throw, but it was suggested i should do the following(as well as throw :P)

when equiped, the shovel will give you an option to spawn a trench or mound of earth like in arma2 objects, the player will then do a animation like healing and spawn the object

I was wondering, is this at all possible as well as throwing it like a grenade, and how would it look in the config?

Offline Loyalguard

  • Former Staff
  • ****
Re: shovel spawning objects etc
« Reply #1 on: 02 Apr 2010, 23:10:55 »
I can't help with the throwing it part (at least not the config part) but it is possible.

For the spawning objects part, here is some partial/untested/pseudocode to consider to get you started looking in the right direction.  Again, this may not be right or the best way, it is a start:

You would need to add an event handler (probably an init EH) to the unit and you should strongly consider using CBA/XEH to make sure you don't conflict with other EHs.  The init EH has a condition that checks to see if the unit has a shovel in its inventory.  To check for this you would use hasWeapon:

Code: [Select]
_this hasWeapon "Shovel"
This assumes you give your shovel a class name of "Shovel"...make your actual name unique, use a tag, and try to have inherit for an existing weapon if at all possible.

If the above condition returns true, start another script that checks in a loop to see if the the unit's current weapon is the shovel (not just in inventory) using currretWeapon:

Code: [Select]
_unit = _this;

while {_unit hasWeapon "Shovel"} do
{
     if ((currentWeapon _unit) == "Shovel") then
     {
          trenchID = _unit addAction ["Dig Trench", "digTrench.sqf"];
          MoundID = _unit addAction ["Make Mound", "makeMound.sqf"];
     }:
sleep .1;
};       

_unit removeAction trenchID;
_unit removeAction MoundID;

Then digTrench.sqf and makeMound.sqf would play the animations and then createVehicle the appropriate objects.

Again, I hope this got you looking in the right direction!  Good luck!

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: shovel spawning objects etc
« Reply #2 on: 04 Apr 2010, 13:57:58 »

 For tour throwing  shovel you could inherit from these probably.

Code: [Select]
class GrenadeHand_stone ;
     class  shovel :GrenadeHand_stone
    {
      hit = 0.5;//set accordingly
      indirectHit = 0.2;
      indirectHitRange = 1; /reduce accordingly
      model = "\ca\Weapons\sutr_grenade";//shovel model and path
      CraterEffects = "NoCrater";
      explosionEffects = "NoExplosion";
      explosive = 0;
     //place shovel hitt sounds here 
soundHit[] = {
        "",
        15.8489,
        1
      };
      cost = 1;
 //create a whistle sound for shovel spinning in air
      whistleDist = 0;
    };

 Sorry for brief description , some idiot decided to invite me to a wedding today :( (its bloody easter sunday for gods sake)
I love ofp

Offline The_Blink

  • Members
  • *
Re: shovel spawning objects etc
« Reply #3 on: 04 Apr 2010, 16:43:27 »
ah cool thanks guys! ill get to work ad tell you how it goes  :)