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 → Teleporting people to eachothers location
Teleporting people to eachothers location
2002-01-03, 6:48 PM #1
I have been working on this cog for a while and I still can't seem to get it right. As of right now it only teleports the player to the victims location.

Code:
# Instantly transports victim to your location and
# transports you to their location

symbols

thing        player                             local                         
thing        victim                             local                         
thing        potential                          local                         
int          tele=-1                            local                         

flex         mana                               local                         
flex         cost=50.0                          local                         
int          rank                               local                         
int          count                              local                         
int          retval=0                           local                         

flex         dot                                local                         
flex         maxDot                             local                         

sound        blindingSound=score2.wav           local                         
template     obj=+bryar                         local                         

int          active=0                           local                         

message      startup                                                          
message      activated                                                        
message      deactivated                                                      
message      pulse                                                            
message      newplayer                                                        
message      killed                                                           
message      deselected                                                       
message      selected                                                         

end                                                                           

# ========================================================================================

code

startup:
   player = GetlocalPlayerThing();

   Return;

# ........................................................................................

activated:
   if(active) Return;

   mana = GetInv(player, 14);
   rank = GetInv(player, 27);
   cost = 100/rank;

   if(mana >= cost)
   {
      victim = -1;
      active = 1;
      SetInvActivated(player, 27, 1);
      SetPulse(0.33);
   }

   Return;

# ........................................................................................

pulse:
   // Check all things for our victim.
   victim = -1;
   maxDot = 0;

   // Search for all players and actors.
   potential = FirstThingInView(player, 30 + 15 * rank, 8, 0x404);
   while(potential != -1)
   {
      if(
         HasLOS(player, potential) &&
         (potential != player) &&
         (VectorDist(GetThingPos(player), GetThingPos(potential)) <= (2 + rank)) &&
         !(GetThingFlags(potential) & 0x200) &&
         !(GetActorFlags(potential) & 0x100) &&
         !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23))
        )
      {
         dot = ThingViewDot(player, potential);
         if(dot > maxDot)
         {
            victim = potential;
            maxDot = dot;
         }
      }
      potential = NextThingInView();
   }

   // If we have a victim...
   if(victim != -1)
   {
      jkSetTargetColors(1, 2, 3);
      jkSetTarget(victim);
   }
   else
   {
      jkEndTarget();
   }

   Return;

# ........................................................................................

deactivated:
   if((victim == -1) || (GetThingHealth(player) <= 0))
   {
      call stop_power;
      Return;
   }

   SetPulse(0);
   jkEndTarget();

   mana = GetInv(player, 14);
   if(mana >= cost)
   {
      if(GetInv(player, 65) != 1) ChangeInv(player, 14, -cost);
      SetBinWait(player, 27, 0.2);

      if(HasLOS(player, victim) && (victim != player))
      {
         PlayMode(player, 24);
         PlaySoundThing(blindingSound, player, 1.0, -1, -1, 0x80);

         tele = CreateThing(obj, GetThingPos(player));
         TeleportThing(player,victim);
         TeleportThing(victim,tele);
         DestroyThing(obj);
      }
   }

   active = 0;
   SetInvActivated(player, 27, 0);

   Return;

# ........................................................................................

selected:
   jkPrintUNIString(player, 27);
   Return;

# ........................................................................................

deselected:
   call stop_power;

   Return;

# ........................................................................................

killed:
   if(GetSenderRef() != player) Return;

newplayer:
   call stop_power;

   Return;

# ........................................................................................

stop_power:
   SetPulse(0);
   SetInvActivated(player, 27, 0);
   active = 0;
   jkEndTarget();

   Return;

end


that is basically the force blinding cog, except for this:
Code:
         tele = CreateThing(obj, GetThingPos(player));
         TeleportThing(player,victim);
         TeleportThing(victim,tele);
         DestroyThing(obj);

