Page 1 of 1

Druids Spells Help Needed

Posted: Sun Sep 14, 2008 10:15 am
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?

Re: Druids Spells Help Needed

Posted: Mon Sep 15, 2008 11:15 pm
by CWO
Exactly what problem are you having with it?

Re: Druids Spells Help Needed

Posted: Tue Sep 16, 2008 3:06 am
by Nightson
show us ecompile error

Re: Druids Spells Help Needed

Posted: Tue Sep 16, 2008 4:09 am
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.

Re: Druids Spells Help Needed

Posted: Wed Sep 17, 2008 9:53 pm
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.

Re: Druids Spells Help Needed

Posted: Wed Sep 24, 2008 2:27 pm
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.

Re: Druids Spells Help Needed

Posted: Thu Sep 25, 2008 12:09 am
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.

Re: Druids Spells Help Needed

Posted: Thu Sep 25, 2008 3:09 pm
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...