Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52

Thread: sonic sword script need help

  1. #1

    Default sonic sword script need help

    As a Bard we get an animated sword, one of the issues is stopping in the middle of a hunt to execute a command. The commands are pretty basic but I wanted to make using the Singing Sword a bit more controllable. for instance if you walk into a room and other players are there It should CEASE it's attack, If it gets stuck somewhere to have it RETURN. Also a Bard may be singing a bunch of songs so a check to see if mana was low. I tried using strormfront scripts but saw Lich had some handles that would do this easily. So I tried to convert my script to Lich and here is my result:
    ## Singing sword utility script
    ## var variable is weapon type or hard code in weapon type in line 6
    ## If weapon is hard coded, change weapon type in Missing subroutine line 26
    ## Ver 1.0 usable in WL Gaveyard against Pookas and Spectral miners
    ## Start Singing Sword
    fPut Prep 1025
    @variable[1] = 'value'
    fPut SING variable[1]
    #Main loop
    Start
    If GameObj.npcs.find { |npc| (npc.status !~ /dead/) && (npc.type =~ /aggressive/) }= Spectral Miner then fput TELL WEAPON TO ATTACK Spectral miner
    If GameObj.npcs.find { |npc| (npc.status !~ /dead/) && (npc.type =~ /aggressive/) }= Ghostly pooka then fput TELL WEAPON TO ATTACK Ghostly Pooka
    if GameObj.pcs == 1 Occupied
    match Missing Animated variable[1]
    match traveling Lich: go2 active.
    if upstream_get =”exit” end
    matchwait
    goto start
    # If Sword not present
    Missing:
    if checkspell "Singing Sword" fput TELL WEAPON TO RETURN else goto sing
    goto start
    # Song not being sung
    sing:
    fPut Prep 1025
    fPut SING variable[1]
    goto start
    # if room is occupied
    Occupied:
    If GameObj.pcs == 0 fput TELL WEAPON TO CEASE else NEXTROOM
    goto start
    # Check mana level
    Mana:
    put mana
    if checkmana <=50 fput Stop 1025
    echo not enough Mana avalable.
    wait_until { mana(90} goto start
    goto start
    # Go2 Traveling
    traveling:
    fput TELL WEAPON TO CEASE
    wait_until Lich: go2 has exited.
    Goto start
    Well as you can see it doesn't even get to singing the song before it errors out. Would one of you all take a look and help me correct my errors?

    Thanks

  2. #2

    Default

    I think this will do what you're looking for:

    Code:
    current_room = Room.current.id
    target_id = nil
    
    loop{
    	if checkmana <= 50
    		fput "stop 1025"
    		echo "Running low on mana."
    		wait_until { checkmana(90) }
    	end
    	Spell[1025].cast(script.vars[1]) if !Spell[1025].active? && checkmana(90)
    	fput "tell weapon to return" if Spell[1025].active? && !GameObj.npcs.find{ |i| i.name =~ /#{script.vars[1]}/}
    	target = GameObj.targets.find{|i| i.name =~ /miner|pooka/i }
    	if target
    		if target_id != target.id
    			fput "tell weapon to attack #{target}"
    			target_id = target.id
    		end
    	end
    	if Room.current.id != current_room
    		current_room = Room.current.id
    		fput "tell weapon to cease" if checkpcs
    	end
    	if running? "go2"
    		fput "tell weapon to cease"
    		wait_while{ running?('go2') }
    	end
    	sleep 0.5
    }
    You're gonna have to play around with it a bit to be sure because I didn't test everything.

    You can start it like:

    ;sonic lance

    For example if you want to use a sonic lance.

    Or:

    ;sonic broadsword

    For a broadsword and etc etc.

  3. #3

    Default

    Except for trying to cast 1025 continuously it works. My programming was all in basic, I can follow your structure. I think the problem is that casting the spell is inside the primary loop. So to correct this put the statement Spell[1025].cast(script.vars[1]) outside the primary loop and just do an if-then statement but I've no idea the correct format for that type of statement in Ruby.
    Last edited by Eliseen; 01-01-2021 at 09:11 PM.

  4. #4

    Default

    It should only cast 1025 if 1025 is not active which is kept track by ;magic.

    Do you have a custom prep message or something for 1025 that would make it so Lich wouldn’t recognize it being cast?

  5. #5

    Default

    the actual terms are prep 1025 (obviously) and Sing weapon type. Using cast works the sword appears, but every time the loop repeats it tries to prep the song again.
    Last edited by Eliseen; 01-01-2021 at 10:04 PM.

  6. #6

    Default

    Yeah Spell[1025].cast does all of that and Lich should track that the spell is active unless you have a custom spell message when casting it or something because Lich looks for the standard cast line to see if the spell was cast.

  7. #7

    Default

    the actual terms are prep 1025 (obviously) and Sing weapon type. Here is a capture of the spell veing cast:

    prepare 1025
    You begin your musical chant for Singing Sword Song...
    Your spellsong is ready.
    >
    [sss]>cast longsword
    You sing a melody.
    An animated longsword appears and hovers near you.
    Sing Roundtime 3 Seconds.

  8. #8

    Default

    Yeah that's the standard messaging.

    With 1025 going does it show up when you do ;magic?

  9. #9

    Default

    You'll love this:

    >;magic?

    - Minor Spirit:
    101: Spirit Warding I - 0:41:01
    104: Disease Resistance - 0:40:21
    105: Poison Resistance - 0:40:23
    107: Spirit Warding II - 0:46:18
    112: Water Walking - 0:46:20

    - Minor Elemental:
    401: Elemental Defense I - 0:44:21
    406: Elemental Defense II - 0:44:23
    414: Elemental Defense III - 0:38:54

    - Major Elemental:
    503: Thurfel's Ward - 0:41:52
    509: Strength - 0:41:54

    - Ranger:
    601: Natural Colors - 0:38:55
    602: Resist Elements - 0:40:59
    618: Mobility - 0:41:04

    - Wizard:
    911: Mass Blur - 0:38:58

    - Minor Mental:
    1204: Foresight - 0:39:42
    1208: Mindward - 0:39:43

    - Armor Specialization:
    9504: Armor Support - 0:31:18

  10. #10

    Default

    And I do have a sonic sword following me around.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •