Okay, so maybe I should know this already, since I have been programming COG for 5 years, but here is the problem (I'll post the entire .cog if you need it): I am making a zipline for JK! It works perfectly, except for one thing, but perhaps I need to explain how it [is supposed to] work(s) first.
It works like the BowCaster, somewhat. When you hit fire 1, you hold it down. As soon as you touch it, you drop an anchor. As soon as you let up you fire the line template. Here is where it gets tricky:
1. You can only have 1 anchor out at a time, but you can fire multiple line templates.
2. The line templates, when fired, are supposed to turn around, and look at the anchor, then fire a line which connects the 2. The only thing, though, is that I can only get 1 at a time to look at the anchor and fire the rope template. Ah well, here is the cog:
Now, I know that every time a "dummy" is created and specified as such, the cog starts to focus on that ONE line template and ignore the others already created, and I need to know how to get it to make all created "dummy's" to look at the anchor and fire the proj3 template. Please help.
It works like the BowCaster, somewhat. When you hit fire 1, you hold it down. As soon as you touch it, you drop an anchor. As soon as you let up you fire the line template. Here is where it gets tricky:
1. You can only have 1 anchor out at a time, but you can fire multiple line templates.
2. The line templates, when fired, are supposed to turn around, and look at the anchor, then fire a line which connects the 2. The only thing, though, is that I can only get 1 at a time to look at the anchor and fire the rope template. Ah well, here is the cog:
Code:
symbols model povModel=BowV.3do local model weaponMesh=BowG.3do local keyframe mountAnim=BowVmnt.key local keyframe dismountAnim=BowVdis.key local keyframe povfireAnim=BowVpst1.key local keyframe holsterAnim=kyhlstr.key local sound mountSound=df_bry_ready.wav local sound dismountSound=PutWeaponAway01.wav local sound fireSound1=BCFire01.wav local sound fireSound2=BCFire02.wav local sound outSound=trprout.wav local template proj1=+anchor local template proj2=+zipline local template proj3=+trueline local flex fireWait=.01 local flex delayTime local flex autoAimFOV=30 local flex autoAimMaxDist=10 local flex powerBoost local flex holsterWait local thing dork local thing player local int trackID=-1 local int holsterTrack local int dowefire=0 local int dummy=-1 local message startup message created message activated message deactivated message selected message deselected message pulse message autoselect message fire message killed message timer end code startup: player = GetLocalPlayerThing(); SetPulse(.01); Return; activated: mode = GetSenderRef(); jkSetWaggle(player, '0 0 0', 0); if(GetInv(player, 12) < 0) { if((GetAutoSwitch() & 1)) SelectWeapon(player, AutoSelectWeapon(player, 1)); else PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80); Return; } if(mode == 0) { ActivateWeapon(player, 0, mode); if(dowefire == 0) { dork = FireProjectile(player, proj1, fireSound2, 18, '.0207 .0888 0', '0 0 0', 1, 0x20, autoAimFOV, autoAimFOV*2); dowefire = 1; } } else { powerBoost = GetInv(player, 63); ActivateWeapon( player, fireWait/powerBoost, mode); } Return; fire: if(GetThingHealth(player) <= 0) Return; if(GetInv(player, 12) < 0) { SelectWeapon(player, AutoSelectWeapon(player, 1)); Return; } SetInvActivated(player, 133, 1); SetTimerEx(.1, 1, 0, 0); dowefire = 0; Return; deactivated: mode = GetSenderRef(); jkSetWaggle(player, '10 7 0', 350); if(mode == 0) { delayTime = DeactivateWeapon(player, mode); SetMountWait(player, fireWait/powerBoost); if (GetCurWeaponMode() != -1) Return; if(GetInv(player, 12) < 0) Return; SetPOVShake('0 -.01 0', '2 0 0', .05, 80); SetInv(player, 134, 1); ChangeInv(player, 12, 0); if(delayTime > 0) { if(GetInv(player, 12) > 0) { dummy = FireProjectile(player, proj2, fireSound2, 18, '.0207 .0888 0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2); SetInv(player, 134, 1); ChangeInv(player, 12, 0); } } // Play animation and set delay. jkPlayPOVKey(player, povfireAnim, 1, 0x38); powerBoost = GetInv(player, 63); } else { DeactivateWeapon(player, mode); } Return; selected: SetInv(player, 134, 0); PlayMode(player, 41); jkSetPOVModel(player, povModel); SetArmedMode(player, 1); jkSetWeaponMesh(player, weaponMesh); jkSetWaggle(player, '10 7 0', 350); PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80); trackID = jkPlayPOVKey(player, mountAnim, 0, 20); SetMountWait(player, GetKeyLen(mountAnim)); jkClearFlags(player, 0x5); SetCurWeapon(player, 5); if(GetInv(player, 12) < 0) { if((GetAutoSwitch() & 1)) SelectWeapon(player, AutoSelectWeapon(player, 1)); } Return; deselected: PlaySoundThing(dismountSound, player, 1, -1, -1, 0x80); jkPlayPOVKey(player, dismountAnim, 0, 18); holsterWait = GetKeyLen(holsterAnim); SetMountWait(player, holsterWait); holsterTrack = PlayKey(player, holsterAnim, 1, 0x4); SetTimerEx(holsterWait, 2, 0, 0); if (trackID != -1) { jkStopPOVKey(player, trackID, 0); trackID = -1; } jkSetWaggle(player, '0 0 0', 0); Return; pulse: if(GetInv(player, 134) == 1) SetThingLook(dummy, VectorSub(GetThingPos(dork), GetThingPos(dummy))); FireProjectile(dummy, proj3, -1, 8, '0 0 0', '0 0 0', 1, 0x0, 0, 0); Return; autoselect: // If the player has the weapon if(GetInv(player, 5) != 0) { // If the player has ammo if(GetInv(player, 12) > 1) { ReturnEx(700); } else { ReturnEx(-1.0); } } else { ReturnEx(-1.0); } Return; timer: StopKey(player, holsterTrack, 0.0); if(GetSenderID() == 1) SetInvActivated(player, 133, 0); Return; end
Now, I know that every time a "dummy" is created and specified as such, the cog starts to focus on that ONE line template and ignore the others already created, and I need to know how to get it to make all created "dummy's" to look at the anchor and fire the proj3 template. Please help.