mIRC Homepage

[Request] Script for Star-Fury Online Game!

Posted By: ahmedjhang

[Request] Script for Star-Fury Online Game! - 17/10/09 07:09 AM

Hello - Could someone make for me or help me to make a script that tells me how many more hits are required to kill a certain empire. For example. When I am in an alliance channel and I type

!Empire ahmed

//I will get this

<@Europa> ahmed (1:4) 150 260 91,300 [DFA]

// ahmed = empire name
// (1:4) = sector name
// 150 = Asteroids in Empire's Possession
// 260 = Land in Empire's Possession

//What I would LIKE to see

!empire ahmed
<@Europa> ahmed (1:4) 150 260 91,300 [DFA]
<@ahmed> X hits to Roid Kill; Y hits to Land kill

//The special mathematical bit about this is that.
//If land is above 200 then 10% of that land is captured per hit, if it is 200 or below then 20 land is captured per hit.
//If Asteroids are above 100 then 10% of the asteroids are captured per hit, if it is below 100 then 10 asteroids are captured per hit.


Hope that made sense!!!
Posted By: Horstl

Re: [Request] Script for Star-Fury Online Game! - 17/10/09 09:42 AM

Without further details/examples, I assume that the reply always
- will start with your nickname
- is followed by (number:number)
- is followed by a number to represent asteroids
- is followed by a number to represent land
- is followed by some further number

The following remote script will calculate and reply back if all of the above conditions are met.
Code:
on *:text:*:#: {
  if ($regex($1-5,/^\Q $+ $me \E\(\d:\d\) (\d+) (\d+) \d/)) {
    var %roidhits = $ceil($calc($regml(1) / 10))
    var %landhits = $ceil($calc($regml(2) / $iif(($regml(2) > 200),10,20)))
    msg $chan %roidhits hits to Roid Kill; %landhits hits to Land kill
  }
}

The problem is how to prevent as much "false positives" in the text matching as possible. This may be improved only if you can provide more details, like
- do you chat on a single network only, or (if not) is the game running only on a specific networks (which network)?
- may the text occur in every channels, or in a specific set of known channels?
- is the person/bot sending the text always op in the channel?
- if "empire name" at the start is not always your own nickname: is it at least always a nickname of the channel?
- is "sector name" always made of single-digit numbers?
- is "91,300" a single, comma-formatted number (and won't contain a comma if below 1,000) or is it two numbers that are separated by a comma (and will always contain a comma)?
- is [DFA] always at the end of the reply? If not, is [something in square brackets without space] always at the end of the reply?

And finally, is the calculation correct at all? If not, please provide a couple of examples together with the intended x / y values smile
Posted By: ahmedjhang

Re: [Request] Script for Star-Fury Online Game! - 17/10/09 01:23 PM

WOW thank you SO much!! You've almost got it right! laugh It turned out almost exactly like how I wanted it to!

Here is what happened

<@ahmed> !empire ahmed
<@Europa> ahmed (1:4) 150 260 91,300 [DFA]
<@ahmed> 15 hits to Roid Kill; 26 hits to Land kill

Here is what SHOULD have happened smile

<@ahmed> !empire ahmed
[18:36] <@Europa> ahmed (1:4) 150 260 91,300 [DFA]
[18:36] <@ahmed> 14 hits to Roid Kill; 13 hits to Land kill

because the roid hit will look like this

Dan conquered 15 roids from ahmed
Dan conquered 13 roids from ahmed
Dan conquered 12 roids from ahmed
Dan conquered 11 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed
Dan conquered 10 roids from ahmed

and the land hit will look like

Dan conquered 26 land from ahmed
Dan conquered 23 land from ahmed
Dan conquered 21 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed
Dan conquered 20 land from ahmed

hope it makes more sense now smile
Now for your questions
-Single Network
-I just want it work in the channel that I am in
-the bot is always op, yes
-sector name doesnt really matter smile but yea it goes up to 3:4
-91,300 is one number and it wont occur below 1000 - and that is just the networth of that empire, but the comma might come in to play when the empire has more land/roids
-sometimes there is an alliance name [DFA]there and sometimes there isnt

Also I would like everyone in the room to be able to use this function and not just me. Also I only seem to be able to use this function for just my own empire - I cant use it on any other empire at the moment frown

Thanks for all your help!
Posted By: ahmedjhang

Re: [Request] Script for Star-Fury Online Game! - 17/10/09 01:35 PM

here is one script that does a similar thing but in a different way

on *:text:*:#: { if ($1 == !land) && ($chan != #chat) {
var %n $2
var %e $2
var %r 0
var %creep 0
:next2
%creep = %n * 0.1
if (%creep < 20) {
var %creep 20
}
%n = %n - %creep
inc %r
if (%n > 0) {
goto next2 }
/msg $chan 12,9 Starting Land: %e It will take %r hits to kill the empire | halt
}

