NewsUnrealEdFilesModsFragBULiandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 9th Jul 2010, 09:44 PM   #1
Cockbite
Registered User
 
Join Date: Jul. 28th, 2009
Posts: 21
[Solved] Cast Error from Mutate

This code is supposed to be a simple Self Destruction mutator. The idea is you just type "Mutate Explode", and then you go out with a bang. My problem is that I'm getting an error that I don't know how to fix.

Quote:
SelfDestruct.uc(11) : Error, Cast from 'Pawn' to 'SelfDestruct' will always fail
SelfDestruct() asks for a Pawn, and I would assume that 'Sender.Pawn' is a pawn, so I don't quite see what the problem is. Does anyone know how to make this work?

Code:
Class SelfDestruct extends UTMutator;

var PlayerController playerController;
var Controller InstigatorController;

function Mutate(string MutateString, PlayerController Sender)
{
	Super.Mutate(MutateString, Sender);
	if (MutateString ~= "Explode" && Sender != None && Sender.Pawn != None)
	{
		SelfDestruct(Sender.Pawn);
	}
}

function SelfDestruct(Pawn P)
{
	local UTProj_HeroRedeemer Proj;
	Proj = Spawn(class'UTProj_HeroRedeemer', InstigatorController,, P.Location);
}

Last edited by Cockbite; 16th Jul 2010 at 10:20 PM. Reason: Problem Solved
Cockbite is offline   Reply With Quote
Old 10th Jul 2010, 03:45 AM   #2
Wormbo
 
 
Wormbo's Avatar
 
Join Date: Jun. 4th, 2001
Location: Germany
Posts: 5,785
Typecasting seems to take precedence over function calls. Your code really tries to typecast that Pawn reference to your mutator class.
__________________
Wormbo's UT/UT2004/UT3 mods | YouTube channel | PlanetJailbreak/JDN | Unreal Wiki | Liandri Archives
Everything you ever wanted to know about replication| UnrealScript security considerations
<elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
<TNSe> nono
<TNSe> its always funny to find code a week later you dont even remember writing
<Pfhoenix> what's worse is when you have a Star Wars moment
<Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
Wormbo is offline   Reply With Quote
Old 16th Jul 2010, 09:03 PM   #3
Cockbite
Registered User
 
Join Date: Jul. 28th, 2009
Posts: 21
I'm still not sure I understand what you said, but I figured out the problem. The error here is that I made a function called "SelfDestruct" when the game already has a native SelfDestruct function. This apparently confuses the game and makes it angry. Once I changed the name of my function to "BlowUp", it works perfectly like I intended.
Cockbite is offline   Reply With Quote
Old 16th Jul 2010, 09:06 PM   #4
Angel_Mapper
Goooooooats
 
Angel_Mapper's Avatar
 
Join Date: Jun. 17th, 2001
Location: Cape Suzette
Posts: 3,530
No, it was because the class name is SelfDestruct, so it thought you were trying to cast the Sender.Pawn to a SelfDestruct class type.
Angel_Mapper is offline   Reply With Quote
Old 16th Jul 2010, 10:18 PM   #5
Cockbite
Registered User
 
Join Date: Jul. 28th, 2009
Posts: 21
Quote:
Originally Posted by Angel_Mapper View Post
No, it was because the class name is SelfDestruct, so it thought you were trying to cast the Sender.Pawn to a SelfDestruct class type.
Okay, I get it now. So, I can call my function SelfDestruct if I change the script name.
Cockbite is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer