Page 1 of 1

Totem.src

Posted: Fri Apr 06, 2012 4:51 pm
by gundamwing84
Hey guys, unfortunately me again :D i was wondering if i could grab some help with my totem.src script in dundee(for the craftable mounts/totems). right now the script keeps getting hung up when im double clicking an obsidian mount, it keeps saying im already mounted... this is in the "mountsteed" function where it says

Code: Select all

	mount.name := totem.name;
	if (!EquipItem(who,mount))
		SendSysMessage( who, "You cannot use that while mounted!");
		return;
	endif
The script is replying that im already mounted, but i havnt got any mounts what so ever when ive tested this script.

Heres the script ive got:

Code: Select all

program totem (who, totem)
	if (!ReserveItem (totem))
		SendSysMessage (who, "You can't use this right now.");
		return;
	endif
	
	if (!totem.movable)
		SendSysMessage (who, "You can't use this while its locked down!");
		return;
	endif
	if (GetObjProperty (totem, "broken"))
		SendSysMessage (who, "It seems to be broken.");
		return;
	endif
	case ( totem.objtype )
		0x2124:
		0x20f6:
		0x2136:
		
			MountSteed( who, totem );
        		return;
		0x2121:
			var newtotem := CreateItemInContainer (who.backpack, 0x2124, 1);
			if ( GetObjProperty (totem, "critter") == "obsidiangolem")
				newtotem.name := "an obsidian golem";
				newtotem.name := "an obsidian drake";
				SetObjProperty (newtotem, "critter", "obsidiansteed");
				SetObjProperty (newtotem, "critcolor", 2498);
				newtotem.color := 2498;
				newtotem.usescript := ":dundee:totem";
				SetObjProperty (newtotem, "totemhp", 250);
				newtotem.decay := 0;
				newtotem.movable := 1;
				destroyitem (totem);
				return;
			else
				newtotem.name := "an porcelain golem";
				newtotem.name := "an porcelain deamon";
				SetObjProperty (newtotem, "critter", "porcelainsteed");
				SetObjProperty (newtotem, "critcolor", 2044);
				newtotem.color := 2044;
				newtotem.usescript := ":dundee:totem";
				SetObjProperty (newtotem, "totemhp", 350);
				newtotem.decay := 0;
				newtotem.movable := 1;
				destroyitem (totem);
				return;
			endif
	endcase
	var npctemplate := GetObjProperty (totem, "critter");
	if (!npctemplate)
		SendSysMessage (who, "There's a problem with this totem.  Contact a GM.");
		return;
	endif



set_critical (1);
		var it := SpawnNPCAtLocation (npctemplate, who.x - 1, who.y + 1, who.z, 0, who.realm);
		if (!it)
			it := SpawnNPCAtLocation (npctemplate, who.x + 1, who.y + 1, who.z, 0, who.realm);
			if (!it)
				SendSysMessage (who, "Error creating creature - try a different location.");
				return;
			endif
		endif

		SetObjProperty (it, "totem", totem.objtype );
		SetObjProperty (it, "totemcolor", totem.color );
		SetObjProperty (it, "master", who.serial );
		
		if (GetObjProperty (totem, "totemdeaths"))
			SetObjProperty (it, "totemdeaths", GetObjProperty (totem, "totemdeaths"));
		endif

		if (GetObjProperty (totem, "ownerserial"))
			SetObjProperty (it, "ownerserial", GetObjProperty (totem, "ownerserial"));
			SetObjProperty (it, "ownername", GetObjProperty (totem, "ownername"));
			SetObjProperty (it, "oldname", GetObjProperty (totem, "oldname"));
		endif

		it.setmaster (who);
		it.script := "::tamed";
		it.name := totem.name;
		it.color := GetObjProperty (totem, "critcolor");
  		it.graphic := GetObjProperty (totem, "critgraphic");
		if ( GetObjProperty (totem, "totemhp"))
			SetVital (it, "Life", CINT (GetObjProperty (totem, "totemhp") * 100));
		endif

		PlaySoundEffect (who, SFX_SPELL_DISPEL);
		PlayStationaryEffect (it.x, it.y, it.z, FX_SMOKE, 0xA, 0xA, 0, it.realm );
		DestroyItem (totem);
		RestartScript (it);

	set_critical (0);
endprogram


function MountSteed( who, totem )

	var mount := CreateItemAtLocation(4550, 3687, REALM_BRITANNIA  , 0, 0xF021,1);
	mount.color := totem.color;
	setobjproperty(mount,"totem",totem.objtype);

	var ownerserial := GetObjProperty(totem, "ownerserial");
	if ( ownerserial )
		var oldname := GetObjProperty(totem, "oldname");
		var ownername := GetObjProperty(totem, "ownername");
		SetObjProperty( mount, "ownerserial", ownerserial );
		SetObjProperty( mount, "oldname", oldname );
		SetObjProperty( mount, "ownername", ownername );
	endif

//	mount.graphic := 0x3ea0;
	case ( totem.objtype )
		0x2124:
			mount.graphic := 0x3ea0;
		0x20f6:	
			mount.graphic := 0x3ea6;	
		0x2136:
			mount.graphic := 0x3ea4;

	endcase
	mount.name := totem.name;
	if (GetEquipmentByLayer( who, 0x19 ))
		SendSysMessage( who, "You cannot use that while mounted!");
		return;
	endif
	PlaySoundEffect( who, SFX_SPELL_DISPEL );
	PlayStationaryEffect( who.x, who.y, who.z, FX_SMOKE, 0xA, 0xA, 0, who.realm );
	DestroyItem(totem);
	who.hidden := 0;
endfunction

function NotYours(who,it)

	var ownerserial := GetObjProperty(it, "ownerserial");
	var ownername;
	if (ownerserial)
		ownername := GetObjProperty(it, "ownername");
	else
		return 0;
	endif

	if  ( ownerserial != who.serial )
		SendSysMessage (who,"You can't use that, it belongs to "+ownername );
		return 1;
	endif

	return 0;

endfunction

Any help is much appreciated :)

Re: Totem.src

Posted: Fri Apr 06, 2012 5:51 pm
by mr bubbles
I havnt touched UO in a while now. But for troubleshooting purposes have your tried altering

Code: Select all

if (!EquipItem(who,mount))
to

Code: Select all

if (GetEquipmentByLayer( who, 0x19 ))

Re: Totem.src

Posted: Fri Apr 06, 2012 6:52 pm
by gundamwing84
ok thats fixed it from stopping me mounting them. but, now the script is going through and mounting me, but no mount appears, the totem/npc completely disappears o.o

Re: Totem.src

Posted: Fri Apr 06, 2012 7:04 pm
by mr bubbles
I'm not familiar with your script base at all sorry. I think i misunderstood what you wanted to do. I was thinking your were trying to 'hatch' a totem, but it kept saying your were mounted so couldn't.

But the problem is that you're trying to mount a crafted mount right?

Code: Select all

  case ( totem.objtype )
      0x2124:
      0x20f6:
      0x2136:
      0x25ce:
      0x2619:
         
         MountSteed( who, totem );
              return;
The above code. Is the steeds objtype there?

I apologise as I am extremelly rusty haha. Try putting a lot of Print() lines in to see where the script goes wrong. For example, put a Print("In mounsteed function") at the start of the mountsteed function so you know it gets that far.

Re: Totem.src

Posted: Fri Apr 06, 2012 7:45 pm
by gundamwing84
ahh the script base im using is World of Dreams, the mount.type and object type are actually defined inside the MountSteed function. What i want to do is when the totem is double clicked for a horse, llama and ostard, instead of them spawning like they would through other totems, id like them to spawn with you automaticly mounted on them

Re: Totem.src

Posted: Fri Apr 06, 2012 8:16 pm
by mr bubbles
Ah ok, I think I know what you mean now :P

In MountSteed function try changing

Code: Select all

   if (GetEquipmentByLayer( who, 0x19 ))
      SendSysMessage( who, "You cannot use that while mounted!");
      return;
   endif
To this

Code: Select all

if (GetEquipmentByLayer( who, 0x19 ))
 SendSysMessage( who, "You cannot use that while mounted!");
 return;
else
 EquipItem( who, mount );
endif

Re: Totem.src

Posted: Fri Apr 06, 2012 8:37 pm
by Agata
Also on this part:

Code: Select all

   var mount := CreateItemAtLocation(4550, 3687, REALM_BRITANNIA  , 0, 0xF021,1);
   mount.color := totem.color;
   setobjproperty(mount,"totem",totem.objtype);
Make sure the item's objtype matches the one used by POL. Recent versions of POL from svn use 0x1F021 for the mount item. It can be defined on the new extobj.cfg file. And set the totem's graphics to the mount you want. You can look at the latest version of the WoD scripts I uploaded, on the scripts/ai/tamed.src file, there you will find the graphic index for the most usual mounts. Set the mount item's graphic to the mount you would like, then equip it.

If you need support with the WoD scripts, I suggest you ask me directly, as I am more likely to know the inner workings of it inside out, and already converted them to POL 099.

Re: Totem.src

Posted: Sat Apr 07, 2012 3:10 am
by gundamwing84
Ok sounds like a plan :) i will try this out later just been world building for 10 hours... lmao! thanks for your help guys ill let you know how it goes :)