Jump to content
  • 0

I need a code <3


Mabuhay

Question


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

is it possible that when a mob will attack a another mob?

what i mean is that it will be mob aggresive?

like an emp will be summoned, then the monsters spawned will attack the emp?

if not, can it be that an NPC will be attacked by mobs? if mobs reaches the NPC, event is over. But if all the mobs has been killed, another wave will appear? if they can successfully defend the NPC, they will be rewarded automatically. if they die along the battle, they will be warped out the event and must wait until the next time the event activates

Edited by MrVandalBus
Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

all answer here require mob controller system

is it possible that when a mob will attack a another mob?
-    script    dkfjhskdfjh    -1,{
OnInit:
   .id[0] = bg_monster( 0,"prontera",150,175,"--ja--",1002, strnpcinfo(0)+"::On0die" );
   .id[1] = bg_monster( 0,"prontera",160,175,"--ja--",1002, strnpcinfo(0)+"::On1die" );
   unitattack .id[0], .id[1];
   unitattack .id[1], .id[0];
   end;
On0die: callsub L_kill, 1;
On1die: callsub L_kill, 0;
L_kill:
   unittalk .id[ getarg(0) ], "I win !!";
   sleep 2000;
   unitkill .id[ getarg(0) ]; // hahaha
   end;
}


what i mean is that it will be mob aggresive?
if you use unitkill script command, yeah, even a non-aggressive monster will attack others


like an emp will be summoned, then the monsters spawned will attack the emp?
-    script    dkfjhskdfjh2    -1,{
OnInit:
   .emp = bg_monster( 0,"prontera",155,175,"--ja--",1288, strnpcinfo(0)+"::OnEmpDown" );
   for ( .@i = 0; .@i < 10; .@i++ ) {
       .id[.@i] = bg_monster( 0,"prontera",150 +.@i,175,"--ja--",1001, "" );
       unitattack .id[.@i], .emp;
   }
   end;
OnEmpDown:
   announce "Emperium has fallen !", 0;
   end;
}


if not, can it be that an NPC will be attacked by mobs?
no, an NPC has no HP whatsoever to make it attack by monsters


if mobs reaches the NPC, event is over. But if all the mobs has been killed, another wave will appear? if they can successfully defend the NPC, they will be rewarded automatically. if they die along the battle, they will be warped out the event and must wait until the next time the event activates

-	script	hero_def	-1,{
if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_WALKACK ) {
	getmobdata .ai_action[AI_ACTION_SRC], .@data;
	if ( .@data[6] < 46 || .@data[6] > 53 || .@data[7] < 46 || .@data[7] > 53 ) {
		unitwalk .ai_action[AI_ACTION_SRC], .@data[6] + .movement[ getd( ".dir_"+ .ai_action[AI_ACTION_SRC] ) *2 ], .@data[7] + .movement[ getd( ".dir_"+ .ai_action[AI_ACTION_SRC] ) *2 +1 ];
		end;
	}
	else {
		unitkill .ai_action[AI_ACTION_SRC];
		.life_left--;
		if ( .life_left ) end;
		announce "what a loser, you guys failed", 0;
	}
}
else if ( !.round )
	end;
else if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_DEAD ) {
	.mob_left--;
	if ( .mob_left ) end;
	.round++;
	if ( .round <= .no_of_wave ) {
		callsub L_spawn;
		end;
	}
	announce "congratulations !", 0;
	for ( .@i = 0; .@i < .register_count; .@i++ )
		getitem 501, 1, .register_aid[.@i]; // reward item here
}
.round = 0;
killmonsterall .map$;
sleep 5000;
getmapxy .@map$, .@x, .@y, 1, .npcname$;
mapwarp .map$, .@map$, .@x, .@y;
donpcevent .npcname$ +"::OnCreateRoom";
end;
OnInit:
.minplayer2start = 1; // minimum player to start
.life = 10; // amount of life
.no_of_mobs_per_side = 25; // max 32
.no_of_wave = 3; // number of wave to be defeated

