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 / Give Player an Item When an Entity Dies?

Author
Message
CrescentMoon
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location:
Posted: 6th Jun 2010 23:54
Okay I'm using a standard destroy script where the entity either drops a key or auto-gives the player a key on death.

Here's the death script so far:



obviously taken from the standard fadecorpse.fpi, I'm trying to edit it adding in whatever I need.

So any ideas on how to rework this script so I can either make the entity appear to drop an item or auto-give the player an item?

[WIP] Paranorma Chapter 1, The Forgotten Inn
Level 1 - In Progress
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 7th Jun 2010 01:44 Edited at: 7th Jun 2010 01:45
This was edited 5:45 pm.

The first thing that popped into my head was that the only thing that you could actually give the player through scripting is a weapon. For him to actually possess and use visually. Although there is a work around to give him a key that will unlock a door because the key and door are connected. The player is not included at all in that connection. Therefore it not necessary that the player actually has the key in his possession. There also may be a way to give the player a dynamic entity where he/she can then actually drop it later.

All of this is going to take some additional scripting plus making sure certain items are actually in the level so that they can be manipulated.

CrescentMoon
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location:
Posted: 7th Jun 2010 03:14
Well here's the only work around I've figured out so far o.o

1. Entity leaves behind a corpse until the player comes within a certain distance.
2. When the player comes within touching distance, the entity activates the key that I place somewhere in the level (maybe beyond a locked door)
3. When the key is activated, it enters the player's inventory (or w/e FPSC has right now, I'm sooo waiting for v1.17 to fully release this game)
4. The entity's death script fully activates and the entity fades out.

that's the only work around I could think of, but I was hoping there was another way. You know, applying the "watch your pennies and the dollars take care of themselves" theory to the game's memory usage.

[WIP] Paranorma Chapter 1, The Forgotten Inn
Level 1 - In Progress
The Storyteller 01
15
Years of Service
User Offline
Joined: 11th May 2009
Location: On a silent hill in dead space
Posted: 7th Jun 2010 03:42
You could also use a "destroyandactivate" script (to be put into the enemies "destroy" tab that spawns the item in the room where the monster is supposed to die.

It's crude but reliable.

In case you find my grammar and spelling weird ---> native German speaker ^^
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 7th Jun 2010 04:47 Edited at: 7th Jun 2010 05:30
Quote: "1. Entity leaves behind a corpse until the player comes within a certain distance."


Does the player kill the entity or does it die from another source somehow?

Quote: "2. When the player comes within touching distance, the entity activates the key that I place somewhere in the level "


This is the difficult part because once the entity is dead I believe that the entity's script no longer functions. However, if one sets "always active?" to yes the AI main script still might be active. At least I am assuming that would work. I have not tested that as yet.

EDIT #1:
I just tested it. I cannot get it to work with "keep active." There is another fpi that I am going to look at.
End Edit

EDIT #2:
Yes, this can work. You take out the "suspend" command. Here is the code.

When the player gets close to the corpse the key is spawned.

The following is when the key is spawned immediately upon the npc's death.

End Edit

Let's start with a simple way to do this. The corpse could either disappear or remain. I am using the leavecorpse.fpi for this example.

Place a key wherever you want the key to show up and set "spawn at start?" to no. Use whatever name you want but it will need to be used in the script. I kept the name of the key as "key". Character entities do not have an ifused parameter, therefore you have to do something that most people don't know about. Since it is not a simple parameter this could be considered the work around. Here is the script that will spawn the key.



CrescentMoon
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location:
Posted: 7th Jun 2010 18:08
Thanks for the help, it took me a bit of effort but I think I managed to get these scripts merged into effectively what I wanted. I guess a work around is the only way to do it ;/

Here's what I got and it seems to work:


and it's coupled with the Lobby_Key Script here:



[WIP] Paranorma Chapter 1, The Forgotten Inn
Level 1 - In Progress

Login to post a reply

Server time is: 2024-11-24 23:50:46
Your offset time is: 2024-11-24 23:50:46