I don't need to test my programs. I have an error-correcting modem.

Legacy:Clam

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Intro[edit]

IIQD[edit]

Interaction Interface Quick Decision v1.1

Use live gameplay control options to set gameplay elements

This is part of the base code for IIQD. The mouse code was taken from Tanus' SyndicateMod. Also the way
the image coding is done may seem familiar with the Sega500 website tutorials.

Also I highly doubt this is the most efficient way to do this. I think I took the long way around in doing
some of these things. I'll change the textures to ones found within UT2k3 as soon as I get around to it.
Also I'll put the playercontroller which is needed for this to make much sense and the gametype for conclusion. The playercontroller is a
stripped down version of Tanus'. Finally the UnitPress() function in the playercontroller still needs tweaked.

class selectorinteraction extends interaction dependson(Actor);
 
#exec texture IMPORT name=CURSOR FILE=Textures\cursor12.tga GROUP="HUD" MIPS=OFF FLAGS=2
#exec texture IMPORT name=CURSORCLICK FILE=Textures\cursor12click.tga GROUP="HUD" MIPS=OFF FLAGS=2
#exec texture IMPORT name=MENU FILE=Textures\menu2.tga GROUP="HUD" MIPS=OFF FLAGS=2
#exec texture IMPORT name=BUTTON FILE=Textures\button.tga GROUP="HUD" MIPS=OFF FLAGS=2
 
var   int     SelectedBox;
 
var   PlayerController    PlayerOwner;
 
var   texture             CursorMat,  CursorMat2,    MenuTemp,   Button;
 
var        bool       CursorClick;
 
 
event Initialized()
{
if (PlayerOwner == None)
PlayerOwner = ViewportOwner.Actor;
}
 
function PostRender(Canvas C)
{
   local float CursorX, CursorY;
   local byte tempstyle;
   local color tempColor;
 
   tempstyle=C.Style;
   tempcolor=C.DrawColor;
 
   CursorX = SelectorPlayer(PlayerOwner).Player.WindowsMouseX;
   CursorY = SelectorPlayer(PlayerOwner).Player.WindowsMouseY;
 
 
 
   //
   //MENU
   //
   c.setPos(0,0);
   c.Style=5;
   c.SetDrawColor(255, 255, 255);
   c.DrawIcon(MenuTemp, 2);
 
 
   //Buttons
   //Draw Button One
   c.setPos(MenuTemp.USize/2,5);
   C.Style=3;
   if(selectedbox==1)
   {
   C.SetDrawColor(0,255,255);
   }
   if(selectedbox!=1)
   {
   C.SetDrawColor(255,255,255);
   }
   C.DrawIcon(Button, 1);
 
   //Draw Button Two
   c.setPos(MenuTemp.USize/2,Button.VSize+45);
   C.Style=3;
   if(selectedbox==2)
   {
   C.SetDrawColor(0,255,255);
   }
   if(selectedbox!=2)
   {
   C.SetDrawColor(255,255,255);
   }
   C.DrawIcon(Button, 1);
 
   //Draw Button Three
   c.setPos(MenuTemp.USize/2,(Button.VSize*2)+90);
   C.Style=3;
   if(selectedbox==3)
   {
   C.SetDrawColor(0,255,255);
   }
   if(selectedbox!=3)
   {
   C.SetDrawColor(255,255,255);
   }
   C.DrawIcon(Button, 1);
 
   //
   //MOUSE
   //
   c.SetDrawColor(255, 255, 255);
   c.Style =6;
   C.SetPos( CursorX, CursorY );
 
   if(cursorclick==true)
   {
   c.DrawIcon(Cursormat2, 1/2);
   }
   if(cursorclick!=true)
   {
   C.DrawIcon(cursormat, 1/2);
   }
 
   C.SetPos( 10, (C.ClipY-20) ); //DISPLAY MOUSE COORDINATES
   C.DrawText( "CursorX:"@CursorX@",CursorY:"@CursorY );
 
   //FINISH UP
    C.Style=tempstyle;
    C.DrawColor=tempColor;
 
}
 
 
 
 
 
 
//KeyEvent
function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
{
 
if ((Action == IST_Press) && (Key == IK_RightMouse))
{
cursorclick=true;
ButtonPress();   //Perform button function
SelectorPlayer(PlayerOwner).UnitPress();
}
 
if ((Action == IST_Release) && (Key == IK_RightMouse))
{
cursorclick=false;
}
return false;
}
 
 
 
