Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-05-2008, 11:12 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Let there be light!

A little lighting effect I made for single levels. You simply put the code in an NPC in the level or place it in a class and join it, the choice is yours really. You can have more than one light source in a level, but it's not gonna do anything advanced, just merely overlaps(and when played with, you can get some nice looking effects out of it). I use it for just aesthetic reasons, not logical. Like in my screenshot I'm not using it to show light coming from a window, but just to create some nice looking effects.
I should note that even though it does a lot of looping, it only does so when you enter the level and it is not noticeable at all(at least in my experience, and I run on a pretty damn terrible computer, and in my level I'm using two).
Anyways, here's the code, and an image attachment of it in effect:
PHP Code:
//#CLIENTSIDE
function onPlayerenters() {
  
// These are tiles that light will 'pass through'... add stuff like vases(that can change 
  // blocking) here. I also have the window tiles in there... so you can have a light source
  // coming from the windows, you might want to remove that
  
temp.nonblocking={0x2AC,0x2AD,0x2BC,0x2BD,0x30C,0x30D,0x30E,0x30F,0x31C,0x31D,0x31E,0x31F};
  
temp.opacity=.5// how opaque the shadow will be
  
temp.checks=300// how many checks to perform, careful not to exceed limit loop

  // NOTHING TO EDIT BELOW THIS
  
temp.seg=(pi*2)/checks;
  
temp.poly={0,0,0,64,64,64,64,0,0,0};

  for (
i=0;i<checks+1;i++) {
    for (
j=0;j<64;j+=.5) {
      if (
onwall(x-sin((i*seg))*j,y-cos((i*seg))*j)) {
        if (!(
tiles[x-sin((i*seg))*j,y-cos((i*seg))*jin nonblocking)) {
          
this.newpoly={int((x-sin((i*seg))*j)+.5),int((y-cos((i*seg))*j)+.5)};
          break;
        }
      }
    }
    
poly.add(this.newpoly[0]);
    
poly.add(this.newpoly[1]);
  }
  
poly.add(0);
  
poly.add(0);

  
showpoly(200,poly);
  
changeimgcolors(200,0,0,0,opacity);
  
changeimgvis(200,0);

Sorry for the bad screenshot... I don't know how to do a full level screenshot in Graalv5.
Attached Thumbnails
Click image for larger version

Name:	graal_1204750948.png
Views:	344
Size:	18.8 KB
ID:	44059  

Last edited by DustyPorViva; 03-05-2008 at 11:38 PM..
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.