Page 1 of 1

Start_Script(script, params)

Posted: Sun Jul 02, 2006 8:47 am
by DevGIB
Ok i have a new problem to do with start script... well its not a problem i just dotn think its working how the scripter meant it to work... if someone could help me this would be greatly appreciated.

start_script line:

Code: Select all

start_script (":combat:"+hitscript, {attacker, defender, attacker.weapon, def_armor, wbasedamage, 0});
wil this work properly

Code: Select all

program mainhit(attacker, defender, weapon, armor, basedamage, rawdamage)
it seems as tho passing everything in an array it doesnt come through properly...

Posted: Sun Jul 02, 2006 9:07 am
by tekproxy
You have to grab all of the params from the array like this:

Code: Select all

Start_Script(":combat:"+hitscript, array{attacker, defender, vbasedamage, 0})

Code: Select all

program mainHit(params)
	var attacker := params[1];
	var defender := params[2];
	var base_damage := params[3];
	var raw_damage := params[4];

	// Combat hooks are complicated, good luck!
	// Make sure it's as optimized as possible
	// You _could_ just use the combat hook in the distro...
One should not have to pass attacker.weapon or def_armor if one already has access to the attacker and defender mobile refrences, but if you do, just put them in.

Posted: Sun Jul 02, 2006 9:11 am
by DevGIB
only problem is with that i now have to go and change every single hitscript to support that method, and the reason why we have to pass the weapons and armour and staff is because its appart of our attack hook and some files need it to retrieve props from the weapons and armour :(

Posted: Sun Jul 02, 2006 9:31 am
by tekproxy
You do not need to pass attacker.weapon to the hit script if you are already passing the mobile refrence attacker. If you want to access attacker's weapon then do so with attacker.weapon in the hit script. If you ever use something other than attacker.weapon for the attacker's weapon then you would need to send the weapon but I don't think that's a good idea. It's your call. That's just how you use Start_Script(). Good luck!

Posted: Sun Jul 02, 2006 1:44 pm
by DevGIB
Thanks to Wywern from the IRC who provided this fix ill post it so if anyone else has questions about it they can check this out... (keeping support active)

Code: Select all

program mainhit(attacker, defender, weapon, armor, basedamage, rawdamage)

If(TypeOf(attacker) == "Array")
defender := attacker[2];
weapon := attacker[3];
armor := attacker[4];
basedamage := attacker[5];
rawdamage := attacker[6];
attacker:= attacker[1]; //Must Be Last To Keep Attacker relative to the hook for other parms above
endif

Posted: Sun Jul 02, 2006 3:17 pm
by tekproxy
What are you trying to do? Why do you start the script that way anyway?

Posted: Sun Jul 02, 2006 4:51 pm
by DevGIB
its a hitscript... we have an attack hook and in the attack hook the end of it, it calls the hitscript
how ever start_script() only allows you to send 1 parm not multiple