//ButtonPress
function ButtonPress()
{
local float CursorX, CursorY;
 
      CursorX = SelectorPlayer(PlayerOwner).Player.WindowsMouseX;
   CursorY = SelectorPlayer(PlayerOwner).Player.WindowsMouseY;
 
 
   //button 1
   if(CursorX > ((MenuTemp.USize - Button.USize) / 2) + 35&& CursorX < (MenuTemp.Usize/2)+ (Button.Usize/2) + 35 && CursorY > 5 && CursorY < Button.VSize+5)
   {
   if(selectedbox==1)
   {
   selectedbox=4;
   return;
   }
   if(selectedbox!=1)
   {
   selectedbox=1;
   return;
   }
   }
 
   //button 2
   if (CursorX > ((MenuTemp.USize - Button.USize) / 2) + 35&& CursorX < (MenuTemp.Usize/2)+ (Button.Usize/2) + 35 && CursorY > Button.VSize+5 && CursorY < (Button.VSize*2)+5)
   {
   if(selectedbox==2)
   {
   selectedbox=4;
   return;
   }
   if(selectedbox!=2)
   {
   selectedbox=2;
   return;
   }
   }
 
   //button 3
   if (CursorX > ((MenuTemp.USize - Button.USize) / 2) + 35&& CursorX < (MenuTemp.Usize/2)+ (Button.Usize/2) + 35 && CursorY > (Button.VSize*2)+75  && CursorY < (Button.VSize*3)+75)
   {
   if(selectedbox==3)
   {
   selectedbox=4;
   return;
   }
   if(selectedbox!=3)
   {
   selectedbox=3;
   }
   }
}   //End of Button Press
 
 
 
 
 
 
 
defaultproperties
{
    cursormat=texture'CURSOR'
    cursormat2=texture'CURSORCLICK'
    MenuTemp=texture'MENU'
    button=texture'BUTTON'
    bVisible=true
    bActive=true
 
}

Player Controller

class selectorplayer extends xPlayer;
 
var float CamHeight, CamDistance;
 
var bool bHasInteraction;
 
var bool bHold;
 
var ScriptedController cdawg;
 
var rotator CameraRot; 
var vector CameraLoc;
var float MaxClipX, MaxClipY;
 
 
 
event PlayerCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )
{
    local vector temp;
    bBehindView=true;
    SetViewTarget(self);
    ViewActor = ViewTarget;
 
 
    CameraLocation = ViewActor.Location;
    temp = CamDistance * vector(CameraRotation);
    CameraLocation = CameraLocation - temp;
    CameraLocation.z+=CamHeight;
    CameraRotation = rotator(ViewActor.Location - CameraLocation);
    //offsetcameraLocation=CameraLocation;
}
 
state PlayerWaiting
{
Begin:
    If ((Viewport(Player) != None) && (!bHasInteraction))
        {
        Player.InteractionMaster.AddInteraction("selector.selectorinteraction", Player);
        bHasInteraction = True;
        }
 
 
}
 
 
function UnitPress()
{
 
         local vector TraceEnd, HitLocation, HitNormal, Dir, CameraLoc;
	local rotator CameraRot;
	local actor ViewActor;
	local float Fov, FovDist;
	local float MouseX, MouseY;
	local actor Other;
 
        MouseX = Player.WindowsMouseX / MaxClipX;
        MouseY = Player.WindowsMouseY / MaxClipY;
 
        CameraRot = GetViewRotation();
	CameraLoc = vect(0,0,0);
 
	PlayerCalcView(ViewActor, CameraLoc, CameraRot);
 
	Fov = (FovAngle/2) * Pi / 180.00;
	FovDist = (MaxClipX/2) / Tan(Fov);
 
	Dir.X = FovDist;
	Dir.Y = MouseX - MaxClipX / 2;
	Dir.Z = -(MouseY - MaxClipY / 2);
 
	Dir = Dir >> CameraRot;
 
	TraceEnd = (CameraLoc) + 50000 * Normal(Dir);
 
	Other = Trace(HitLocation, HitNormal, TraceEnd, CameraLoc, true);
        if( Other.IsA('xpawn'))
        {
        log("halloween");
        return;
        }
 
        return;
}
 
