This is the cog:
[Use code tags!]
I would really appreciate any help.....I looked at quib's example and couldnt figure out how to implement it....
Arden Lyn
Code:
# Weap Concrifle.cog # Trying to make it fire automatically when an enemy comes in # Player Point of View symbols model povModel=conv.3do local model weaponMesh=cong.3do local keyframe mountAnim=ConVmnt.key local keyframe dismountAnim=ConVdis.key local keyframe povfireAnim=ConVpst1.key local keyframe holsterAnim=kyhlstr.key local sound mountSound=df_rif_ready.wav local sound dismountSound=PutWeaponAway01.wav local sound fireSound=concuss5.wav local sound outSound=concuss1.wav local flex fireWait=1.0 local flex powerBoost local flex autoAimFOV=45 local flex autoAimMaxDist=99999999999 local flex holsterWait local int dummy local template projectile=+concbullet local template projectile3=+concblast2 local thing player local int trackID=-1 local int mode local int holsterTrack local int selectMode=1 local message activated message deactivated message selected message deselected message newplayer message autoselect message fire message timer end # ======================================================================================== code fire: // Check that the player is still alive. if(GetThingHealth(player) <= 0) { Return; } // Check Ammo - If we are out, autoselect best weapon. if(GetInv(player, 12) < 8.0) { PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80); if(GetAutoSwitch() & 1) SelectWeapon(player, AutoSelectWeapon(player, 1)); Return; } SetPOVShake('0.0 -.03 0.0', '4.0 0.0 0.0', .05, 80.0); if(mode == 0) { dummy = FireProjectile(player, projectile, fireSound, 18, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist); ChangeInv(player, 12, -8.0); } else { dummy = FireProjectile(player, projectile3, fireSound, 18, '0.0 0.0 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist); ChangeInv(player, 12, -4.0); } jkPlayPOVKey(player, povfireAnim, 1, 0x38); // Provide a kick backwards ApplyForce(player, VectorScale(GetThingLVec(player), -80)); powerBoost = GetInv(player, 63); ChangeFireRate(player, fireWait/powerBoost); SetTimerEx(0.01, dummy, mode, 0.0); Return; # ........................................................................................ activated: player = GetSourceRef(); mode = GetSenderRef(); jkSetWaggle(player, '0.0 0.0 0.0', 0); powerBoost = GetInv(player, 63); ActivateWeapon( player, fireWait/powerBoost, mode ); Return; # ........................................................................................ deactivated: player = GetSourceRef(); mode = GetSenderRef(); jkSetWaggle(player, '10.0 7.0 0.0', 350); DeactivateWeapon( player, mode ); Return; # ........................................................................................ selected: player = GetSourceRef(); // Play external mounting animation PlayMode(player, 41); // Setup the meshes and models. jkSetPOVModel(player, povModel); SetArmedMode(player, 1); jkSetWeaponMesh(player, weaponMesh); jkSetWaggle(player, '10.0 7.0 0.0', 350); // Play mounting sound. PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80); // Play the animation (NOLOOP + UNIQUE + ENDPAUSE). // The animation is held at the last frame after it is played. trackID = jkPlayPOVKey(player, mountAnim, 0, 20); SetMountWait(player, GetKeyLen(mountAnim)); // Clear saber flags, and allow activation of the weapon jkClearFlags(player, 0x5), SetCurWeapon(player, 9); // Check Ammo - If we are out, autoselect best weapon. if(GetInv(player, 12) < 2.0) { if(GetAutoSwitch() != 99) SelectWeapon(player, 1); } Return; # ........................................................................................ deselected: PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80); Return; # ........................................................................................ newplayer: SetMapModeFlags(0xc); SetThingMass(player, 9999999999); Return; # ........................................................................................ autoselect: player = GetSourceRef(); // If the player has the weapon if(GetInv(player, 9) != 0.0) { // If the player has ammo if(GetInv(player, 12) > 7.0) { ReturnEx(1000.0); Return; } else { } } else { } ReturnEx(-1.0); Return; # ........................................................................................ timer: if((GetParam(0) == 1)) { Return; } projectile = GetSenderID(); target = FirstThingInView(player, 45, 50, 0x400); if(target == -1) { Return; } if((GetThingCurGeoMode(target) < 3)) { Return; } if((GetThingFlags(target) & 10)) { Return; } veldif=VectorSub(GetThingVel(projectile), GetThingVel(target)); speed=VectorLen(veldif); distance=VectorDist(GetThingPos(target), GetThingPos(projectile)); time=distance / speed; moved=VectorScale(GetThingVel(target), time); meetpos=VectorAdd(GetThingPos(target), moved); lvec=VectorNorm(VectorSub(meetpos, GetThingPos(projectile))); SetThingLook(projectile, lvec); projspeed=VectorLen(GetThingVel(projectile)); SetThingVel(hacked, VectorScale(lvec, projspeed)); Return; end
[Use code tags!]
I would really appreciate any help.....I looked at quib's example and couldnt figure out how to implement it....
Arden Lyn