Page 1 of 1

Any way to force a player to attack?

Posted: Sat Jun 04, 2011 6:19 am
by Poi
I searched the forums and only found a few dead end topics, is there any way to force a player to attack a mobile via script(text command, not use script)?

Re: Any way to force a player to attack?

Posted: Sat Jun 04, 2011 9:58 am
by Terciob
Yeah, you can enable warmode with who.setwarmode(1) and who.attack_once(target) to force a swing from who on a mobile.

Re: Any way to force a player to attack?

Posted: Sat Jun 04, 2011 10:54 am
by Poi
who.attack_once(target) doesn't seem to be working, the war mode works perfectly though..

I could be mistaken, but isn't .attack_once a 97 thing, not 96?

Re: Any way to force a player to attack?

Posted: Sat Jun 04, 2011 6:22 pm
by CWO
mobile.attack_once() was implemented in POL098. There is no other way to force someone to attack another.

Re: Any way to force a player to attack?

Posted: Sat Jun 04, 2011 7:14 pm
by Poi
Okay, so then I want to ask one more question,

My mainhitscript is set up like this:
MainHitScript(attacker, defender, weapon, armor, basedamage, rawdamage)

How could I use start_script(mainhitscript, params) to run this, as far as I understand start_script only allows for one param, I could use arrays for the startscript but I don't want to change my mainhitscript because I'm not sure how it would affect any other scripts, is there any way to pass multiple variables using start_script or only one?

Re: Any way to force a player to attack?

Posted: Sun Jun 05, 2011 2:24 am
by CWO
Not sure if it will return the completely desired result as you want but you would have to change mainhitscript... What you would do is pass an array with all of the values in their order with start_script then change mainhitscript like this:

Code: Select all

Program MainHitScript(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]; // Always be sure to set attacker last!
     endif
     // The rest of your MainHitScript code

Re: Any way to force a player to attack?

Posted: Sun Jun 05, 2011 5:33 am
by Poi
That should actually work perfectly!

Now just one more question, how can I get the weapon damage?(I'm not sure what the name of the prop is, ive tried damage, dmg, not sure what else)
:)

Re: Any way to force a player to attack?

Posted: Sun Jun 05, 2011 8:05 am
by CWO
For that you'll have to read the itemdesc.cfg entry for it.

You get basedamage from the random die string. To calculate rawdamage, you'll have to follow the combat pseudocode. What you're looking for is the last IF block on this page http://docs.polserver.com/pol099/attack.php

Re: Any way to force a player to attack?

Posted: Sun Jun 05, 2011 1:45 pm
by Poi
Alright thank you a TON, but I have one LAST question(for this topic :D)

When using Start_script how would I go about defining the script location? Will it find it by just using the script name?

Re: Any way to force a player to attack?

Posted: Sun Jun 05, 2011 3:05 pm
by CWO
Your hitscript is in a package right? Its the regular :packagename:scriptname... start_script(":package:scriptname", params);

Re: Any way to force a player to attack?

Posted: Sun Jun 05, 2011 3:56 pm
by Poi
Awesome thank you, still not working the way I want but Ill figure it out from here, thank you so much :D
:bacondance: