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 Throwable Objects
Teleporting Throwable Objects
2004-07-02, 4:20 PM #1
Hello friends,

I haven't had much time lately to do stuff on my Temple level, but today I continued building again. Having a new idea for a room, I was wondering if it's possible to teleport throwable objects (like the Stormie helmets, the rocks, etc.).

I am using the sector teleport cog from massassi, but it only teleports the player. I have browsed through Datamaster (recommended to me by Lucky_Jackpot and PJB), but it's all very new and confusing to me. So I couldn't figure out how to let it teleport throwables too.

Would anyone be so kind to implement this for me? [http://forums.massassi.net/html/smile.gif] (Unless its a helluvalotta work ofcourse [http://forums.massassi.net/html/wink.gif] )

Here's the code of the cog I'm using:

Code:
# teleport.cog
#
# Teleports the player to a ghost position upon entry into a sector 
#
# Nightmare (6/16/98)
#============================================================================
flags=0x240

symbols
message entered
message startup        

sector	telechamber

thing	gotospot
                                
int 	player  		                local
int     dummy                                   local

sound   telesound=ForceThrow01.WAV

template	sparks=+telesparks

end

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

code
entered:
	player=GetLocalPlayerThing();
	StopThing(player);	

	dummy = CreateThing(sparks, player);
        
        dummy = PlaySoundLocal(telesound, 1.0, 0, 0);
        
        TeleportThing(player, gotospot);

	dummy = CreateThing(sparks, player);

	return;
end


------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I
2004-07-02, 8:25 PM #2
It may please you to know that it is quite simple. Just add the proper 'mask' flags after the telechamber declaration.

Now chances are you don't know what mask flags are, so here's a brief definition. Mask flags limit what TYPE of object can call the messages related to a symbol. For instance the mask flags 0x400 calls only messages caused by objects of type 'player'

Here is a list of all mask flags
Code:
hex    dec   type
0x001  1     Free
0x002  2     Camera
0x004  4     Actor
0x008  8     Weapon
0x010  16    Debris
0x020  32    Item
0x040  64    Explosion
0x080  128   Cog
0x100  256   Ghost
0x200  512   Corpse
0x400  1024  Player
0x800  2048  Particle

to use mask flags, place them next to their respecive symbol. In this case
Code:
sector	telechamber     mask=0x10
will cause any messages related to the telechamber sector (ex. entered) to be called by debris.


[edit] Just so you know, the leading zeros after the 'x' are NOT needed. ex. 0x008 is the same as 0x8 [/edit]
------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited July 03, 2004).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-03, 2:59 PM #3
Wow, that's all?

I thought I was going to have to add the throwables in all the lines where it says 'player', lol. Don't ask me why. Cog is still very much like Chinese to me.

