Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Global variables? Any idea?

Author
Message
wetekom
17
Years of Service
User Offline
Joined: 7th Jun 2007
Location:
Posted: 7th Jun 2007 17:03
I have been searching in all kinds of places (this forum, FAQs, Hints'n'Tips, Tutorials...), but I cannot find a clue to answer a question which should be very obvious if you want to program a good game. The question is: How can something like "global variables" be achieved?

Here is what I want to do: The player meets an NPC (any character), and this NPC will react, e.g. by starting a dialog. (I can do this easily by FPI scripting.) However, I want the NPC's reaction be different depending on the player's previous actions. For example, I imagine the following logic:

- Player meets NPC
- If player has found item XY, NPC reacts by saying some text
- If player does not have item XY, NPC reacts differently.

This could easily be done by using "global variables", like a "state" variable that is not local to a FPI script but can be used in all FPI scripts. However, FPSC does not seem to have that kind of "in-game memory" - which seems to be essential for a good in-game logic.

Does anybody have a clue?
tyrano man
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location: Battle City - Kalspher :)
Posted: 7th Jun 2007 20:17
nope no variables ingame apart from health and lives. A real shame really.

xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 7th Jun 2007 20:19
We've been asking for them at each update, but to no avail. Maybe next time.

best.

I'm sorry, my answers are limited. You must ask the right question.

wetekom
17
Years of Service
User Offline
Joined: 7th Jun 2007
Location:
Posted: 7th Jun 2007 23:06
That's a shame! I've been thinking... could the following idea work?

Instead of creating 1 NPC I could create 2 NPCs that are equal except for the FPI script. The level starts with NPC no.1 present, having the "standard reaction". Now, when the player gets the item, NPC No. 1 is deleted and NPC No. 2 spawned instead. (They both look alike, so the player will not notice the difference.)

However, there still are many questions:
1) How to destroy NPC No. 1 when taking the item?
2) How to spawn NPC No. 2 at the same position?
3) How to find out that the player has taken the item? .....

What do you think about this idea? (I'm not that experienced yet, so I have my doubts if this could actually work.)
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 8th Jun 2007 05:59 Edited at: 8th Jun 2007 06:00
Quote: "
- Player meets NPC
- If player has found item XY, NPC reacts by saying some text
- If player does not have item XY, NPC reacts differently.
"


Used activated states to know what to say...

Object 1 picked up then activateifused=1

If activated=1 then say some text
If activated=0 then react differently

No need for a variable in this case.
The character gets activated becasue it is named in the ifused of the object.

Edit
For more responses try activateifused=2, activateifused=3, etc.

Don't forget to visit Conjured Entertainment
wetekom
17
Years of Service
User Offline
Joined: 7th Jun 2007
Location:
Posted: 8th Jun 2007 07:59
Conjured Entertainment,
I wasn't aware of this simple possibility (shame on me ). I just tested your solution and it works great! Thanks a lot for your help!

Wouldn't it be possible to generally use this mechanism to store some kind of "global variables" in (invisible) dummy entities? Is it possible to have various activated states, like "if activated=2"? And is it be possible to "read" the activated state of some entity in other scripts? (I guess not, as scripts are only local...)

Again: thank you very much!
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 8th Jun 2007 16:27
With global variables we could make team based Multiplayer games, maybe even CTF.

E.D.

xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 8th Jun 2007 18:12
@Conjured Entertainment,

Nice.... thanks for that.

Best.

I'm sorry, my answers are limited. You must ask the right question.

Butter fingers
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 8th Jun 2007 19:12
OR you could make the object you must find a key, that way you can run plrhaskey in the NPCs script,

wetekom
17
Years of Service
User Offline
Joined: 7th Jun 2007
Location:
Posted: 9th Jun 2007 07:20
@Butter fingers

I tried that first. Did not work for me - I think that's because a character entity does not have the "use key" property. The plrhaskey therefore never had any effect.

I tried "plrhaskey=1" in the script, but as the script doesn't know which key to look for, the condition was always false.

Did I miss something? Why does a character entity not have the "AI Automated" properties?

Login to post a reply

Server time is: 2024-11-23 18:17:53
Your offset time is: 2024-11-23 18:17:53