Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Archetypes with Gani Script (https://forums.graalonline.com/forums/showthread.php?t=74346)

Angel_Light 06-02-2007 05:50 AM

Archetypes with Gani Script
 
I have a gani script and I'm trying to load archetype variables. But it doesn't work.

PHP Code:

SCRIPT
function onCreated() {
  
this.baddyname "Default";
  
getBaddy();
  
onTimeOut();
}

function 
getBaddy() {
  
this.baddy.loadVars(
  
format("archetypes/baddies/%s.arc"this.baddyname));  
}

function 
onTimeOut() {
  
showtextthis.indexthis.x+2this.y+3,"Verdana""c",
    
this.baddy.nick);
  
showtextthis.index+1this.x+2this.y,"Verdana""c",
    
this.baddy.hp "/" this.baddy.fullhp);

  
changeimgzoomthis.index0.75);
  
changeimgzoomthis.index+10.75); 
     
if (
this.baddy.hp this.baddy.hp/3
  
changeimgcolorsthis.index+10100.99);
if (
this.baddy.hp this.baddy.hp/3)
  
changeimgcolorsthis.index+11100.99);
if (
this.baddy.hp this.baddy.hp/6)
  
changeimgcolorsthis.index+11000.99); 

if (
this.baddy.aggressor == 0changeimgcolorsthis.index0110.99); 
if (
this.baddy.aggressor == 1changeimgcolorsthis.index1100.99); 
if (
this.baddy.aggressor == 2changeimgcolorsthis.index1000.99); 

setTimer(0.05);
}
SCRIPTEND 


Inverness 06-02-2007 06:23 AM

I don't work with ganis often, but I believe they're clientside? x.x

Angel_Light 06-02-2007 06:30 AM

Quote:

Originally Posted by Inverness (Post 1314407)
I don't work with ganis often, but I believe they're clientside? x.x

Tried, also if so how would I load the vars.

Inverness 06-02-2007 06:41 AM

Quote:

Originally Posted by Angel_Light (Post 1314409)
Tried, also if so how would I load the vars.

Uh, they're automatically clientside even without the //#CLIENTSIDE thingy in the script. You would need to use player attributes or gani params I believe. Like I said, don't work with ganis often.

Novo 06-02-2007 11:25 AM

You can't load serverside variables clientside... You can't display clientside showimg's serverside.

When you create the object (gani), leave 0.05 seconds for the attributes / params to work.

killerogue 06-02-2007 11:31 AM

Since you can't load serverside vars clientside, I'd suggest making a frame class then using a function that uses with() on a putnpc2 to set the baddy name an any other variables prior to it's creation.

Also another serverside function for getting the baddy information would be good. Public is preferable.

Inverness 06-02-2007 04:33 PM

You could use this script for calling serverside functions from the gani, I haven't tested it with ganis, but it is an object so it should work the same.
You would need to use serverFunction() since the second one doesn't wait for a return. Recommend placing this script in a weapon called System or something, it looks the coolest like that.
PHP Code:

