SphereCommunity
@DeathCorpse - ATTACKER problem - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: @DeathCorpse - ATTACKER problem (/Thread-DeathCorpse-ATTACKER-problem)

Pages: 1 2


@DeathCorpse - ATTACKER problem - xwerswoodx - 01-31-2017 04:06 PM

I am trying to do experience system but there is a problem because ATTACKER doesn't work under @DeathCorpse, but I search little and some developers gives feedback that it works under deathcorpse so where I am doing wrong?

Code:
[Events e_npc_level]
On=@DeathCorpse
IF !<dTAG0.LEVEL>
TAG0.LEVEL=1
ENDIF
SERV.ALLCLIENTS SYSMESSAGE A: <ATTACKER.LAST>
IF (<BRAIN> == brain_monster)
  LOCAL.TOT=<EVAL <TAG0.LEVEL> * 2>
  LOCAL.TOT=<EVAL <DLOCAL.TOT> / <ATTACKER>>
  FOR y 0 <EVAL <ATTACKER> - 1>
    SERV.ALLCLIENTS SYSMESSAGE X: <ARGO.NAME> - <ATTACKER> - <SRC.NAME> - <SRC.ATTACKER.0> - <ATTACKER.<DLOCAL.y>>
    REF1=<ATTACKER.<DLOCAL.Y>>
    ARGO.ATTACKER.ADD=<REF1>
    IF <REF1.ISINPARTY>
      LOCAL.PEXP=<EVAL <DLOCAL.TOT> / <REF1.PARTY.MEMBERS>>
      FOR x 0 <eval <REF1.PARTY.MEMBERS> - 1>
        ARGO.ATTACKER.ADD=<REF1.PARTY.MEMBER.<DLOCAL.x>>
        REF1.PARTY.MEMNER.<DLOCAL.x>.GIVEXP <DLOCAL.PEXP>
      ENDFOR
    ELSE
      REF1.GIVEXP <DLOCAL.TOT>
    ENDIF
  ENDFOR
ENDIF

Code:
[Function GIVEXP]
LOCAL.GIVEN <DARGS>
IF <ISINPARTY>
  TAG0.EXP += <PARTY.MEMBERS>
  SYSMESSAGE <REF5.LANG youhaveearned> <PARTY.MEMBERS> <REF5.LANG experience>
ENDIF

IF <UoMMO_CHECKPRE exp>
  LOCAL.GIVEN +=<EVAL <DLOCAL.GIVEN> / 2>
ENDIF
TAG0.EXP +=<DLOCAL.GIVEN>
SYSMESSAGE <REF5.LANG youhaveearned> <DLOCAL.GIVEN> <REF5.LANG experience>

<ATTACKER> - RETURN 0
<ATTACKER.LAST> - RETURN 0

Errors: It says eval doesn't divide by 0 (which is equals to <ATTACKER>)
Code:
06:01:ERROR:(sphere_events_uommo.scp,126)Exp_GetVal: Divide by 0
06:01:ERROR:(sphere_events_uommo.scp,129)Undefined keyword 'ATTACKER.ADD'
06:01:ERROR:(sphere_events_uommo.scp,129)Undefined keyword 'ARGO.ATTACKER.ADD'
06:01:ERROR:(sphere_events_uommo.scp,129)Undefined keyword 'ATTACKER.ADD'
06:01:ERROR:(sphere_events_uommo.scp,129)Undefined keyword 'ARGO.ATTACKER.ADD'



RE: @DeathCorpse - ATTACKER problem - darksun84 - 01-31-2017 08:14 PM

Argo is actually an item (the corpse item), and items doesn't have the attacker property.


RE: @DeathCorpse - ATTACKER problem - xwerswoodx - 02-01-2017 01:42 AM

Yeah, I just tried it but the problem is, <UID> (which is npc) doesn't attacker either.

On=@Death, I can see attackers, but on=@Deathcorpse, Attacker returns 0 for NPC, I change my code that to save attackers (maybe someone need it);

Code:
[Events e_npc_level]
On=@Death
IF !<dTAG0.LEVEL>
TAG0.LEVEL=1
ENDIF

IF <dATTACKER>
  FOR x 0 <EVAL <ATTACKER> - 1>
    REF1=<ATTACKER.<DLOCAL.X>>
    SERV.LIST.<UID>.ADD <REF1>
  ENDFOR
