Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
eamonnsoll
Newbie


Joined: 30 May 2020
Posts: 3

PostPosted: Wed Jun 03, 2020 6:21 am   

Scanning Help
 
Good Evening, I'm hoping someone can help me. I'm looking to write a script that will scan for mobs and then move to the direction it is in. For all intents and purposes, I need to be able to set a variable with the mobs name to detect which mob to move towards. Below is the syntax I'm for the script: Thank you so much for all your help!!



You start looking in the different directions :


You check out this room and see :
- Character

You look north and see :
- Mob #1

You look west and see :
- Mob #2
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Wed Jun 03, 2020 12:29 pm   
 
Something like this should work in CMUD.
Stores all the mobNames in a dbVar then assesses the data in 5 seconds (to ensure everything had time to be captured, this time can be shortened)
Code:

targetMob=some mob

#TR {You start looking in the different directions :} {
  scanMobs=""
  #ALARM "mobSort" +5 {#RAISE onMobsFound}
  }

#TR {You check out this room and see :} {
#COND {*} {
  #IF (%match(%line, "- ([%w%s])", $mob)) {
    #STATE 1
    $this=%db(@scanMobs, here)
    $this=%additem($mob, $this)
    #ADDKEY scanMobs here $this
    }} {within|param=1}

#TR {You look (%w) and see :} {}
#COND {*} {
  #IF (%match(%line, "- ([%w%s])", $mob)) {
    #STATE 1
    $this=%db(@scanMobs, %t1)
    $this=%additem($mob, $this)
    #ADDKEY scanMobs %t1 $this
    }} {within|param=1}

#EVENT onMobsFound {
  #FORALL %dbkeys(@scanMobs) {
    $this=%db(@scanMobs, %i)
    #IF (%ismember(@targetMob, $this)) {
      #IF (%i!="here") {%i}
      kill @targetMob
      }}}
_________________
Discord: Shalimarwildcat
Reply with quote
eamonnsoll
Newbie


Joined: 30 May 2020
Posts: 3

PostPosted: Wed Jun 03, 2020 2:39 pm   
 
Would that also work in Zmud? Sorry, I don't have CMud.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Wed Jun 03, 2020 3:13 pm   
 
You need to add more of the dirMob variable names where I put the etcs.

Code:
targetMob=some mob

#TR {You start looking in the different directions :} {
  hereMob=""
  eastMob=""
  westMob=""
  //etc etc
  #ALARM "mobSort" +5 {onMobsFound}
  }

#TR {You check out this room and see :} {
#COND {*} {
  #IF (%match(%line, "- ([%w%s])", thisMob)) {
    #STATE 1
    #VAR hereMob %additem(@thisMob, @hereMob)
    }} {within|param=1}

#TR {You look (%w) and see :} {}
#COND {*} {
  #IF (%match(%line, "- ([%w%s])", thisMob)) {
    #STATE 1
    #VAR %concat(%t1, "Mob") %additem(@thisMob, %expand(%concat("@", %t1, "Mob")))
    }} {within|param=1}

#ALIAS onMobsFound {
  #FORALL "hereMob|eastMob|westMob|etc" {
    thisMob=%expand(%concat("@", %i))
    #IF (%ismember(@targetMob, @thisMob)) {
      #IF (%i!="hereMob") {%i}
      kill @targetMob
      }}}
_________________
Discord: Shalimarwildcat
Reply with quote
ClarkWillson
Newbie


Joined: 11 Mar 2023
Posts: 1

PostPosted: Sat Mar 11, 2023 11:37 pm   
 
First, you'll need to figure out how to scan for mobs in the game. This will likely involve using a game-specific API or library that allows you to access information about the game world, such as the location and name of nearby mobs.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net