Summon Creature

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Trike
Journeyman Poster
Posts: 62
Joined: Mon Aug 19, 2019 7:55 pm

Summon Creature

Post by Trike » Fri Aug 30, 2019 1:03 pm

Kind time of the day, tell me you need to ensure that the spell does not automatically select the beast, but issues a sign to select the listed animals

use util;

include "summon";
include "include/attributes";
include "include/spellRestrictions";

program cast_summon( parms )
var circle := 5;
var delivery := "indirect";
var noto := "neutral";
var result := maincast(parms, delivery, circle, noto, 40);
if(result == 0)
return;
endif
var caster := result[1];
var cast_on := result[2];
var thecreature;
var thecritter;
var critgroup;
var basemagery := CInt(GetEffectiveSkill(caster, SKILLID_MAGERY));
if (basemagery < 70)
critgroup := RandomInt(1);
elseif (basemagery < 80)
critgroup := RandomInt(1)+1;
elseif (basemagery < 90)
critgroup := RandomInt(1)+2;
else
critgroup := 3;
endif
var critter := RandomInt(19);
case (critter)
0: thecreature := "chicken";
1: thecreature := "cat";
2: thecreature := "slime";
3: thecreature := "sheep";
4: thecreature := "pig";
5: thecreature := "dog";
6: thecreature := "grat";
7: thecreature := "eagle";
8: case(RandomInt(4))
0: thecreature := "horse";
1: thecreature := "horse2";
2: thecreature := "horse3";
3: thecreature := "horse4";
endcase
9: thecreature := "gorilla";
10: thecreature := "panther";
11: thecreature := "deer";
12: thecreature := "bear";
13: thecreature := "ghart";
14: thecreature := "blackbear";
15: thecreature := "alligator";
16: thecreature := "giantspider";
17: thecreature := "giant_serpent";
18: thecreature := "polar";
endcase
summon_creature( caster, circle, thecreature, cast_on );
endprogram

Yukiko
Distro Developer
Posts: 2781
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Summon Creature

Post by Yukiko » Fri Aug 30, 2019 4:49 pm

If I understand correctly, when the Summon Creature spell is cast you want a gump to appear that would allow the player to select the creature.
.
I have always wondered why no one ever created a script for that. It should be easy. Give me some time and I can probably create it.

I do not mind helping you with some scripts but Trike, I want you to continue learning eScript. I realize the language barrier is a challenge. Other non-English speakers have accomplished it.

Yukiko
Distro Developer
Posts: 2781
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Summon Creature

Post by Yukiko » Fri Aug 30, 2019 5:08 pm

Also, you had posted this topic twice. I deleted the duplicate post.

Trike
Journeyman Poster
Posts: 62
Joined: Mon Aug 19, 2019 7:55 pm

Re: Summon Creature

Post by Trike » Sat Aug 31, 2019 12:20 am

Yukiko wrote:
Fri Aug 30, 2019 4:49 pm
If I understand correctly, when the Summon Creature spell is cast you want a gump to appear that would allow the player to select the creature.
.
I have always wondered why no one ever created a script for that. It should be easy. Give me some time and I can probably create it.

I do not mind helping you with some scripts but Trike, I want you to continue learning eScript. I realize the language barrier is a challenge. Other non-English speakers have accomplished it.
I study Russian-language manuals, but so far it is not so easy, thanks for your help, you are very kind to me, this was done at Dream Worlde before) I have never seen a better server) Debugged systems)

Yukiko
Distro Developer
Posts: 2781
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Summon Creature

Post by Yukiko » Mon Sep 02, 2019 12:51 am

Here is the summon creature spell script with a selection gump to allow the player to choose which creature to summon. Anyway, I hope this helps you Trike.

Code: Select all

use util;
use cliloc;

include ":magery:summon";
include ":attributes:attributes";
include ":gumps:gumps";
include ":magery:spells";