ENDIF

On=@DeathCorpse
IF ((<BRAIN> == brain_monster) && (<SERV.LIST.<UID>.COUNT> > 0))
  LOCAL.TOT=<EVAL <TAG0.LEVEL> * 2>
  LOCAL.TOT=<EVAL <DLOCAL.TOT> / <SERV.LIST.<UID>.COUNT>>
  FOR a 0 <EVAL <SERV.LIST.<UID>.COUNT> - 1>
    REF2=<SERV.LIST.<UID>.<DLOCAL.A>>
    IF <REF2.ISINPARTY>
      LOCAL.TOT=<EVAL <DLOCAL.TOT> / <REF2.PARTY.MEMBERS>>
      FOR b 0 <EVAL <REF2.PARTY.MEMBERS> - 1>
        REF3=<REF2.PARTY.MEMBER.<DLOCAL.B>>
        SERV.LIST.<ARGO>.ADD <REF3>
        REF3.GIVEXP <DLOCAL.TOT>
      ENDFOR
    ELSE
      REF2.GIVEXP <DLOCAL.TOT>
      SERV.LIST.<ARGO>.ADD <REF2>
    ENDIF
  ENDFOR
  SERV.LIST.<UID>.CLEAR
ENDIF



RE: @DeathCorpse - ATTACKER problem - Catalan_mistral - 02-01-2017 02:16 AM

Sorry if i'm talking crap, can you not make use of the MORE2 on the corpse, as that holds the serial of the person who did the killing blow?


RE: @DeathCorpse - ATTACKER problem - xwerswoodx - 02-01-2017 02:19 AM

Yes I think we can but under @DeathCorpse I and SRC is equals to <MORE2>, I ckeched it Smile


RE: @DeathCorpse - ATTACKER problem - Coruja - 02-01-2017 02:31 AM

I can't remember correctly, but I think when an char kills another char, sphere will call triggers using this sequence:
1) @Kill
2) @Death
3) @DeathCorpse

and the ATTACKER list is cleared on @Kill or @Death, so there's no way to get it on @DeathCorpse

anyway, if you don't want to do nothing with the corpse, maybe it's better change your event to only use @Death instead @DeathCorpse


RE: @DeathCorpse - ATTACKER problem - xwerswoodx - 02-01-2017 02:46 AM

I remember @Death before than @Kill but this is not important (just for information if someone need it), because I needed to check attacker (list) on deathcorpse and it's possible to get corpse uid only on @Deathcorpse, I thought we can use ATTACKER under @Deathcorpse because I found this topic which has a post from XUN (Developer) with ATTACKER under @Deathcorpse,

https://forum.spherecommunity.net/Thread-Loot-help?page=2

Because I tried to add EXP command which makes you clear corpses near you and get experience, but I try to add block that you don't get if you don't have any damage on it. So I tried to check attackers on from corpse but it's 0 so I tried to add attackers under DeathCorpse but it's cleared like you said. But in the link Xun send a post with attacker under deathcorpse and I thought I did something wrong.

Also I don't wanna post new topic for that, is there any Trigger or Setting to block items get damage? I tried @Damage but it's not working, and I didn't find any settings under Sphere.ini


RE: @DeathCorpse - ATTACKER problem - darksun84 - 02-01-2017 04:00 AM

I tried <attacker> inside @deathcorpse and it actually works for me Shock


RE: @DeathCorpse - ATTACKER problem - xwerswoodx - 02-01-2017 02:22 PM

(02-01-2017 04:00 AM)darksun84 Wrote:  I tried <attacker> inside @deathcorpse and it actually works for me Shock

Which version are you using? I am using 0.56c, maybe older versions has it.


RE: @DeathCorpse - ATTACKER problem - darksun84 - 02-01-2017 07:00 PM

Ah i am using 56d, however from the revision:

27-11-2006, Vjaka
- Added: ATTACKER keyword to access last attackers of a character. Usage:
<attacker> returns amount of attackers
<attacker.x> returns UID of the attacker (or 0 if there is no attacker)
<attacker.x.dam> returns total damage done by the attacker
The list is being cleared upon death after @DeathCorpse trigger.