Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-01-2015, 06:10 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Mirror

Since testbed back I'm trying to make some new stuff and thought I could try to make a mirror but I no idea on how I would make the tiles show on the mirror. The only way I could think of is to make a screenshot of a specific spot of where I want a mirror.
I thought I would ask here if anyone has any idea how to do this. I just seem to stuck on the tile issue. I sorta have an idea on how to show the player in the mirror with showani possibly but want to get the hard things out of the way first.
Reply With Quote
  #2  
Old 11-06-2015, 12:24 PM
Cubes Cubes is offline
Registered User
Cubes's Avatar
Join Date: Dec 2005
Location: Chesapeake, Virginia
Posts: 498
Cubes is a jewel in the roughCubes is a jewel in the rough
just use a npc that mimics the players gani and look.
Reply With Quote
  #3  
Old 11-06-2015, 07:16 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Get the tile data: this.level.tiles[tx, ty]

Use these functions:

PHP Code:
gettileset(); // returns the current tileset image

//credit to dusty
function TilesToImage(t) {
  if (
t.type() == 0) {
    
temp.px = (int(t%16)*16)+(int(t/512)*256);
    
temp.py = (int(t/16)*16)%512;
    return {
px,py};
  } else if (
t.type() == 3) {
    
temp.imgarray = new[0];
    for (
temp.t) {
      
temp.px = (int(i%16)*16)+(int(i/512)*256);
      
temp.py = (int(i/16)*16)%512;
      
imgarray.add({px,py}); 
    }
    return 
imgarray;
  } else return -
1;

use stretchy = -1; to flip an the tile image.

Just make your mirror image dimensions match the tiles so you don't have to do any clipping.
__________________
Quote:
Reply With Quote
  #4  
Old 11-07-2015, 06:11 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Quote:
Originally Posted by fowlplay4 View Post
Get the tile data: this.level.tiles[tx, ty]

Use these functions:

PHP Code:
gettileset(); // returns the current tileset image

//credit to dusty
function TilesToImage(t) {
  if (
t.type() == 0) {
    
temp.px = (int(t%16)*16)+(int(t/512)*256);
    
temp.py = (int(t/16)*16)%512;
    return {
px,py};
  } else if (
t.type() == 3) {
    
temp.imgarray = new[0];
    for (
temp.t) {
      
temp.px = (int(i%16)*16)+(int(i/512)*256);
      
temp.py = (int(i/16)*16)%512;
      
imgarray.add({px,py}); 
    }
    return 
imgarray;
  } else return -
1;

use stretchy = -1; to flip an the tile image.

Just make your mirror image dimensions match the tiles so you don't have to do any clipping.
Thanks, tiles show now!! Just gotta make them appear in correct spot now.

edit: I got everything to work but just looks weird to me.
Only problem I have is only yourself will show on mirror and when you swing your sword the gani doesn't play fully.

Last edited by Kirko; 11-07-2015 at 07:45 PM.. Reason: added pic
Reply With Quote
  #5  
Old 11-07-2015, 09:05 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Do a check so you aren't updating the ani every time your script times out.

e.g. if (ani != player.ani) ani = player.ani;
__________________
Quote:
Reply With Quote
  #6  
Old 11-08-2015, 02:30 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Quote:
Originally Posted by fowlplay4 View Post
Do a check so you aren't updating the ani every time your script times out.

e.g. if (ani != player.ani) ani = player.ani;
Thanks it works!
I Still got one or two small problems but I'll try to figure it out on my own.
Reply With Quote
  #7  
Old 11-08-2015, 04:04 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I'd suggest drawing a black polygon or something at the bottom of the mirror to visually separate it from the ground.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #8  
Old 11-08-2015, 04:59 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Quote:
Originally Posted by xXziroXx View Post
I'd suggest drawing a black polygon or something at the bottom of the mirror to visually separate it from the ground.
I did something a little different. I made a image instead and then just stretched the x and y to fit the size of the mirror I gave. I attached image below.

this is how it came out.



Also for gani not showing fully you could do this also
PHP Code:
player.ani.name "[" player.anistep "]" 
I'm guessing all it does is get the exact frame of your gani and starts from there instead of the beginning.
Attached Images
 
Reply With Quote
  #9  
Old 11-08-2015, 05:23 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Include a video or gif! Looks good!
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #10  
Old 11-08-2015, 08:46 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Really cool guys!
__________________
Reply With Quote
  #11  
Old 11-12-2015, 01:43 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
I had to do it this way for the players on Era-

HTML Code:
function onTimeout() {
  temp.timer = 1;
  if (player.x in |this.x - 15, this.x + 15| &&
      player.y in |this.y - 10, this.y + 15|) 
    temp.timer = 0.05;
  
  if ((player.x + 1.5) in |this.x + 1.5, this.x + (this.width - 1.5)| &&
      player.y in |this.y + 3, this.y + 6|) {
    temp.dir = (player.dir == 0? 2: (player.dir == 2? 0: player.dir));
    temp.x = player.x;
    temp.y = this.y + 4 - ((player.y - thiso.y) - 2);
    temp.ani = player.ani;
    
    with (findimg(200)) {
      this.x = temp.x;
      this.y = temp.y;
      
      if (this.ani != temp.ani)
        this.ani = temp.ani;
        
      this.layer = 2;
      this.dir = temp.dir;
      playerlook = false;
      actor.head = playero.head;
      actor.body = playero.body;      
      actor.colors[0] = playero.colors[0];
      actor.colors[1] = playero.colors[1];
      actor.colors[2] = playero.colors[2];
      actor.colors[3] = playero.colors[3];
      actor.colors[4] = playero.colors[4]; 
      actor.attr[1] = playero.attr[1];
      actor.shield = playero.shield;
    }    
  } else {
    hideimg(200);
  }
  setTimer(temp.timer);
}
__________________
Reply With Quote
  #12  
Old 07-26-2016, 06:40 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
oops I never posted the code :o

been a while since I made it so I decided to rewrite it just now to shorten it up.
Only problem is that it only shows your character
PHP Code:

//#CLIENTSIDE
function onPlayerEnters() {
  
setshape(1this.mirror_width 16this.mirror_height 16);
  
showTiles();
  
onTimeOut();
}

function 
onTimeOut() {
  if (
player.x in |thiso.1.5thiso.this.mirror_width 1.5| && 
      
player.y in |thiso.this.mirror_height 1.5+ (this.mirror_height 2) - 2|){ 
    
with (findimg(50)) {
      
player.x;
      
thiso.+ (thiso.playero.y) + thiso.mirror_height 2.5;
      
layer 1;
      
      
ani player.ani.name "[" player.anistep "]";
      
dir player.dir == player.dir == player.dir;
      
head   player.head;
      
shield player.shield;
      for (
temp.0temp.5temp.++) colors[i] = player.colors[i];
      for (
temp.0temp.20temp.++) attr[i] = player.attr[i];
    }
  } else
    
hideimg(50);
    
  
setTimer(0.05);
}

function 
showTiles(){
  
temp.mw this.mirror_width;
  
temp.mh this.mirror_height;

  
temp.area temp.mw temp.mh;
  
temp.y    this.temp.mh 1;
  
  for(
temp.0temp.temp.areatemp.++) {
    
temp.+= (temp.temp.mw) == 0;

    
with (findimg(201 temp.i)) {
      
= (thiso.x) + ((temp.temp.mw) * 1);
      
= (thiso.temp.mh 1) - (int(temp.temp.mh) * 1);
      
      
image gettileset();
      
partx TilesToImage(this.level.tiles[xtemp.y])[0];
      
party TilesToImage(this.level.tiles[xtemp.y])[1];
      
partw parth 16;
      
stretchy = -1;
      
layer 0;
    }
  }
}

//credit to dusty 
function TilesToImage(t) {
  if (
t.type() == 0) {
    
temp.px = (int(t%16)*16)+(int(t/512)*256);
    
temp.py = (int(t/16)*16)%512;
    return {
px,py};
  } else if (
t.type() == 3) {
    
temp.imgarray = new[0];
    for (
temp.t) {
      
temp.px = (int(i%16)*16)+(int(i/512)*256);
      
temp.py = (int(i/16)*16)%512;
      
imgarray.add({px,py}); 
    }
    return 
imgarray;
  } else return -
1;

Reply With Quote
  #13  
Old 07-27-2016, 02:06 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Kirko View Post
Only problem is that it only shows your character
PHP Code:
for (temp.plplayers) {
  if (!
temp.pl.x in .... || !temp.pl.y in ...) continue;
  
with (findimg(200+temp.count)) {

  }

Used continue so it would still display the characters to all players, even if they aren't in the mirror. Don't know if you only want to show your own character on purpose. If not, this would fix it
__________________
MEEP!
Reply With Quote
  #14  
Old 07-27-2016, 10:50 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Kirko I'm amazed by you, you have come a long way my friend.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #15  
Old 07-28-2016, 11:53 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Quote:
Originally Posted by callimuc View Post
PHP Code:
for (temp.plplayers) {
  if (!
temp.pl.x in .... || !temp.pl.y in ...) continue;
  
with (findimg(200+temp.count)) {

  }

Used continue so it would still display the characters to all players, even if they aren't in the mirror. Don't know if you only want to show your own character on purpose. If not, this would fix it
Thanks!


Quote:
Originally Posted by MysticalDragon View Post
Kirko I'm amazed by you, you have come a long way my friend.
Reply With Quote
Reply

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 04:19 AM.


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