Thank you for your explanation [http://forums.massassi.net/html/smile.gif]

But this raises new questions. Is it possible to add several masks? Like to have it teleport corpses too for example? How would that be done? (Just out of curiosity)

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=

[This message has been edited by ORJ_JoS (edited July 03, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-07-03, 3:11 PM #4
Haha, I tested it. I think I was right about having to change more. The result is pretty hilarious. I push the throwable in the teleportsector, but it doesnt teleport, the player does, lol.

Any idea why?

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I
2004-07-03, 4:48 PM #5
Lol, i should have read your cog. Basically, where you said 'player=GetLocalPlayerThing();' you want 'player=GetSourceRef();' instead. That way it will make 'player' equal to the object which called the message (the debris entering the sector). I would suggest renaming the variable to something like 'object' so that anyone reading the code (yourself included) won't get confused that it really isn't the player.

As for having several masks, just use the windows calculator set on hex mode, and add the hex values you want together. For example, corpses and debris is 0x210, actors, weapons, and players is 0x40C. (8+1=9, 8+2=A, 8+3=B, 8+4=C). For less confusion, I'm going to reformat the table, you may want to look at it again to see if it is less confusing.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited July 03, 2004).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-04, 12:26 PM #6
Alright, I'll change that.

as for the masks... ummmmm, 0x210 just seems to be the sum of 0x200 and 0x10, but the other one... I don't see how you get 0x40C in your example. I don't understand the letters part, I'm sorry. What's the mask for:

player, corpse, Debris ?

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I
2004-07-04, 1:06 PM #7
I tried to explain that in the last paragraph, but I was in a hurry.

You must first remember that this is not like decimal (base 10) adding. Base 10 means that there are 10 different "numbers" that we can use, 0-9. The mask flags are in a format called Hexadecimal which is base 16. That means that there are 16 different "numbers" 0-F.
I shall now count base 10 (Decimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. There are 10 "numbers" in decimal, hence base 10.
Here is base 16 (Hexadecimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. There are 16 "numbers" in hexadecimal, hence base 16.

When adding corpses and debris you have 0x200 and 0x010 respectively. When adding in hex, you add in each column. The first column (right to left) has '0' in the first number (0x200) and '0' in the second (0x010), therefore the column on the right is '0'. The second column has a '0' and a '1', therefore the second column from the right is 1 (0+1). Currently we have 0x010. Now we add the third column from the right, which is '2' and '0' respectively. The end result is 0x210.
Code:
 0x200
+0x010
------
 0x210



Now for a harder example. This time we are adding actors (0x004), weapons (0x008), and players (0x400). The first column (remember that all adding is read right to left) is '4', '8', and '0'. 8+4+0=C (I got 'C' using adding: 8+1=9, 8+2=A, 8+3=B, 8+4=C). Now to the second column, '0', '0', and '0'. This is simply '0'. We currently have 0x00C. Finally we add the last column, '0', '0', and '4'. 0+0+4=4. When you put the columns together you get 0x40C.
Code:
 0x004
 0x008
+0x400
------
 0x40C



In a 3-column situation like this, the maximum number is 0xFFF. This is because 'F' is the largest hexadecimal "number". In regular decimal, '9' is the biggest number.

If I'm still not clear, just tell me which part you don't understand.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited July 04, 2004).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-04, 1:52 PM #8
Wow, thanks for that explanation, that is very very clear. I get it now, once you go 'over 9' (in hexadecimal), you get the letters, where A is the equivalent of 10, etc. and F is the equivalent of 15.

So I need:

0x010 (debris)
0x200 (corpse)
0x400 (player)
----- +
0x610 (total mask)

Is that correct?

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=

[This message has been edited by ORJ_JoS (edited July 04, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-07-04, 2:38 PM #9
Yep, it sounds like you got it [http://forums.massassi.net/html/smile.gif]

That last mask is correct.

Glad that I could help.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-04, 3:43 PM #10
I tested it and it worked. I couldn't test it on 2 computers to see if it works on clients comps too, because my other comp is out of service, but I think it'll work.

Thanks again, and you're on the credits list with all the people who helped me out with cogs for my ORJ Secret Temple level. [http://forums.massassi.net/html/smile.gif]

(Think I'll make a scrolling credits board somewhere in it, lol, it's a lot of people already.)

BTW, GBK's universal door cog is pure genius! (Random remark)
------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=

[This message has been edited by ORJ_JoS (edited July 04, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-07-04, 7:38 PM #11
I would suggest using 0xE7C for the teleport sector flags, it should teleport everything, including weapons fire and explosions. Always thought more games should do that.

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2004-07-05, 2:49 AM #12
lol, why not.

I didn't plan on more, because the room won't be for guns or AI, but oh well. I think you're right. It's more realistic to let it teleport everything.

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I
2004-07-05, 11:00 PM #13
On second thought, no. I tried lots of combinations, but the mask 0x610 is actually the only one that works properly. If I add other types, I'll get weird anomalies, like laserbolts or destructions sitting frozen in the respawnpoint of the teleport.

The mask you suggested didn't work btw. Ít disrupts the teleporting. It gives telesparks, but you stay where you are.

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=

[This message has been edited by ORJ_JoS (edited July 06, 2004).]
ORJ / My Level: ORJ Temple Tournament I
2004-07-05, 11:12 PM #14
The weapons/objects staying frozen is due to the StopThing(player); line. It completely stops all movement in the object, which was a moving projectile [http://forums.massassi.net/html/smile.gif] To let the weapons move after teleporting, just comment out that line.

I would actually suggest using the flag 0xFFF, I have used it before and certain mods use type cog (among others) as objects and projectiles. Actually, there is no problem with any of the flags. Chances are that the flags are causing something that you were expecting to stay put to teleport (a ghost for example)

Then, I have also found that my tests have required me to sleep before teleporting. Technically, I shouldn't need to, and it may have been the result of another line of code, but you may want to see if adding a really, really SMALL sleep (0.000000001) before the TeleportThing line.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-06, 2:14 AM #15
Ok, I'll try that, the sleep, although I don't see why. I'll take out that line which tells it to stop and test those flags again.

Thanks [http://forums.massassi.net/html/smile.gif]

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I
2004-07-06, 2:43 AM #16
Ok, the laserbolts aren't freezing anymore, so that helped.

But the mask is still a problem. 0xFFF didn't work. Things end up not being teleported, I assume because all the teleportsparks itself are also being teleported. So I tried 0x7FF (leaving particles out) and it improved a little, but somehow when multiple things are being teleported, some won't teleport. I'll experiment a bit more, but it seems like 0x610 is still the safest. I left particles out, but it was trying to teleport the sparks created by the saber... which flag could that be?

Btw what does 'free' (0x001) stand for?

------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I
2004-07-06, 5:17 AM #17
I'm sticking with 0x610 as it is. I tried a lot of combinations but none of them worked perfectly. (some things wont teleport with more flags).

Here's the current version of the cog, just for anyone who might find it useful:

(sorry for weird spacing in the script)

Code:
# Jedi Knight Cog Script
# Teleport V 1.0
# Teleports an object (player/corpse/debris) to a ghost position upon entry into a sector
# By Nightmare (6/16/98), minor upgrades by SG-fan (July 2004)
#============================================================================
flags=0x240

symbols
message entered
message startup        

sector	telechamber	mask=0x610

thing	gotospot
                                
int 	object  		                local
int     dummy                                   local

sound   telesound=ForceThrow01.WAV

template	sparks=+telesparks

end

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

code
entered:
	object=GetSourceRef();
	
	dummy = CreateThing(sparks, object);
        
        dummy = PlaySoundLocal(telesound, 1.0, 0, 0);

	Sleep(0.000000001);
        
        TeleportThing(object, gotospot);

	dummy = CreateThing(sparks, object);

	return;
end


------------------
ORJ_JoS
=Council Member=
+Order of Reborn Jedi+

http://www.rebornjedi.cjb.net

Long live JK! =Best Game Ever=
ORJ / My Level: ORJ Temple Tournament I

↑ Up to the top!