Jump to content

Photo

Detecting casings?

casings misc weapons script

  • Please log in to reply
4 replies to this topic

#1
PAPVAFS11

PAPVAFS11

    Enthusiast

  • Members
  • PipPip
  • 121 posts

I recently re-implemented junk rounds into the game and decided I'd make them more interesting by giving them a small chance to cause the weapon they're fired from to explode. I figured that the most versatile way to go about this would be to change the casing type for each junk round to a misc item with a script attached to it to handle explosion odds.

 

Unfortunately, the script won't fire when the "casing" is added to the player's inventory. It has to be dropped and picked back up for it to start running. I tried adding an OnAdd block to the script, but that doesn't seem to fire when the "casing" is first generated.

 

Is there any way I can inexpensively detect if the player has a casing item in their inventory and kickstart the script?



#2
Mktavish

Mktavish

    Pleb

  • Premium Member
  • 2,645 posts

Have you tried the "OnFire"  Begin block ?   Is that to expensive ?   But you would have to use a variable reference set to the current weapon equipped in order for the weapon fired to trigger an OnFire block.   That or script every weapon you want to have the problem of casings exploding.

 

The OnAdd block isn't going to be checking per round fired anyways .    But yes the OnAdd block has a problem with being detected through the object creation directly into inventory.



#3
Mktavish

Mktavish

    Pleb

  • Premium Member
  • 2,645 posts

Oh wait I'm stupid ... just use "IsControlPressed" in a gamemode block ... which would calculate the explode chance.

 

But putting this script on a perk ... and how you control the perk on/off ... is in the condition , use "GetItemCount  >= ? "   

In the Function Parameters select each item you want to check for , like 10mm rounds.   Hence you need to add a condition for each item.  Therefore at the end of each line ... you have to select the "OR" operator instead of the default "AND"

 

That means that your condition will be true if this or that or the other is in inventory ... instead of this and that and the other which is cummulative.   Just mentioning incase you didn't know :wink:


Edited by Mktavish, 22 October 2016 - 03:50 AM.


#4
PAPVAFS11

PAPVAFS11

    Enthusiast

  • Members
  • PipPip
  • 121 posts

I'd hoped to get away without using a GameMode block as I abuse them far too much as it is, but if that's the way it has to be, c'est la vie. Thanks for the help and sorry for the late response.



#5
Mktavish

Mktavish

    Pleb

  • Premium Member
  • 2,645 posts

Well the "OnFire"  block could still work if you don't want game mode checks going on.

 

I just felt it would be more extensive to set that up vs letting a game mode block checking for "IsControlPressed"sort it out for you. Since the equipped , then fired weapon has to have an object script on it using "Begin OnFire"

And not really sure if a reference can be used to trigger that block ... it's wording doesn't seem to suggest it's possible , but it's worth some testing I suppose.

 

For the game mode block ... try to keep as little as possible checking in it.  Like only 1 explode chance going on.  Which means you set up multiple scripts for all the different rounds , different explode chances.  And depending on what weapon gets equipped , it then turns this, that or the other specific game mode script on.







Also tagged with one or more of these keywords: casings, misc, weapons, script

Page loaded in: 1.083 seconds