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 → Randomising positions of CreateThing();
Randomising positions of CreateThing();
2001-10-31, 2:01 AM #1
Ok, in the massassi chat room last night, LordVader told me that it was possible to create a thing from random positions around a ghost object instead of just having it come from one point from the ghost object. He said it involved some math and stuff like that. I'm not that good in cog to do it so i was wondering if Lordvader or someone else could help me with this?

Here's the equasion Loardvader gave to me: Distance is: d = sqrt(sqr(x1-x2) + sqr(y1-y2) + sqr(z1-z2))

And here is the cog i want to apply it to:
Code:
## Jedi Knight Cog Script ###########################################
#                                                                   #
# rain.cog                                                          #
#                                                                   #
# This is a cog that should maske realistic rain in levels,         #
# the rain is generated by chost objects positioned near eachother  #
#                                                                   #
# [E3 - 29/10/2001]                                                 #
#                                                                   #
#####################################################################
flags=0x240
# .........
symbols

template	rainsprite
thing		ghost0
thing		ghost1
thing		ghost2
thing		ghost3
thing		ghost4
thing		ghost5
thing		ghost6
thing		ghost7
thing		ghost8
thing		ghost9

message 	startup
message		pulse
message		timer

end

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

code

startup:

SetPulse(0.6);

Return;

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

pulse:

SetTimerEx(Rand(), 1, 0, 0);
SetTimerEx(Rand(), 2, 0, 0);
SetTimerEx(Rand(), 3, 0, 0);
SetTimerEx(Rand(), 4, 0, 0);
SetTimerEx(Rand(), 5, 0, 0);
SetTimerEx(Rand(), 6, 0, 0);
SetTimerEx(Rand(), 7, 0, 0);
SetTimerEx(Rand(), 8, 0, 0);
SetTimerEx(Rand(), 9, 0, 0);
SetTimerEx(Rand(), 10, 0, 0);

Return;

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

timer:

if(GetSenderID() == 1)
   {
	CreateThing(rainsprite, ghost0);
   }
   else
   if(GetSenderID() == 2)
   {
	CreateThing(rainsprite, ghost1);
   }
   else
   if(GetSenderID() == 3)
   {
	CreateThing(rainsprite, ghost2);
   }
   else
   if(GetSenderID() == 4)
   {
	CreateThing(rainsprite, ghost3);
   }
   else
   if(GetSenderID() == 5)
   {
	CreateThing(rainsprite, ghost4);
   }
   else
   if(GetSenderID() == 6)
   {
	CreateThing(rainsprite, ghost5);
   }
   else
   if(GetSenderID() == 7)
   {
	CreateThing(rainsprite, ghost6);
   }
   else
   if(GetSenderID() == 8)
   {
	CreateThing(rainsprite, ghost7);
   }
   else
   if(GetSenderID() == 9)
   {
	CreateThing(rainsprite, ghost8);
   }
   else
   if(GetSenderID() == 10)
   {
	CreateThing(rainsprite, ghost9);
   }

Return;

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


end



------------------
Generating Electro Vibes™ for the masses on Massassi
Go To: EL3CTROPROSE or DEEPMATRIX or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
<EL3CTRO> EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!

[This message has been edited by Electro (edited October 31, 2001).]
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
&lt;EL3CTRO&gt; EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
2001-10-31, 2:44 AM #2
Try something like:

Code:
if(GetSenderID() == 1)
{
RANDV = VectorAdd(GetThingPos(ghost0), VectorSet((Rand()-0.5)*2, (Rand()-0.5)*2, (Rand()-0.5)*2));
CreateThingatPosNR(rainsprite, GetThingSector(ghost0), RANDV, '0 0 0');
}
else
// You get the idea


See the *2 in the RANDV line. By increasing or decreasing that number you can control how much distance away from the original pos you allow your rain to form.
LucasArts could have saved us all this work if only they had made the RandVec(); function work correctly.

------------------
- Wisdom is 99% experience, 1% knowledge. -
- Wisdom is 99% experience, 1% knowledge. -
2001-10-31, 4:04 AM #3
Thanks man, it looks great in game [http://forums.massassi.net/html/biggrin.gif]
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
&lt;EL3CTRO&gt; EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!

↑ Up to the top!