program cast_summon_with_gump( parms )
  var caster := parms[1];
  var info := parms[2];
  var cast_on := MS_TargetCoordinates(caster, info.targ, "Select a place:");
    if (!cast_on) // If no cast_on then get cast_on from parms[4]. Used mostly for NPC casting.
        cast_on := parms[4];
    endif
    if (!cast_on)
        SendSysMessage (caster, "Cancelled.", color := 33);
        return 0;
    endif
  if ( !CheckLosAt(caster, cast_on.x, cast_on.y, cast_on.z) )
        return 0;
  endif
  Sleepms (200);

  var thecreature := DoCreatureSelection( caster );
  summon_creature( caster, info.circle, thecreature, cast_on, 30, "animal" );

  return;
endprogram

function DoCreatureSelection (who)
	// This is an array containing the graphic numbers of the NPC graphics displayed in the "gump".
	var creature_graphics := array {0x20D1, 0x211b, 0x20E8, 0x20e6, 0x2101, 0x211c, 0x20D0, 0x211d,
								0x2121, 0x2124, 0x211f, 0x2120, 0x20C9, 0x2119, 0x20D4, 0x2118,
								0x20D4, 0x20CF, 0x2131, 0x25C6, 0x25BF, 0x20E1, 0x20F9, 0x210A,
								0x2103, 0x20EF, 0x25D2, 0x259F, 0x20DC, 0x211e, 0x25D0};
	// This is an array containing the name of the NPC as it appears in the npcdesc.cfg file.
	var creature_names := {"chicken", "cat", "slime", "sheep", "pig", "dog", "grat", "eagle",
	                      "horse", "horse2", "horse3", "horse4", "gorilla", "panther", "deer", "bear",
						  "ghart", "blackbear", "alligator", "giantspide", "giantserp", "polarbear", "mongbat", "headless",
						  "cow", "bull", "frostwolf", "imp", "harpy", "grizzlybear", "direwolf"};
	// This is an array containing the names of the creatures displayed as tool tips in the "gump".
	var creature_tips := {"chicken", "cat", "slime", "sheep", "pig", "dog", "giant rat", "eagle",
	                      "brown horse", "palomino horse", "grey horse", "tan horse", "gorilla", "panther", "deer", "bear",
						  "great hart", "black bear", "alligator", "giant spide", "giant serpion", "polar  bear", "mongbat", "headless one",
						  "cow", "bull", "frost wolf", "imp", "harpy", "grizzly bear", "dire wolf"};

	// This line creates the creature gump.
	var selection := BuildCreatureGump(who, creature_graphics, creature_tips);
	// If the player closed the gump without clicking on a creature (Usually by right-clicking on the gump)
	// then we send the word "Canceled", using the built in localization, and exit the script.
	if (!selection)
		SendSysMessageCL( who, 1042021, color := 33 ); //Cancelled
		return;
	endif

	// Here we retrieve the return value from the gump.
	selection := selection[0];
	// This finds the ordinal position of the graphic in the array 'creature_graphics'.
	var graphic_position := selection - 100;
	// Retrieve the name used to summon the creature.
	var summon_this := creature_names[graphic_position];
	return summon_this;
endfunction

