Totem.src

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

Moderator: POL Developer

Post Reply
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Totem.src

Post by gundamwing84 » Fri Apr 06, 2012 4:51 pm

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 :)
Last edited by gundamwing84 on Fri Apr 06, 2012 6:59 pm, edited 1 time in total.

mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: Totem.src

Post by mr bubbles » Fri Apr 06, 2012 5:51 pm

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 ))

gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Totem.src

Post by gundamwing84 » Fri Apr 06, 2012 6:52 pm

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

mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: Totem.src

Post by mr bubbles » Fri Apr 06, 2012 7:04 pm

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.

gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Totem.src

Post by gundamwing84 » Fri Apr 06, 2012 7:45 pm

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

mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: Totem.src

Post by mr bubbles » Fri Apr 06, 2012 8:16 pm

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

Agata
Journeyman Poster
Posts: 63
Joined: Sun Oct 30, 2011 6:33 am

Re: Totem.src

Post by Agata » Fri Apr 06, 2012 8:37 pm

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.

gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Totem.src

Post by gundamwing84 » Sat Apr 07, 2012 3:10 am

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 :)

Post Reply