SphereCommunity
Army Job - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Army Job (/Thread-Army-Job)



Army Job - x77x - 10-25-2015 03:13 AM

a better and working way to do this please?

Code:
[EVENTS e_army_job]
ON=@CLICK
IF (<EVAL <SRC.TAG0.MILITARY>>==1) && !(STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>"))//IS A PLAYER IN THE MILITARY AND NOT SAME ARMY
ATTACK
SAY Die soldier of <SRC.TAG.ARMY>!
ELSE
SAY Hi//DO NOTHING LEAVE CIVILIANS WITH NO MILITARY TAG ALONE
RETURN 0
//
IF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
Say Beat it criminal!
ATTACK
ELSE
IF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
ATTACK
//
ENDIF
RETURN 1

ON=@NPCSeeNewPlayer
IF !(STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>"))//FOR NPCS TO ATTACK OTHER NPCS NOT IS SAME ARMY
ATTACK
SAY Die!

i want them to attack military PLAYERS and other military NPCS in any other army other than their own! (all armies are at war)
i want them to leave non criminal civilians alone.
i want them to attack criminal players.(civilian or military dont matter...)
i want them to attack any player made guild.


RE: Army Job - XuN - 10-25-2015 05:24 AM

First: Do you really need tag.army to be a text? Using numbers makes the comparisons SO MUCH faster and you can use defs to store and show the text.
Second: your ELSE -> IF (in separate lines) is NOT the same as ELSEIF, per each opened IF you need one closing ENDIF to give your code some sense, this is how you code looks like:
Code:
ON=@CLICK
IF (<EVAL <SRC.TAG0.MILITARY>>==1) && !(STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>"))//IS A PLAYER IN THE MILITARY AND NOT SAME ARMY
    ATTACK
    SAY Die soldier of <SRC.TAG.ARMY>!
ELSE
    SAY Hi//DO NOTHING LEAVE CIVILIANS WITH NO MILITARY TAG ALONE
    RETURN 0
    //
    IF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
        Say Beat it criminal!
        ATTACK
    ELSE
        IF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
            ATTACK
        //
        ENDIF
        RETURN 1
    // you should have one ENDIF for this IF block.
// and another one for this one.

However, if you read carefully that code you'll realize that what is there is doing nothing similar to what you requested... the first ELSE has a return 0, which is STOPPING EVERYTHING under it so in this case you have to check first under which scenario the NPC should attack and then what to do if nothing of this requiremets were achieved.


Code:
[defname armynames] // using this you can define anything to use in scripts in an easier way
army_01=Army_1_Name //change 'Army_1_Name' with the name of one of your armies
army_02=Army_2_Name //and so on
army_03=Army_3_name
etc

[events e_army_job]
ON=@Click
// First I should know if TAG.MILITARY and TAG.ARMY are working together, I mean if TAG.MILITARY is ONLY present when someone has a TAG.ARMY, if so use the first if ... use the second if not
//first if
IF ( <SRC.TAG0.MILITARY> && (<TAG.ARMY>==<SRC.TAG.ARMY>) )
//second if
IF ( (<SRC.TAG0.MILITARY>) && (<TAG.ARMY> && <SRC.TAG.ARMY>) && (<SRC.TAG0.ARMY> != <TAG0.ARMY>) ) //You must check too that they have an army, or the tag.military is only set when tag.army is set too?
    ATTACK
    SAY Die solder of <DEF0.army_<SRC.TAG.ARMY>>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0



RE: Army Job - x77x - 10-25-2015 05:59 AM

players are tagged with
"TAG.MILITARY 1" and "TAG.ARMY Wei"
when they join the Wei army,
there are 7 different armies (Wei, Wu, Shu, YS, LB, YT, MH)

you will have both tags, or none

both tags are removed when they are not in an army and are civilians

you can resign at anytime

Code:
ON=I resign from my guild
SRC.TAG.ARMY
SRC.TITLE Villager
src.events -e_armylife_wei
src.events -e_armylife_wu
src.events -e_armylife_shu
src.events -e_armylife_ys
src.events -e_armylife_lb
src.events -e_armylife_yt
src.events -e_armylife_mh
SRC.TAG.MILITARY
findid.i_military_cap.remove
findid.i_military_leggings.remove
findid.i_military_tunic.remove
findid.i_military_overplate.remove
findid.i_military_apron.remove
findid.i_military_uniform.remove
findid.i_military_boots.remove

TAG.ARMY=xxxx designates what army they belong to
TAG.MILITARY=1 is used for an item check, only military players can use military items


RE: Army Job - x77x - 10-25-2015 08:34 AM

with...
Code:
[defname armynames] // using this you can define anything to use in scripts in an easier way
army_01=Wei
army_02=Wu
army_03=Shu
army_04=YS
army_05=LB
army_06=YT
army_07=MH

[events e_army_job]
ON=@Click
// First I should know if TAG.MILITARY and TAG.ARMY are working together, I mean if TAG.MILITARY is ONLY present when someone has a TAG.ARMY, if so use the first if ... use the second if not
//first if
IF ( <SRC.TAG0.MILITARY> && (<TAG.ARMY>==<SRC.TAG.ARMY>) )
//second if
//IF ( (<SRC.TAG0.MILITARY>) && (<TAG.ARMY> && <SRC.TAG.ARMY>) && (<SRC.TAG0.ARMY> != <TAG0.ARMY>) ) //You must check too that they have an army, or the tag.military is only set when tag.army is set too?
    ATTACK
    SAY Die solder of <DEF0.army_<SRC.TAG.ARMY>>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0

i get

Code:
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol 'Wei' ['Wei==) )']
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol '' [') )']
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol 'Wu' ['Wu==) )']
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol '' [') )']

did i mention i want NPCs to fight each other too?

okay this seems to be working
I NOW TAGGED NPCS with TAG.MILITARY 1
Code:
[events e_army_job]
ON=@Click//TO INTERACT WITH PLAYERS
IF (<SRC.TAG0.MILITARY>) && !STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>")
    ATTACK
    SAY Die solder of <SRC.TAG.ARMY>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0

ON=@NPCLookAtChar//TO INTERACT NPCS
IF (<SRC.TAG0.MILITARY>) && !STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>")
    ATTACK
    SAY Die solder of <SRC.TAG.ARMY>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0



RE: Army Job - XuN - 10-26-2015 05:01 AM

The idea on using defs was to use numbers instead of strings for the armies, BTW '!STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>")' will be true if the strings does NOT match, change it to STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>") (just remove the !).