elseif ($1 == !roids) && ($chan != #chat) {
var %n $2
var %e $2
var %r 0
var %creep 0
:next2
%creep = %n * 0.1
if (%creep < 10) {
var %creep 10
}
%n = %n - %creep
inc %r
if (%n > 0) {
goto next2 }
/msg $chan 12,9 Starting Roids: %e It will take %r hits to kill the empire | halt

Posted By: Horstl

Re: [Request] Script for Star-Fury Online Game! - 18/10/09 12:08 AM

Ah, I think I got the idea by now. Give this a try:
Code:
; text received
on *:text:*:#: {

  ; nick is op 
  if ($nick isop $chan) {

    ; check for text matching "<EmpireName> <SectorName> <Asteroids> <Land> <Networth> <?Alliance?>" and capture values "Asteroids" and "Land"
    ; text format: <word> <(digit:digit)> <number with possible commas> <number with possible commas> <number with at least one comma> <possibly some text in square brackets>
    if ($regex($1-,/^\S+ \(\d:\d\) ([\d\54]+) ([\d\54]+) [\d\54]+\54\d+(?:\s\[.+\])?$/)) {

      ; set the captured values "Asteroids" and "Land", with the possible commas removed, into variables 
      var %r = $remove($regml(1),$chr(44)), %l = $remove($regml(2),$chr(44)), %r.hits = 0, %l.hits = 0

      ; calculate asteroids remaining per hit - count required no. of hits
      while (%r > 0) {
        dec %r $iif((%r > 100),$calc($v1 * 0.1),10)
        inc %r.hits
      }

      ; calculate land remaining per hit - count required no. of hits
      while (%l > 0) {
        dec %l $iif((%l > 200),$calc($v1 * 0.1),20)
        inc %l.hits
      }

      ; output result to the channel
      msg $chan %r.hits hits to Roid kill; %l.hits hits to Land kill
    }
  }
}
Posted By: ahmedjhang

Re: [Request] Script for Star-Fury Online Game! - 18/10/09 03:30 PM

hey thanks again! well we have ALMOST got it!

Here is what happened

<@ahmed> !empire ahmed
<@Europa> ahmed (1:4) 166 346 119,394 [DFA]
<@ahmed> 15 hits to Roid kill; 16 hits to Land kill

This is EXACTLY how it should happen

BUT

I am unable to use this script on other empires

Here is what happened

<@ahmed> !empire ninja
<@Europa> Ninjas Kim Taeyeon (3:2) 212 350 117,780 [Annex]

It should have had the kill script too but it didnt for some reason frown

Lets crack this!
Thanks again for all your help!
Posted By: ahmedjhang

Re: [Request] Script for Star-Fury Online Game! - 18/10/09 09:29 PM

hey I think I found what the problem is -

; text format: <word>

you need to change that format because some empire names may have more words than just one!!!

Thank You again!
Posted By: Horstl

Re: [Request] Script for Star-Fury Online Game! - 18/10/09 09:34 PM

I didn't know "empire name" may be multiple words (the regular expression checked for a single word before "secor name"). I set it this way to prevent as many "false positive"-matches as possible.

Here's a modified and condensed version:
Code:
on *:text:*:#: {
  if ($nick isop $chan) {
    if ($regex($1-,/ \(\d:\d\) ([\d\54]*\d+) ([\d\54]*\d+) [\d\54]+?\54\d{3}(?: \[.+\])?$/)) {
      var %r = $remove($regml(1),$chr(44)), %l = $remove($regml(2),$chr(44)), %r.hits = 0, %l.hits = 0
      while (%r > 0) { dec %r $iif((%r > 100),$calc(%r * 0.1),10) | inc %r.hits }
      while (%l > 0) { dec %l $iif((%l > 200),$calc(%l * 0.1),20) | inc %l.hits }
      
      msg $chan %r.hits hits to Roid kill; %l.hits hits to Land kill
    }
  }
}
Posted By: ahmedjhang

