Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Game Control (https://forums.graalonline.com/forums/showthread.php?t=23220)

lordhelmut 02-07-2002 06:48 AM

Game Control
 
I am making a game where there are 2 buttons. when a player grabs one it sets focus on a area and they control one of the 2 NPCs inside there.

My code so far looks like this...

// NPC made by Lord Helmut
if (created) {
x+=.4;
y+=.7;
}
if (playertouchsme&&keydown(6)) {
setstring server.axegameplayer,#a;
setfocus 31,28;
disabledefmovement;
playersprite=19;
say2 Do you want to play?;
timereverywhere;
}

Thats the code so far for the button. For some reason u have to hold A and run at it to get it to work LOL.

// Graal2002 NPC by Stefan Knorr
if (created) {
showcharacter;
setcharprop #3,head0.png;
setcharprop #C0,orange;
setcharprop #C1,white;
setcharprop #C2,blue;
setcharprop #C3,red;
setcharprop #C4,black;
setcharprop #2,noshield.gif;
dir = 3;
}
if(timeout){
tokenize #s(server.axegameplayer);
if(strequals(#a,#t(1))){
if(keydown(3)){
x+=5;
timeout=.05;
}
timeout=.05;
}
}

Thats the character NPC. I want it so it can be controlled by the player touching to button but its not working for some reason

LiquidIce00 02-07-2002 07:37 AM

is setfocus allowed??
no1 ever answered my Q about that.

lordhelmut 02-07-2002 07:40 AM

yes u can use setfocus on free PWs. Can you tell whats wrong with that code so far?

Saga2001 02-07-2002 07:42 AM

Re: Game Control
 
Quote:

Originally posted by lordhelmut
// Graal2002 NPC by Stefan Knorr
look hes lying STEFAN MADE IT!!!
lol sorry, i am joking...lol. (conspiracy i think...)

Faheria_GP2 02-07-2002 07:51 AM

lmao, he used the predefined showchar :D

lordhelmut 02-07-2002 08:38 AM

Quote:

Originally posted by Faheria_GP2
lmao, he used the predefined showchar :D
isnt there some command u can use to set the look of the NPC to that of a player? rather than setting each individual piece to the same?

lordhelmut 02-07-2002 08:42 AM

Does anyone have any idea how to fix this? Also would triggeraction work for detecting if one NPC hits the other?

Python523 02-07-2002 08:50 AM

Quote:

Originally posted by lordhelmut
yes u can use setfocus on free PWs. Can you tell whats wrong with that code so far?
You could use setfocus but are you ALLOWED to? At first I thought setfocus was going to be Newworld only then it got added into the exe when 2k2 came out, where did you here that you could use it?

lordhelmut 02-07-2002 08:58 AM

YES U CAN USE IT! LORIEL SAID ITS ALLOWED ON FREE SERVERS AND HES GM AND HE KNOWS AND YES IT IS I TELL YOU SO DONT ASK AGAIN.

LOL, any other questions?

Falcor 02-07-2002 08:59 AM

I deosnt matter now, sadly it was released withought consent from the new world staff, seeinga s how hey were jipped with 2k2 taking thier EXE and all, methinks the fetures will just be plucked away one by one until NW is just another Player World.

TDK_RC6 02-07-2002 09:46 AM

is this like robot wars or something??

lordhelmut 02-07-2002 09:57 AM

1 Attachment(s)
Axe wars

see...

TDK_RC6 02-07-2002 10:05 AM

first off, the character npc doesnt have a part that calls the timeout in it, so it wont work at all

Lomgren 02-07-2002 10:32 AM

1 Attachment(s)
Hmm... why does that look familiar?
*remembers*
Oh yeah!

dragoonvenganc 02-07-2002 10:43 AM

well just woundering is there a point to tokenizing the string.. why not just put the string in the if statment..

and ya the time out..

nyghtGT 02-07-2002 12:06 PM

Quote:

Originally posted by lordhelmut


isnt there some command u can use to set the look of the NPC to that of a player? rather than setting each individual piece to the same?

NPC Code:

NPC Code:

if (playerenters||created) {
for (i=0;i<5;i++) {
setcharprop #Ci,#Ci;
}
}




not sure about the syntax though but it would work
something like that ...

TDK_RC6 02-07-2002 08:14 PM

you might have to do this

NPC Code:

if (playerenters||created) {
for (i=0;i<5;i++) {
setcharprop C#v(i),C#v(i); }
}



i think that would work

Falcor 02-07-2002 10:27 PM

I think graal handles Real input literally. so you are trying to set the player prop of

#C#v(i) instead of #C0-4 =\

Kadar 02-07-2002 10:39 PM

bah i was gonna make something like this for whatever im working on..
ohwhell :(

Saga2001 02-08-2002 01:03 AM

Quote:

Originally posted by Kaimetsu
People, please learn about compilative processes. Variable names don't matter - they just provide a way for us humans to tell the computer what we want. They don't exist when the script is running so you can't tell it to select different vars based on runtime-encoded names.
it makes sence, but it is hard for people to understand, they think that after they type in the code it stays in that form and it gets directly read, but actually like with html it is "compiled" by graal, as html gets "compiled" by netscape or IE or whatever u use. So it is not in the form you see it as. What you name something doesn't matter and the name of #C0 doesn't either. So what i think he is saying if i am correct is that #C#v(i) will not work because if gets read as a message code so instead of being read as #C0 if i == 0 it reads directly as #C#v(i).

lordhelmut 02-08-2002 03:55 AM

Quote:

Originally posted by TDK_RC6
first off, the character npc doesnt have a part that calls the timeout in it, so it wont work at all
the button has a timereverywhere

and I didnt know about Tyhms game. Thats cool though cuz now I do know its possible =D

TDK_RC6 02-08-2002 04:29 AM

Quote:

Originally posted by lordhelmut


the button has a timereverywhere

and I didnt know about Tyhms game. Thats cool though cuz now I do know its possible =D


timereverywhere doesnt call timeouts in other npcs, well atleast i dont think so

lordhelmut 02-08-2002 04:48 AM

Quote:

Originally posted by TDK_RC6


timereverywhere doesnt call timeouts in other npcs, well atleast i dont think so

It should, it does a timeout for the whole level

Lomgren 02-08-2002 08:27 AM

I'm not sure, but I think timeout is local, the only thing I know about timeouts on this level is what is in the npcprogrammng.rtf
Quote:

5.4. timeouts/ sleep command

To do animations or movements, you can use the 'timeout' variable.
If you set the timeout to 1sec, then after one second a 'timeout' event occurs and the npcs action script will be called with the flag 'timout' set. To show how it works, here a little example:

if (playerenters) timeout = 1;
if (timeout) {
x += 0.5;
timeout = 1;
}

If an npc has that script, then every second it moves 0.5 fields to the right:
1. When the player enters the level, the script will be called with the 'playerenters' flag set
2. So the timeout will be set to 1 (1 second)
3. The game counts the timeout down to 0
4. After 1 second the script will be called again, this time with the 'timeout' flag set
5. So the x variable will be increased and the timeout will be set again to 1
6. continue with step 3.
If you don't set the timeout again, then the timeout event will not occur again.

You can do the same stuff with the ‘sleep’ command:

if (playerenters) {
while (1==1) {
sleep 1;
x += 0.5;
}
}

When doing ‘sleep’, then the script execution will be paused for 1 second. So in this example the npc will forever do a while loop, in this loop the npc ‘sleeps’ 1 second, then moves to the right, then sleeps 1 second, then moves to the right and so on. Internernally the ‘sleep’ command only uses the ‘timeout’ variable: it sets the timeout variable, then when the ‘timeout’ event occurs the script execution will be started one line behind the ‘sleep’ command. If you change the timeout variable while doing ‘sleep’ (e.g. when another event occurs), then the next timeout event will start with the first script line, so be patient with changing ‘timeout’ while another animation loop may be running.

5.5. timeouts in online mode

In the online mode normally only the player who entered the level first (of all players in the current room) is getting timeout events. With ‘timereverywhere’ you can enable timeout events for all players: it enables the current player to get timeout events, so you should do it while processing the ‘playerenters’ event.
But if you want to do animations or movements you should only change the npc properties on one machine, otherwise you produce too much network traffic and strange npc movements. So check if ‘isleader’ is true. That flag is only true when the player is the one who entered the level first and would always get timeout events.
:megaeek:

lordhelmut 02-08-2002 09:53 AM

Umm that basically says what I said. It does a timeout for everwhere online in that level...

dragoonvenganc 02-08-2002 10:31 AM

lol..
timereverywhere just makes it so that every player gets the timeout instead of just the leader getting the time out..

lordhelmut 02-08-2002 10:49 AM

Quote:

Originally posted by dragoonvenganc
lol..
timereverywhere just makes it so that every player gets the timeout instead of just the leader getting the time out..

oh so its for all players but not all NPCs?

TDK_RC6 02-08-2002 11:06 AM

that would be correct

timereverywhere for all people in level, not all npcs

lordhelmut 02-08-2002 11:34 AM

so then how may I ask would controlling a NPC be possible from a certain area? Loriel did it on Londeroth


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

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