Results 1 to 2 of 2
  1. #1
    turtleboy69's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    Thumbs up Assembly reflexil callvirt GetComponent<T>() ?

    Hey all, first off i'd like to mention that i'm new to IL editing!

    And here's what i'm trying to do in c#, taken from Gun.shootPlayer()

    Code:
    ...
    
    if ((limb == 5) && (user.model.GetComponent<Clothes>().vest != -1))
    {
    	num *= ArmorStats.getArmor(user.model.GetComponent<Clothes>().vest);
    }
    if (limb == 4) && (user.model.GetComponent<Clothes>().hat != -1)
    {
    	num *= ArmorStats.getArmor(user.model.GetComponent<Clothes>().hat);
    }
    if (user.model.GetComponent<Clothes>().hat == 0)
    {
    	num *= 0f;
    }
    
    ...
    pseudocode is; if the person getting shot is wearing fancy shades, the bullets do no damage.

    Red is existing code and green is what i would like to add, but when i add it (using reflexil), save and reload it ends up looking like this:

    Code:
    if (user.model.GetComponent().hat == 0)
    {
    	num *= 0f;
    }
    IL code is attached (not allowed to post link to imgur yet, sorry!)



    I mostly just took code from above it and tried to replicated it to my need, however i'm not sure if i picked the correct GetComponent, the one i pointed to was in UnityEngine\GameObject\GetComponent<T>() :T, but in the reflexil editor it shows up as GetComponent() : T

    Help is appreciated!

    EDIT: Figured it out, had to call GetComponent(type string), attached the updated IL code for anyone else who got stuck like i did



    Code:
    if (user.model.GetComponent("Clothes").hat == 0)
    {
    	num *= 0f;
    }
    Can i mark this as solved somehow?
    Attached Thumbnails Attached Thumbnails
    Knxxebd.png  

    itK65Ta.png  

    Last edited by turtleboy69; 08-10-2014 at 04:07 PM. Reason: Solved!

  2. #2
    Color's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    19,896
    Reputation
    2588
    Thanks
    7,864
    My Mood
    Lurking
    Moved to the correct section.

    Member Since 8/05/2012
    Editor 4/04/13 - 4/21/13
    Middleman 7/14/13 - 11/4/13

    Battlefield Minion 6/13/14-3/20/15
    Steam Minion 7/16/14-3/20/15

    Minion+ 10/1/14-3/20/15
    M.A.T. Minion 10/19/14-3/20/15
    ROTMG Minion 1/14/15-3/20/15

    Donator Since 2/26/15 (Thanks @Cursed!)
    Steam Minion 5/9/15 - 11/5/15
    OSFPS Minion 9/15/15 - 11/5/15


Similar Threads

  1. [Assembly Tutorial] Object-oriented assembly <FASM>
    By TrollerCoaster in forum Programming Tutorials
    Replies: 3
    Last Post: 01-02-2013, 09:53 AM
  2. Assembly Code pbcl
    By New11acc in forum Anti-Cheat
    Replies: 3
    Last Post: 06-04-2009, 12:19 AM
  3. In What Do you Code Assembly ?
    By apezwijn in forum Assembly
    Replies: 5
    Last Post: 08-11-2008, 10:47 AM
  4. I wanne start learning Assembly plz read.!
    By Niratsio in forum Visual Basic Programming
    Replies: 14
    Last Post: 10-31-2007, 08:05 AM
  5. Converting Assembly Into Bytes
    By radnomguywfq3 in forum Visual Basic Programming
    Replies: 0
    Last Post: 09-24-2007, 04:42 PM