defaultproperties
{
 
    CamHeight=350
    CamDistance=300
    InputClass=class'viewtest.SyndicatePlayerInput'
    PawnClass=Class'selector.selectorpawn'
}

SelectorGame

class selectorgame extends xDeathMatch;
 
function startmatch()
{
Super.startmatch();
DropPawns();
}
 
function DropPawns()
{
local playercontroller theplayer;
local pawn temppawn;
 
 
 
 
      foreach AllActors(class'playercontroller', theplayer)
      {
       temppawn=theplayer.pawn;
       theplayer.GotoState('Spectating');
       temppawn.destroy();
       }
 
}
 
defaultproperties
{
 
   PlayerControllerClassName="selector.selectorplayer"
   HudType="selector.selectorHUD"
 
}

Dll To Lib, Header File[edit]

//	dinterface_supp.h : supplement header file for dinterface.dll
//	Author: DLL to Lib version 1.42
//	Date: Friday, December 12, 2003
//	Description: The declaration of the dinterface.dll's entry-point function.
//	Prototype: BOOL WINAPI xxx_DllMain(HINSTANCE hinstance, DWORD fdwReason, LPVOID lpvReserved);
//	Parameters: 
//		hinstance
//		  Handle to current instance of the application. Use AfxGetInstanceHandle()
//		  to get the instance handle if your project has MFC support.
//		fdwReason
//		  Specifies a flag indicating why the entry-point function is being called.
//		lpvReserved 
//		  Specifies further aspects of DLL initialization and cleanup. Should always
//		  be set to NULL;
//	Comment: Please see the help document for detail information about the entry-point 
//		 function
 
/////////////////////////////////////////////////////////////////////
 
#if !defined(D2L_DINTERFACE_SUPP_H__1E4C3315_1197_226C_06A6_6C4616652C9D__INCLUDED_)
#define D2L_DINTERFACE_SUPP_H__1E4C3315_1197_226C_06A6_6C4616652C9D__INCLUDED_
 
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
#include <windows.h>
 
/* This is dinterface.dll's entry-point function. You should call it to do necessary
 initialization and finalization. */
 
BOOL WINAPI DINTERFACE_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
 
 
#ifdef __cplusplus
}
#endif
 
#endif // !defined(D2L_DINTERFACE_SUPP_H__1E4C3315_1197_226C_06A6_6C4616652C9D__INCLUDED_)

Goal[edit]

My Goal right now is to fool around with creating an RTS style gametype.
1.Spawn a playercontroller at the playerstart
2.Spawn 6 possessable pawns in a circular position around the playercontrollers start.
3.Create a HUD with a mouse pointer where I can click on the pawns to possess them.
4.When I left click on a pawn it posseses it, when I right click on a place, the pawn will move there.\\

CODE[edit]

Startmatch()
6 ai controlled pawns
1 playercontroller in spec mode to take care of extra bot

*Pawns stand still, don't shoot each other
*Click on Pawn, selects it

Decide which pawn is selected
InterFace
Make Pawn Look selected
Mouse cursor


On click, trace from viewactor down, if pawn, select pawn

On right click, if pawn is selected, trace down and move pawn to location

Pawn AI - stand still, dont shoot, move when playercontroller tells it to
playercontroller - calls to pawns, must decide which pawn, decide which pawn.function, detect pawn


Wormbo: Maybe you could make a new Pipebomb tutorial page at the UnrealScript Lessons.

Switch`: What's that dinterface_supp.h for?