Using skill->castend_nodamage_id [DOUBT]

Tio Akima

New member
Messages
349
Points
0
Age
36
Discord
TioAkima#0636
Github
Tio Akima
Emulator
Hello guys
I made a custom structure in my skill
But I'm messing around somewhere .. Help me out.

I call sumono a MOB

            struct mob_data *md;
            md = mob->once_spawn_sub(src, src->m, x, y, clif->get_bl_name(src), mob_id, "", size, type); //example
            mob->spawn (md);    //sumona o mob


Then I use an SC in this mob

sc_start4(src,&md->bl,SC_RUN,100,skill_lv,0,0,0);


in status.c, within the function responsible for terminating this status (SC)
in status_change_end_
I'm putting a function (within the case of SC_RUN)
I'm trying to use this function

struct map_session_data *pl_sd = map->nick2sd(bl);

skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0); //function to call the skill NPC_SELFDESTRUCTION on target


But... But ... Skill_castend is not working correctly
It should call the Selfdestruction skill on the target (the same target I'm using SC)
but he uses selfdestruction in PLAYER

his is the skill_castend structure:

The first or second parameter is responsible for the target

//skill castend in skill.c
int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag){}



I'm pretty sure I'm wrong here:

struct map_session_data *pl_sd = map->nick2sd(bl);


Because when compiling it says:
 warning C4133: 'function': incompatible types - from 'block_list *' to 'const char *'

map->nick2sd() accepts const char
but bl is block_list


But, I do not know how to do it the right way.
how can I put the correct path to my target (The mob that was summoned)
Help me

 
Last edited by a moderator:
Code:
[COLOR=#000000]I think you're supposed to put the target on 2nd, but based on your code both src and target parameters are the same  which is &pl_sd->bl[/COLOR]
 
I think you're supposed to put the target on 2nd, but based on your code both src and target parameters are the same which is &pl_sd->bl

Cool that someone answered my topic :D  <3 
So, what do you think I should do Happy?

I honestly tried several alternatives, but I did not succeed.

 
Cool that someone answered my topic :D  <3 
So, what do you think I should do Happy?

I honestly tried several alternatives, but I did not succeed.
try putting bl on first and second since bl is already a block list you probably won't need the pl_sd 

 
try putting bl on first and second since bl is already a block list you probably won't need the pl_sd 
I tried to do this...

skill->castend_nodamage_id(bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0);


I put it like you said... but the server crashes

error.png


when we store in struct map_session_data and use in the parameter (such for example as pl_sd)

apparently not from error
but if I only use bl
the server map crashed


 
try to remove 

Code:
[COLOR=#000000]&pl_sd->bl all together, just put bl on there too. that's what i meant by "[/COLOR][COLOR=#272a34]try putting bl on first and second since bl is already a block list you probably won't need the pl_sd [/COLOR]"
 
Last edited by a moderator:
try to remove 

&pl_sd->bl all together, just put bl on there too. that's what i meant by "try putting bl on first and second since bl is already a block list you probably won't need the pl_sd "

Yes, I did it.

I also put in both arguments BL
and the error is the same ... the map server crashed

error.png


 
In function status_change_end_ sd already present. In this function only one pair of bl/sd from caster, and here no any targets.

This mean in

skill->castend_nodamage_id


you can use bl for call it.

 
Make sure that bl is a monster,

Make sure that bl is not null,

Its crashing prolly because of that bl being null,

I dont think mobs needs the map_session_data, so drop the pl_sd,

Find a way to get the mob_data->bl to that function,

 
In function status_change_end_ sd already present. In this function only one pair of bl/sd from caster, and here no any targets.

This mean in

skill->castend_nodamage_id


you can use bl for call it.
how can i use bl to call them?

I already tried to use only bl in the two arguments of the function:

skill->castend_nodamage_id(bl, bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0);


but it does not work
 

Make sure that bl is a monster,

Make sure that bl is not null,

Its crashing prolly because of that bl being null,

I dont think mobs needs the map_session_data, so drop the pl_sd,

Find a way to get the mob_data->bl to that function,
Oh yes...
I made the following debug
I put an if () to know the contents of bl:

if(bl->type == BL_MOB)
printf("this is BL_MOB \n"); //msg in console


so, he enters into this condition, and shows the message.


@benching  @4144 @Happy

Look at an example in this command
it uses map_session_data

in the atcommando.c file, look for this function: // command to blow up a player if I'm not mistaken

ACMD (nuke) {

But this command uses a string (typed by the player)
it uses the following form:

skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0);


I tried to follow the example ..
It worked, but as I said above
it explodes the player and not the target.

I thought it would be so easy ...
I believed that, just passing BL as an argument that the target would already be found

 
But this command uses a string (typed by the player)
it uses the following form:
it is because it first search for that string name if that user exist on the server once found it will pass that player's instance to pl_sd and use to that function(map->nick2sd(bl))..and take note sd or session_data is for players only the one you must look for is md or mob_data...

show us your whole code for that part and we will gladly pinpoint the issue and fix that...

 
it is because it first search for that string name if that user exist on the server once found it will pass that player's instance to pl_sd and use to that function(map->nick2sd(bl))..and take note sd or session_data is for players only the one you must look for is md or mob_data...

show us your whole code for that part and we will gladly pinpoint the issue and fix that...
Okay, I'll post the code here.

This is my custom skill .. in skill.c
She summons a MOB and uses SC in the same monster

case ALL_TEST:
{

int mob_id = 1142; //marina sphere
struct mob_data *md;
md = mob->once_spawn_sub(src, src->m, x, y, clif->get_bl_name(src), mob_id, "", SZ_BIG, AI_SPHERE);

if (md) {

mob->spawn (md); //summon mob
sc_start4(src,&md->bl,SC_RUN,100,skill_lv,dir,0,0,0);

}// end if

}
break;


in status.c, within the function responsible for terminating this status (SC)
in status_change_end_

case SC_RUN:
{

struct map_session_data *pl_sd = map->nick2sd(bl);

struct unit_data *ud = unit->bl2ud(bl);
bool begin_spurt = true;
// Note: this int64 value is stored in two separate int32 variables (FIXME)
int64 starttick = (int64)sce->val3&0x00000000ffffffffLL;
starttick |= ((int64)sce->val4<<32)&0xffffffff00000000LL;

if (ud) {
if(!ud->state.running)
begin_spurt = false;
printf("enter 1 \n"); //console debug
ud->state.running = 0;
if (ud->walktimer != INVALID_TIMER)
unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
printf("enter 2 \n"); //console debug

skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0); //cast skill

if(bl->type == BL_PC)
printf("BL_PC \n"); //console debug

if(bl->type == BL_MOB)
printf("BL_MOB \n"); //console debug


}
if (begin_spurt && sce->val1 >= 7
&& DIFF_TICK(timer->gettick(), starttick) <= 1000
&& (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0))
)
sc_start(bl, bl,SC_STRUP,100,sce->val1,skill->get_time2(status->sc2skill(type), sce->val1));
printf("enter 3 \n"); //console debug
}
break;


