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

A few questions

Discussion in 'Scripts' started by greatguys1, Jul 28, 2016.

  1. greatguys1

    greatguys1 Developers

    Messages:
    104
    Likes Received:
    0
    Joined:
    Apr 20, 2013
    Location:
    Yes
    That'd... Probably be better. I sometimes manage to make things harder than they need to be.
     
  2. Thothie

    Thothie Administrator Staff Member

    Messages:
    14,524
    Likes Received:
    4
    Joined:
    Apr 8, 2005
    Occupation:
    psycho-oligist
    Location:
    lost
    Well, for future reference, while I would avoid it, I tested it, and it does indeed work...

    ...Although I fsked up with my correction above, as you can't pull a local with scriptvar either.

    Stuck this in the player/externals:
    Code:
    { test_insanity
    	setvard TEST_VAR1 this_is
    	setvard TEST_VAR2 insane
    
    	setvard BUILT_VAR 'TEST_VAR'
    	local L_RND $rand(1,2)
    	stradd BUILT_VAR $int(L_RND)
    	dbg test_insanity $get(ent_me,scriptvar,BUILT_VAR) [ L_RND ] [ BUILT_VAR ]
    }
    Returns (in debug builds):
    Code:
    * Script Debug (Server): MAP_TEST_CHAR - test_insanity this_is [ 1 ] [ TEST_VAR1 ]
    [...or...]
    * Script Debug (Server): MAP_TEST_CHAR - test_insanity insane [ 2 ] [ TEST_VAR2 ]
    So, that was interesting... May have some application in the future - but I kinda hope not. ;)
     
  3. greatguys1

    greatguys1 Developers

    Messages:
    104
    Likes Received:
    0
    Joined:
    Apr 20, 2013
    Location:
    Yes
    For gravity and velocity
    If gravity is 1, does it add 1 unit of speed downwards per frame/tick?
    If the velocity of something is 20 with the direction in front of it, would it move forward 20 units per frame/tick?
     
  4. Thothie

    Thothie Administrator Staff Member

    Messages:
    14,524
    Likes Received:
    4
    Joined:
    Apr 8, 2005
    Occupation:
    psycho-oligist
    Location:
    lost
    Well, the math's not quite that simple, as the gravity factor is 800, but yes, gravity 1 is normal gravity, fractions of 1 reduce gravity, and numbers over increase it.

    I wouldn't try to change something's vertical velocity by altering it's gravity though, as the reaction to the change isn't always instant, especially in lag.

    Velocity works by left, right, forward, back, and vertical vectors, in addition to angle, but yes, setting a forward velocity of 20 will send something forward... Not quite 20 units per frame though, even in a friction-less zero-G environment (20 is pretty darn slow - more like per second). Bit uncertain as to the units per frame to velocity ratio. I suspect they are independent, however, as frame rate can vary, even on the server's side, yet things flying in consistent arcs still land consistently in the same period of time - even if teleportation may sometimes come into play due to dropped frames.
     
  5. greatguys1

    greatguys1 Developers

    Messages:
    104
    Likes Received:
    0
    Joined:
    Apr 20, 2013
    Location:
    Yes
    Still confused on those if conditionals without brackets...
    Code:
    if SOMETHING_IS
    //dothing1
    //dothing2
    if ( BLAHBLAH )
    {
       //dothings
    }
    
    Would if ( BLAHBLAH ) be run if SOMETHING_IS is 0? Does the conditional without brackets "capture" the whole thing? Or just up until the next contitional?
     
  6. Thothie

    Thothie Administrator Staff Member

    Messages:
    14,524
    Likes Received:
    4
    Joined:
    Apr 8, 2005
    Occupation:
    psycho-oligist
    Location:
    lost
    If SOMETHING_IS = 0, in that case, it'd stop at the first conditional, and never reach the second.

    If the terminating condition is inside another conditional, rather than exiting the entire event, it'll exit the conditional, so...
    Code:
    if ( !SOMETHING_IS )
    {
    	if SOMETHING_IS
    	saytext Not getting here.
    }
    saytext Well, that was pointless, but we're here now.
    
    However, the "exitevent" command will, as the name suggests, exit the entire event, regardless of whether it's inside a conditional or not (well, provided the condition is true, of course).

    Code:
    if ( !SOMETHING_IS )
    {
    	exitevent
    	if SOMETHING_IS
    	saytext Obviously not getting here.
    }
    saytext Not here either.
    
    Basically, a terminating conditional (ie. one without parentheses), will attempt to exit to the next level down - if there isn't one, the event ends.
     
  7. greatguys1

    greatguys1 Developers

    Messages:
    104
    Likes Received:
    0
    Joined:
    Apr 20, 2013
    Location:
    Yes
    What if something were after that second conditional in my example? Outside of the brackets.
    Like:
    Code:
    if SOMETHING_IS
    //dothing1
    //dothing2
    if ( BLAHBLAH )
    {
       //dothings
    }
    saytext "can I make it here?"
    
    Assuming again SOMETHING_IS = 0
     
  8. Thothie

    Thothie Administrator Staff Member

    Messages:
    14,524
    Likes Received:
    4
    Joined:
    Apr 8, 2005
    Occupation:
    psycho-oligist
    Location:
    lost
    No, it won't get there.

    Provided the terminating conditional is at the lowest level, it exits the event, regardless of the brackets that follow.

    Code:
    setvard SOMETHING_IS 0
    
    if ( !SOMETHING_IS )
    {
    	if SOMETHING_IS
    	saytext This ain't happening
    }
    saytext This *is* happening...
    
    if SOMETHING_IS //This ain't, thus we stop here
    
    saytext So this isn't happening.
    
    if ( SOME_CONDITIONAL ) //not ever seeing this
    {
    	saytext Not gettin here.
    	if ( XX_XX == XX_XX )
    	{
    		saytext True as that was, we ain't ever gonna test it, cuz we stopped awhile ago.
    	}
    }
    
    saytext Not getting here either.
    
    if ( SOME_OTHER_CONDITIONAL )
    {
    	saytext Also not gettin here.
    }
    
    saytext Nor here.
    
    Mind that you can't use "else" nor "else if" with a terminating conditional either... So...
    Code:
    setvard SOMETHING_IS 0
    if SOMETHING_IS
    saytext I coulda done this, but alas.
    else
    saytext This is ignored, cuz I stopped at the first conditional.
    
    A loose else is actually a syntax error - think it'll just be ignored without being tied to a non-terminating conditional.
     
  9. greatguys1

    greatguys1 Developers

    Messages:
    104
    Likes Received:
    0
    Joined:
    Apr 20, 2013
    Location:
    Yes
    Code:
    game_scriptflag_update		//<action> <name> <type> <value> <base_expire_time> - called whenever scriptflags are updated via scriptflags command - do not alter scriptflags here or you may cause an infinite loop (delay 0.1 secs)
    Does <action> mean the stuff in:
    Code:
    scriptflags	//New flag tracking system, has several formats, depending on desired action:
    		//scriptflags <target> add <name> <type> [value] [expiretime:-1] [expiremsg]
    		//- adding a scriptflag with a duplicate name resets its value, and its expire time
    		//- unless the name starts with "stack", in which case it should have an expire time set
    		//scriptflags <target> remove <name>
    		//scriptflags <target> cleartype <type> - removes all of <type> from <target>
    		//scriptflags <target> clearall - removes all scriptflags from target ent
    		//scriptflags <target> remove_expired - removes expired flags from <target>
    		//scriptflags <target> edit <name> <type> <value> [expiretime] [msg] - edits properties of first flag found with this name
    
    Like the "add" "remove" "cleartype" 'n stuff?
     
  10. Thothie

    Thothie Administrator Staff Member

    Messages:
    14,524
    Likes Received:
    4
    Joined:
    Apr 8, 2005
    Occupation:
    psycho-oligist
    Location:
    lost
    Yes, the first param it receives is the second param of the scriptflags command.

    Ye can search out "scriptflags" in ScriptCmds.cpp and "$get_scriptflag" in Scripts.cpp for the nitty gritties.
     
  11. greatguys1

    greatguys1 Developers

    Messages:
    104
    Likes Received:
    0
    Joined:
    Apr 20, 2013
    Location:
    Yes
    Does setting a quest to '0' still save it to the character?
     
  12. Thothie

    Thothie Administrator Staff Member

    Messages:
    14,524
    Likes Received:
    4
    Joined:
    Apr 8, 2005
    Occupation:
    psycho-oligist
    Location:
    lost
    Apparently yes, darnitall.

    There's a quest erase function, but it tends to cause memory dealloc errors.
     

Share This Page