Druids Spells Help Needed

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 095. Note: Core 095 is no longer officially supported.
Post Reply
Breg
New User
Posts: 27
Joined: Sat Dec 09, 2006 11:58 am

Druids Spells Help Needed

Post by Breg »

Alright, Im having abit of trouble cyphering all this and Im an amatuer at scripting..

Code: Select all

use uo;
use os;
use util;

include "include/magic";
var spell_circle := 7;

program summon_player (parms)
	var caster := GetSpellCaster(parms);
	if (!caster)
		EraseObjProperty(parms[1], "#castingdruidspell");
		return 0;
	endif
	EraseObjProperty(caster, "#castingdruidspell");
	var caston := SelectPlayer( caster );

	//allow them to cast another spell now
	SetScriptController( caster );

	Detach();

	OpenGate( caster, caston );

endprogram

function SelectPlayer( who )

	var menuname := "Summon whom?";

	var dict := getonlineplayerslist();
	var roster := {};
	foreach memberserial in ( dict.keys() )
		roster.append( dict[ memberserial ] );
	endforeach

	var citnum := 1;
	var selection := { };
	repeat
		var stonemenu := CreateMenu(menuname);
		var i;
		for ( i := citnum; i <= citnum+10; i := i + 1 )
			if ( i <= roster.size() )
				var citizen := roster[ i ];
				AddMenuItem(stonemenu, 0, citizen);
			endif
		endfor
		if ( roster.size() > (citnum+10) )
			AddMenuItem(stonemenu, 0, "NEXT PAGE");
		endif
		selection := SelectMenuItem2(who, stonemenu);
		if ( selection[3] == 12 )
			citnum := citnum + 10;
		else
			if ( selection[3] )
				var vote := (selection[3] + (citnum-1) );
				return roster[vote];
			else
				SendSysMessage( who, "Canceled");
				return;
			endif
		endif
	until (selection[3] != 12);
	return;
endfunction

function getonlineplayerslist()

	var dict := dictionary;
	foreach plr in EnumerateOnlineCharacters()
		if (!plr.cmdlevel)
			if (!GetObjProperty( plr, "private"))
				dict[ plr.serial ] := plr.name;
			endif
		endif
	endforeach
	return dict;

endfunction

function FindCastOn( cast_on )

	foreach plr in EnumerateOnlineCharacters()
		if (plr.name == cast_on )
			return plr;
		endif
	endforeach
	return 0;

endfunction

function OpenGate( caster, caston )

	caston := FindCastOn( caston );
	if (!caston)
		SendSysMessage( caster, "Your gate fails to open..." );
		return;
	endif

	if (caston.x > 5118)
		SendSysMessage(caster, "Blocked!");
		return 0;
	endif

	var pregate := CreateItemAtLocation(caston.x, caston.y, caston.z, 0x1af3, 1);
	var pregate2 := CreateItemAtLocation(caster.x, caster.y, caster.z, 0x1af3, 1);
	pregate.facing := 1;
	pregate.movable := 0;
	pregate.color := 1435;

	pregate2.facing := 1;
	pregate2.movable := 0;
	pregate2.color := 1435;

	pregate.name := "a druid gate";
	pregate2.name := "a druid gate";

	PlaySoundEffect(caston, SFX_SPELL_GATE_TRAVEL);
	PlaySoundEffect(caster, SFX_SPELL_GATE_TRAVEL);
	sleepms(1500);
	var castonx := pregate.x;
	var castony := pregate.y;
	var castonz := pregate.z;
	DestroyItem(pregate);

	var gate := CreateItemAtLocation(castonx, castony, castonz, UOBJ_BLUE_MOONGATE, 1);
	if (!gate) return; endif
	gate.facing := 1;
	gate.movable := 0;
	gate.color := 1435;
	gate.name := "a druid gate";
        PrintTextAbove( gate, caster.name + "'s gate", 0, 259 );

	SetObjProperty(gate, "GateDestX", caster.x);
	SetObjProperty(gate, "GateDestY", caster.y);
	SetObjProperty(gate, "GateDestZ", caster.z);

	Detach();
	set_critical( 0 );

        sleep(10);
        PrintTextAbove( gate, caster.name + "'s gate", 0, 259 );
	sleep(20);
   
	set_critical(1);
	DestroyItem(gate);
	DestroyItem(pregate2);
	set_critical(0);

endfunction
So can anyone tell me exactly where I went wrong?
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Druids Spells Help Needed

Post by CWO »

Exactly what problem are you having with it?
Nightson
Neophyte Poster
Posts: 33
Joined: Mon Apr 02, 2007 1:13 pm

Re: Druids Spells Help Needed

Post by Nightson »

show us ecompile error
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Re: Druids Spells Help Needed

Post by OldnGrey »

That looks similar to the World of Dreams script, but yeah, we do need you to copy/paste the compiler error you get.
Learn to decipher the compiler messages and it will be time well spent.
Waluy
New User
Posts: 8
Joined: Sat Aug 02, 2008 12:40 am

Re: Druids Spells Help Needed

Post by Waluy »

Well the code as you have it listed compiles just fine. Are you having issues with it in game not working?
Need more detail to be of any assistance.
Breg
New User
Posts: 27
Joined: Sat Dec 09, 2006 11:58 am

Re: Druids Spells Help Needed

Post by Breg »

Okay when I cast the spell is displays the powerwords "Shiva Sov" and then abit later it prompts, "Your Gate Fails To Open..." after that its that, just doesnt work like its supposed to, for it to work correctly it will send a gate to a player selected on the gump list of players online and should allow them to be gated to the Druid.
Waluy
New User
Posts: 8
Joined: Sat Aug 02, 2008 12:40 am

Re: Druids Spells Help Needed

Post by Waluy »

That brings up the next question. Are you trying to test when no one else is online? If so that is your problem.
Another possibility could be that where your code reads selection[3] you should replace that with selection.index I only suggest this because that is the only place your code and mine are different.
Breg
New User
Posts: 27
Joined: Sat Dec 09, 2006 11:58 am

Re: Druids Spells Help Needed

Post by Breg »

Thank you Waluy, the [3] Parameter was the issue, seems some scripts are abit messy.. I got alot of work ahead of me wait till you see my Theivery script.. oh what a mess...
Post Reply