If someone could help me, that'd be greatly appreciated
2002-01-04, 11:02 AM #2
this should be realy simple, but it eludes me... please help.
2002-01-04, 11:23 AM #3
TeleportThing(victim,obj);
instead of
TeleportThing(victim,tele);
maybe?? guess not...
2002-01-04, 11:47 AM #4
ok, i've done some editing to the cog...
Code:
         vpos = GetThingPos(victim);
         ppos = GetThingPos(player);
         plook = GetThingLook(player);
         vlook = GetThingLook(victim);
         SetThingPos(victim, ppos);
         SetThingPos(player, vpos);
         SetThingLook(victim, plook);
         SetThingLook(player, vlook);

that all works, ecept that i never see where the victim was looking, and sometimes I get teleported to a room the causes a horrible HOM... i suspect the setthinglook...
2002-01-04, 1:38 PM #5
GAH!![/i] NEVER use Setthingpos() on the player. If the position is outside of your previos sector, the player is dropped outside of the world, hence the HOM.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2002-01-04, 3:08 PM #6
JediJigge - That is competly wrong...

Here ... just override the orginal with this...

tele = CreateThing(obj, player);

TeleportThing(player,victim);

TeleportThing(victim,tele);

DestroyThing(tele);

[EDIT: Text was stuffed /EDIT]

[This message has been edited by *_Seifer_* (edited January 04, 2002).]
2002-01-05, 10:47 AM #7
Oh man, i can't beleive i didn't catch this earlier, the template for obj is +brayr... which doesn't exist. i'ts kinda hard to teleport to nothing. Thanks everyone for all the help, now all i need to know is how to make the people switch views, aka player looks at what victim was looking at and victim was looking at what player looked at.
2002-01-05, 10:54 AM #8
PlayerLVec=GetThingLVec(player);
VictimLVec=GetThingLVec(victim);
SetThingLook(player, VictimLVec);
SetThingLook(victim, PlayerLVec);

Add this before you do any teleporting, and add the two vector variables under symbols, and you'll have it made in the shade. [http://forums.massassi.net/html/smile.gif]



------------------
-Hell Raiser
Cogging type person that does, umm, stuff?
"Free, your, mind."
DBZ: TDIR has a new home!
-Hell Raiser
2002-01-05, 11:22 AM #9
Hell raiser, that doesn't work... i've tried it before and a friend of mine said that inorder to get it to work i needed to fire out a ghost object from the victim and player and then set the victim and players current camera or something to that ghost object...
2002-01-05, 11:31 AM #10
You're friend is silly. [http://forums.massassi.net/html/smile.gif] You can't set the headpitch of the player at all in JK, so the people will retain their own headpitch with SetThingLook.

------------------
-Hell Raiser
Cogging type person that does, umm, stuff?
"Free, your, mind."
DBZ: TDIR has a new home!
-Hell Raiser
2002-01-05, 11:44 AM #11
so... what you're saying is that it is basically imposible for people to exchange looks... If thats the case then i guess it'll have to do, but if someone can come up with any solution, no matter how confusing i'll be thankful
2002-01-05, 12:47 PM #12
You can set where they are looking in general, just not their headpitch. It'll have to do. (unless it's MotS)

------------------
-Hell Raiser
Cogging type person that does, umm, stuff?
"Free, your, mind."
DBZ: TDIR has a new home!
-Hell Raiser
2002-01-05, 12:57 PM #13
it's not mots, and how do i do that?
2002-01-05, 1:26 PM #14
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Hell Raiser:
PlayerLVec=GetThingLVec(player);
VictimLVec=GetThingLVec(victim);
SetThingLook(player, VictimLVec);
SetThingLook(victim, PlayerLVec);

Add this before you do any teleporting, and add the two vector variables under symbols, and you'll have it made in the shade. [http://forums.massassi.net/html/smile.gif]
</font>


[http://forums.massassi.net/html/tongue.gif] [http://forums.massassi.net/html/tongue.gif] [http://forums.massassi.net/html/tongue.gif]
-Hell Raiser

↑ Up to the top!