Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Random Event + Preceeding NPC

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Shadowiii
It's been real.




Joined: 14 Feb 2003
Posts: 2460

PostPosted: Tue Oct 07, 2003 6:55 am    Post subject: Random Event + Preceeding NPC Reply with quote

For those who know me, I suck at plotscripting, so I need a little help/advice...

1) In a game I'm making, I want an event to happen periodically throughout the game in certain maps. But the time when it happens needs to be random (to catch the player off guard). Basically, every say 15-60 seconds I want this 'event' to happen, then after its over game resumes as normal but the event can happen again every 15-60 seconds. I also want to avoid a timer in the corner, if possible. How might I pull this off?

2) Another question is having an NPC be always two spaces in front of the player when a certain item is being used (say, flashlight or gun with targeting system), except I dont' really know how to do this when turning left or right, or how to make it be able to turn on and off (say, by pressing "u" for use)


So yeah, all help is greatly appreciated. Thanks in advance.
_________________
But enough talk, have at you!
Back to top
View user's profile Send private message Send e-mail
Shadowiii
It's been real.




Joined: 14 Feb 2003
Posts: 2460

PostPosted: Tue Oct 07, 2003 6:57 am    Post subject: Reply with quote

Sorry for double posting, but another question...

In regards to the flashlight/gun crosshairs, say I wanted to have that NPC altered when I stood on something (say crosshairs faded out when I looked over a cliff, or the flashligh changed when I saw something). Could I have it so a NPC that you stand on alters that npc? And how would to change it back to the original when you stepped away?

Another thing is moving the 'light'. Can you change an NPC when a character is moving verses when they are standing? Just curious.

Thnx
_________________
But enough talk, have at you!


Last edited by Shadowiii on Tue Oct 07, 2003 7:05 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Minnek
Conjurer




Joined: 03 Jun 2003
Posts: 430
Location: Somewhere

PostPosted: Tue Oct 07, 2003 7:01 am    Post subject: Reply with quote

I'm not sure what to do with number one, but I can help you with number two. I'll work on a script to do that, and PM you it or something. Perhaps if you could provide a template for it or a more detailed example it'll be a bit easier to make, but none-the-less I'll help Big grin Let me know if you'd like to take me up on the offer. I'm not available on weekends, and as I can only use the computers here at my school, I cannot test my scripts I make. Just a word of caution Ha ha ha! Anyways, that'll be it. Sorry I couldn't help with number one, but I'll think on it Oookay...

Edit: Ah, for that second post of yours, I think I can help with that too...
_________________
* SDHawk has joined #Minnek
SDHawk> AAAAAAAAAAAAAUUUUUUUUUGH
* SDHawk has left #Minnek (Leaving)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Shadowiii
It's been real.




Joined: 14 Feb 2003
Posts: 2460

PostPosted: Tue Oct 07, 2003 7:53 am    Post subject: Reply with quote

Final question:

Ok, so far we've got a flashlight. After that, when you step on something (say, you 'see' something in the dark) the NPC alters. Now, is there away to check to see what direction you are facing and alter the flashlight NPC accordingly? Say, if the hero is facing north, alter npc to this but if he's facing east, alter npc to this?

Whoever answers all these question will have my highest gratitude, as well as be freakin' smart. Raspberry!
_________________
But enough talk, have at you!
Back to top
View user's profile Send private message Send e-mail
Mr B




Joined: 20 Mar 2003
Posts: 382

PostPosted: Tue Oct 07, 2003 8:52 am    Post subject: Reply with quote

That's all easy. Rolling Eyes *wink*

1.) Use a new game/load game script wi. this pseudocode:

while(1){
wait(random(15-20 seconds))
}

2.) This would require an On Keypress script. When the player presses a direction key, move the flashlight/target NPC and the hero. When 'u' is toggled, create/delete NPC.

3.) This would be a bit more difficult, but doable. The cliff...that would probably require checking to see what maptiles the light is on. If you step on/look at something, that would be a little different. Stepping on: have the stepped-on object call a script that changes the value of a given Global Variable -- probably with a generic script that is passed a value by the triggered NPC. After the global is changed, a script should be called to change the flashlight NPC to a different picture -- based on the value of the global.

When the player moves again, you want the flashlight to change back. This could be done by altering the on keypress script a tad by including a call to the script that was called by the script in the previous paragraph -- the script that changed the flashlight NPC based on the value of the global. This should change it back (though sometime in the process you should re-evaluate what the value of the global is).

An alternate method would to not have anything you step of call a script, and just have the on keypress script check tileblocks and look for NPCs on the tile the hero is standing on and where the flashlight is pointed. That's probably easier and better, if not necessarily more elegant.

4.) This is probably the easiest. In the on keypress script, just have a couple of lines that check which direction the hero is facing, and then alter the flashlight NPC accordingly.

Any of this help?
Back to top
View user's profile Send private message
Shadowiii
It's been real.




Joined: 14 Feb 2003
Posts: 2460

PostPosted: Tue Oct 07, 2003 9:24 am    Post subject: Reply with quote

In regards to what you said (thanks Mr. B! MWahaahaha)...

1. The flashlight is probably staying on the entire time, except during the random scene (its all coming together now...mwahaa). So, it woudl have to check not on keypress, but on the TILE which direction a hero is before altering the NPC.

2.
Quote:
An alternate method would to not have anything you step of call a script, and just have the on keypress script check tileblocks and look for NPCs on the tile the hero is standing on and where the flashlight is pointed. That's probably easier and better, if not necessarily more elegant.

::MR. B


Is it possible to check where a person is (and direction) every STEP and THEN check if the light is on? If so, that would be simply amazingly helpful.

Email me, man. Raspberry!
_________________
But enough talk, have at you!
Back to top
View user's profile Send private message Send e-mail
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Tue Oct 07, 2003 5:43 pm    Post subject: Reply with quote

Just add the herox(who), heroy(who), and the direction-chacking function (I think it's chack hero direction(who) or get hero direction(who), but check the Plotdictionary just to be sure) into an every-step script on the map (add the every-step script in General Map Data). Of course, this would result in the flashlight NPC only updating its position every step, so i would be kinda jerky, but this script is relatively small, and thus won't run the risk of a buffer overflow. If you wanted it to update constantly, you would have to run the whole thing as the map's startup code and check everything every tick, setting the NPC's PIXEL accordingly. This would seem to interfere with the random event script, but you could just add one to a variable every tick (all of this would be in a loop, by the way), and check every tick if the variable equals whatever random number of ticks you want. If the variable equaled the random number, it would run the random event code (simple if-then statement) and reset the variable.[/code]
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Oct 07, 2003 10:00 pm    Post subject: Reply with quote

A random event happens ever so now and then? By sheer coincidence, I had (or wanted) EXACTLY the same thing for my last years haloween game. I wanted a which to randomly fly over every couple of minutes, and then resume the game afterwards. And you want
Code:


variable (startmap, waitno)
startmap := currentmap
wait (40) # this is here so that the event doesn't occur the instant the map is loaded
while (current map == startmap) do (
 waitno := random (15, 60)
 wait (waitno)
 suspend player
 #something happens
 resumeplayer
 waitno := random (15, 60)
 wait (waitno)
)


replace 15, 60m with the minimum and maximum bounds on the wait amount. Just call this script as the autorun script on whatever maps you want it to run on. It will automatically stops when you change maps, unlike 'while (1)'.
Also, you shouldn't skimp on the quality of your scripts to save space in the script buffer. There's actually pently there, and you shouldn't run into it unless you have a whole lot of the scripts already loaded in the background.[/code]
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group