function BuildCreatureGump(who, creature_list, creature_tool_tips)
	var num_creatures := CInt(creature_list.Size());
	var multiplier, ItemX, ItemY := 20;
	var gump := GFCreateGump(50, 50);
	GFPage(gump, 0);
	GFResizePic(gump, 0, 0, 9250, 392, 274);
	GFPicTiled(gump, 12, 12, 368, 250, 2624);
	GFAddAlphaRegion(gump, 12, 12, 368, 250);
	GFPage(gump, 1);
	foreach entry in ( creature_list )
		entry := Hex(entry);
		multiplier := CInt( _entry_iter - 1 );
		var CustName := creature_tool_tips[_entry_iter];
		ItemX := CInt( 20 + ( 90 * ( multiplier % 4 )));
		// Return value from SendGump() will be 100 + the ordinal postion of 'entry' in the array 'creature_list'.
		GFAddButton(gump, ItemX, ItemY, 2328, 2329, GF_CLOSE_BTN, 100+_entry_iter);
		GFTooltip(gump, 1042971, CStr(CustName));
		GFPicTiled( gump, ItemX, ItemY, 80, 60, 3004 );
		GFTilePic(gump, ItemX + 15, ItemY + 12, entry, 0);

		if( _entry_iter < num_creatures && ItemX == 290 && ItemY == 160 )
				GFAddButton(gump, 346, 236, 4005, 4007, GF_PAGE_BTN, gump.cur_page+1);
				GFAddHTMLLocalized(gump, 283, 236, 60, 20, 1011066, 0, 0, 66); //Next Page
				GFPage( gump,  gump.cur_page+1 );
				GFAddButton(gump, 16, 236, 4014, 4016, GF_PAGE_BTN, gump.cur_page-1);
				GFAddHTMLLocalized(gump, 46, 236, 140, 20, 1011067, 0, 0, 66); //Previos Page
		endif
			SleepMS( 2 );
		if ( ItemX == 290 && ItemY == 20 )
			ItemY := CInt(ItemY + 70);
		elseif ( ItemX == 290 && ItemY == 90 )
			ItemY := CInt(ItemY + 70);
		elseif ( ItemX == 290 && ItemY == 160 )
			ItemY := CInt(20);
		endif
	endforeach

	return GFSendGump(who, gump);
endfunction

Trike
Journeyman Poster
Posts: 62
Joined: Mon Aug 19, 2019 7:55 pm

Re: Summon Creature

Post by Trike » Mon Sep 02, 2019 2:03 am

Yukiko wrote:
Mon Sep 02, 2019 12:51 am
Here is the summon creature spell script with a selection gump to allow the player to choose which creature to summon. Anyway, I hope this helps you Trike.

Code: Select all

use util;
use cliloc;

include ":magery:summon";
include ":attributes:attributes";
include ":gumps:gumps";
include ":magery:spells";


program cast_summon_with_gump( parms )
  var caster := parms[1];
  var info := parms[2];
  var cast_on := MS_TargetCoordinates(caster, info.targ, "Select a place:");
    if (!cast_on) // If no cast_on then get cast_on from parms[4]. Used mostly for NPC casting.
        cast_on := parms[4];
    endif
    if (!cast_on)
        SendSysMessage (caster, "Cancelled.", color := 33);
        return 0;
    endif
  if ( !CheckLosAt(caster, cast_on.x, cast_on.y, cast_on.z) )
        return 0;
  endif
  Sleepms (200);

  var thecreature := DoCreatureSelection( caster );
  summon_creature( caster, info.circle, thecreature, cast_on, 30, "animal" );

  return;
endprogram

