Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → SetThingLook() on multiple objects of same template.
SetThingLook() on multiple objects of same template.
2001-02-06, 4:39 AM #1
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:

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.
2001-02-06, 9:59 AM #2
Not sure if this'll help, but I'll try.

Have each dummy created in a thing array, done like so in your variables:

thing dummy0 local
thing dummy1 local
thing dummy2 local
thing dummy3 local

Now have a counter count how many projectiles are fired, everytime you fire it out. This will be limited by how many spaces are in your dummy array. Store the dummy like so:

dummycount=dummycount+1;
dummy0[dummycount] = Fireprojectile(blah,blah......

Then use a for loop, and run through each projectile and make it do what you want it to do. Like so:


Code:
(for index=1;index<=dummycount;index=index+1)
{
   DoStuff(Dummy0[index],Stuff);
}


Hope this helps. [http://forums.massassi.net/html/biggrin.gif]

------------------
-Hell Raiser
"I am not defeated so easily!"
Co-staffer of Rbots
-Hell Raiser
2001-02-06, 10:48 AM #3
[http://forums.massassi.net/html/eek.gif] [http://forums.massassi.net/html/confused.gif] Uh huh. Well, that's... uh... great. What's do I do for the dummycount, i.e. what do I call it? Sorry, and thanks for trying to help. Ya' wanna have the .cog and such and do it for me? I haven't achieved mastery of the "for" verb... sorry.

------------------
"Death has many faces, but Time is the most prevalent... All things end... in Time."
2001-02-06, 10:49 AM #4
Or you could copy and paste my .cog into your next post and simply add what you said I need. I'LL TRY ANYTHING!!!

------------------
"Death has many faces, but Time is the most prevalent... All things end... in Time."
2001-02-06, 12:04 PM #5
I seriously doubt you've been COGing for 5 years, seeing as JK was released in October 1997, which means if you began right away, you could have only been COGing for 3 years and 4 months! [http://forums.massassi.net/html/wink.gif]

There's several for/while tutorials - one is available on Hideki's site, and another is available at Code Alliance. They should help [http://forums.massassi.net/html/smile.gif]

-Jipe
2001-02-06, 12:15 PM #6
Didn't Dark Forces have some early form of cog?

------------------
Together we stand.
Divided we fall.
2001-02-06, 1:16 PM #7
Yeah. Su-u-u-u-ure. Pity, because JK was released in...

*/me takes a peek at LEC web-site*

August 1997 where I live, I preordered it, so I recieved it a little before that (God loves me), I played and edited the demo (so I edited it even earlier), and it happens to be 2001. So maybe it's not an EXACT 5 years, perhaps it's just 4 years and 1 month. It's still pathetic, though, that you have to pick your way through helping people just to point out that they read the date of the year instead of counting days... sheesh, go bug someone else or help me like Hell Raiser, or... take a long walk off a short-but-deep cliff... Besides, for some reason (I'll give you ONE guess why) I can't access Millenium, and I was HOPING to get this finished. There, satisfied? And ple-e-ea-a-ase don't be a pain and tell me that it's probably illegal to edit demos, I didn't sell anything, I just want to edit (and your so-called "help" isn't worth anything)! I'll try Code Alliance, but... I've never heard of it. I always use Massassi guides/tutorials (sad, isn't it?) and since I seem to have (start praying) temporarily lost Massassi...
2001-02-06, 2:40 PM #8
No, it's not close to 5 years. August 1997 to August 2000 is 3 years, then add on 5.5 months or so.

And if you notice, I *did* attempt to help you by pointing (if vaguely) towards some websites that would have help, instead of just replying to nitpick.

It irritates me when people claim they've been editing for "so long", which they want to infer that they're "the best".

In fact, I believe my help was fairly useful, as Code Alliance has a tutorial on Arrays, which is the concept Hell Raiser suggested. BTW.. you've never heard of Code Alliance? The guys who made Jed? How long *have* you been around? [http://forums.massassi.net/html/wink.gif]

-Jipe
2001-02-07, 5:10 AM #9
Aw, forget it, your lunacy doesn't have to affect me...

Now, anyone else care to HELP me, like Hell Raiser, not badger me?

[This message has been edited by Mr. Mistoffelees (edited February 07, 2001).]
2001-02-07, 11:59 PM #10
Hello-o-o-o-o?
2001-02-09, 1:23 PM #11
Okay, I think I know how to do that. Now the problem is how to I do that in pulse? Thanks.

[edit] Oh, I know what loop means, Hell raiser, but I need the dummy template to fire in pulse. Thank you again! [/edit]

------------------
"Death has many faces, but Time is the most prevalent... All things end... in Time."

[This message has been edited by Mr. Mistoffelees (edited February 09, 2001).]

↑ Up to the top!