public void OnMainGripGrabbed(RagdollHand interactor, Handle handle, EventTime eventTime)
        {
            if (interactor.playerHand == Player.local.handRight)
            {
                gunGripHeldRight = true;
            }
            if (interactor.playerHand == Player.local.handLeft)
            {
                gunGripHeldLeft = true;
            }

            if (!gunGripHeldLeft && !gunGripHeldRight)
            {
                if (isEmpty)
                {
                    ReloadWeapon();
                }
                thisNPC      = interactor.ragdoll.creature;
                thisNPCBrain = thisNPC.brain.instance;
                BrainBow     = thisNPCBrain.GetModule <BrainModuleBow>();
                BrainMelee   = thisNPCBrain.GetModule <BrainModuleMelee>();
                BrainParry   = thisNPCBrain.GetModule <BrainModuleParry>();
                thisNPC.brain.currentTarget = Player.local.creature;
                thisNPC.brain.isParrying    = true;

                BrainMelee.meleeEnabled = module.npcMeleeEnableOverride;
            }
        }
Esempio n. 2
0
 private static bool Prefix(BrainData __instance)
 {
     if (__instance != null)
     {
         return(!__instance.targetCreature.FreezeData().IsCreatureFrozen);
     }
     return(true);
 }
Esempio n. 3
0
        public void Initialize()
        {
            if (myRagdollPart)
            {
                NPC   = myRagdollPart.ragdoll.creature;
                brain = NPC.brain;


                foreach (RagdollPart part in NPC.ragdoll.parts)
                {
                    if (part.name == "Part_LeftHand")
                    {
                        leftHand = part;
                    }
                    if (part.name == "Part_RightHand")
                    {
                        rightHand = part;
                    }
                }

                if (module.choking)
                {
                    if (NPC.umaCharacter.GetSex() == UMAPreset.Sex.Male)
                    {
                        if (item.transform.Find("MaleChokeSFX"))
                        {
                            chokeSFX = item.transform.Find("MaleChokeSFX").GetComponent <AudioSource>();
                        }
                        else
                        {
                            Debug.Log("AudioSource not found");
                        }
                    }
                    else if (NPC.umaCharacter.GetSex() == UMAPreset.Sex.Female)
                    {
                        chokeSFX = item.transform.Find("FemaleChokeSFX").GetComponent <AudioSource>();
                    }
                    else
                    {
                        Debug.Log("NPC is neither male or female");
                    }
                }
            }
            else
            {
                Debug.Log("MyRagdollPart doesn't exist!");
            }
        }
        public void OnMainGripUnGrabbed(RagdollHand interactor, Handle handle, EventTime eventTime)
        {
            if (interactor.playerHand == Player.local.handRight)
            {
                gunGripHeldRight = false;
            }
            if (interactor.playerHand == Player.local.handLeft)
            {
                gunGripHeldLeft = false;
            }

            if (thisNPC != null)
            {
                thisNPC      = null;
                thisNPCBrain = null;
                BrainBow     = null;
                BrainMelee   = null;
                BrainParry   = null;
            }
        }
Esempio n. 5
0
 private void Start()
 {
     brainData    = ReadData();
     completePath = dataPrefix + brainData.dataType + "_" + brainData.dataIndex;
     Debug.Log(completePath);
 }
Esempio n. 6
0
        public void RunAndSaveData(BrainData data, CompleteData cData)
        {
            float[]               _input    = data.input;
            float[]               _hidden   = data.hidden;
            float[]               _output   = data.output;
            float[][]             _repition = data.repition;
            int                   wIndex;
            int                   repitionWIndex;
            ActivateNeuronFormula activeNeuronFormula;

            if (hidden.Length > 0)
            {
                int     lastNeuronAmount = 0;
                float[] wArray;
                float[] biasArray;
                float[] repitionWArray;
                for (int i = 0; i < hidden.Length; i++)
                {
                    wArray              = hiddenConnection[i].wArray;
                    biasArray           = hidden[i].biasArray;
                    activeNeuronFormula = hidden[I].activeNeuronFormula;
                    float[] io_;
                    int     io__;
                    if (i == 0)
                    {
                        io_  = input;
                        io__ = input.Length;
                    }
                    else
                    {
                        io_  = _hidden;
                        io__ = lastNeuronAmount;
                    }
                    if (hidden[i].repition == true)
                    {
                        float[] irep = _repition[i];
                        repitionWArray = repitionConnection[i].wArray;
                        Array.Copy(irep, cData.repitionBuffer[i], irep.Length);
                        wIndex         = 0;
                        repitionWIndex = 0;
                        int k = biasArray.Length;
                        while (k-- > 0)
                        {
                            float kbia = biasArray[k];
                            int   j    = io__;
                            while (j-- > 0)
                            {
                                kbia += io_[j] * wArray[wIndex++];
                            }
                            j = irep.Length;
                            while (j-- > 0)
                            {
                                kbia += irep[j] * repitionWArray[repitionWIndex++];
                            }
                            _hidden[k] = activeNeuronFormula(kbia);
                        }
                        Array.Copy(_hidden, irep, biasArray.Length);
                    }
                    else
                    {
                        wIndex = 0;
                        int k = biasArray.Length;
                        while (k-- > 0)
                        {
                            float kbia = biasArray[k];
                            int   j    = io__;
                            while (j-- > 0)
                            {
                                kbia += io_[j] * wArray[wIndex++];
                            }
                            _hidden[k] = activeNeuronFormula(kbia);
                        }
                    }
                    Array.Copy(_hidden, cData.buffer[i], biasArray.Length);
                    lastNeuronAmount = biasArray.Length;
                }
                activeNeuronFormula = output.ActivateNeuronFormula;
                wArray         = outputConnection.wArray;
                biasArray      = output.biasArray;
                wIndex         = 0;
                repitionWIndex = 0;
                int i = _output.Length;
                while (i-- > 0)
                {
                    float ibia = biasArray[i];
                    int   k    = lastNeuronAmount;
                    while (k-- > 0)
                    {
                        ibia += _hidden[k] * wArray[wIndex++];
                    }
                    _output[i] = activeNeuronFormula(ibia);
                }
            }
            else
            {
                activeNeuronFormula = output.ActivateNeuronFormula;
                float[] wArray    = outputConnection.wArray;
                float[] biasArray = output.biasArray;
                wIndex         = 0;
                repitionWIndex = 0;
                int i = _output.Length;
                while (i-- > 0)
                {
                    float ibia = biasArray[i];
                    int   k    = _input.Length;
                    while (k-- > 0)
                    {
                        ibia += _input[k] * wArray[wIndex++];
                    }
                    _output[i] = activeNeuronFormula(ibia);
                }
            }
        }
 private static bool Prefix(BrainData __instance)
 {
     return(!Instance.IsTimeFrozen);
 }