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 Product Chat / Enemy drops item when died

Author
Message
TIMON
14
Years of Service
User Offline
Joined: 28th Aug 2011
Location: France
Posted: 20th May 2012 02:25
Hi
How to make an enemy drops an item when he dies??

Thanks
Troutflies
15
Years of Service
User Offline
Joined: 24th Feb 2011
Location: Stuck outside my map.
Posted: 20th May 2012 08:27 Edited at: 21st May 2012 01:35
Well the way I've done it in the past is change the entity that's going to die destroy script to destroy and activate. Add the name of the item to be dropped in the ifused field. Place the item where you want it to be dropped. Change the spawn at start field to no And be sure to rename it to whatever you put in the ifused field.
TIMON
14
Years of Service
User Offline
Joined: 28th Aug 2011
Location: France
Posted: 20th May 2012 23:39
But I want the item to be dropped appears in the same square where the enemy dies
Flatlander
FPSC Tool Maker
19
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 21st May 2012 07:59 Edited at: 21st May 2012 08:22
Quote: "But I want the item to be dropped appears in the same square where the enemy dies"


That's the difficult part and I don't think it's possible.

Having the player drop something is possible but not an NPC.

Addendum:

We have a start because we can find out where the NPC is when he dies by using the internal variables, $EPX, $EPY, and $EPZ. I at least think we can have that information. But next we have to figure out a way to move an entity to that position. First the entity has to be in the map somewhere. You can either hide it or have it invisible. Best way is to hide it perhaps. Then we need to move it to the NPC's position. I don't think there is a scripting command to do that.But, I'm not sure yet. It would probably have to be modded.

Addendum #2:

Yes, I'm sure someone would have to create commands to move the entity that is to be dropped. We would know the name of the entity, find it in the entity element list by it's name. Then perhaps using that entity elements x, y, and z it can be changed to match the NPC's position. However, I'm not sure that this would automatically move the entity to the NPC's position. There might be more code that needs to be executed.

So, none of this is in the scripting langauage. This would all have to be created in the FPSC engine as individual scripting commands. Anyone game? :LOL:

"A programmer is just a tool which converts caffeine into code . . . reminds me….. if I had one more brain cell, I could have a synapse! woo hoo, Sparky!

~I'm the Terry of the Flatlands.
Ched80
15
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 21st May 2012 08:45
I think this mechanic should be possible with scripting in v120. Currently the setvar= command does not work with entity location ($EPX, etc), but I've seen a statement that says this is fixed within v120.

Flatlander
FPSC Tool Maker
19
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 21st May 2012 08:56
Thanks for reminding me Ched80.

I forgot that I have the fix already in RPG EdMod. So, once v120 is released in beta it will work. As far as the rest goes. . .

I might play around with the easiest part of it and if it requires more work -- just doesn't work right away -- then I'll probably forget it.

"A programmer is just a tool which converts caffeine into code . . . reminds me….. if I had one more brain cell, I could have a synapse! woo hoo, Sparky!

~I'm the Terry of the Flatlands.
Anigma
15
Years of Service
User Offline
Joined: 25th Mar 2011
Location:
Posted: 22nd May 2012 22:49
Easiest way is to make sure the enemy you want to "drop" the item doesn't move. No reason why he can't just stand there and shoot at you while his buddies run around and try to kill you. Then you just use the method described by Troutflies and Robert's your father's brother. Most players won't notice and fewer still would care. Lots of games have NPC's that just stand there and shoot at you.

It compiled! Ship it!
The Storyteller 01
17
Years of Service
User Offline
Joined: 11th May 2009
Location: On a silent hill in dead space
Posted: 23rd May 2012 00:57
Or you use the old workaround to have the desired item in a small cell whith a locked door, that becomes unlocked or automatically opens after the NPC has been killed.

In case you find my grammar and spelling weird ---> native German speaker ^^
JD2
16
Years of Service
User Offline
Joined: 13th Feb 2010
Location:
Posted: 23rd May 2012 03:30
Quote: "Flatlander - This would all have to be created in the FPSC engine as individual scripting commands."

If the source code needs to be modified to make this happen (and it looks like it does), a more easily usable solution than relying on custom FPI scripting would be to modify the FPE schema for character entities to have "hasitem" and "cantakeitem" properties similar to "hasweapon" and "cantakeweapon". The code to do this for the NPC weapon could simply be reused for this holdable/dropable item. And unlike the weapon, this holdable item doesn't have to be spawned and rendered until it is actually dropped, so it wouldn't waste resources. It just would be defined.

I would really like to see this functionality added to the official release of FPSC because having NPC's drop items is a staple of classic FPS gameplay.
Marc Steene
FPSC Master
20
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Bahrain
Posted: 31st May 2012 21:10
This script should work with v1.20:

Key Script

:state=0:dimvar=tempx,dimvar=tempy,dimvar=tempz,hide,state=1
:state=1,activated=1:show,setvar=$EPX %tempx,setvar=$EPY %tempy,setvar=$EPZ %tempz,state=2
:state=2,plrdistwithin=40:playertake,destroy

Enemy Destroy Script (Set IfUsed to Key Name)

:state=0:setvar=tempx $EPX,setvar=tempy $EPY,setvar=tempz $EPZ,activateifused=1 (then suspend, coloff etc)


Official LightStorm Engine BETA Tester
/?m=forum_view&t=190541&b=21

Login to post a reply

Server time is: 2026-07-03 15:30:53
Your offset time is: 2026-07-03 15:30:53