inventory without bisplayer?

Discussions about Coding and Scripting
Post Reply
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

inventory without bisplayer?

Post by Rakiayn »

as the title says.
Is it posible to make a scriptedpawn that can carry an inventory item without bisplayer is true?
I thought first of the skaarjtrooper, who can carry a weapon. but after looking at the code , i think a skaarjtrooper has bisplayer set to true temporarely
User avatar
Shadow
Masterful
Posts: 743
Joined: Tue Jan 29, 2008 12:00 am
Personal rank: Mad Carpenter
Location: Germany
Contact:

Re: inventory without bisplayer?

Post by Shadow »

Looking at Engine\Classes\Inventory.uc I found the following line in state 'Pickup', function ValidTouch, which controls if the Item is allowed to be added to inventory:

Code: Select all

if( Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
So if you want to "hack" around that, subclass your own Inventory Base Class and rewrite the Pickup State and ValidTouch Function without Pawn(Other).bIsPlayer
Image
User avatar
TheDane
Masterful
Posts: 660
Joined: Tue Feb 12, 2008 2:47 pm
Personal rank: Happy fool :-)

Re: inventory without bisplayer?

Post by TheDane »

you can try and force a weapon on the ScriptedPawn like this:

local SniperRifle Weapon;
local ScriptedPawn SP;
ForEach(class'ScriptedPawn', SP) {
if (SP.IsA('WhatEverScriptedPawnClass')) {
Weapon.GiveTo(SP); } }

This should give a sniper rifle to the monsterclass you define.
I haven't tested it but maybe it'll work? I'm sry i cant be more helpfull, but i'm on vacation and have no UT present.
Retired.
User avatar
Shadow
Masterful
Posts: 743
Joined: Tue Jan 29, 2008 12:00 am
Personal rank: Mad Carpenter
Location: Germany
Contact:

Re: inventory without bisplayer?

Post by Shadow »

TheDane wrote:you can try and force a weapon on the ScriptedPawn like this:

local SniperRifle Weapon;
local ScriptedPawn SP;
ForEach(class'ScriptedPawn', SP) {
if (SP.IsA('WhatEverScriptedPawnClass')) {
Weapon.GiveTo(SP); } }

This should give a sniper rifle to the monsterclass you define.
I haven't tested it but maybe it'll work? I'm sry i cant be more helpfull, but i'm on vacation and have no UT present.
yes, could, didn't think of that ^^

small tip: when iterating through pawns, it's unrecommended to use actor-iterators using the foreach-loop, use the faster for-loop instead:

Code: Select all

local scriptedpawn PawnList;
local weapon YourWeapon;

for(PawnList=level.pawnlist;PawnList.isa('WhatEverScriptedPawnClass');PawnList=PawnList.nextpawn)
   YourWeapon.GiveTo(WhatEverScriptedPawnClass(PawnList));
level.pawnlist is a dynamic linked list in the levelinfo, iterating through dynamic linked lists using for loops is muuuch faster than the foreach-loop.
Image
User avatar
TheDane
Masterful
Posts: 660
Joined: Tue Feb 12, 2008 2:47 pm
Personal rank: Happy fool :-)

Re: inventory without bisplayer?

Post by TheDane »

true it's faster, I just ran into some bad checks in the Survival mod so i reverted back to the ForEach check because then the check was successfull every time.
Retired.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: inventory without bisplayer?

Post by Rakiayn »

coool thanx.
Ill try them both out. the inventory i want to give to the monsters is custom anyway.
@shadow
in what script do I have to add that? gametype or mutator i guess?
and I want to give a custom kind of shieldbelt. does that also work with your code? , because its not a weapon
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: inventory without bisplayer?

Post by Rakiayn »

Shadow wrote:Looking at Engine\Classes\Inventory.uc I found the following line in state 'Pickup', function ValidTouch, which controls if the Item is allowed to be added to inventory:

Code: Select all

if( Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
So if you want to "hack" around that, subclass your own Inventory Base Class and rewrite the Pickup State and ValidTouch Function without Pawn(Other).bIsPlayer
thanx that worked great!
User avatar
Shadow
Masterful
Posts: 743
Joined: Tue Jan 29, 2008 12:00 am
Personal rank: Mad Carpenter
Location: Germany
Contact:

Re: inventory without bisplayer?

Post by Shadow »

Rakiayn wrote:coool thanx.
Ill try them both out. the inventory i want to give to the monsters is custom anyway.
@shadow
in what script do I have to add that? gametype or mutator i guess?
and I want to give a custom kind of shieldbelt. does that also work with your code? , because its not a weapon
simply create your new item class, then write a mutator that replaces the original item with yours
Rakiayn wrote:
Shadow wrote:Looking at Engine\Classes\Inventory.uc I found the following line in state 'Pickup', function ValidTouch, which controls if the Item is allowed to be added to inventory:

Code: Select all

if( Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
So if you want to "hack" around that, subclass your own Inventory Base Class and rewrite the Pickup State and ValidTouch Function without Pawn(Other).bIsPlayer
thanx that worked great!
hehe you're welcome :)
Image
gopostal

Re: inventory without bisplayer?

Post by gopostal »

Be sure to watch ammo classes though if your item is weaponry subclassed. As far as I know there is no good way around the buggy dropped weapon glitch you get from scripted pawns dropping them. This is due to the monsters (skaarj subclass) accessing the ammo count to decide fire mode. When scripted pawns hold a weapon it loses it's ammo count reference, so when dropped and recovered by a player it will mess up the HUD in MH, along with many of the mods (like doublejump).
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: inventory without bisplayer?

Post by Rakiayn »

i have tried to make a weapon ad give it to a skaarjtrooper, but it didnt work.
I also discovered that the armor that I gave to the scripted pawn doesnt function as an armor anymore, it cant absorb damage anymore. I tried searching through 'inventory', 'armor' and 'pickup' but i couldnt find any code that I think was the cause
gopostal

Re: inventory without bisplayer?

Post by gopostal »

In short, monsters function only as "partial" players. Many of the subroutines are incomplete, especially in the area of inventory and weapons. It's been a pet project of mine for quite some time to make a bot-code based replacement for the default monster classes so this isn't a problem any longer.

Feel free to email me if you get stuck on something.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: inventory without bisplayer?

Post by Rakiayn »

thax, I will do that :tu:
the mod im working on is basicly the same.
My monsters attack eachother, other scripted pawns,can follow orders etc...
oh. and i managed the monster to be able to wear armor
I am still working on the core file. I will send it to you soon. you might find it interresting
gopostal

Re: inventory without bisplayer?

Post by gopostal »

Cool, I'm very interested! One of the areas that really holds the various monster games back is better AI and inventory for the scripted pawn.
Post Reply