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
  #16  
Old 02-03-2011, 09:48 AM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
Yeah I still can't get it to work. I have a custom bomb that explodes and when it explodes I want it to hit a switch that triggers something else. I'm just not sure how to send it...
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming
Reply With Quote
  #17  
Old 02-03-2011, 09:50 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
does this.gmap.blah work aswell so a variable can be pulled from anywhere on the gmap?
Reply With Quote
  #18  
Old 02-03-2011, 10:00 AM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
i don't really know... I do know that this.level works (Clientside) but with the bomb I would think that it would be easier to just add a trigger? or a public function (which I'm not completely sure i know how or what to do with besides placing in all npcs involved). Since the bomb is added via putnpc2, but I don't really know..
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming
Reply With Quote
  #19  
Old 02-03-2011, 05:05 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally Posted by ffcmike View Post
Strangest thing actually, I tried it myself and it seemed to be doing nothing at all despite all of my echo's suggesting it was working, I then reconnect to find that the NPC was indeed being hidden just for some reason this was not being sent to the player so it remained visible on my client, this is something Stefan should probably look into.

You can always just to this Clientside if this is a single player thing.
I've encountered that problem before. Try calling a function to force an update to all players. I think I used the move function without actually moving the npc. Just a hack, but it should work. Changing visibility should force the same update.... but it doesn't.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #20  
Old 02-03-2011, 05: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
Quote:
Originally Posted by adam View Post
I've encountered that problem before. Try calling a function to force an update to all players. I think I used the move function without actually moving the npc. Just a hack, but it should work. Changing visibility should force the same update.... but it doesn't.
You can just use this.trigger("RandomUnknownEventExample", ""); to force an update of an NPC and DB-NPC to save it's flags/values.

I noticed this behaivor when I called public functions which should have updated the NPCs X, Y or hid them but nothing would happen. Adding a trigger causes it to update to players.
__________________
Quote:
Reply With Quote
  #21  
Old 02-03-2011, 05:58 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura about
Send a message via AIM to adam
Sounds great, thanks.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #22  
Old 02-03-2011, 08:12 PM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
Still unsure of how that would work.. I haven't really worked with DB NPCs, and I can't seem to get that trigger to function correctly.. set it clientside and check severside right?
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming
Reply With Quote
  #23  
Old 02-03-2011, 11:22 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
A simple bomb demonstration and how to use getareanpcs.

class: bomb

PHP Code:
function onCreated() {
  
this.image "wbomb1.png";
  
// Set Timer to Go Off in a Few Seconds
  
setTimer(int(random(37)));
}

function 
onTimeout() {
  
// Explode Bomb
  
explodeBomb();
}

function 
explodeBomb() {
  if (!
this.exploded) {
    
// Set Flag to Prevent Double Explosion
    
this.exploded true;
    
// Trigger/Notify NPCs around it in a 4 tile square that it exploded
    
for (temp.ngetareanpcs(this.4this.488)) {
      
temp.n.trigger("ExplosionHit""");
    }
    
// Destroy Bomb
    
destroy();
  }
}

function 
onExplosionHit() {
  
explodeBomb();

class: block_explodable

PHP Code:
function onCreated() {
  
this.image "block.png";
}

function 
onExplosionHit() {
  
// Make sure Block hasn't Exploded
  
if (!this.exploded) {
    
// Set Image to Fire
    
this.image "g4_animation_fire.gif";
    
// Set Flag to Exploded
    
this.exploded true;
    
// Set Timer to Go Off in 3 Seconds
    
setTimer(3);
  }
}

function 
onTimeout() {
  
// Destroy the Fire
  
destroy();

Lay a bunch of them in a level using a level script or putnpc2:

Level script for bomb:

PHP Code:
function onCreated() {
  
this.join("bomb");

Level script for explodable block:

PHP Code:
function onCreated() {
  
this.join("block_explodable");

__________________
Quote:
Reply With Quote
  #24  
Old 02-04-2011, 01:39 AM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
Ok so that all works, but stil working with the bomb, and I want to trigger client now because the this.level.whatever doesn't seem to work serverside. Also it would require every player to use a bomb here.
PHP Code:
function onExplode() { 
  if (!
this.exploded) { 
    
this.image "door.png"
    
this.exploded true;
    
setTimer(3);
    
triggerClient("boom");
  } 

//#CLIENTSIDE
function onActionClientSide(cmd) { 
  if (
cmd == "boom") { 
  echo(
"working");
  
this.level.j.wasExploded(); 
  } 

__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming

Last edited by kingcj; 02-04-2011 at 01:40 AM.. Reason: sorry, meant to say that this isn't working as well and there is more script this is just the part that doesn't seem to work.
Reply With Quote
  #25  
Old 02-04-2011, 08:25 PM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
Sorry for the double post, but is it required to triggerserver to be able to triggerclient?
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming
Reply With Quote
  #26  
Old 02-04-2011, 08:34 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by Cubical View Post
does this.gmap.blah work aswell so a variable can be pulled from anywhere on the gmap?
bump
Reply With Quote
  #27  
Old 02-04-2011, 08:36 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
Quote:
Originally Posted by kingcj View Post
Sorry for the double post, but is it required to triggerserver to be able to triggerclient?
triggerserver allows you to send "messages" to the server from the client.

triggerclient allows the server to send "messages" to the client.

They aren't dependent on each other, so your script doesn't have to include both if they don't need to.
__________________
Quote:
Reply With Quote
  #28  
Old 02-05-2011, 04:14 AM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
ok so why won't this work?

PHP Code:
function onCreated() {
  
this.attr[1] = eswitch//switch name 
  
this.attr[2] = edoor//door name 
  
this.attr[3] = 3//hide time
  
this.image "block.png"


function 
onExplode() { 
  if (!
this.exploded) { 
    
this.image "door.png"
    
this.exploded true;
    
setTimer(3);
    
triggerclient(this.name"boom");
  } 


function 
onTimeout() { 
  
this.exploded false;
  
this.image "block.png"
}  

//#CLIENTSIDE

function onCreated(){ 
  
this.attr[1];
  
this.attr[2];
  
this.attr[3];
  
this.level.this
}

function 
onActionClientSide(cmd) {
  if (
cmd == "boom") {
    
this.chat "ClientSide works";
    
this.level.n.wasExploded();
  } 
}

public function 
wasExploded(){ 
  
this.hide(); 
  
sleep(o);
  
this.show();

onExplode is when the bomb explodes and it has a distance that it hits.
I just can't get the clientside to function correctly. This is a switch that when it explodes it sends the wasExploded() to do something in another npc in the same level. Maybe public function needs to be server side, but a different puublic function works fine in clientside with a touch switch?
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming

Last edited by kingcj; 02-05-2011 at 04:19 AM.. Reason: Sorry for the edit but I missed the this.attr[1]
Reply With Quote
  #29  
Old 02-05-2011, 04:27 AM
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
Only weapon scripts can receive messages from triggerclient.

Why not just hide and show on the server-side instead?
__________________
Quote:
Reply With Quote
  #30  
Old 02-05-2011, 04:37 AM
kingcj kingcj is offline
Registered User
kingcj's Avatar
Join Date: Apr 2006
Location: TN
Posts: 114
kingcj will become famous soon enough
Send a message via MSN to kingcj
this way everyone has to use a bomb to use the switch not just one person can hit the switch with the bomb and the rest get the effect.
So can I join this from a weapon script or is there another way to work around it?
__________________
Zie

"It is not necessary to change. Survival is not mandatory." - W. Edwards Deming
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 10:46 AM.


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