I'm using the function

skill->castend_nodamage_id


that way it works
but it works wrong ..
Instead of blasting the target (MOB)
she explodes the player

 
change 

sc_start4(src,&md->bl,SC_RUN,100,skill_lv,dir,0,0,0);


to

sc_start4(src,&md->bl,SC_RUN,100,skill_lv,dir,src->id,0,0);

then remove your changes on status.c then add this instead...put after

int64 starttick


add this

struct block_list *src = map->id2bl(val3);

if(bl->type == BL_MOB && (src && src->type == BL_PC)){ // check to make sure source is available and a pc type

skill->castend_nodamage_id(src, bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0); //active bomb

Code:
[COLOR=#000000]}[/COLOR]
 
change 

sc_start4(src,&md->bl,SC_RUN,100,skill_lv,dir,0,0,0);


to

sc_start4(src,&md->bl,SC_RUN,100,skill_lv,dir,src->id,0,0);

then remove your changes on status.c then add this instead...put after

int64 starttick


add this

struct block_list *src = map->id2bl(val3);

if(bl->type == BL_MOB && (src && src->type == BL_PC)){ // check to make sure source is available and a pc type

skill->castend_nodamage_id(src, bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0); //active bomb

}

hey man....
I tried this ... I got a mistake ...
he is saying that in status.c 
Val3 was not declared

struct block_list *src = map->id2bl(val3);


so I tried to put it this way:
 

struct block_list *src = map->id2bl(sce->val3);


The Status.c code looks like this:

case SC_RUN:
{

struct unit_data *ud = unit->bl2ud(bl);
bool begin_spurt = true;
// Note: this int64 value is stored in two separate int32 variables (FIXME)
int64 starttick = (int64)sce->val3&0x00000000ffffffffLL;
starttick |= ((int64)sce->val4<<32)&0xffffffff00000000LL;

if (ud) {
if(!ud->state.running)
begin_spurt = false;
printf("enter 1 \n"); //console debug
ud->state.running = 0;
if (ud->walktimer != INVALID_TIMER)
unit->stop_walking(bl, STOPWALKING_FLAG_FIXPOS);
printf("enter 1 \n"); //console debug

struct block_list *src = map->id2bl(sce->val3);

if(bl->type == BL_MOB && (src && src->type == BL_PC)){ // check to make sure source is available and a pc type

skill->castend_nodamage_id(src, bl, NPC_SELFDESTRUCTION, 1, timer->gettick(), 0); //active bomb
printf("enter 3 \n"); //console debug
}


}
if (begin_spurt && sce->val1 >= 7
&& DIFF_TICK(timer->gettick(), starttick) <= 1000
&& (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0))
)
sc_start(bl, bl,SC_STRUP,100,sce->val1,skill->get_time2(status->sc2skill(type), sce->val1));
}
break;



but it's not working
I'm using printf to debug ...
And he is not going through the BL and SRC check

take a look and tell me if I'm doing something wrong

 
oops sorry I forgot to add sce..:)

ok I got a question how do you call/use ALL_TEST? via the skill window?, script? or db?
 
yes, skill window!
I use the skill in the area .. and then do the whole process right.
My skill ALL_TEST case is in skill_castend_pos2

 
Back
Top