.map$ = "guild_vs2"; // name of the map
setarray .spawn, // rand(x1,x2) , rand(y1,y2)
	46,53 , 88,93 , // North spawn coordinates
	88,93 , 46,53 , // West spawn coordinates
	46,53 , 6,11 , // South spawn coordinates
	6,11 , 46,53 ; // East spawn coordinates
setarray .movement, // movement directions
	0, -1, // north movement towards south
	-1, 0, // west movement towards east
	0 , 1, // south movement towards north
	1 , 0; // east movement towards west
setarray .mapflag,
	mf_nosave,
	mf_nowarp,
	mf_nowarpto,
	mf_noteleport,
	mf_nomemo,
	mf_nopenalty,
	mf_nobranch,
	mf_noicewall,
	mf_nomobloot,
	mf_nomvploot;
.@size = getarraysize( .mapflag );
for ( .@i = 0; .@i < .@size; .@i++ )
	setmapflag .map$, .mapflag[.@i];
sleep 1;
donpcevent .npcname$ +"::OnCreateRoom";
end;
OnEventInit:
.round = 1;
callsub L_spawn;
.life_left = .life;
while ( .round ) {
	for ( .@i = 0; .@i < .register_count; .@i++ ) {
		attachrid .register_aid[.@i];
		showdigit .life_left;
	}
	sleep 5050;
}
end;
L_spawn:
.mob_left = .no_of_mobs_per_side * 4;
for ( .@i = 0; .@i < 4; .@i++ ) {
	for ( .@j = .no_of_mobs_per_side * .@i; .@j < .no_of_mobs_per_side * ( .@i +1 ); .@j++ ) {
		.id[.@j] = mobspawn( "--ja--", 1002, .map$, rand( .spawn[ 4 * .@i + 0 ] , .spawn[ 4 * .@i + 1 ] ), rand( .spawn[ 4 * .@i + 2 ], .spawn[ 4 * .@i + 3 ] ) );
		setd ".dir_"+ .id[.@j], .@i;
		mobattach .id[.@j], strnpcinfo(0);
		setmobdata .id[.@j], 25, AI_ACTION_TYPE_WALKACK | AI_ACTION_TYPE_DEAD;
		setmobdata .id[.@j], 26, 1;
		getmobdata .id[.@j], .@data;
		unitwalk .id[.@j], .@data[6] + .movement[ 2 * .@i + 0 ], .@data[7] + .movement[ 2 * .@i + 1 ];
	}
}
return;
OnPCDieEvent:
OnPCLogoutEvent:
if ( !.round || strcharinfo(3) != .map$ ) end;
while ( .register_aid[.@i] != getcharid(3) && .@i < .register_count ) .@i++;
deletearray .register_aid[.@i], 1;
.register_count--;
warp "Save", 0,0;
if ( .register_count ) end;
announce "all players log out <.<", 0;
killmonsterall .map$;
.round = 0;
donpcevent .npcname$ +"::OnEventInit";
end;
}
prontera,155,187,6	script	Hero Defence	100,{
end;
OnInit:
set getvariableofnpc( .npcname$, "hero_def" ), strnpcinfo(0);
end;
OnCreateRoom:
waitingroom "Hero Defence", getvariableofnpc( .minplayer2start, "hero_def" ) +1, strnpcinfo(0)+"::OnEventInit", getvariableofnpc( .minplayer2start, "hero_def" );
end;
OnEventInit:
warpwaitingpc getvariableofnpc( .map$, "hero_def" ), 0,0;
copyarray getvariableofnpc( .register_aid, "hero_def" ), $@warpwaitingpc,  $@warpwaitingpcnum;
set getvariableofnpc( .register_count, "hero_def" ), $@warpwaitingpcnum;
delwaitingroom;
donpcevent "hero_def::OnEventInit";
end;
}

