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 → First Transmute, now this!
First Transmute, now this!
2005-04-01, 10:55 PM #1
HEAVENLY LIGHT:

Code:
# spell_heavenly.cog
# Turns night into day.
# [Grismath]
#==============================================================#
symbols
message		activated
message		selected
int		level			local
int		bin=35			local
int		mana			local
int		cost=200		local
sound		castSound=morning.wav	local
int		soundChannel=-1		local
int		num_surf		local
int		num_sect		local
int		player			local
int		i			local
material	newsky=sky-blue.mat	local
end
#==============================================================#
code
#------------------------------------------------------
activated:
 player=GetSourceRef();
 level=GetInv(player, bin);
 mana=GetInv(player, 14);
 if(level==0) {
  Print("Spell Untrained");
  Return;
 }

if((!IsInvActivated(player, bin)) && (GetThingHealth(player) > 0)) {
 mana = GetInv(player, 14);
 if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69)) {
 if(GetInv(player, 64) != 1) ChangeInv(player, 14, mana-cost);
 SetInvActivated(player, bin, 1);
 PlayMode(player, 24);
 soundChannel = PlaySoundThing(castSound, player, 0.8, -1, -1, 0x80);
 SetBinWait(player, bin, 0.2);
 num_surf=GetSurfaceCount();
 for(i=0; i<num_surf; i=i+1) {
  if(GetSurfaceFlags(i)==0x204) {
   SetSurfaceMat(i, newsky);
  }
 }
 num_sect=GetSectorCount();
 for(i=0; i<num_sect; i=i+1) {
  SetSectorLight(i, 0.7, 2);
 }
 call stop_power;
}
}
return;
#------------------------------------------------------
selected:
 Print("Heavenly Light");
return;
#------------------------------------------------------
stop_power:
 SetInvActivated(player, bin, 0);
return;
#------------------------------------------------------
end


For some reason, it doesn't do all surfaces and mats.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2005-04-01, 11:16 PM #2
The line:
if(GetSurfaceFlags(i)==0x204) {

should probably be:
if(GetSurfaceFlags(i) & 0x204) {

:)
2005-04-02, 9:16 AM #3
Now it changes all surfaces, even ones without 0x204.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2005-04-02, 10:50 AM #4
Oh, I see, now.

Okay, try this:
surfaceFlags = GetSurfaceFlags(i);
if ((surfaceFlags & 0x200) && (surfaceFlags & 0x4))
{

:)
2005-04-02, 11:39 AM #5
That'll work. What you were looking for 1st time Zeq was this:
if(GetSurfaceFlags(i) & 0x204 == 0x204)

The '&' will return the flags (bits) that both numbers have. Thus, it could return either 0x200, 0x204, 0x4, or 0x0. 0x204 contains 2 bits, 0x4 and 0x200. The surface flags could contain one, both, or neither of the bits. In JK, 0 is 'false', but any nonzero value counts as 'true'. 'if(GetSurfaceFlags(i) & 0x204)' will return a nonzero value if either 0x4 or 0x200 are contained within the surface flags. Adding '== 0x204' makes the comparison true only if both bits are returned.

Hopefully that made sense. :) I'm not always that good at explaining things.
May the mass times acceleration be with you.
2005-04-02, 11:55 AM #6
"What you were looking for 1st time Zeq was this:
if(GetSurfaceFlags(i) & 0x204 == 0x204)"

Yep. (Silly me.)

:)

↑ Up to the top!