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 / Has anyone used the "currentweapon" condition?

Author
Message
ncmako
12
Years of Service
User Offline
Joined: 19th Feb 2012
Location: Hendersonville,NC
Posted: 11th Dec 2012 17:18 Edited at: 11th Dec 2012 17:21
Trying to use Flashlight when a weapon is being used.
I'm using 1.20 beta6. I haven't had any luck in getting currentweapon=x to return true. Basically I forced a weapon to slot#2.(really any slot) Then placed this into a trigger.

Been trying alot of different combinations in the code.This one the light comes on, but stays on.

Any help in the right direction would be great.
Corno_1
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 11th Dec 2012 19:24 Edited at: 11th Dec 2012 19:25
First in beta 6 currentweapon is now plrcurrentweapon=
and you must switch the flashlight off

now it should work

you need a script? I need useful requests at the moment!
http://forum.thegamecreators.com/?m=forum_view&t=200918&b=23
ncmako
12
Years of Service
User Offline
Joined: 19th Feb 2012
Location: Hendersonville,NC
Posted: 11th Dec 2012 21:15 Edited at: 11th Dec 2012 21:16
A big thank you Corno_1.
I tried it out,and it wants to work, but for some reason my frame rates drop to 2fps? Was 80-90fps.(entity logic goes thru the roof).
Your script makes sense. By chance,has the :weapontoslot=X also changed? That's the action I'm using.
Corno_1
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 12th Dec 2012 17:13
Quote: "By chance,has the :weapontoslot=X also changed?"

please post the script here other way i can not say!

So i test it and i see this entity logic problem too! But all work arrounds are not working for me, but try it yourself:


you need a script? I need useful requests at the moment!
http://forum.thegamecreators.com/?m=forum_view&t=200918&b=23
ncmako
12
Years of Service
User Offline
Joined: 19th Feb 2012
Location: Hendersonville,NC
Posted: 12th Dec 2012 17:59 Edited at: 12th Dec 2012 18:01
Hi Corno_1 Thanks for testing this. I looked at all the script Syntax lists and couldn't find "plrcurrentweapon" only "currentweapon"? Tried both ways,nothing works. Right now I'm testing if it works with something like posteffects-nightvision, but does not seem to be?
Here's the script I used to force weapon to slot 2.

This is working just fine.

EDIT: I getting a feeling "currentweapon" is not returning a true condition?
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 13th Dec 2012 01:38
BTW, did you know this?

Quote: "Updated command to now accept names. E.g.

plrcurrentweapon=www2/colt45"


If the player is holding this weapon then it will return true. It does work. You have to include the full weapons path from gamecore/guns.

THEORY - you know everything but nothing works. PRACTICE - when everything works but don't know why. For me, theory and practice are combined: nothing works and I don't know why.
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 13th Dec 2012 06:49
Quote: "Updated command to now accept names. E.g.

plrcurrentweapon=ww2/colt45"

Fixed that for you

-TZK

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 13th Dec 2012 17:08
@corno_1

Your code:



We need to understand that the game engine is a loop. It has to continually loop through level code so that it can execute all the commands that are currently needed which is determined by the scripts. It also has to look a the physics, the re-positioning of the player and the characters as well as any of the animation and culling.

The script you have given executes two states and the second state contains actually two commands -- the same command. However, both states executes the same command: plrcurrentweapon. So, for every iteration of the game engine loop these commands are executed at least once if not twice. This is called a continuous loop for this command.

As I elsewhere to ncmako, you cannot have this in a continuous loop like this without it effecting the resources and in particularly the FPS. Now, you mentioned that plrhealthless or plrhealthgreater does not do this. That is true. You see, it depends on what the command has to do in order to check the conditions. The latter commands are simple checks of a variable that is already present that contains the current player's health. However, the plrcurrentweapon command has to go through extensive logic to find if the player is actually holding the weapon.

In other words, if you want to find out if the player's health is less than a certain value then the value given for the condition is compared to the players health. The player's health is already kept track of in a variable so it doesn't have to find this information out each time the command condition was called. If it did it probably would cause a problem with FPS as well.

This is why "plrcurrentweapon" does have this problem. Each time the command is called, then two major things happen. First, it has to find what weapon the player has. There are at least two separate subroutines that has to be executed and possibly three to find this out. Every time a subroutine is executed at during a compare like this brings the FPS down. Then after if finds the index of the gun, a comparison can be made, however, it has to go through each slot - there are nine - for the check.

So, this condition is not a good one to have executing with every loop the game engine has to perform.

Since English is not your primary language I have to apologize for the lengthy explanation. However, there is no other way in order to prove my point that it just doesn't work well under those conditions.

THEORY - you know everything but nothing works. PRACTICE - when everything works but don't know why. For me, theory and practice are combined: nothing works and I don't know why.
ncmako
12
Years of Service
User Offline
Joined: 19th Feb 2012
Location: Hendersonville,NC
Posted: 13th Dec 2012 17:37
@Flatlander
I agree, keep it here for now.
BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 13th Dec 2012 17:37 Edited at: 13th Dec 2012 17:39
Just want to demonstrate how we use the command. Reminder since I am in v1.17 and still have my condition as "currentweapon=x", my results may differ from newer versions. I also have the "internal" flashlight feature.

