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 → Floo Powder
Floo Powder
2005-08-21, 9:53 PM #1
I am making a multiplayer level for JK of the Griffindor
common room from Harry Potter. I want to have the
fire place serve as a floo powder teleporter. Hopefully
you've read the books or at least have seen the
movies. There will be a basin next to the fire place
with the powder. I want to use that basin as a switch
to activate the teleporter. If you enter the sector where
the fire is after activating the 3do basin then you will
be teleported at random to one of 4 ghost positions and
the screen will flash bright green. If you don't activate
the 3do and you enter the fire sector then you will be
burned by the fire.

It would be great if someone would be willing to write
a cog that would work like that. Sorry if it's a bit
complicated. I don't even know if the 3do activation is
possible.

If that made no sense at all then post back and I'll
elaborate.

Here's some pics so you kinda know what I mean.

[http://i6.photobucket.com/albums/y215/millerpj/griff1.jpg]
a view of the common room still a very early WIP

[http://i6.photobucket.com/albums/y215/millerpj/griff2.jpg]
basic explaination if it even helps
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-22, 12:34 AM #2
[QUOTE=jedi I]It would be great if someone would be willing to write
a cog that would work like that.[/QUOTE]
Sure. I haven't read the books yet, and didn't see the beginning of the first movie, so just describe in detail what you want, other than what you posted.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-22, 1:19 AM #3
I'd make it so that the player gets a new item when he activates the basin thing. The fire sector then checks this item and either burns or takes away the item and teleports the player.
If you want to have several teleport destinations, you could display a print menu, just like I'm doing it in my Ultimate Domination mod. I'd display it when activating the floo powder basin, something like that:
Code:
activated:
  KillTimerEx(333 + cycle % numoptions);
  cycle = cycle + 1;
  if(cycle % num_options == 1)
    Print("Take some floo powder and travel to <Place 1>");
  else if(cycle % num_options == X)
    Print("Take some floo powder and travel to <Place X>");
  else
    Print("Forget it");
  if(cycle % numoptions != 0)
    SetTimerEx(2, 333 + cycle % numoptions, GetSourceRef(), -1);
  else
    cycle = 0;
  Return;

timer:
  option = GetSenderID() - 333;
  if((option < 0) || (option > (num_options - 1)))
    Return;
  Print("Enter a fireplace to teleport to your chosen location");
  SetInv(GetParam(0), floo_powder_bin, option);
  Return;

It's nowhere near complete, but it should give you an idea...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-08-22, 1:35 AM #4
u could use a teleport cog in the cogs section.... (ya level looks great)
2005-08-22, 7:11 AM #5
Originally posted by zagibu:
I'd make it so that the player gets a new item when he activates the basin thing. The fire sector then checks this item and either burns or takes away the item and teleports the player.
If you want to have several teleport destinations, you could display a print menu, just like I'm doing it in my Ultimate Domination mod. I'd display it when activating the floo powder basin, something like that:
Code:
activated:
  KillTimerEx(333 + cycle % numoptions);
  cycle = cycle + 1;
  if(cycle % num_options == 1)
    Print("Take some floo powder and travel to <Place 1>");
  else if(cycle % num_options == X)
    Print("Take some floo powder and travel to <Place X>");
  else
    Print("Forget it");
  if(cycle % numoptions != 0)
    SetTimerEx(2, 333 + cycle % numoptions, GetSourceRef(), -1);
  else
    cycle = 0;
  Return;

timer:
  option = GetSenderID() - 333;
  if((option < 0) || (option > (num_options - 1)))
    Return;
  Print("Enter a fireplace to teleport to your chosen location");
  SetInv(GetParam(0), floo_powder_bin, option);
  Return;

It's nowhere near complete, but it should give you an idea...


I really like the item idea but it will be multiplayer and I
don't want to search through a menu while someone is
shooting me.

I don't know how to make an item show up in your
inventory. It would have to be destroyed after you
teleport as well. I really have a very basic understanding
of cog so I wont be able to do the item check dealy by
myself. I am going to try to write the cog with my original
Ideas and if anyone feels like making it as Zagibu has
described minus the menus then It'd be great.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-22, 7:57 AM #6
[QUOTE=Knuckles ßeta]u could use a teleport cog in the cogs section.... (ya level looks great)[/QUOTE]

There is a couple of cogs in there that I just looked at.
They don't have quite the effect I want so I'll tweak
with it and see if I can make something work.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-22, 9:14 AM #7
Here is a cog I've been editing. So far
I've got it to where if you enter the
sector without activating the switch
it won't do anything but when you
activate the switch it teleports you
to one of the random locations. I
want to make it teleport only if you
press the switch and then enter the
sector. Then I want to make the
switch deactivate after you are
teleported so the next person has
to press the switch before the enter
the teleport sector.

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

symbols
message entered
message startup
message activated

thing	         switch		

thing            player 		        local

thing            ghost1 	
thing            ghost2
thing            ghost3
thing            ghost4

template	sparks=+telesparks		local

sound		teleportsnd=ForceThrow01.WAV	local

flex            rval                            local        

sector	telechamber

sound   telesound=ForceThrow01.WAV              local

template	sparks=+telesparks              local

end

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

code

entered:
	
if (activated: )

{
AddDynamicTint(GetSourceRef(), 0.0, 0.75, 0.0);
StopThing(GetSourceRef());
dummy = CreateThingAtPos(sparks, GetThingSector(GetSourceRef()), GetThingPos(GetSourceRef()), '0 0 0');

rval = Rand();
   if (rval < 0.25)
   {
    TeleportThing(GetSourceRef(), ghost1);

   }
   else if (rval <0.50)
   {
    TeleportThing(GetSourceRef(), ghost2);
   }
   else if (rval <0.75)
   {
    TeleportThing(GetSourceRef(), ghost3);
   }
   else if (rval <1.00)
   {
    TeleportThing(GetSourceRef(), ghost4);
   }

dummy = CreateThingAtPos(sparks, GetThingSector(GetSourceRef()), GetThingPos(GetSourceRef()), '0 0 0');
dummy = PlaySoundThing(teleportsnd, GetSourceRef(), 1.0, -1, -1, 0x80);
}
return;
}

return;
end
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-22, 9:35 PM #8
Here you go. Bins and a player's userInfo can and are used by mods, so I used the COG's heap to store an "inventory" for all players.

Summary of all the variables that'll show up in JED:

switch = the powder basin to be activated
ghost1-4 = the ghost destinations to teleport to
teleportSound = the sound you make when you teleport
flash_r/g/b = the R, G and B values for the screen flash effect
alignLook = a boolean, 1 or 0. When set to 1, the ghost destination's look vector will be set to that of the player's, so when you walk through the teleporter your viewing angle doesn't change. I.e. if you walk through backwards you are facing backwards on the other side.
maxPowder = the maximum floo powder the player can pick up. I guess you could call it the number of handfuls. So if you set maxPowder to 5, the player can use the basin 5 times, picking up 5 handfuls so he can use the teleporter 5 times before refelling. If you only want one at a time, simply set it to 1.
teleChamber = the teleporter chamber

basin = the texture of the actual powder
numMatCels = the number of animation cels in that basin texture

Basin and numMatCels are for an optional visual effect I thought of. You could have say, half a dozen material cels for the basin texture, each one showing a different shadow from the player's hand scooping up the powder. So when you pick up floo powder, it looks as if the player just dipped his hand into the powder. Just an idea, you don't have to use it. If you leave the values at JED's default -1, nothing should happen. If it crashes, let me know.

Also, do you want any special particle effects for the teleporting? Right now it's just a simple spark. I wrote some code for Space Noxx II that creates a whole field of particles around the player. I.e. instead of creating one particle at the player's origin, it fills their position with particles. Looks really cool.

This is untested by there are no syntax errors according to Parsec. Lemme know if you have any problems, questions or suggestions for features.

Code:
# flooPowder.cog
#
# Teleport COG for Jedi I's Harry Potter level thing. Floo powder or somesuch.
# Stores the powder as an item in a psuedo inventory using the heap.
#
# Original by Nightmare 6/16/98, modified 2005 Jedi I
# Almost completely redone by Emon in August, 2005
#==============================================================================
symbols

thing		switch
thing		player								local
thing		ghost1
thing		ghost2
thing		ghost3
thing		ghost4

material	basin
int			numMatCels
template	sparks=+telesparks
sound		teleportSound=ForceThrow01.wav

flex		flash_r=0.0
flex		flash_g=0.75
flex		flash_b=0.0

int			alignLook=1
int			maxPowder=1
int			disabled=0							local
int			playerNum							local
flex		rVal								local
flex		temp								local
flex		temp2								local

sector		teleChamber

message		entered
message		activated
message		startup

end
#==============================================================================
code

#------------------------------------------------------------------------------
startup:
	// Allocate the heap to store Floo powder status for all 32 players.
	// We'll use the player's number (from getPlayerNum(player) as the index
	// for the heap. The value will be an integer representing how much Floo
	// powder a player has. This could be a maximum of 1, requiring the player
	// to pick up more Floo powder each time, or as high as the editor wants
	// it to be.
	heapNew(32);
	return;

#------------------------------------------------------------------------------
activated:
		playerNum = getPlayerNum(getSourceRef());
		// If the player already has Floo powder, return.
		if(heapGet(playerNum) >= maxPowder)
			return;
		// Add more Floo powder to the "inventory".
		heapSet(playerNum, heapGet(playerNum) + 1);
		
		// Here we randomly set the animation cel on the basin texture for
		// the powder. Each time the basin is activated, the different cels
		// will show the powder being pushed around by the hand of the player.
		// Or rather create that illusion.
		temp = rand() * numMatCels;
		temp2 = (temp + .5) - (temp + .5) % 1;
		setMaterialCel(basin, temp2);
	return;

#------------------------------------------------------------------------------
entered:
	if(heapGet(player) > 0)
	{
		player = getSourceRef();
		addDynamicTint(player, flash_r, flash_g, flash_b);
		createThingAtPos(sparks, getThingSector(player),
						 getThingPos(player), '0 0 0');
		playSoundThing(teleportSound, player, 1.0, -1, -1, 0x80);
		heapSet(getPlayerNum(player), heapGet(getPlayerNum(player)) - 1);
		rVal = rand();
		if(rVal < 0.25)
		{
			// Set the look vector of the ghost to that of the player's,
			// so when the player teleports he'll be facing in the same
			// direction he was when he entered the teleporter. This makes
			// for a very smooth transition. Toggleable within JED with the
			// variable 'alignLook'.
			if(alignLook == 1)
				setThingLook(ghost1, getThingLVec(player));
			teleportThing(player, ghost1);
		}
		else if(rVal < 0.50)
		{
			if(alignLook == 1)
				setThingLook(ghost2, getThingLVec(player));
			teleportThing(getSourceRef(), ghost2);
		}
		else if(rVal < 0.75)
		{
			if(alignLook == 1)
				setThingLook(ghost3, getThingLVec(player));
			teleportThing(getSourceRef(), ghost3);
		}
		else if(rVal < 1.00)
		{
			if(alignLook == 1)
				setThingLook(ghost4, getThingLVec(player));
			teleportThing(getSourceRef(), ghost4);
		}
	}
	return;
	
end
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-22, 9:55 PM #9
The concepts are great! I love what you've done.
I tested it however and it didn't quite work. Well
it didn't quite work in the worst possible way. It
crashed the game... I have no clue what could be
wrong with it but all the help is greatly appreciated.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-22, 11:42 PM #10
Probably something with the heap, I'll check it out tomorrow, it's getting late.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-23, 3:25 AM #11
Whats the point of using the heap in that cog? Activating the basin should just enable the teleporter for a short time. Ever heard of KISS? Keep It Simple Stupid.
2005-08-23, 7:19 AM #12
I believe the idea is each player must activate it seperately. The crash is a simple problem. The heap needs to be initialized.
for(i = 0; i < 32; i = i + 1){
HeapSet(i, 0);
}
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-08-23, 3:53 PM #13
JM, it's not actually a switch. You're supposed to actually pick up a handful of Floo powder and throw it into the fire. This means the player can pick some up, walk away, come back and still use the teleporter without burning to death. Speaking of which, I'll have to implement damage.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-23, 4:48 PM #14
Here's an updated version:
http://rafb.net/paste/results/ikbX1w27.html

I (think) I fixed the heap crashing. I also added a damage pulse. It just constantly runs and damages any player, actor or weapon that's in the sector. I did actors and weapons incase you ever wanted synched AI or wanted weapons like thermal detonators or sequencers to blow up faster when they enter the sector.

The damage value is 5, which means 5 health points of damage. damageFrequency is how often the pulse runs. So 5 points of damage every 100 milliseconds (one tenth of a second), or 50 damage points every second. I opted for such a fast pulse because I never liked fire in games where you lose like, 25 health points every two seconds. This way is smoother and also makes sure the player gets *some* amount of damage when they enter by accident.

There's also the printMsgs boolean, which defaults to 1. When this value is true, messages will be printed to the screen about picking up Floo powder, the number of handfuls of Floo powder remaining (only if maxPowder is greater than 1), or if you enter without Floo powder, it tells you you forget to pick some up. You can easily edit the strings that print to the screen in the COG.

Lemme know how it works out.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-23, 4:52 PM #15
The initialization should've fixed it. The problem comes when you try to use HeapGet() on an uninitialized index slot. JK crashes if you do.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-08-23, 4:55 PM #16
Yeah, I just didn't test it, so I wasn't completely sure.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-23, 10:52 PM #17
The new cog works great. I really love all the features
that have been put into it. The only problem I can find
is that the sector damage doesn't work at all. Thanks
for the help Emon!

p.s. if you want me to just use the sector damage cog
I can do that and it wouldn't bother me having an extra
cog in there. Thanks again.

p.p.s. I don't understand how the animated mat will
work. Does the mat have to be part of my 3do for it
to work?
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-23, 11:34 PM #18
Okay, I think I fixed the damage. Here's the new one:
http://rafb.net/paste/results/n40MbO26.html

The texture animation uses setMaterialCel(), which sets the cel of a material for all materials in the level. It's the only way to set the cel on a material on a 3DO, so if you have more than one of these basins you'll need seperate 3DOs with seperate texture names.

Basically my idea was this: You have a texture that illustrates the Floo powder. You can draw several versions of the texture, each showing different marks and shading from people scooping their hands into the pile. You save all those textures as an animated MAT and my COG will randomly choose one of those cels every time the basin is used. With maybe a half dozen animation cels it will appear random. Get what I'm saying?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 8:16 PM #19
The damage still doesn't work but I'm pretty sure
it's just because the pulse message wasn't initialized
in the startup.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-24, 8:19 PM #20
Good call. Here you go.
Code:
# floo_powder.cog
#
# Teleport COG for Jedi I's Harry Potter level thing. Floo powder or somesuch.
# Stores the powder as an item in a psuedo inventory using the heap.
#
# Original by Nightmare 6/16/98, modified 2005 Jedi I
# Almost completely redone by Emon in August, 2005
#==============================================================================
symbols

thing		switch
thing		player								local
thing		ghost1
thing		ghost2
thing		ghost3
thing		ghost4

material	basin
int			numMatCels
template	sparks=+telesparks
sound		teleportSound=ForceThrow01.wav

flex		flash_r=0.0
flex		flash_g=0.75
flex		flash_b=0.0
flex		damage=5
flex		damageFrequency=0.1

int			alignLook=1
int			printMsgs=1
int			maxPowder=1
int			disabled=0							local
int			playerNum							local
int			i									local
int			type								local
flex		rVal								local
flex		temp								local
flex		temp2								local
thing		victim								local

sector		teleChamber

message		entered
message		activated
message		startup
message		pulse

end
#==============================================================================
code

#------------------------------------------------------------------------------
startup:
	// Allocate the heap to store Floo powder status for all 32 players.
	// We'll use the player's number (from getPlayerNum(player) as the index
	// for the heap. The value will be an integer representing how much Floo
	// powder a player has. This could be a maximum of 1, requiring the player
	// to pick up more Floo powder each time, or as high as the editor wants
	// it to be.
	heapNew(32);
	for(i = 0; i < 32; i = i + 1)
		heapSet(i, 0);
	setPulse(damageFrequency);
	return;

#------------------------------------------------------------------------------
activated:
		playerNum = getPlayerNum(getSourceRef());
		// If the player already has Floo powder, return.
		if(heapGet(playerNum) >= maxPowder)
			return;
		// Add more Floo powder to the "inventory".
		heapSet(playerNum, heapGet(playerNum) + 1);
		
		// Here we randomly set the animation cel on the basin texture for
		// the powder. Each time the basin is activated, the different cels
		// will show the powder being pushed around by the hand of the player.
		// Or rather create that illusion.
		temp = rand() * numMatCels;
		temp2 = (temp + .5) - (temp + .5) % 1;
		setMaterialCel(basin, temp2);
		
		if(printMsgs == 1)
		{
			if(maxPowder > 1)
			{
				jkStringClear();
				jkStringConcatAsciiString("You have ");
				jkStringConcatInt(heapGet(playerNum));
				jkStringConcatAsciiString(" handfuls of Floo powder.");
				jkStringOutput(-1, -1);
			}
			else
				print("You picked up some Floo powder.");
		}
	return;

#------------------------------------------------------------------------------
entered:
	if(heapGet(player) > 0)
	{
		player = getSourceRef();
		addDynamicTint(player, flash_r, flash_g, flash_b);
		createThingAtPos(sparks, getThingSector(player),
						 getThingPos(player), '0 0 0');
		playSoundThing(teleportSound, player, 1.0, -1, -1, 0x80);
		heapSet(getPlayerNum(player), heapGet(getPlayerNum(player)) - 1);
		rVal = rand();
		if(rVal < 0.25)
		{
			// Set the look vector of the ghost to that of the player's,
			// so when the player teleports he'll be facing in the same
			// direction he was when he entered the teleporter. This makes
			// for a very smooth transition. Toggleable within JED with the
			// variable 'alignLook'.
			if(alignLook == 1)
				setThingLook(ghost1, getThingLVec(player));
			teleportThing(player, ghost1);
		}
		else if(rVal < 0.50)
		{
			if(alignLook == 1)
				setThingLook(ghost2, getThingLVec(player));
			teleportThing(getSourceRef(), ghost2);
		}
		else if(rVal < 0.75)
		{
			if(alignLook == 1)
				setThingLook(ghost3, getThingLVec(player));
			teleportThing(getSourceRef(), ghost3);
		}
		else if(rVal < 1.00)
		{
			if(alignLook == 1)
				setThingLook(ghost4, getThingLVec(player));
			teleportThing(getSourceRef(), ghost4);
		}
		
		if(printMsgs == 1)
		{
			if(maxPowder > 1)
			{
				jkStringClear();
				jkStringConcatAsciiString("You have ");
				jkStringConcatInt(heapGet(playerNum));
				jkStringConcatAsciiString(" handfuls of Floo powder remaining.");
				jkStringOutput(-1, -1);
			}
		}
	}
	
	else
	{
		if(printMsgs == 1)
			print("You forget to get some Floo powder!");
	}
	
	return;

#------------------------------------------------------------------------------	
pulse:
	victim = firstThingInSector(teleChamber);
	while(victim != -1)
	{
		type = getThingType(victim);
		if(type == 10 || type == 2 || type == 3)
			damageThing(victim, damage, 0x2, teleChamber);
		victim = nextThingInSector(victim);
	}
	return;
end
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 9:49 PM #21
Thanks a ton for helping me with the cog!
It works great! I never would have thought
it would turn out to be this cool when my
friend gave me the idea. It is awesome!
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-24, 11:24 PM #22
No problem. Good luck with your level!
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!