... I admit this last one is the one that pose a bit of challenge for my scripting ability

EDIT: I even update this script about 3 times already

by the way

if you want to ask several question, its better to open several topics >.>

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

all answer here require mob controller system

is it possible that when a mob will attack a another mob?
-	script	dkfjhskdfjh	-1,{
OnInit:
.id[0] = bg_monster( 0,"prontera",150,175,"--ja--",1002, strnpcinfo(0)+"::On0die" );
.id[1] = bg_monster( 0,"prontera",160,175,"--ja--",1002, strnpcinfo(0)+"::On1die" );
unitattack .id[0], .id[1];
unitattack .id[1], .id[0];
end;
On0die: callsub L_kill, 1;
On1die: callsub L_kill, 0;
L_kill:
unittalk .id[ getarg(0) ], "I win !!";
sleep 2000;
unitkill .id[ getarg(0) ]; // hahaha
end;
}


what i mean is that it will be mob aggresive?
if you use unitkill script command, yeah, even a non-aggressive monster will attack others


like an emp will be summoned, then the monsters spawned will attack the emp?
-	script	dkfjhskdfjh2	-1,{
OnInit:
.emp = bg_monster( 0,"prontera",155,175,"--ja--",1288, strnpcinfo(0)+"::OnEmpDown" );
for ( .@i = 0; .@i < 10; .@i++ ) {
	.id[.@i] = bg_monster( 0,"prontera",150 +.@i,175,"--ja--",1001, "" );
	unitattack .id[.@i], .emp;
}
end;
OnEmpDown:
announce "Emperium has fallen !", 0;
end;
}


if not, can it be that an NPC will be attacked by mobs?
no, an NPC has no HP whatsoever to make it attack by monsters


if mobs reaches the NPC, event is over. But if all the mobs has been killed, another wave will appear? if they can successfully defend the NPC, they will be rewarded automatically. if they die along the battle, they will be warped out the event and must wait until the next time the event activates

-	script	hero_def	-1,{
if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_WALKACK ) {
	getmobdata .ai_action[AI_ACTION_SRC], .@data;
	if ( .@data[6] < 46 || .@data[6] > 53 || .@data[7] < 46 || .@data[7] > 53 ) {
		unitwalk .ai_action[AI_ACTION_SRC], .@data[6] + .movement[ getd( ".dir_"+ .ai_action[AI_ACTION_SRC] ) *2 ], .@data[7] + .movement[ getd( ".dir_"+ .ai_action[AI_ACTION_SRC] ) *2 +1 ];
		end;
	}
	else {
		unitkill .ai_action[AI_ACTION_SRC];
		.life_left--;
		if ( .life_left ) end;
		announce "what a loser, you guys failed", 0;
	}
}
else if ( !.round )
	end;
else if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_DEAD ) {
	.mob_left--;
	if ( .mob_left ) end;
	.round++;
	if ( .round <= .no_of_wave ) {
		callsub L_spawn;
		end;
	}
	announce "congratulations !", 0;
	for ( .@i = 0; .@i < .register_count; .@i++ )
		getitem 501, 1, .register_aid[.@i]; // reward item here
}
.round = 0;
killmonsterall .map$;
sleep 5000;
getmapxy .@map$, .@x, .@y, 1, .npcname$;
mapwarp .map$, .@map$, .@x, .@y;
donpcevent .npcname$ +"::OnCreateRoom";
end;
OnInit:
.minplayer2start = 1; // minimum player to start
.life = 10; // amount of life
.no_of_mobs_per_side = 25; // max 32
.no_of_wave = 3; // number of wave to be defeated

.map$ = "guild_vs2"; // name of the map
setarray .spawn, // rand(x1,x2) , rand(y1,y2)
	46,53 , 88,93 , // North spawn coordinates
	88,93 , 46,53 , // West spawn coordinates
	46,53 , 6,11 , // South spawn coordinates
	6,11 , 46,53 ; // East spawn coordinates
