+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: different "fire modes" in e2?

  1. #11
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: different "fire modes" in e2?

    NONONONONONO, do not listen to the wolf!
    That code is horrible!, here lemme fix it a bit. Edit soon.

    EDIT (later than I thought):

    Ok, so a problem with how keyAttack works made this become finished later than I thought, as I didn't think it was an error witht he function, so I had to debugg the whole fricking thing before resigning to the fact that the function must be odd on every server, even my listen server.

    anywho, here's code:

    Code:
    @name Kinetic -ktccd-
    @outputs [Own Object]:entity
    @outputs [Weapon Mode]:string
    @outputs [Said]:array
    @outputs [Land HoldPlace]:vector
    @outputs Collide
    @outputs Key1 Key2
    #Test: E:keyAttack1() changed value?
    @outputs CKey1 CKey2
    #Test result: Succes!
    #Test conclusion: Some error in the code makes changed(keyAttack1/2 not work. Must be fixed.
    
    
    #W00T, structure!
    
    
    ##start setup##
    if (first()|duped())
    {
        runOnTick(1)
        #interval(10), don't need both.
        #Actually, you should NOT have both.
        runOnChat(1)#or the chatcommand fails horribly.
        Own=owner()
        Mode="Grabbing"
        Collide=20
        #This is how much distance to the target counts as collision
        #if it goes back and forth on target, make value higher.
        print("Kinetic: COMMANDS ARE AS FOLLOWS")
        print("Kinetic: MOUSE1 IS GRAB OBJECT")
        print("Kinetic: MOUSE2 IS THROW OBJECT")
        print("Kinetic: WARNING! SECURITY LEVEL1, DISALLOW MANIPULATION OF OTHER PLAYERS PROPS!")
        print("****************")
        timer("CHAT",5000)
    }
    
    if (clk("CHAT"))
    {   
        print("Kinetic: CHAT COMMANDS ARE AS FOLLOWS")
        print("Kinetic: -KINETIC MASS <NUMBER>")
        print("Kinetic: -KINETIC DROP")
    }
    ##Chat##
    if (chatClk(Own))
    {
        Said=Own:lastSaid():lower():explode(" ")
    }
    
    ##Weapon##
    Weapon=(Own:weapon():type())
    
    ##After that, it's too messy to even bother cleaning. I'll just re-do to save time.
    
    if (Weapon=="weapon_crowbar")
    {
        Key1=Own:keyAttack1()
        Key2=Own:keyAttack2()
        CKey1=changed(Key1)
        CKey2=changed(Key2)
        ##Mouseclick left##
        if (Key1 & CKey1)
        {
            ##Grab object##
            if (Mode=="Grabbing")
            {
                ##This line is for not picking up others stuff##
                Object=(Own:aimEntity():owner()==Own ? Own:aimEntity() : noentity())
                hint("Kinetic: GRABBING " + toString(Object):upper(),5)
    
    
                ##Holding object##
                if (Object)
                {
                    Mode="Holding"
                }
            }
        }
        
        ##Mouseclick right##
        if (Key2 & CKey2)
        {
            ##Throw object##
            if (Mode=="Holding")
            {
                hint("Kinetic: THROWING!",5)
                Land=Own:aimPos()
                Mode="Throwing"
            }
        }
    }
    
    ##Hold, I'm gonna make it fly a little above you too##
    if (Mode=="Holding")
    {
        HoldPlace=Own:pos()+vec(0,0,Object:radius()+100)-Object:pos()
        #Fly above owner
    
    
        Object:applyForce((HoldPlace-Object:vel())*Object:mass())
    
        ##This part is if yuo have propcore. if you don't, don't worry, it won't break, I know my stuff.
    
        #ifdef propSpawn(string,vector,number)
        Object:propNotSolid(1)
        #endif
        ##This should make it non-solid if it can use that command.
    }
    
    if (Mode=="Throwing")
    {
        ##Throw##
        Object:applyForce((Land-Object:pos()-Object:vel()/sqrt(Object:pos():distance(Land)))*Object:mass())
    
        #ifdef propSpawn(string,vector,number)
        Object:propNotSolid(0)
        #endif
        ##makes solid again##
    
    
        ##Detect collision##
        if (Object:pos():distance(Land)<Collide)
        {
            if (Object)
            {
                Mode="Grabbing"
                Object=noentity()
                Land=vec(0,0,0)
                hint("Kinetic: TARGET REACHED!",5)
            }
        }
    }
    
    if (Mode=="Throwing" | Mode=="Holding")
    {
        if (!Object)
        {
            #ifdef propSpawn(string,vector,number)
            Object:propNotSolid(0)
            #endif
            Object=noentity()
            Land=vec(0,0,0)
            Mode="Grabbing"
            hint("Kinetic: ABORT!",5)
        }
    }
    
    ##chat commands##
    if (chatClk(Own))
    {
        if (Said[1,string]=="-kinetic")
        {
            hideChat(1)
            if (Said[2,string]=="mass")
            {
                Object:setMass(Said[3,string]:toNumber())
                hint("Kinetic: INCREASE MASS!",5)
            }
            
            if (Said[2,string]=="drop")
            {
                #ifdef propSpawn(string,vector,number)
                Object:propNotSolid(0)
                #endif
                Object=noentity()
                Land=vec(0,0,0)
                Mode="Grabbing"
                hint("Kinetic: ABORT!",5)
            }
        }
    }
    marvel at it's beauty!
    XD

    EDIT2: Fixed some stuff (like what happens if the object is gone when throwing?) and made print stuff to understand how to use it.
    Last edited by ktccd; 03-13-2010 at 03:54 PM.

  2. #12
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: different "fire modes" in e2?

    BUMP for progress!

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots