Author Topic: Check for enemies sub routine  (Read 2283 times)

0 Members and 1 Guest are viewing this topic.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Check for enemies sub routine
« on: January 16, 2009, 05:43:22 AM »
0
Does this seem right?
Code: [Select]
gosub check_for_enemies
if ! #result
  goto main_loop

sub check_for_enemy
  finditem #enemyid G
  if #findcnt > 0
  {
    gosub calc_next_location
    return #true
  }
return #false

The calc_next_location will set the next rune in the runebook to recall from. In the main_loop is the recall sub. So if a threat is detected it will force a recall to the next location.

Does the if ! #result look right? Or is that backwards?
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Check for enemies sub routine
« Reply #1 on: January 16, 2009, 10:23:06 AM »
0
Just a personal preference, just use "if #RESULT = #TRUE".  It's just more clear to the novice reader.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Check for enemies sub routine
« Reply #2 on: January 16, 2009, 11:08:54 AM »
0
Yeah, I like that better also. I'm rewriting some portions of an older script.

It's an old LJ script that works great for Library/Museum donations. It's a decent LJ script on it's own.

I'm adding an enemy detection sub, changing out the older subs that are out dated (like clickpos, gumpwait, journal stuff and recalling), and then I'll work on putting in a "dump then donate" so the char will dump tree stuff at a secure (home or bank) then go donate the boards.

XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Tags: