Page 1 of 1

I need help with something POL95 script

Posted: Sat Aug 19, 2006 12:52 pm
by Avenging Angel
I have donator horses people can get however when they dismount it produces a horse I would want it to not to do this.here is a script

Use uo;

Program Horse_Mount( who, item )

If( !ReserveItem( item ) )
Return;
Endif

var mounttype := 0x3ea0;

var alreadymounted := GetEquipmentByLayer( who, 25 );
if( alreadymounted )
SendSysMessage( who , "You are already mounted." );
return 0;
endif
if( mounttype )
var mount := CreateItemAtLocation( who.x, who.y, who.z, 0xF021, 1 );
mount.movable := 1;
mount.color := item.color;
mount.graphic := mounttype;
EquipItem( who, mount );
mount.movable := 0;
SendSysMessage( who, "You mounted the horse." );
SetObjProperty( who, "DMount", 1 );
endif

EndProgram
please tell me how to fix it so when they dismount the mount disappears.

Posted: Sat Aug 19, 2006 1:10 pm
by Poi
It looks to me as if you would have to add
DestroyItem( mounttype);

somewhere, but im not sure where..

Posted: Sat Aug 19, 2006 1:37 pm
by Avenging Angel
and do i have to put like sphinxmount where it says mounttype?

Posted: Sat Aug 19, 2006 1:40 pm
by Poi
In your script you set the variable "mounttype" to what im assuming is the mount type, so it should delete the mount, but dont take my word im a noobie scriptor

Posted: Sat Aug 19, 2006 1:43 pm
by Avenging Angel
That didnt work thanks tho for trying.

Posted: Sat Aug 19, 2006 2:38 pm
by Avenging Angel
Someone told me i have to look at the dismount script I did and Its all confusing I am not sure where to tweek this at.




include "include/myutil";
//include "include/attributes";
include "include/client";

//function returns 0 if the animal couldn't be created and/or
//if the mount wasn't destroyed

function dismount( me, mount := 0 )

set_critical(1);

if( !mount )
if( !me )
set_critical(0);
return 0;
else
if( !me.corpseType )
mount := GetEquipmentByLayer( me, LAYER_MOUNT );
else
foreach item in ListRootItemsInContainerOfObjtype(me, 0xf021)
mount := item;
endforeach
endif
endif
endif

if( !mount )
set_critical(0);
return 0;
endif

var critter := GetObjProperty( mount, "npctemplate" );
if( !critter )
critter := "horse";
endif

var animal := CreateNpcFromTemplate(critter, me.x, me.y, me.z);
if( !animal )
set_critical(0);
return 0;
endif

animal.color := mount.color;
SetObjProperty( animal, "color", mount.color );

if (GetObjProperty(mount, "petname"))
animal.name := GetObjProperty(mount, "petname");
endif

if (GetObjProperty(mount,"pethp"))
SetHp(animal, GetObjProperty(mount,"pethp"));
endif

if (GetObjProperty(mount,"petmana"))
SetMana(animal, GetObjProperty(mount,"petmana"));
endif

if( me )
if( me.corpseType )
SetObjProperty(animal, "master", me.serial );
var master := SystemFindObjectBySerial( CInt(GetObjProperty( me, "whose" )) );
if( master )
animal.script := "tamed";
animal.setmaster( master );
endif
animal.facing := me.facing;
RestartScript(animal);
elseif( !me.npctemplate )
SetObjProperty( animal, "master", me.serial );
animal.setmaster( me );
animal.script := "tamed";
animal.facing := me.facing;
RestartScript(animal);
endif
else
SetObjProperty(animal,"killme",1);
endif

if (DestroyItem( mount ))
set_critical(0);
return 1;
else
set_critical(0);
return 0;
endif

endfunction

Posted: Sun Aug 20, 2006 6:40 am
by Terryl
Hi, Im trying to solve the same problem, I was the one who thought the dismount include was probobly what he should edit. Right now I've made this change to the include file. My thought was that this would stop it from even being created, although this was wrong :P can anyone point my in any direction on how I should do this?

Code: Select all


var donatormount := GetObjProperty( me, "DMount");

if(!donatormount)
		var animal := CreateNpcFromTemplate(critter, me.x, me.y, me.z);
		if( !animal )
			set_critical(0);
			return 0;
		endif
	endif

I also tried the solution of setting like

Code: Select all

if(donatormount==1)
DestroyItem(animal);
should I use something else than destroy item for animals?

Posted: Sun Aug 20, 2006 6:51 am
by Poi
In your first code terryl, could you post the entire thing because i don't see where you actually dismount in just that small script... But i would find the part where it sees if its dismounted or not, and if it is then do
if ( mounttype )
destroyitem(mounttype);
endif


And i would think thats all you would have to do

Posted: Sun Aug 20, 2006 7:01 am
by Terryl
Poi wrote:In your first code terryl, could you post the entire thing because i don't see where you actually dismount in just that small script... But i would find the part where it sees if its dismounted or not, and if it is then do
if ( mounttype )
destroyitem(mounttype);
endif


And i would think thats all you would have to do
The whole script is the one that Avenging Angel posted, the problem with what you said is that only way you can accually tell its a donatormount is by the color or the prop that the player has while sitting on it. Thats why I want to try to use the var donatormount. It is a good idea you have, I can look into the colors different mounts get and if its a special one I could just set something like mountcolor

Code: Select all

var mountcolor := GetObjectProp (animal, "color");
if (mountcolor > 0)
destroyitem(animal);
endif
couldn't I? Or am I completely wrong?

Posted: Sun Aug 20, 2006 7:24 am
by Tritan
You can use the color of the mount to check for this special mount. I would recommend making a new object number for this mount though and use that. Then regardless of the color, say someone gets one that is a different color at some point :) , the objtype number stays the same.

You do not need to add a new graphic for this either. Just define it with the existing graphic you want to use and away you go.

Here is an example of something I did to set up a new steed in my scripts.

Code: Select all

NpcTemplate praetoriansteed
{
	Name			Ibn'Najm
	script		:domestic_animals:ai_animal_barker
	ObjType		0xe4
	Color		0
	TrueColor		0
	RandomColor	6
	Gender		0
	STR			90
	INT			25
	DEX			80
	HITS			90
	MANA			0
	STAM			50

	AttackSpeed		38
	AttackDamage		1d6+3
	AttackAttribute	Wrestling
	AttackHitScript	:hitscripts:npc_melee
	AttackHitSound		0xAB
	AttackMissSound	0x239
	DeathSound		0xad
	AR				6
	msPerAttack		2100
	hitSound		0xa9
	hitSound		0xaa
	hitSound		0xab
	hitSound		0xac
	missSound		0x239
	missSound		0x23a
	missSound		0x23b
	attackAnim		0x5
	attackAnim		0x6
	attackAnim		0x7

	MagicResistance	30
	Tactics			50
	Wrestling			60

	npc_helper		horse2
	npc_helper		horse3
	npc_helper		horse4
	npc_helper		horse5

	tameskill			50
	food				veggie
	guardignore		1
	provoke			40
}


The objtype is the same as the one for a normal horse. This allows me to do some different things with the animal should I want to, such as you are wanting to so. This is just one option of course and I am sure there are others out there.