function DoCreatureSelection (who)
	// This is an array containing the graphic numbers of the NPC graphics displayed in the "gump".
	var creature_graphics := array {0x20D1, 0x211b, 0x20E8, 0x20e6, 0x2101, 0x211c, 0x20D0, 0x211d,
								0x2121, 0x2124, 0x211f, 0x2120, 0x20C9, 0x2119, 0x20D4, 0x2118,
								0x20D4, 0x20CF, 0x2131, 0x25C6, 0x25BF, 0x20E1, 0x20F9, 0x210A,
								0x2103, 0x20EF, 0x25D2, 0x259F, 0x20DC, 0x211e, 0x25D0};
	// This is an array containing the name of the NPC as it appears in the npcdesc.cfg file.
	var creature_names := {"chicken", "cat", "slime", "sheep", "pig", "dog", "grat", "eagle",
	                      "horse", "horse2", "horse3", "horse4", "gorilla", "panther", "deer", "bear",
						  "ghart", "blackbear", "alligator", "giantspide", "giantserp", "polarbear", "mongbat", "headless",
						  "cow", "bull", "frostwolf", "imp", "harpy", "grizzlybear", "direwolf"};
	// This is an array containing the names of the creatures displayed as tool tips in the "gump".
	var creature_tips := {"chicken", "cat", "slime", "sheep", "pig", "dog", "giant rat", "eagle",
	                      "brown horse", "palomino horse", "grey horse", "tan horse", "gorilla", "panther", "deer", "bear",
						  "great hart", "black bear", "alligator", "giant spide", "giant serpion", "polar  bear", "mongbat", "headless one",
						  "cow", "bull", "frost wolf", "imp", "harpy", "grizzly bear", "dire wolf"};

	// This line creates the creature gump.
	var selection := BuildCreatureGump(who, creature_graphics, creature_tips);
	// If the player closed the gump without clicking on a creature (Usually by right-clicking on the gump)
	// then we send the word "Canceled", using the built in localization, and exit the script.
	if (!selection)
		SendSysMessageCL( who, 1042021, color := 33 ); //Cancelled
		return;
	endif

	// Here we retrieve the return value from the gump.
	selection := selection[0];
	// This finds the ordinal position of the graphic in the array 'creature_graphics'.
	var graphic_position := selection - 100;
	// Retrieve the name used to summon the creature.
	var summon_this := creature_names[graphic_position];
	return summon_this;
endfunction

function BuildCreatureGump(who, creature_list, creature_tool_tips)
	var num_creatures := CInt(creature_list.Size());
	var multiplier, ItemX, ItemY := 20;
	var gump := GFCreateGump(50, 50);
	GFPage(gump, 0);
	GFResizePic(gump, 0, 0, 9250, 392, 274);
	GFPicTiled(gump, 12, 12, 368, 250, 2624);
	GFAddAlphaRegion(gump, 12, 12, 368, 250);
	GFPage(gump, 1);
	foreach entry in ( creature_list )
		entry := Hex(entry);
		multiplier := CInt( _entry_iter - 1 );
		var CustName := creature_tool_tips[_entry_iter];
		ItemX := CInt( 20 + ( 90 * ( multiplier % 4 )));
		// Return value from SendGump() will be 100 + the ordinal postion of 'entry' in the array 'creature_list'.
		GFAddButton(gump, ItemX, ItemY, 2328, 2329, GF_CLOSE_BTN, 100+_entry_iter);
		GFTooltip(gump, 1042971, CStr(CustName));
		GFPicTiled( gump, ItemX, ItemY, 80, 60, 3004 );
		GFTilePic(gump, ItemX + 15, ItemY + 12, entry, 0);

		if( _entry_iter < num_creatures && ItemX == 290 && ItemY == 160 )
				GFAddButton(gump, 346, 236, 4005, 4007, GF_PAGE_BTN, gump.cur_page+1);
				GFAddHTMLLocalized(gump, 283, 236, 60, 20, 1011066, 0, 0, 66); //Next Page
				GFPage( gump,  gump.cur_page+1 );
				GFAddButton(gump, 16, 236, 4014, 4016, GF_PAGE_BTN, gump.cur_page-1);
				GFAddHTMLLocalized(gump, 46, 236, 140, 20, 1011067, 0, 0, 66); //Previos Page
		endif
			SleepMS( 2 );
		if ( ItemX == 290 && ItemY == 20 )
			ItemY := CInt(ItemY + 70);
		elseif ( ItemX == 290 && ItemY == 90 )
			ItemY := CInt(ItemY + 70);
		elseif ( ItemX == 290 && ItemY == 160 )
			ItemY := CInt(20);
		endif
	endforeach

	return GFSendGump(who, gump);
endfunction
I check how I get home with work, I am very grateful to you for your help, I will start the server on the online forum, I will write off who helped in creating the scripts, and I will show you your help, thank you, so I’m a little master - an expert grandmaster, and so on, that he does not work on the adjustment, that it is not identified, gives advantages and this is not correct, the skin should be covered with skin should not be 20 per set

Post Reply