public function waitForNotify(objactiontime) {
  return 
waitfor(obj"Notify" actiontime);
}
public function 
notifyClient(objenametime) {
  
triggerClient("gui"name"notify"objenametime);
}
public function 
notifyServer(objenametime) {
  
scheduleEvent(0"ActionServerSide"objenametime);
}
public function 
clientFunction(fobjfnamefparams) {
  
temp.out 0;
  
  
client.temp.(@ "clientfunction_" fname) = null;
  
triggerClient("gui"name"clientfunction"fnamefparamsfobj);
  
waitForNotify(name"ClientFunctionEnd"5);
  
out client.temp.(@ "clientfunction_" fname);
  
client.temp.(@ "clientfunction_" fname) = null;
  return 
out;
}
public function 
clientFunction2(fobjfnamefparams) {
  
triggerClient("gui"name"clientfunction"fnamefparamsfobj);
}
function 
onActionServerSide() {
  switch (
params[0]) {
    case 
"notify":
      
makevar(params[1]).scheduleEvent(params[3], "Notify" params[2], null);
      break;
    case 
"serverfunction":
      
temp.0;
      
temp.fn params[1];
      
      if (
params[3] != null)
        
makevar(params[3] @ "." params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      else 
        
makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      
client.temp.(@ "serverfunction_" fn) = r;
      
notifyClient(name"ServerFunctionEnd"0);
      break;
    case 
"serverfunction2":
      if (
params[3] != null)
         
makevar(params[3] @ "." params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      else 
        
makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      break;
  }
}
//#CLIENTSIDE
function onActionClientSide() {
  switch (
params[0]) {
    case 
"notify":
      
makevar(params[1]).scheduleEvent(params[3], "Notify" params[2], null);
      break;
    case 
"clientfunction":
      
temp.0;
      
temp.fn params[1];
      
      if (
params[3] != null)
        
makevar(params[3] @ "." params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      else 
        
makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      
client.temp.(@ "clientfunction_" fn) = r;
      
notifyServer(name"ClientFunctionEnd"0);
      break;
    case 
"clientfunction2":
      if (
params[3] != null)
        
makevar(params[3] @ "." params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
      else 
        
makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
  }
}
public function 
waitForNotify(objactiontime) {
  return 
waitfor(obj"Notify" actiontime);
}
public function 
notifyServer(objenametime) {
  
triggerServer("gui"name"notify"objenametime);
}
public function 
notifyClient(objenametime) {
  
scheduleEvent(0"ActionClientSide""notify"objenametime);
}
public function 
serverFunction(fobjfnamefparams) {
  
temp.out 0;
  
  
client.temp.(@ "serverfunction_" fname) = null;
  
triggerServer("gui"name"serverfunction"fnamefparamsfobj);
  
waitForNotify(name"ServerFunctionEnd"5);
  
out client.temp.(@ "serverfunction_" fname);
  
client.temp.(@ "serverfunction_" fname) = null;
  return 
out;
}
public function 
serverFunction2(fobjfnamefparams) {
  
triggerServer("gui"name"serverfunction2"fnamefparamsfobj);



Angel_Light 06-02-2007 05:57 PM

i tried it with params and with attr, and I had no luck here's what I did both times.

params try:

in the class part:
PHP Code:

  setcharani"nir_baddy_idle"this.baddy.nick
               
this.baddy.hpthis.baddy.fullhp,
               
this.baddy.aggressor); 

In the gani this:
PHP Code:

SCRIPT
function onCreated() onTimeOut();

function 
onTimeOut() {
  
showtextthis.indexthis.x+2this.y+3,"Verdana""c",
    
params[0]);
  
showtextthis.index+1this.x+2this.y,"Verdana""c",
    
params[1] @ "/" params[2]);

  
changeimgzoomthis.index0.75);
  
changeimgzoomthis.index+10.75); 
     
if (
params[1] > params[1]/3
  
changeimgcolorsthis.index+10100.99);
if (
params[1] < params[1]/3)
  
changeimgcolorsthis.index+11100.99);
if (
params[1] < params[1]/6)
  
changeimgcolorsthis.index+11000.99); 

if (
params[3] == 0changeimgcolorsthis.index0110.99); 
if (
params[3] == 1changeimgcolorsthis.index1100.99); 
if (
params[3] == 2changeimgcolorsthis.index1000.99); 

setTimer(0.05);
}
SCRIPTEND 

in the attr try I did this

class part:
PHP Code:

    thiso.attr[1] = this.baddy.nick
  
thiso.attr[2] = this.baddy.hp
  
thiso.attr[3] = this.baddy.fullhp;
  
thiso.attr[4] = this.baddy.aggressor

Gani:
PHP Code:

SCRIPT
function onCreated() onTimeOut();

function 
onTimeOut() {
  
showtextthis.indexthis.x+2this.y+3,"Verdana""c",
    
thiso.attr[1]);
  
showtextthis.index+1this.x+2this.y,"Verdana""c",
    
thiso.attr[2] @ "/" thiso.attr[3]);

  
changeimgzoomthis.index0.75);
  
changeimgzoomthis.index+10.75); 
     
if (
thiso.attr[2] > thiso.attr[2]/3
  
changeimgcolorsthis.index+10100.99);
if (
thiso.attr[2] < thiso.attr[2]/3)
  
changeimgcolorsthis.index+11100.99);
if (
thiso.attr[2] < thiso.attr[2]/6)
  
changeimgcolorsthis.index+11000.99); 

if (
thiso.attr[4] == 0changeimgcolorsthis.index0110.99); 
if (
thiso.attr[4] == 1changeimgcolorsthis.index1100.99); 
if (
thiso.attr[4] == 2changeimgcolorsthis.index1000.99); 

setTimer(0.05);
}
SCRIPTEND 


Chompy 06-02-2007 06:04 PM

I would use Inverness' method


All times are GMT +2. The time now is 03:48 PM.

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