1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

More struggles with client side scripts

Discussion in 'Scripts' started by greatguys1, Aug 22, 2018.

  1. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    I'm trying to get a blood spurt sfx to work, but while it does, color doesn't seem to work all of the time, resulting in NPCs spurting gray blood. It seems viewing it from certain angles will only allow you to see the red.

    The script in question:
    Code:
    //statotionary, temporary sprite (why is there no function for this?)
    //- remember to precache sprite
    #scope client
    { client_activate //<owner index> <sprite_name> <render_props> <duration> <model height> <model width>
        //render props format: fadeout:0|1;scale;renderamt;rendermode;rendercolor;framerate;frames
    
        setvard SFX_OWNER PARAM1
        setvard SPRITE_NAME PARAM2
        setvard RENDER_PROPS PARAM3
        setvard SPRITE_DURATION PARAM4
        setvard MODEL_HEIGHT PARAM5
        setvard MODEL_WIDTH PARAM6
    
        setvard ANG_OFFSET $rand(-100,100)
    
        callevent 0.1 spurt_blood
        callevent SPRITE_DURATION remove_me
    }
    
    { spurt_blood
    
        local L_POS $getcl(SFX_OWNER,origin)
        vectoradd L_POS $vec(0,0,$math(multiply,0.6,MODEL_HEIGHT))
    
        cleffect tempent sprite SPRITE_NAME L_POS setup_temp_sprite redo_color
        callevent 0.1 spurt_blood
    }
    
    { setup_temp_sprite
    
        local L_VEL $relvel($vec(0,$math(add,ANG_OFFSET,$getcl(SFX_OWNER,angles.yaw)),0),$vec(0,$math(add,MODEL_WIDTH,30),20))
    
        cleffect tempent set_current_prop death_delay 1
        if ( $get_token(RENDER_PROPS,0) == 1 ) cleffect tempent set_current_prop fadeout lifetime
        cleffect tempent set_current_prop scale $get_token(RENDER_PROPS,1)
        cleffect tempent set_current_prop renderamt $get_token(RENDER_PROPS,2)
        cleffect tempent set_current_prop rendermode $get_token(RENDER_PROPS,3)
        cleffect tempent set_current_prop rendercolor $get_token(RENDER_PROPS,4)
        cleffect tempent set_current_prop framerate $get_token(RENDER_PROPS,5)
        cleffect tempent set_current_prop frames $get_token(RENDER_PROPS,6)
        cleffect tempent set_current_prop velocity L_VEL
        cleffect tempent set_current_prop gravity 0.3
        cleffect tempent set_current_prop collide none
        cleffect tempent set_current_prop update 1
    }
    
    { redo_color
    
        cleffect tempent set_current_prop rendercolor $get_token(RENDER_PROPS,4)
    }
    
    { remove_me
    
        removescript
    }
    Params sent to it:
    Code:
    local L_RENDER_PROPS "0;0.15;255;color;"
            stradd L_RENDER_PROPS $clcol(255,0,0)
            stradd L_RENDER_PROPS ";10;10"
            clientevent new all effects/sfx_bleed $get(PARAM1,index) bloodspray.spr L_RENDER_PROPS 10 $get(PARAM1,height) $get(PARAM1,width)
     
  2. Thothie

    Thothie Administrator Staff Member Administrator Moderator Developer

    15,079
    54
    Apr 8, 2005
    psycho-oligist
    lost
    Few things...

    - There's already a command for this, "bleed <target> <red|green|yellow> <amt>". (Example usage in monsters/worm_abyssal_head.script) It also handles scaling, scatter, and decaling.

    - If you're going to be generating a sprite regularly, ya probably don't want to be sending so many bytes of data to the client each time (particularly when the server's gotta send it to all the clients). Better to have it set in the client script, since they already have that. This dynamic "tell them everything" method is intended for occasional sprites, not the sort that are gonna crop up every strike/every dot tick, potentially on multiple mobs - better that they already know.

    - $clcol(<RBG>) is for converting an RBG integer color (eg. 255,0,0) to an RBGA float color (eg. 1.0,0,0,1.0). Sprites, however, use RBG integer colors. This is probably what's bjorking it (beyond the more fundamental issues mentioned above).
     
  3. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    This'll be a neat addition to the effect, but it's not a replacement for what I want out of it.
    It seems, however, green and yellow are the same, but red doesn't work correctly. The video below shows how red looks.

    i shouldve mentioned i tried it without clcol but it turns out the whole problem was me using color instead of normal. normal colors the sprites correctly but color doesn;t. see the video pls
    uugh
    i
    am
    very
    upset

    The first clip shows how the blood command looks when the color is red, the second clip shows the sprites reacting when the rendermode is color, and the color being (255,0,0).
    In case it's hard to tell in the video, the blood command spews out white, red, and yellowish particles.

     
    Last edited: Aug 24, 2018
    Malachite likes this.
  4. Malachite

    Malachite Adventurer Heroes of Dawn

    95
    6
    Dec 31, 2015
    Male
    United States
    Is this in some attempt for implementing critical hits?
     
  5. MS:C community

    MS:C community Active Adventurer

    382
    31
    Jul 7, 2011
    Jagged arrow bleeding is being re-implemented @Malachite
     
  6. Lucifer Majiskus

    Lucifer Majiskus Adventurer Sons of Babel

    LOL
     
    Malachite likes this.
  7. Thothie

    Thothie Administrator Staff Member Administrator Moderator Developer

    15,079
    54
    Apr 8, 2005
    psycho-oligist
    lost
    Never, had, jagged arrow bleeding. :p

    Hrmm... Might be a overflow/datatype issue in the bleed command sequence or some such (thus randomizing color), will need to examine the code. (edit: Seem to have fixed that - some odd thing about how UTIL_BloodStream works.)

    As for the clscript... Looking at bloodspray.spr, it seems that's a {solid render sprite (alphatest), so ya wanna use rendermode alpha on that.
     
    Malachite likes this.
  8. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    Could I get the update that fixes that?

    Done

    Thanks again
     
    Malachite likes this.
  9. Thothie

    Thothie Administrator Staff Member Administrator Moderator Developer

    15,079
    54
    Apr 8, 2005
    psycho-oligist
    lost
    Sent...

    For some reason UTIL_BloodStream needs to receive 70 instead of BLOOD_COLOR_RED (247), but the decal still needs to receive BLOOD_COLOR_RED, so, weird.

    Also, this is the simplified script I was using for testing:
    Code:
    #scope client
    { client_activate //<owner index> 
    
        setvard SFX_OWNER PARAM1
        setvard SPRITE_DURATION 10.0
    
        callevent 0.01 spurt_blood
        callevent SPRITE_DURATION remove_me
    }
    
    { spurt_blood
    
        local L_POS $getcl(SFX_OWNER,origin)
    	local L_HEIGHT $getcl(SFX_OWNER,height)
        if ( !$getcl(FX_OWNER,isplayer) ) vectoradd L_POS $vec(0,0,$math(multiply,0.6,L_HEIGHT))
    
        cleffect tempent sprite bloodspray.spr L_POS setup_temp_sprite
        callevent 0.1 spurt_blood
    }
    
    { setup_temp_sprite
    
    	local L_RND_ANG $randf(0,359.99)
    	local L_RND_PITCH $randf(-100,100)
    	local L_RND_FORCE $randf(100,200)
        local L_VEL $relvel($vec(L_RND_PITCH,L_RND_ANG,0),$vec(0,0,L_RND_FORCE))
    
        cleffect tempent set_current_prop death_delay 1
        cleffect tempent set_current_prop scale $randf(0.15,0.2)
        cleffect tempent set_current_prop renderamt 255
        cleffect tempent set_current_prop rendermode alpha
        cleffect tempent set_current_prop rendercolor (255,0,0)
        cleffect tempent set_current_prop framerate 20
        cleffect tempent set_current_prop frames 10
        cleffect tempent set_current_prop velocity L_VEL
        cleffect tempent set_current_prop gravity 0.3
        cleffect tempent set_current_prop collide none
    }
    
    { remove_me
    
        removescript
    }
    Just, worth noting you can get the model height from an client side index, as well as whether the target is a player, and thus has a different origin. Thinking ya may as well just start from the center, as it's gonna exit randomly from the model.
     
    Last edited: Aug 25, 2018
    Malachite likes this.
  10. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    I'll check this out, but I dunno if it'll quite give the effect I want. I do plan on cutting down the params sent, as you suggested.

    Can you rephrase this? I'm not sure I quite understand. I can't get other monster's width or height via $getcl
     
    Malachite likes this.
  11. Thothie

    Thothie Administrator Staff Member Administrator Moderator Developer

    15,079
    54
    Apr 8, 2005
    psycho-oligist
    lost
    Ya should be able to. Should return the height of the model index.

    Should I be on crack, you can also try $getcl(<index>,center) - though I can't recall what problems that causes, if any.
     
    Malachite likes this.
  12. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    $getcl(SFX_OWNER,height)
    $getcl(SFX_OWNER,width)
    each return 0

    $getcl(SFX_OWNER,center), however, seems to work as intended.
     
    Malachite likes this.
  13. Thothie

    Thothie Administrator Staff Member Administrator Moderator Developer

    15,079
    54
    Apr 8, 2005
    psycho-oligist
    lost
    Blah, it's the crack again, apparently.

    Center should work - only circumstance where I see it might not is if the mob involved has no collision box, like maybe Wraiths (though they don't bleed, so not an issue here). I suppose it might be a tad screwy if the model has an oversized submodel, like the Mummy's aura (again, bloodless, but I'm sure there's others). Possibly also if the model is oriented off center, but can't think of a mob that does that, off hand, saving when "burrowing" and invulnerable.

    Given that it finds its center using mins/maxs bounds, thinking of tweaking that up to return height/width.
     
    Malachite likes this.
  14. Kanta

    Kanta Active Adventurer

    293
    36
    Jan 24, 2013
    Level 45 Zauberei Basher
    ms_swamp
    Oh my god, that blood is amazing. I want it everywhere.
     
    Malachite likes this.
  15. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    Have another teaser:
     
    Malachite likes this.
  16. Lucifer Majiskus

    Lucifer Majiskus Adventurer Sons of Babel

    I like the concept, although the gibbing looks a little silly. It is a cool thought that you're cutting out chunks of their organs, but without a physical model change (Brainbread does this well) it looks a bit silly.
     
  17. Malachite

    Malachite Adventurer Heroes of Dawn

    95
    6
    Dec 31, 2015
    Male
    United States
    Is it possible to have a chance of it happening, greatguys?

    Instead of every hit you do .. gibs/bleeds them with the satisfactory sound of medieval combat and grandeur ingame.. maybe it can be random/stat-based chanced and forged into critical hits?
     
  18. Kanta

    Kanta Active Adventurer

    293
    36
    Jan 24, 2013
    Level 45 Zauberei Basher
    ms_swamp
    I think the gibs look fine, so long as the chunks match up at least a little with what you're butchering. Skeletons could give off hunks of bone.

    Edit: Pleeeeaaase keep the original gib sound effect, it's so great.
     
  19. Lucifer Majiskus

    Lucifer Majiskus Adventurer Sons of Babel

    Yeah, if you cut at an orc's leg and suddenly a skull gib pops out... we're gonna have to talk.
     
  20. TheOysterHippopotami

    TheOysterHippopotami Adventurer Source Developer Developer DarkTide RiP

    1,050
    13
    Sep 6, 2009
    I agree with this.


    And this.
     
  21. Kanta

    Kanta Active Adventurer

    293
    36
    Jan 24, 2013
    Level 45 Zauberei Basher
    ms_swamp
    Maybe they wear human skulls as knee guards.
     
  22. greatguys1

    greatguys1 Active Adventurer Developer Warriors of the North

    279
    34
    Apr 20, 2013
    Yes
    It'll be on a chance, but I dunno if it should be based on a stat, or what stat it'd be based on. I don't think we need a critical hit system, at least not now.

    I've excluded the skull gib specifically because of this. Depending on how stuff turns out, I'll play with the sounds and gibs a bit more.
     
    Malachite likes this.
  23. zeus9860

    zeus9860 Adventurer Crusaders Blades of Urdual The True Followers of the Lost

    2,507
    6
    Feb 28, 2008
    Troll
    lolwut
    Tbh, i think gib should be used only demonstrate heavy hits on a target, perhaps related to weakness if any. If there was a critical hit system, would make sense for the gib to be there but rarelly, in some sort of case you land a very high critical hit. Some games use critical systems that have multiple tiers, i believe warframe has this from what i remember a few years ago. Or landing a critical final blow to the enemy wouldn't be bad either.

    The bleeding effect is on point though. I'm wondering if the blood splash/trail can be changed into something more... excessive in some occasions.

    Like this:
     
    Malachite likes this.
  24. Lucifer Majiskus

    Lucifer Majiskus Adventurer Sons of Babel

    Critical hits on roll would be really cool, and more DnD esque like how the game is trying to be I think
     
    Malachite likes this.
  25. Malachite

    Malachite Adventurer Heroes of Dawn

    95
    6
    Dec 31, 2015
    Male
    United States
    I think it would be awesome to have those random critical hits either boosted or less-chanced based on skill and/or enemy hp, or just entirely random.
     

Share This Page