Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Creating Polys from Chat? (https://forums.graalonline.com/forums/showthread.php?t=72955)

killerogue 03-20-2007 12:31 AM

Creating Polys from Chat?
 
What would be the best course of action any of you would choose to create polys from a number the player states?

Using cos and sin I am not sure how I would go about this,

godofwarares 03-20-2007 12:41 AM

Here:

PHP Code:

//#CLIENTSIDE
function onPlayerChats()
{
     if (
player.chat.starts("/putpoly"))
     {
          
temp.verticies player.chat.substring(11).tokenize();
          echo(
temp.verticies);
          
          
          
showPoly(15temp.verticies);
     }


How to use: /putpoly vert1 vert2 vert3 vert4

killerogue 03-20-2007 01:23 AM

I meant more along the lines of stating a number of sides. And getting an even polygon from that.

Falcor 03-20-2007 05:38 AM

I didn't test it, but something like this should work.

PHP Code:

//#CLIENTSIDE
function onPlayerChats()
{
    
temp.radius 3;
    
temp.phi 0;
    
    if (
player.chat.starts("/putpoly"))
    {
        
temp.tok player.chat.tokenize();
        
temp.sides temp.tok[1];
        if(
temp.sides 2) {
            
temp.dt 2*pi/temp.sides;
            
temp.vert = {player.x+temp.radius*cos(temp.phi),player.y+temp.radius*sin(temp.phi)};
            for(
temp.1temp.temp.sides; ++temp.i) {
                
temp.vert.addplayer.x+temp.radius*cos(temp.phi temp.i*temp.dt) );
                
temp.vert.addplayer.y+temp.radius*sin(temp.phi temp.i*temp.dt) );
            }
            
showpoly(20,temp.vert);
        }
    }



killerogue 03-20-2007 06:23 AM

Quote:

Originally Posted by Falcor (Post 1290882)
I didn't test it, but something like this should work.

PHP Code:

//#CLIENTSIDE
function onPlayerChats()
{
    
temp.radius 3;
    
temp.phi 0;
    
    if (
player.chat.starts("/putpoly"))
    {
        
temp.tok player.chat.tokenize();
        
temp.sides temp.tok[1];
        if(
temp.sides 2) {
            
temp.dt 2*pi/temp.sides;
            
temp.vert = {player.x+temp.radius*cos(temp.phi),player.y+temp.radius*sin(temp.phi)};
            for(
temp.1temp.temp.sides; ++temp.i) {
                
temp.vert.addplayer.x+temp.radius*cos(temp.phi temp.i*temp.dt) );
                
temp.vert.addplayer.y+temp.radius*sin(temp.phi temp.i*temp.dt) );
            }
            
showpoly(20,temp.vert);
        }
    }



Yeah, thanks Falados. I worked something of that order our with Hell Raven and it worked. :)

Kristi 03-20-2007 08:11 PM

What are you going to learn by having someone do your code for you ^-^

godofwarares 03-20-2007 08:39 PM

Quote:

Originally Posted by Kristi (Post 1291040)
What are you going to learn by having someone do your code for you ^-^

Absolutely nothing :P

DustyPorViva 03-20-2007 08:51 PM

Actually I originally learned gscript by looking at codes other people have done and picking apart how it worked...


All times are GMT +2. The time now is 03:55 AM.

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