Jump to content
  • 0
Tio Akima

Using skill->castend_nodamage_id [DOUBT]

Question

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

        



 

Edited by Tio Akima

Share this post


Link to post
Share on other sites

16 answers to this question

Recommended Posts

  • 0
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

Share this post


Link to post
Share on other sites
  • 0
6 minutes ago, Happy said:

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.

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, Tio Akima said:

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 

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, Happy said:

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

Share this post


Link to post
Share on other sites
  • 0

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 "
Edited by Happy

Share this post


Link to post
Share on other sites
  • 0
10 minutes ago, Happy said:

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

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, Tio Akima said:

Yes, I did it.

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

error.png

Maybe develop while on debug mode, could produce a more understandable error http://herc.ws/wiki/MSVC_Crash_Debugging check this link to enable it on Visual Studio run the map server thru it. and trigger the error again, then post what shows up.

Share this post


Link to post
Share on other sites
  • 0

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.

 

Share this post


Link to post
Share on other sites
  • 0

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,

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, 4144 said:

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
 

17 minutes ago, benching said:

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

Share this post


Link to post
Share on other sites
  • 0
On 9/7/2017 at 2:34 PM, Tio Akima said:

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...

Share this post


Link to post
Share on other sites
  • 0
9 hours ago, malufett said:

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

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
  • 0

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

}

Share this post


Link to post
Share on other sites
  • 0
6 hours ago, malufett said:

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

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Tio Akima said:

Val3 was not declared

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?
 

Share this post


Link to post
Share on other sites
  • 0
40 minutes ago, malufett said:

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.