Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-11-2007, 11:32 PM
Cherrykao Cherrykao is offline
Banned
Join Date: Apr 2007
Posts: 37
Cherrykao is on a distinguished road
making roof semi-transparent

I'm having some trouble getting my scripts to work properly online. It works good offline on the editor.

Basically when you enter a house, the roof turns semi-transparent and then when you exit the house through the door, the roof turns back to normal.

Here's my code for the roof NPC:

NPC Code:

//#CLIENTSIDE
//function onCreated() {
if (created) {
setimg roof.gif;
dontblock;
drawoverplayer;
vRoofV();
vUnderRoof = false;
}

//function onPlayerTouchsMe() {
if (playertouchsme) {
vUnderRoof = true;
}

if (vUnderRoof == true) {
vRoofI();
}
if (vUnderRoof == false) {
vRoofV();
}

// Makes roof transparent
function vRoofI() {
setcoloreffect 1,1,1,0.22;
drawaslight;
}

// Puts roof back to normal
function vRoofV() {
setcoloreffect 1,1,1,1;
//drawaslight;
}

timeout = 0.05;



When someone walks out through the door, the "vUnderRoof" flag is set back to false by touching a grass NPC as they walk out through the door:

NPC Code:

if (created) {
setimg vivendi_h10grass.png;
drawunderplayer;
dontblock;
//vUnderRoof = false;
}

if (playertouchsme) {
vUnderRoof = false;
}

timeout = 0.05;

Reply With Quote
  #2  
Old 05-11-2007, 11:36 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
Well that's a bad way to do it.
You should probably check the players.x/y in a timeout and when the player enters the coordinates of the roof, transparent, otherwise, return to normal.
Reply With Quote
  #3  
Old 05-11-2007, 11:37 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Cherrykao View Post
Yadda yadda yadda
Well first of all, You need to define the variable on the client. Something like "client.vUnderRoof = false/true" will work fine.

Next, You need to do a loop to enable the code to detect the variable.

PHP Code:
timeout 0.05;

if (
timeout)
{
if (
client.vUnderRoof == true) {
  
vRoofI();
}
if (
client.vUnderRoof == false) {
  
vRoofV();
}

_______
Quote:
Originally Posted by DustyPorViva
Well that's a bad way to do it.
You should probably check the players.x/y in a timeout and when the player enters the coordinates of the roof, transparent, otherwise, return to normal.
I agree. Cherry, Why not check if the player's X and Y isn't in the NPC to undo it?

PHP Code:
// In timeout code
this.4// How many tiles the roof takes up, Horizontally
this.4// How many tiles the roof takes up, Vertically
if (!(playerx in |this.x, (this.x+this.w)|) && !(playery in |this.y, (this.y+this.h)|)
{
// Code to make roof opaque
} else {
// Code to make roof translucent

__________________
What signature? I see no signature?

Last edited by godofwarares; 05-11-2007 at 11:41 PM.. Reason: Code error!
Reply With Quote
  #4  
Old 05-12-2007, 12:09 AM
Cherrykao Cherrykao is offline
Banned
Join Date: Apr 2007
Posts: 37
Cherrykao is on a distinguished road
thanks. it is better to check the x & y coordinates of the players and i actually started doing that, but i thought it would be easier to use flags.
Reply With Quote
  #5  
Old 05-12-2007, 12:32 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
The best way to do it, in my opinion, is the way Hikaru is doing it. That's what I do too.
Reply With Quote
Reply


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:53 AM.


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