setarray .movement, // movement directions
	0, -1, // north movement towards south
	-1, 0, // west movement towards east
	0 , 1, // south movement towards north
	1 , 0; // east movement towards west
setarray .mapflag,
	mf_nosave,
	mf_nowarp,
	mf_nowarpto,
	mf_noteleport,
	mf_nomemo,
	mf_nopenalty,
	mf_nobranch,
	mf_noicewall,
	mf_nomobloot,
	mf_nomvploot;
.@size = getarraysize( .mapflag );
for ( .@i = 0; .@i < .@size; .@i++ )
	setmapflag .map$, .mapflag[.@i];
sleep 1;
donpcevent .npcname$ +"::OnCreateRoom";
end;
OnEventInit:
.round = 1;
callsub L_spawn;
.life_left = .life;
while ( .round ) {
	for ( .@i = 0; .@i < .register_count; .@i++ ) {
		attachrid .register_aid[.@i];
		showdigit .life_left;
	}
	sleep 5050;
}
end;
L_spawn:
.mob_left = .no_of_mobs_per_side * 4;
for ( .@i = 0; .@i < 4; .@i++ ) {
	for ( .@j = .no_of_mobs_per_side * .@i; .@j < .no_of_mobs_per_side * ( .@i +1 ); .@j++ ) {
		.id[.@j] = mobspawn( "--ja--", 1002, .map$, rand( .spawn[ 4 * .@i + 0 ] , .spawn[ 4 * .@i + 1 ] ), rand( .spawn[ 4 * .@i + 2 ], .spawn[ 4 * .@i + 3 ] ) );
		setd ".dir_"+ .id[.@j], .@i;
		mobattach .id[.@j], strnpcinfo(0);
		setmobdata .id[.@j], 25, AI_ACTION_TYPE_WALKACK | AI_ACTION_TYPE_DEAD;
		setmobdata .id[.@j], 26, 1;
		getmobdata .id[.@j], .@data;
		unitwalk .id[.@j], .@data[6] + .movement[ 2 * .@i + 0 ], .@data[7] + .movement[ 2 * .@i + 1 ];
	}
}
return;
OnPCDieEvent:
OnPCLogoutEvent:
if ( !.round || strcharinfo(3) != .map$ ) end;
while ( .register_aid[.@i] != getcharid(3) && .@i < .register_count ) .@i++;
deletearray .register_aid[.@i], 1;
.register_count--;
warp "Save", 0,0;
if ( .register_count ) end;
announce "all players log out <.<", 0;
killmonsterall .map$;
.round = 0;
donpcevent .npcname$ +"::OnEventInit";
end;
}
prontera,155,187,6	script	Hero Defence	100,{
end;
OnInit:
set getvariableofnpc( .npcname$, "hero_def" ), strnpcinfo(0);
end;
OnCreateRoom:
waitingroom "Hero Defence", getvariableofnpc( .minplayer2start, "hero_def" ) +1, strnpcinfo(0)+"::OnEventInit", getvariableofnpc( .minplayer2start, "hero_def" );
end;
OnEventInit:
warpwaitingpc getvariableofnpc( .map$, "hero_def" ), 0,0;
copyarray getvariableofnpc( .register_aid, "hero_def" ), $@warpwaitingpc,  $@warpwaitingpcnum;
set getvariableofnpc( .register_count, "hero_def" ), $@warpwaitingpcnum;
delwaitingroom;
donpcevent "hero_def::OnEventInit";
end;
}

... I admit this last one is the one that pose a bit of challenge for my scripting ability

EDIT: I even update this script about 3 times already

by the way

if you want to ask several question, its better to open several topics >.>

