OFPEC Forum
Addons & Mods Depot => Arma2 - Configs & Scripting => Topic started by: The_Blink 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?
-
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:
_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:
_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!
-
For tour throwing shovel you could inherit from these probably.
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)
-
ah cool thanks guys! ill get to work ad tell you how it goes :)