A few questions

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
Location
Yes
Thothie said:
Yeeeah, while it may be possible, an array could probably be implemented do it more simply, if simply passing the intended the var into a temporary var wouldn't. I'd have to see the sauce to be sure, of course, just can't imagine a situation where it'd be otherwise off the top of my head.
That'd... Probably be better. I sometimes manage to make things harder than they need to be.
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
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. ;)
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
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?
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
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.
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
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?
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
greatguys1 said:
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?
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.
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
Location
Yes
Thothie said:
greatguys1 said:
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?
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...
...
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
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
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.
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
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?
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
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.
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
Location
Yes
Does setting a quest to '0' still save it to the character?
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Apparently yes, darnitall.

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