Sorry to disturb you annie :(

Btw, i tested the last one you posted. It seems that getmobdata is not functioning in my server ? :(

I will test the other you made :3

Thanks btw annie :3

edit sorry for got to see the first link :3

Edited by MrVandalBus
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

all answer here require mob controller system

is it possible that when a mob will attack a another mob?
-	script	dkfjhskdfjh	-1,{
OnInit:
.id[0] = bg_monster( 0,"prontera",150,175,"--ja--",1002, strnpcinfo(0)+"::On0die" );
.id[1] = bg_monster( 0,"prontera",160,175,"--ja--",1002, strnpcinfo(0)+"::On1die" );
unitattack .id[0], .id[1];
unitattack .id[1], .id[0];
end;
On0die: callsub L_kill, 1;
On1die: callsub L_kill, 0;
L_kill:
unittalk .id[ getarg(0) ], "I win !!";
sleep 2000;
unitkill .id[ getarg(0) ]; // hahaha
end;
}


what i mean is that it will be mob aggresive?
if you use unitkill script command, yeah, even a non-aggressive monster will attack others


like an emp will be summoned, then the monsters spawned will attack the emp?
-	script	dkfjhskdfjh2	-1,{
OnInit:
.emp = bg_monster( 0,"prontera",155,175,"--ja--",1288, strnpcinfo(0)+"::OnEmpDown" );
for ( .@i = 0; .@i < 10; .@i++ ) {
	.id[.@i] = bg_monster( 0,"prontera",150 +.@i,175,"--ja--",1001, "" );
	unitattack .id[.@i], .emp;
}
end;
OnEmpDown:
announce "Emperium has fallen !", 0;
end;
}


if not, can it be that an NPC will be attacked by mobs?
no, an NPC has no HP whatsoever to make it attack by monsters


if mobs reaches the NPC, event is over. But if all the mobs has been killed, another wave will appear? if they can successfully defend the NPC, they will be rewarded automatically. if they die along the battle, they will be warped out the event and must wait until the next time the event activates

-	script	hero_def	-1,{
if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_WALKACK ) {
	getmobdata .ai_action[AI_ACTION_SRC], .@data;
	if ( .@data[6] < 46 || .@data[6] > 53 || .@data[7] < 46 || .@data[7] > 53 ) {
		unitwalk .ai_action[AI_ACTION_SRC], .@data[6] + .movement[ getd( ".dir_"+ .ai_action[AI_ACTION_SRC] ) *2 ], .@data[7] + .movement[ getd( ".dir_"+ .ai_action[AI_ACTION_SRC] ) *2 +1 ];
		end;
	}
	else {
		unitkill .ai_action[AI_ACTION_SRC];
		.life_left--;
		if ( .life_left ) end;
		announce "what a loser, you guys failed", 0;
	}
}
else if ( !.round )
	end;
else if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_DEAD ) {
	.mob_left--;
	if ( .mob_left ) end;
	.round++;
	if ( .round <= .no_of_wave ) {
		callsub L_spawn;
		end;
	}
	announce "congratulations !", 0;
	for ( .@i = 0; .@i < .register_count; .@i++ )
		getitem 501, 1, .register_aid[.@i]; // reward item here
}
.round = 0;
killmonsterall .map$;
sleep 5000;
getmapxy .@map$, .@x, .@y, 1, .npcname$;
mapwarp .map$, .@map$, .@x, .@y;
donpcevent .npcname$ +"::OnCreateRoom";
end;
OnInit:
.minplayer2start = 1; // minimum player to start
.life = 10; // amount of life
.no_of_mobs_per_side = 25; // max 32
.no_of_wave = 3; // number of wave to be defeated

.map$ = "guild_vs2"; // name of the map
setarray .spawn, // rand(x1,x2) , rand(y1,y2)
	46,53 , 88,93 , // North spawn coordinates
	88,93 , 46,53 , // West spawn coordinates
	46,53 , 6,11 , // South spawn coordinates
	6,11 , 46,53 ; // East spawn coordinates
setarray .movement, // movement directions
	0, -1, // north movement towards south
	-1, 0, // west movement towards east
	0 , 1, // south movement towards north
	1 , 0; // east movement towards west
setarray .mapflag,
	mf_nosave,
	mf_nowarp,
	mf_nowarpto,
	mf_noteleport,
	mf_nomemo,
	mf_nopenalty,
	mf_nobranch,
	mf_noicewall,
	mf_nomobloot,
	mf_nomvploot;
.@size = getarraysize( .mapflag );
for ( .@i = 0; .@i < .@size; .@i++ )
	setmapflag .map$, .mapflag[.@i];
sleep 1;
donpcevent .npcname$ +"::OnCreateRoom";
end;
OnEventInit:
.round = 1;
callsub L_spawn;
.life_left = .life;
while ( .round ) {
	for ( .@i = 0; .@i < .register_count; .@i++ ) {
		attachrid .register_aid[.@i];
		showdigit .life_left;
	}
	sleep 5050;
}
end;
L_spawn:
.mob_left = .no_of_mobs_per_side * 4;
for ( .@i = 0; .@i < 4; .@i++ ) {
	for ( .@j = .no_of_mobs_per_side * .@i; .@j < .no_of_mobs_per_side * ( .@i +1 ); .@j++ ) {
		.id[.@j] = mobspawn( "--ja--", 1002, .map$, rand( .spawn[ 4 * .@i + 0 ] , .spawn[ 4 * .@i + 1 ] ), rand( .spawn[ 4 * .@i + 2 ], .spawn[ 4 * .@i + 3 ] ) );
		setd ".dir_"+ .id[.@j], .@i;
		mobattach .id[.@j], strnpcinfo(0);
		setmobdata .id[.@j], 25, AI_ACTION_TYPE_WALKACK | AI_ACTION_TYPE_DEAD;
		setmobdata .id[.@j], 26, 1;
		getmobdata .id[.@j], .@data;
		unitwalk .id[.@j], .@data[6] + .movement[ 2 * .@i + 0 ], .@data[7] + .movement[ 2 * .@i + 1 ];
	}
}
return;
OnPCDieEvent:
OnPCLogoutEvent:
if ( !.round || strcharinfo(3) != .map$ ) end;
while ( .register_aid[.@i] != getcharid(3) && .@i < .register_count ) .@i++;
deletearray .register_aid[.@i], 1;
.register_count--;
warp "Save", 0,0;
if ( .register_count ) end;
announce "all players log out <.<", 0;
killmonsterall .map$;
.round = 0;
donpcevent .npcname$ +"::OnEventInit";
end;
}
prontera,155,187,6	script	Hero Defence	100,{
end;
OnInit:
set getvariableofnpc( .npcname$, "hero_def" ), strnpcinfo(0);
end;
OnCreateRoom:
waitingroom "Hero Defence", getvariableofnpc( .minplayer2start, "hero_def" ) +1, strnpcinfo(0)+"::OnEventInit", getvariableofnpc( .minplayer2start, "hero_def" );
end;
OnEventInit:
warpwaitingpc getvariableofnpc( .map$, "hero_def" ), 0,0;
copyarray getvariableofnpc( .register_aid, "hero_def" ), $@warpwaitingpc,  $@warpwaitingpcnum;
set getvariableofnpc( .register_count, "hero_def" ), $@warpwaitingpcnum;
delwaitingroom;
donpcevent "hero_def::OnEventInit";
end;
}

... I admit this last one is the one that pose a bit of challenge for my scripting ability

EDIT: I even update this script about 3 times already

by the way

if you want to ask several question, its better to open several topics >.>

Everything works fine and perfect. Except for the Emperium thing. When the scorpions are summoned. they will attack themselves. the last one that survives will

kill the emp.

for the 3rd one, can it be that it will use an Emperium? it will be like tower defense thingy. Mobs will be spawned and will try to kill the emp. players should protect the emp from the monsters. same mechanics, there will be waves of mobs (most preferably different mobs per wave if possible)

Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...