Re: [Request] Script for Star-Fury Online Game! - 18/10/09 10:19 PM

yayy! it works! thank you so much! ure the best!!! laugh
Posted By: Bijou666

Re: [Request] Script for Star-Fury Online Game! - 18/10/09 11:38 PM

i dont want to "highjack" ahmeds thread, but i also play the same game. I just have a question about the script, I took the same script, and i just want to change what is said:

Code:
on *:text:*:#: {
  if ($nick isop $chan) {
    if ($regex($1-,/ \(\d:\d\) ([\d\54]*\d+) ([\d\54]*\d+) [\d\54]+?\54\d{3}(?: \[.+\])?$/)) {
      var %r = $remove($regml(1),$chr(44)), %l = $remove($regml(2),$chr(44)), %r.hits = 0, %l.hits = 0
      while (%r > 0) { dec %r $iif((%r > 100),$calc(%r * 0.1),10) | inc %r.hits }
      while (%l > 0) { dec %l $iif((%l > 200),$calc(%l * 0.1),20) | inc %l.hits }

      msg $chan 4 %r.hits 11 Roid Hits /\4 %l.hits 11 Land Hits
    }
  }
} 

this is what it currently says:

19:19 Bijou666 !empire killing
19:19 Europa Thekillingfields (1:1) 150 394 128,249 [DFA]
19:19 Bijou666 14 Roid Hits /\ 17 Land Hits

how would i modifiy it to repeat the empire name and co-ordinates? so it would look like this:

19:19 Bijou666 !empire killing
19:19 Europa Thekillingfields (1:1) 150 394 128,249 [DFA]
19:19 Bijou666 Thekillingfields (1:1) 14 Roid Hits /\ 17 Land Hits

the bot will always say the empire name and galaxy and sector,
thanks for any help you can provide
Posted By: Bijou666

Re: [Request] Script for Star-Fury Online Game! - 19/10/09 04:57 AM

i apologise for the double post
a friend helped me get the name and sector in there, but the only problem now is that some empire names can be one,two or even 3 words long, such as "Ninjas Kim Taeyeon", while some are one word long

Code:
msg $chan 3 $1 $2 4 %r.hits 12 Roid Hits |4 %l.hits 12 Land Hits


that is what i have, it works when doing a single worded name:

00:53 bijou666 !empire killing
00:53 Europa Thekillingfields (1:1) 150 414 131,804 [DFA]
00:53 bijou666 Thekillingfields (1:1) 14 Roid Hits | 17 Land Hits

but for multiple word empires:

00:53 bijou666 !empire Ninja
00:53 Europa Ninjas Kim Taeyeon (3:2) 269 350 150,606 [Annex]
00:53 bijou666 Ninjas Kim 20 Roid Hits | 16 Land Hits

if you would know how to fix this i would greatly appreciate it wink
Posted By: Horstl

Re: [Request] Script for Star-Fury Online Game! - 19/10/09 10:26 AM

No trouble smile
Code:
on *:text:*:#: {
  if ($nick isop $chan) {
    if ($regex($1-,/^(.+) (\(\d:\d\)) ([\d\54]*\d+) ([\d\54]*\d+) [\d\54]+?\54\d{3}(?: \[.+\])?$/)) {
      var %empire = $regml(1), %sector = $regml(2), %r = $remove($regml(3),$chr(44)), %l = $remove($regml(4),$chr(44))
      var %r.hits = 0, %l.hits = 0
      while (%r > 0) { dec %r $iif((%r > 100),$calc(%r * 0.1),10) | inc %r.hits }
      while (%l > 0) { dec %l $iif((%l > 200),$calc(%l * 0.1),20) | inc %l.hits }

      msg $chan %empire %sector %r.hits Roid Hits %l.hits Land Hits
      msg $chan 03 $+ %empire %sector 04 $+ %r.hits 03Roid Hits 04 $+ %l.hits 03Land Hits
    }
  }
}
(the doubled line is a coloring proposal only)
Posted By: Bijou666

Re: [Request] Script for Star-Fury Online Game! - 19/10/09 02:08 PM

thank you for the help wink it works perfectly
© 2019 mIRC Discussion Forums