We have three triggers placed, each with a script that controls a torch, blue glowstick, and a green glowstick. As the player collects each item, I can switch and the light changes according to what "currentweapon" is being called. The scripts also check to ensure that weapon is in my inventory before continuing.

Here is an example video concept we had started a while back to show it in action.



The scripts I used to make this work effectively are as follows:

torch script (attached to a trigger on the map)



glowstick (blue) script (attached to a trigger on the map)



glowstick (green) script (attached to a trigger on the map)



So the torch is the "currentweapon=1", the blue glowstick is "currentweapon=2", and the green glowstick is "currentweapon=3". The key is making sure that the weapons go in the correct slot. If the torch script ends up in slot 3, then obviously my torch will not work. Even though my command does not have the "plr" in front, the command is still the same and works the same as the "plrcurrentweapon".


There's no problem that can't be solved without applying a little scripting.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 13th Dec 2012 18:02 Edited at: 13th Dec 2012 18:03
Blackfox's code does not put the command currentweapon into a perpetual loop. It is only executed when the torch is turned off.

I talked to Lee about using my code from RPG Mod as it is coded more efficiently. I've had this as a command from just about day one of RPG Mod. However, it went through a couple of modifications to where it works very well now and doesn't matter if it goes into a perpetual loop or not.

Because it is not a bug, Lee didn't want to change the code at this point. He is planning on getting Beta 7 out today or tomorrow because, he is sure that this will be the final beta. In fact, he may be compiling it as an official release right now. He's anxious to do this because he wants to be sure and start work on Reloaded the first of January without having to worry about the old FPSC. This means you have to find a way to do this using it in such a way as Blackfox has suggested or at least shown.

I did test both scripts by ncmako and corno_1. Yes, my FPS went from 140 to 8.

Another solution is for me to modify the source replacing the code FPSC has with what I have in RPG Mod so you can use it. I have taken ncmako's script and used my command -- rpg_playerhasthisweapon -- instead. My command works great and I still get 140 FPS. The only modification would be for that command and nothing else.

THEORY - you know everything but nothing works. PRACTICE - when everything works but don't know why. For me, theory and practice are combined: nothing works and I don't know why.
Corno_1
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 13th Dec 2012 18:18
@ flatlander and black fox
thanks for this! I did not know much about the source code, so this explanation is what i needed! I also understand everything what you write, so dont worry. Maybe i should work a little bit with the source.

All in all: THANKS!!!

you need a script? I need useful requests at the moment!
http://forum.thegamecreators.com/?m=forum_view&t=200918&b=23
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 13th Dec 2012 18:24
Corno_1, if you have access to the source and can compile your own mod, I'll be glad to give you my code for plrcurrentweapon (what I call rpg_playerhasthisweapon. I'll email it to you. Just let me know here.

THEORY - you know everything but nothing works. PRACTICE - when everything works but don't know why. For me, theory and practice are combined: nothing works and I don't know why.
ncmako
12
Years of Service
User Offline
Joined: 19th Feb 2012
Location: Hendersonville,NC
Posted: 13th Dec 2012 18:39
@BlackFox Very nice, love the glow sticks.
Thank you all for the input and help so far.
What I'm doing is I modeled a lantern, then attached the stock hands. Turned it into a weapon, so when the lantern is pulled up the "FlashLight" comes on.If another weapon is drawn it goes off.My work around is to just have the Flashlight keyed with the basic FlashLight script.
ncmako
12
Years of Service
User Offline
Joined: 19th Feb 2012
Location: Hendersonville,NC
Posted: 15th Dec 2012 15:54 Edited at: 15th Dec 2012 18:10
Quick update: Finally got the "plrcurrentweapon" to work properly.
Turns out it was just a simple typo.

@Flatlandero you remember posting this from google code?
Quote: ""Updated command to now accept names. E.g.
plrcurrentweapon=ww2/colt45""

Thanks to Blackfox posting his scripts I realized we were using a foreslash instead of a backslash.
This works perfect now.

FlashLight now comes on/off without a keycode.

Script without plrwithinzone.

One final question? Should I end this script going to state=0,or can I leave it at state=1? It seems to work fine.
BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 15th Dec 2012 16:01
Quote: "Thanks to Blackfox posting his scripts I realized we were using a foreslash instead of a backslash."


You are welcome. Sometimes it is easier for me to post my scripts. This helps people to see just how to do it, and they can alter/pick apart/use whatever we post. It is not like a trade secret, we just like to "pass the knowledge". I've done the forward slash instead of a back slash too sometimes, or in larger scripts I've had a semi-colon instead of a colon. It happens to the best of us.


There's no problem that can't be solved without applying a little scripting.

Login to post a reply

Server time is: 2024-11-23 17:06:28
Your offset time is: 2024-11-23 17:06:28